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

12 KiB

\KeyApi

All URIs are relative to http://localhost:3903/v0

Method HTTP request Description
AddKey Post /key Create a new API key
DeleteKey Delete /key?id={access_key} Delete a key
GetKey Get /key?id={access_key} Get key information
ImportKey Post /key/import Import an existing key
ListKeys Get /key List all keys
SearchKey Get /key?search={pattern} Select key by pattern
UpdateKey Post /key?id={access_key} Update a key

AddKey

KeyInfo AddKey(ctx).AddKeyRequest(addKeyRequest).Execute()

Create a new API key

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    addKeyRequest := *openapiclient.NewAddKeyRequest() // AddKeyRequest | \"You can set a friendly name for this key, send an empty string instead\" 

    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
addKeyRequest AddKeyRequest "You can set a friendly name for this key, send an empty string instead"

Return type

KeyInfo

Authorization

bearerAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteKey

DeleteKey(ctx, accessKey).Execute()

Delete a key

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    accessKey := "GK31c2f218a2e44f485b94239e" // string | The exact API access key generated by Garage

    configuration := openapiclient.NewConfiguration()
    apiClient := openapiclient.NewAPIClient(configuration)
    resp, r, err := apiClient.KeyApi.DeleteKey(context.Background(), accessKey).Execute()
    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

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
accessKey string The exact API access key generated by Garage

Other Parameters

Other parameters are passed through a pointer to a apiDeleteKeyRequest struct via the builder pattern

Name Type Description Notes

Return type

(empty response body)

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetKey

KeyInfo GetKey(ctx, accessKey).Execute()

Get key information

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    accessKey := "GK31c2f218a2e44f485b94239e" // string | The exact API access key generated by Garage

    configuration := openapiclient.NewConfiguration()
    apiClient := openapiclient.NewAPIClient(configuration)
    resp, r, err := apiClient.KeyApi.GetKey(context.Background(), accessKey).Execute()
    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

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
accessKey string The exact API access key generated by Garage

Other Parameters

Other parameters are passed through a pointer to a apiGetKeyRequest struct via the builder pattern

Name Type Description Notes

Return type

KeyInfo

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ImportKey

KeyInfo ImportKey(ctx).ImportKeyRequest(importKeyRequest).Execute()

Import an existing key

Example

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 Information on the key to import

Return type

KeyInfo

Authorization

bearerAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListKeys

[]ListKeys200ResponseInner ListKeys(ctx).Execute()

List all keys

Example

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**

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

SearchKey

KeyInfo SearchKey(ctx, pattern).Execute()

Select key by pattern

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    pattern := "test-k" // string | A pattern (beginning or full string) corresponding to a key identifier or friendly name

    configuration := openapiclient.NewConfiguration()
    apiClient := openapiclient.NewAPIClient(configuration)
    resp, r, err := apiClient.KeyApi.SearchKey(context.Background(), pattern).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.SearchKey``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `SearchKey`: KeyInfo
    fmt.Fprintf(os.Stdout, "Response from `KeyApi.SearchKey`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
pattern string A pattern (beginning or full string) corresponding to a key identifier or friendly name

Other Parameters

Other parameters are passed through a pointer to a apiSearchKeyRequest struct via the builder pattern

Name Type Description Notes

Return type

KeyInfo

Authorization

bearerAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

UpdateKey

KeyInfo UpdateKey(ctx, accessKey).UpdateKeyRequest(updateKeyRequest).Execute()

Update a key

Example

package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "./openapi"
)

func main() {
    accessKey := "GK31c2f218a2e44f485b94239e" // string | The exact API access key generated by Garage
    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)
    resp, r, err := apiClient.KeyApi.UpdateKey(context.Background(), accessKey).UpdateKeyRequest(updateKeyRequest).Execute()
    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

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
accessKey string The exact API access key generated by Garage

Other Parameters

Other parameters are passed through a pointer to a apiUpdateKeyRequest struct via the builder pattern

Name Type Description Notes

updateKeyRequest | UpdateKeyRequest | 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

Authorization

bearerAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]