Skip to content

Commit

Permalink
add organization edit command [EH-389]
Browse files Browse the repository at this point in the history
[EH-389]
  • Loading branch information
dogukancagatay committed Jul 3, 2023
1 parent 52a988c commit 57c7872
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 15 additions & 2 deletions aiven/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,11 +1418,9 @@ def service__backup_list(self) -> None:
self.print_response(backups, json=self.args.json, table_layout=layout)

def _get_project_ca(self) -> str:

return self.client.get_project_ca(project=self.get_project())["certificate"]

def _get_store_from_args(self) -> Store:

if self.args.overwrite:
store = Store.overwrite
elif self.args.write:
Expand Down Expand Up @@ -5550,6 +5548,21 @@ def organization__list(self) -> None:
]
self.print_response(organizations, json=self.args.json, table_layout=layout)

@arg.json
@arg.positional_organization_id
@arg("-n", "--name", required=True, help="New name for the organization")
def organization__update(self) -> None:
"""Update an organization"""
layout = [
"organization_name",
"organization_id",
"account_id",
"create_time",
"update_time",
]
organization = self.client.update_organization(self.args.organization_id, self.args.name)
self.print_response(organization, json=self.args.json, single_item=True, table_layout=layout)

@arg.positional_organization_id
@arg.force
def organization__delete(self) -> None:
Expand Down
5 changes: 5 additions & 0 deletions aiven/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,11 @@ def delete_organization(self, organization_id: str) -> None:
organization = self.verify(self.get, self.build_path("organization", organization_id))
self.delete_account(account_id=organization["account_id"])

def update_organization(self, organization_id: str, organization_name: str) -> Dict[str, Any]:
organization = self.verify(self.get, self.build_path("organization", organization_id))
self.update_account(account_id=organization["account_id"], account_name=organization_name)
return self.verify(self.get, self.build_path("organization", organization_id))

def list_organization_users(self, organization_id: str) -> Sequence[Dict[str, Any]]:
return self.verify(
self.get,
Expand Down

0 comments on commit 57c7872

Please sign in to comment.