No description
Find a file
2022-11-12 23:05:29 +01:00
example Simplify+validate examples 2022-11-12 22:48:50 +01:00
garage@74ea449f4b Add missing parameter on UpdateBucket 2022-11-12 23:05:29 +01:00
python Add missing parameter on UpdateBucket 2022-11-12 23:05:29 +01:00
.gitignore Improve code generation 2022-09-13 16:00:03 +02:00
.gitmodules Improve code generation 2022-09-13 16:00:03 +02:00
build.gradle Update package version 2022-11-12 22:39:53 +01:00
README.md Simplify+validate examples 2022-11-12 22:48:50 +01:00

Garage Admin SDK

For SDK users

The SDK is currently only available for Python.

Python

You need at least Python 3.6, pip, and setuptools. Because the python package is in a subfolder, the command is a bit more complicated than usual:

pip3 install --user 'git+https://git.deuxfleurs.fr/quentin/garage-admin-sdk#egg=garage-admin-sdk&subdirectory=python'

Now, let imagine you have a fresh Garage instance running on localhost, with the admin API configured on port 3903 with the bearer s3cr3t:

import garage_admin_sdk
from garage_admin_sdk.apis import *
from garage_admin_sdk.models import *

configuration = garage_admin_sdk.Configuration(
  host = "http://localhost:3903/v0",
  access_token = "s3cr3t"
)

# Init APIs
api = garage_admin_sdk.ApiClient(configuration)
nodes = NodesApi(api)
layout = LayoutApi(api)
keys = KeyApi(api)

# Display some info on the node
status = nodes.get_nodes()
print(f"running garage {status.garage_version}, node_id {status.node}")

# Change layout of this node
current = layout.get_layout()
layout.add_layout({
  status.node: NodeClusterInfo(
    zone = "dc1",
    capacity = 1,
    tags = [ "dev" ],
  )
})
layout.apply_layout(LayoutVersion(
  version = current.version + 1
))

# Create key, allow it to create buckets
kinfo = keys.add_key(AddKeyRequest(name="openapi"))

allow_create = UpdateKeyRequestAllow(create_bucket=True)
keys.update_key(kinfo.access_key_id, UpdateKeyRequest(allow=allow_create))

# Display key
print(f"""
cluster ready
key id is {kinfo.access_key_id}
secret key is {kinfo.secret_access_key}
""")

This example is named short.py in the example folder. Other python examples are also available.

See also:

For SDK developpers

PR are accepted for other languages as soon as meaningful, manually written, covering a large range of the API are provided. Thanks in advance :-)

Clone this repo

git clone ...
git submodule update --init

(Re)generate libraries

# Check the OpenAPI spec file
gradle validate 

# (re)build the python client
gradle buildPythonClient

Support a new language

Read the doc: https://openapi-generator.tech/docs/installation
We use the Gradle plugins: https://openapi-generator.tech/docs/plugins
Many generators exist: https://openapi-generator.tech/docs/generators