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
|
||||
import garage_admin_sdk
|
||||
from garage_admin_sdk.api import nodes_api, layout_api, key_api
|
||||
from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
|
||||
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
|
||||
from garage_admin_sdk.apis import *
|
||||
from garage_admin_sdk.models import *
|
||||
|
||||
configuration = garage_admin_sdk.Configuration(
|
||||
host = "http://localhost:3903/v0",
|
||||
|
@ -31,9 +27,9 @@ configuration = garage_admin_sdk.Configuration(
|
|||
|
||||
# Init APIs
|
||||
api = garage_admin_sdk.ApiClient(configuration)
|
||||
nodes = nodes_api.NodesApi(api)
|
||||
layout = layout_api.LayoutApi(api)
|
||||
keys = key_api.KeyApi(api)
|
||||
nodes = NodesApi(api)
|
||||
layout = LayoutApi(api)
|
||||
keys = KeyApi(api)
|
||||
|
||||
# Display some info on the node
|
||||
status = nodes.get_nodes()
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import garage_admin_sdk
|
||||
from garage_admin_sdk.api import nodes_api, layout_api, key_api
|
||||
from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
|
||||
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
|
||||
from garage_admin_sdk.apis import *
|
||||
from garage_admin_sdk.models import *
|
||||
|
||||
configuration = garage_admin_sdk.Configuration(
|
||||
host = "http://localhost:3903/v0",
|
||||
|
@ -13,12 +9,12 @@ configuration = garage_admin_sdk.Configuration(
|
|||
|
||||
with garage_admin_sdk.ApiClient(configuration) as api_client:
|
||||
# --- NODE INFO ---
|
||||
nodes = nodes_api.NodesApi(api_client)
|
||||
nodes = NodesApi(api_client)
|
||||
status = nodes.get_nodes()
|
||||
print(f"running garage {status.garage_version}, node_id {status.node}")
|
||||
|
||||
# --- LAYOUT ---
|
||||
layout = layout_api.LayoutApi(api_client)
|
||||
layout = LayoutApi(api_client)
|
||||
|
||||
current = layout.get_layout()
|
||||
dirty_node = len(current.roles) != 0 or \
|
||||
|
@ -52,7 +48,7 @@ with garage_admin_sdk.ApiClient(configuration) as api_client:
|
|||
|
||||
|
||||
# --- CREATE KEY ---
|
||||
keys = key_api.KeyApi(api_client)
|
||||
keys = KeyApi(api_client)
|
||||
kreq = AddKeyRequest(name="openapi")
|
||||
kinfo = keys.add_key(kreq)
|
||||
print(f"key {kinfo.name} added.")
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import garage_admin_sdk
|
||||
from garage_admin_sdk.api import nodes_api, layout_api, key_api
|
||||
from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo
|
||||
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
|
||||
from garage_admin_sdk.apis import *
|
||||
from garage_admin_sdk.models import *
|
||||
|
||||
configuration = garage_admin_sdk.Configuration(
|
||||
host = "http://localhost:3903/v0",
|
||||
|
@ -13,9 +9,9 @@ configuration = garage_admin_sdk.Configuration(
|
|||
|
||||
# Init APIs
|
||||
api = garage_admin_sdk.ApiClient(configuration)
|
||||
nodes = nodes_api.NodesApi(api)
|
||||
layout = layout_api.LayoutApi(api)
|
||||
keys = key_api.KeyApi(api)
|
||||
nodes = NodesApi(api)
|
||||
layout = LayoutApi(api)
|
||||
keys = KeyApi(api)
|
||||
|
||||
# Display some info on the node
|
||||
status = nodes.get_nodes()
|
||||
|
|
Loading…
Reference in a new issue