Simplify+validate examples
This commit is contained in:
parent
675c677ab5
commit
9f4d8d2ebe
3 changed files with 15 additions and 27 deletions
14
README.md
14
README.md
|
@ -17,12 +17,8 @@ Now, let imagine you have a fresh Garage instance running on localhost, with the
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import garage_admin_sdk
|
import garage_admin_sdk
|
||||||
from garage_admin_sdk.api import nodes_api, layout_api, key_api
|
from garage_admin_sdk.apis import *
|
||||||
from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
|
from garage_admin_sdk.models import *
|
||||||
from garage_admin_sdk.model.layout_version import LayoutVersion
|
|
||||||
from garage_admin_sdk.model.add_key_request import AddKeyRequest
|
|
||||||
from garage_admin_sdk.model.update_key_request import UpdateKeyRequest
|
|
||||||
from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow
|
|
||||||
|
|
||||||
configuration = garage_admin_sdk.Configuration(
|
configuration = garage_admin_sdk.Configuration(
|
||||||
host = "http://localhost:3903/v0",
|
host = "http://localhost:3903/v0",
|
||||||
|
@ -31,9 +27,9 @@ configuration = garage_admin_sdk.Configuration(
|
||||||
|
|
||||||
# Init APIs
|
# Init APIs
|
||||||
api = garage_admin_sdk.ApiClient(configuration)
|
api = garage_admin_sdk.ApiClient(configuration)
|
||||||
nodes = nodes_api.NodesApi(api)
|
nodes = NodesApi(api)
|
||||||
layout = layout_api.LayoutApi(api)
|
layout = LayoutApi(api)
|
||||||
keys = key_api.KeyApi(api)
|
keys = KeyApi(api)
|
||||||
|
|
||||||
# Display some info on the node
|
# Display some info on the node
|
||||||
status = nodes.get_nodes()
|
status = nodes.get_nodes()
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import garage_admin_sdk
|
import garage_admin_sdk
|
||||||
from garage_admin_sdk.api import nodes_api, layout_api, key_api
|
from garage_admin_sdk.apis import *
|
||||||
from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
|
from garage_admin_sdk.models import *
|
||||||
from garage_admin_sdk.model.layout_version import LayoutVersion
|
|
||||||
from garage_admin_sdk.model.add_key_request import AddKeyRequest
|
|
||||||
from garage_admin_sdk.model.update_key_request import UpdateKeyRequest
|
|
||||||
from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow
|
|
||||||
|
|
||||||
configuration = garage_admin_sdk.Configuration(
|
configuration = garage_admin_sdk.Configuration(
|
||||||
host = "http://localhost:3903/v0",
|
host = "http://localhost:3903/v0",
|
||||||
|
@ -13,12 +9,12 @@ configuration = garage_admin_sdk.Configuration(
|
||||||
|
|
||||||
with garage_admin_sdk.ApiClient(configuration) as api_client:
|
with garage_admin_sdk.ApiClient(configuration) as api_client:
|
||||||
# --- NODE INFO ---
|
# --- NODE INFO ---
|
||||||
nodes = nodes_api.NodesApi(api_client)
|
nodes = NodesApi(api_client)
|
||||||
status = nodes.get_nodes()
|
status = nodes.get_nodes()
|
||||||
print(f"running garage {status.garage_version}, node_id {status.node}")
|
print(f"running garage {status.garage_version}, node_id {status.node}")
|
||||||
|
|
||||||
# --- LAYOUT ---
|
# --- LAYOUT ---
|
||||||
layout = layout_api.LayoutApi(api_client)
|
layout = LayoutApi(api_client)
|
||||||
|
|
||||||
current = layout.get_layout()
|
current = layout.get_layout()
|
||||||
dirty_node = len(current.roles) != 0 or \
|
dirty_node = len(current.roles) != 0 or \
|
||||||
|
@ -52,7 +48,7 @@ with garage_admin_sdk.ApiClient(configuration) as api_client:
|
||||||
|
|
||||||
|
|
||||||
# --- CREATE KEY ---
|
# --- CREATE KEY ---
|
||||||
keys = key_api.KeyApi(api_client)
|
keys = KeyApi(api_client)
|
||||||
kreq = AddKeyRequest(name="openapi")
|
kreq = AddKeyRequest(name="openapi")
|
||||||
kinfo = keys.add_key(kreq)
|
kinfo = keys.add_key(kreq)
|
||||||
print(f"key {kinfo.name} added.")
|
print(f"key {kinfo.name} added.")
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import garage_admin_sdk
|
import garage_admin_sdk
|
||||||
from garage_admin_sdk.api import nodes_api, layout_api, key_api
|
from garage_admin_sdk.apis import *
|
||||||
from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
|
from garage_admin_sdk.models import *
|
||||||
from garage_admin_sdk.model.layout_version import LayoutVersion
|
|
||||||
from garage_admin_sdk.model.add_key_request import AddKeyRequest
|
|
||||||
from garage_admin_sdk.model.update_key_request import UpdateKeyRequest
|
|
||||||
from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow
|
|
||||||
|
|
||||||
configuration = garage_admin_sdk.Configuration(
|
configuration = garage_admin_sdk.Configuration(
|
||||||
host = "http://localhost:3903/v0",
|
host = "http://localhost:3903/v0",
|
||||||
|
@ -13,9 +9,9 @@ configuration = garage_admin_sdk.Configuration(
|
||||||
|
|
||||||
# Init APIs
|
# Init APIs
|
||||||
api = garage_admin_sdk.ApiClient(configuration)
|
api = garage_admin_sdk.ApiClient(configuration)
|
||||||
nodes = nodes_api.NodesApi(api)
|
nodes = NodesApi(api)
|
||||||
layout = layout_api.LayoutApi(api)
|
layout = LayoutApi(api)
|
||||||
keys = key_api.KeyApi(api)
|
keys = KeyApi(api)
|
||||||
|
|
||||||
# Display some info on the node
|
# Display some info on the node
|
||||||
status = nodes.get_nodes()
|
status = nodes.get_nodes()
|
||||||
|
|
Loading…
Reference in a new issue