Skip to content

Commit

Permalink
Merge pull request #342 from aiven/dogukancagatay/EH-390/add-organiza…
Browse files Browse the repository at this point in the history
…tion-delete

add organization delete [EH-390]

#342
  • Loading branch information
BadassHenkka authored Jun 28, 2023
2 parents 5b05e40 + 5721f0a commit 351890d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions aiven/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5550,6 +5550,23 @@ def organization__list(self) -> None:
]
self.print_response(organizations, json=self.args.json, table_layout=layout)

@arg.positional_organization_id
@arg.force
def organization__delete(self) -> None:
"""Delete an organization"""
if not self.args.force:
self.print_boxed(
[
"Deleting organization cannot be undone and all data in the organization will be lost!",
]
)

if not self.confirm("Confirm delete (y/N)?"):
raise argx.UserError("Aborted")

self.client.delete_organization(self.args.organization_id)
print("Deleted")

@arg.json
@arg.organization_id
def organization__user__list(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions aiven/client/cliarg.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def wrapped(self: CommandLineTool) -> T:
help="Minimum required nodes In Sync Replicas (ISR) to produce to a partition (default: 1)",
)
arg.organization_id = arg("--organization_id", help="Organization identifier")
arg.positional_organization_id = arg("organization_id", help="Organization identifier")
arg.partitions = arg("--partitions", type=int, required=True, help="Number of partitions")
arg.project = arg(
"--project",
Expand Down
4 changes: 4 additions & 0 deletions aiven/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,10 @@ def flink_cancel_application_deployment(
def get_organizations(self) -> Sequence:
return self.verify(self.get, "/organizations", result_key="organizations")

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 list_organization_users(self, organization_id: str) -> Sequence[Dict[str, Any]]:
return self.verify(
self.get,
Expand Down

0 comments on commit 351890d

Please sign in to comment.