garage-admin-sdk-golang/README.md

185 lines
8.1 KiB
Markdown
Raw Permalink Normal View History

2022-11-13 13:22:00 +00:00
# Go API client for garage
Administrate your Garage cluster programatically, including status, layout, keys, buckets, and maintainance tasks.
*Disclaimer: The API is not stable yet, hence its v0 tag. The API can change at any time, and changes can include breaking backward compatibility. Read the changelog and upgrade your scripts before upgrading. Additionnaly, this specification is very early stage and can contain bugs, especially on error return codes/types that are not tested yet. Do not expect a well finished and polished product!*
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
2023-11-22 17:28:14 +00:00
- API version: v0.9.0
2023-11-22 20:17:35 +00:00
- Package version: 0.9.0
2022-11-13 13:22:00 +00:00
- Build package: org.openapitools.codegen.languages.GoClientCodegen
## Installation
Install the following dependencies:
```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
```
Put the package under your project folder and add the following in import:
```golang
2022-11-13 14:51:20 +00:00
import garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
2022-11-13 13:22:00 +00:00
```
To use a proxy, set the environment variable `HTTP_PROXY`:
```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```
## Configuration of Server URL
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
### Select Server Configuration
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
```golang
ctx := context.WithValue(context.Background(), garage.ContextServerIndex, 1)
```
### Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
```golang
ctx := context.WithValue(context.Background(), garage.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```
Note, enum values are always validated and all unused variables are silently ignored.
### URLs Configuration per Operation
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
```golang
ctx := context.WithValue(context.Background(), garage.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), garage.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```
## Documentation for API Endpoints
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
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*BucketApi* | [**AllowBucketKey**](docs/BucketApi.md#allowbucketkey) | **Post** /bucket/allow | Allow key
*BucketApi* | [**CreateBucket**](docs/BucketApi.md#createbucket) | **Post** /bucket | Create a bucket
2023-11-22 20:17:35 +00:00
*BucketApi* | [**DeleteBucket**](docs/BucketApi.md#deletebucket) | **Delete** /bucket | Delete a bucket
2022-11-13 13:22:00 +00:00
*BucketApi* | [**DeleteBucketGlobalAlias**](docs/BucketApi.md#deletebucketglobalalias) | **Delete** /bucket/alias/global | Delete a global alias
*BucketApi* | [**DeleteBucketLocalAlias**](docs/BucketApi.md#deletebucketlocalalias) | **Delete** /bucket/alias/local | Delete a local alias
*BucketApi* | [**DenyBucketKey**](docs/BucketApi.md#denybucketkey) | **Post** /bucket/deny | Deny key
2023-11-22 20:17:35 +00:00
*BucketApi* | [**GetBucketInfo**](docs/BucketApi.md#getbucketinfo) | **Get** /bucket | Get a bucket
*BucketApi* | [**ListBuckets**](docs/BucketApi.md#listbuckets) | **Get** /bucket?list | List all buckets
2022-11-13 13:22:00 +00:00
*BucketApi* | [**PutBucketGlobalAlias**](docs/BucketApi.md#putbucketglobalalias) | **Put** /bucket/alias/global | Add a global alias
*BucketApi* | [**PutBucketLocalAlias**](docs/BucketApi.md#putbucketlocalalias) | **Put** /bucket/alias/local | Add a local alias
2023-11-22 20:17:35 +00:00
*BucketApi* | [**UpdateBucket**](docs/BucketApi.md#updatebucket) | **Put** /bucket | Update a bucket
*KeyApi* | [**AddKey**](docs/KeyApi.md#addkey) | **Post** /key?list | Create a new API key
*KeyApi* | [**DeleteKey**](docs/KeyApi.md#deletekey) | **Delete** /key | Delete a key
*KeyApi* | [**GetKey**](docs/KeyApi.md#getkey) | **Get** /key | Get key information
2022-11-13 13:22:00 +00:00
*KeyApi* | [**ImportKey**](docs/KeyApi.md#importkey) | **Post** /key/import | Import an existing key
2023-11-22 20:17:35 +00:00
*KeyApi* | [**ListKeys**](docs/KeyApi.md#listkeys) | **Get** /key?list | List all keys
*KeyApi* | [**UpdateKey**](docs/KeyApi.md#updatekey) | **Post** /key | Update a key
2022-11-13 13:22:00 +00:00
*LayoutApi* | [**AddLayout**](docs/LayoutApi.md#addlayout) | **Post** /layout | Send modifications to the cluster layout
*LayoutApi* | [**ApplyLayout**](docs/LayoutApi.md#applylayout) | **Post** /layout/apply | Apply staged layout
*LayoutApi* | [**GetLayout**](docs/LayoutApi.md#getlayout) | **Get** /layout | Details on the current and staged layout
*LayoutApi* | [**RevertLayout**](docs/LayoutApi.md#revertlayout) | **Post** /layout/revert | Clear staged layout
2023-11-28 13:32:46 +00:00
*NodesApi* | [**AddNode**](docs/NodesApi.md#addnode) | **Post** /connect | Connect a new node
*NodesApi* | [**GetHealth**](docs/NodesApi.md#gethealth) | **Get** /health | Cluster health report
*NodesApi* | [**GetNodes**](docs/NodesApi.md#getnodes) | **Get** /status | Describe cluster
2022-11-13 13:22:00 +00:00
## Documentation For Models
- [AddKeyRequest](docs/AddKeyRequest.md)
- [AddNode200ResponseInner](docs/AddNode200ResponseInner.md)
- [AllowBucketKeyRequest](docs/AllowBucketKeyRequest.md)
- [AllowBucketKeyRequestPermissions](docs/AllowBucketKeyRequestPermissions.md)
2023-11-22 17:28:14 +00:00
- [ApplyLayout200Response](docs/ApplyLayout200Response.md)
2022-11-13 13:22:00 +00:00
- [BucketInfo](docs/BucketInfo.md)
- [BucketInfoQuotas](docs/BucketInfoQuotas.md)
- [BucketInfoWebsiteConfig](docs/BucketInfoWebsiteConfig.md)
- [BucketKeyInfo](docs/BucketKeyInfo.md)
- [ClusterLayout](docs/ClusterLayout.md)
- [CreateBucketRequest](docs/CreateBucketRequest.md)
- [CreateBucketRequestLocalAlias](docs/CreateBucketRequestLocalAlias.md)
- [CreateBucketRequestLocalAliasAllow](docs/CreateBucketRequestLocalAliasAllow.md)
2023-11-28 13:32:46 +00:00
- [GetHealth200Response](docs/GetHealth200Response.md)
2022-11-13 13:22:00 +00:00
- [GetNodes200Response](docs/GetNodes200Response.md)
- [ImportKeyRequest](docs/ImportKeyRequest.md)
- [KeyInfo](docs/KeyInfo.md)
- [KeyInfoBucketsInner](docs/KeyInfoBucketsInner.md)
- [KeyInfoBucketsInnerPermissions](docs/KeyInfoBucketsInnerPermissions.md)
- [KeyInfoPermissions](docs/KeyInfoPermissions.md)
- [LayoutVersion](docs/LayoutVersion.md)
- [ListBuckets200ResponseInner](docs/ListBuckets200ResponseInner.md)
- [ListBuckets200ResponseInnerLocalAliasesInner](docs/ListBuckets200ResponseInnerLocalAliasesInner.md)
- [ListKeys200ResponseInner](docs/ListKeys200ResponseInner.md)
- [NodeClusterInfo](docs/NodeClusterInfo.md)
- [NodeNetworkInfo](docs/NodeNetworkInfo.md)
2023-11-22 17:28:14 +00:00
- [NodeRoleChange](docs/NodeRoleChange.md)
- [NodeRoleRemove](docs/NodeRoleRemove.md)
- [NodeRoleUpdate](docs/NodeRoleUpdate.md)
2022-11-13 13:22:00 +00:00
- [UpdateBucketRequest](docs/UpdateBucketRequest.md)
- [UpdateBucketRequestQuotas](docs/UpdateBucketRequestQuotas.md)
- [UpdateBucketRequestWebsiteAccess](docs/UpdateBucketRequestWebsiteAccess.md)
- [UpdateKeyRequest](docs/UpdateKeyRequest.md)
- [UpdateKeyRequestAllow](docs/UpdateKeyRequestAllow.md)
- [UpdateKeyRequestDeny](docs/UpdateKeyRequestDeny.md)
## Documentation For Authorization
### bearerAuth
- **Type**: HTTP Bearer token authentication
Example
```golang
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
```
## Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:
* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`
## Author