garage-admin-sdk-golang/docs/KeyApi.md

410 lines
11 KiB
Markdown
Raw Normal View History

2022-11-13 13:22:00 +00:00
# \KeyApi
2023-11-22 17:28:14 +00:00
All URIs are relative to *http://localhost:3903/v1*
2022-11-13 13:22:00 +00:00
Method | HTTP request | Description
------------- | ------------- | -------------
2023-11-22 20:17:35 +00:00
[**AddKey**](KeyApi.md#AddKey) | **Post** /key?list | Create a new API key
[**DeleteKey**](KeyApi.md#DeleteKey) | **Delete** /key | Delete a key
[**GetKey**](KeyApi.md#GetKey) | **Get** /key | Get key information
2022-11-13 13:22:00 +00:00
[**ImportKey**](KeyApi.md#ImportKey) | **Post** /key/import | Import an existing key
2023-11-22 20:17:35 +00:00
[**ListKeys**](KeyApi.md#ListKeys) | **Get** /key?list | List all keys
[**UpdateKey**](KeyApi.md#UpdateKey) | **Post** /key | Update a key
2022-11-13 13:22:00 +00:00
## AddKey
> KeyInfo AddKey(ctx).AddKeyRequest(addKeyRequest).Execute()
Create a new API key
### Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
2023-11-22 17:28:14 +00:00
addKeyRequest := *openapiclient.NewAddKeyRequest() // AddKeyRequest | You can set a friendly name for this key. If you don't want to, you can set the name to `null`. *Note: the secret key is returned in the response.*
2022-11-13 13:22:00 +00:00
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.KeyApi.AddKey(context.Background()).AddKeyRequest(addKeyRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.AddKey``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `AddKey`: KeyInfo
fmt.Fprintf(os.Stdout, "Response from `KeyApi.AddKey`: %v\n", resp)
}
```
### Path Parameters
### Other Parameters
Other parameters are passed through a pointer to a apiAddKeyRequest struct via the builder pattern
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
2023-11-22 17:28:14 +00:00
**addKeyRequest** | [**AddKeyRequest**](AddKeyRequest.md) | You can set a friendly name for this key. If you don't want to, you can set the name to `null`. *Note: the secret key is returned in the response.* |
2022-11-13 13:22:00 +00:00
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)
## DeleteKey
2023-11-23 07:54:51 +00:00
> DeleteKey(ctx).Id(id).Execute()
2022-11-13 13:22:00 +00:00
Delete a key
### Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
2023-11-23 07:54:51 +00:00
id := "GK31c2f218a2e44f485b94239e" // string | The exact API access key generated by Garage
2022-11-13 13:22:00 +00:00
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
2023-11-23 07:54:51 +00:00
resp, r, err := apiClient.KeyApi.DeleteKey(context.Background()).Id(id).Execute()
2022-11-13 13:22:00 +00:00
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.DeleteKey``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
}
```
### Path Parameters
### Other Parameters
Other parameters are passed through a pointer to a apiDeleteKeyRequest struct via the builder pattern
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
2023-11-23 07:54:51 +00:00
**id** | **string** | The exact API access key generated by Garage |
2022-11-13 13:22:00 +00:00
### Return type
(empty response body)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)
## GetKey
2023-11-22 20:17:35 +00:00
> KeyInfo GetKey(ctx).Id(id).Search(search).ShowSecretKey(showSecretKey).Execute()
2022-11-13 13:22:00 +00:00
Get key information
### Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
2023-11-22 20:17:35 +00:00
id := "GK31c2f218a2e44f485b94239e" // string | The exact API access key generated by Garage. Incompatible with `search`. (optional)
search := "test-k" // string | A pattern (beginning or full string) corresponding to a key identifier or friendly name. Incompatible with `id`. (optional)
showSecretKey := "true" // string | Wether or not the secret key should be returned in the response (optional) (default to "false")
2022-11-13 13:22:00 +00:00
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
2023-11-22 20:17:35 +00:00
resp, r, err := apiClient.KeyApi.GetKey(context.Background()).Id(id).Search(search).ShowSecretKey(showSecretKey).Execute()
2022-11-13 13:22:00 +00:00
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.GetKey``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetKey`: KeyInfo
fmt.Fprintf(os.Stdout, "Response from `KeyApi.GetKey`: %v\n", resp)
}
```
### Path Parameters
### Other Parameters
Other parameters are passed through a pointer to a apiGetKeyRequest struct via the builder pattern
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
2023-11-22 20:17:35 +00:00
**id** | **string** | The exact API access key generated by Garage. Incompatible with `search`. |
**search** | **string** | A pattern (beginning or full string) corresponding to a key identifier or friendly name. Incompatible with `id`. |
**showSecretKey** | **string** | Wether or not the secret key should be returned in the response | [default to "false"]
2022-11-13 13:22:00 +00:00
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)
## ImportKey
> KeyInfo ImportKey(ctx).ImportKeyRequest(importKeyRequest).Execute()
Import an existing key
### Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
importKeyRequest := *openapiclient.NewImportKeyRequest("test-key", "GK31c2f218a2e44f485b94239e", "b892c0665f0ada8a4755dae98baa3b133590e11dae3bcc1f9d769d67f16c3835") // ImportKeyRequest | Information on the key to import
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.KeyApi.ImportKey(context.Background()).ImportKeyRequest(importKeyRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.ImportKey``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `ImportKey`: KeyInfo
fmt.Fprintf(os.Stdout, "Response from `KeyApi.ImportKey`: %v\n", resp)
}
```
### Path Parameters
### Other Parameters
Other parameters are passed through a pointer to a apiImportKeyRequest struct via the builder pattern
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**importKeyRequest** | [**ImportKeyRequest**](ImportKeyRequest.md) | Information on the key to import |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)
## ListKeys
> []ListKeys200ResponseInner ListKeys(ctx).Execute()
List all keys
### Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.KeyApi.ListKeys(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.ListKeys``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `ListKeys`: []ListKeys200ResponseInner
fmt.Fprintf(os.Stdout, "Response from `KeyApi.ListKeys`: %v\n", resp)
}
```
### Path Parameters
This endpoint does not need any parameter.
### Other Parameters
Other parameters are passed through a pointer to a apiListKeysRequest struct via the builder pattern
### Return type
[**[]ListKeys200ResponseInner**](ListKeys200ResponseInner.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)
## UpdateKey
2023-11-23 07:54:51 +00:00
> KeyInfo UpdateKey(ctx).Id(id).UpdateKeyRequest(updateKeyRequest).Execute()
2022-11-13 13:22:00 +00:00
Update a key
### Example
```go
package main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
2023-11-23 07:54:51 +00:00
id := "GK31c2f218a2e44f485b94239e" // string | The exact API access key generated by Garage
2022-11-13 13:22:00 +00:00
updateKeyRequest := *openapiclient.NewUpdateKeyRequest() // UpdateKeyRequest | For a given key, provide a first set with the permissions to grant, and a second set with the permissions to remove
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
2023-11-23 07:54:51 +00:00
resp, r, err := apiClient.KeyApi.UpdateKey(context.Background()).Id(id).UpdateKeyRequest(updateKeyRequest).Execute()
2022-11-13 13:22:00 +00:00
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.UpdateKey``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `UpdateKey`: KeyInfo
fmt.Fprintf(os.Stdout, "Response from `KeyApi.UpdateKey`: %v\n", resp)
}
```
### Path Parameters
### Other Parameters
Other parameters are passed through a pointer to a apiUpdateKeyRequest struct via the builder pattern
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
2023-11-23 07:54:51 +00:00
**id** | **string** | The exact API access key generated by Garage |
2022-11-13 13:22:00 +00:00
**updateKeyRequest** | [**UpdateKeyRequest**](UpdateKeyRequest.md) | For a given key, provide a first set with the permissions to grant, and a second set with the permissions to remove |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)