Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get/Set Metadata from Tenant #129

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/duplo_resource/tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,31 @@ def remove_user(self,
raise DuploError(f"Failed to remove user '{name}' from tenant '{self.duplo.tenant}'", res["status_code"])
else:
return f"User '{name}' removed from tenant '{self.duplo.tenant}'"


@Command()
def get_metadata(self, name: args.NAME=None):
"""Get Tenant Metadata

Get the metadata for the tenant.

Usage: CLI Usage
```sh
duploctl tenant get_metadata
```

Returns:
metadata: The metadata for the tenant.
"""
tenant = self.find(name)
tenant_id = tenant["TenantId"]
response = self.duplo.get(f"admin/GetTenantConfigData/{tenant_id}")
return response.json()

@Command()
def set_metadata(self,
name: args.NAME=None,
metadata: args.METADATA=[],
deletes: args.DELETES=[]) -> dict:
"""Set Tenant Metadata"
"""
current = self.get_metadata(name)
6 changes: 6 additions & 0 deletions src/duplocloud/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@
nargs=2,
metavar=('key', 'value'))

SETMETA = Arg("setmeta", "-V",
help='A key value and type for the metadata.',
action='append',
nargs=3,
metavar=('key', 'type', 'value'))

STRATEGY = Arg("strategy", "-strat",
help='The merge strategy to use. Valid options are \"merge\" or \"replace\". Default is merge.',
choices=['merge', 'replace'],
Expand Down
Loading