From 90080c4e21a6c9f57e89522b8e5a6e68d6ae03b0 Mon Sep 17 00:00:00 2001 From: Angelo Cutaia Date: Wed, 20 Dec 2023 16:52:19 +0100 Subject: [PATCH] Remove avn account authentication-method We want to keep the user experience for authentication-methods in the console. [EH-829] --- aiven/client/cli.py | 91 ------------------------------------------ aiven/client/cliarg.py | 1 - aiven/client/client.py | 36 ----------------- 3 files changed, 128 deletions(-) diff --git a/aiven/client/cli.py b/aiven/client/cli.py index 28dd199..3637f8a 100644 --- a/aiven/client/cli.py +++ b/aiven/client/cli.py @@ -13,7 +13,6 @@ from aiven.client.connection_info.kafka import KafkaCertificateConnectionInfo, KafkaSASLConnectionInfo from aiven.client.connection_info.pg import PGConnectionInfo from aiven.client.connection_info.redis import RedisConnectionInfo -from aiven.client.pretty import TableLayout from aiven.client.speller import suggest from argparse import ArgumentParser from ast import literal_eval @@ -34,16 +33,6 @@ import sys import time -AUTHENTICATION_METHOD_COLUMNS = [ - "account_id", - "authentication_method_enabled", - "authentication_method_id", - "authentication_method_name", - "authentication_method_type", - "state", - "create_time", - "update_time", -] USER_GROUP_COLUMNS = [ "user_group_name", "user_group_id", @@ -683,86 +672,6 @@ def _parse_auth_config_options(config_cmdline: Sequence[str], config_file: Seque options[name] = value return options - @arg.json - @arg.account_id - @arg("-n", "--name", required=True, help="Authentication method name") - @arg( - "-t", - "--type", - required=True, - help="Authentication method type", - choices=["saml"], - ) - @arg.config_cmdline - @arg.config_file - def account__authentication_method__create(self) -> None: - """Create new account authentication method""" - options = self._parse_auth_config_options(self.args.config_cmdline, self.args.config_file) - method = self.client.create_account_authentication_method( - self.args.account_id, - method_name=self.args.name, - method_type=self.args.type, - options=options, - ) - acs_url = "https://api.aiven.io/v1/sso/saml/account/{}/method/{}/acs".format( - self.args.account_id, method["authentication_method_id"] - ) - metadata_url = "https://api.aiven.io/v1/sso/saml/account/{}/method/{}/metadata".format( - self.args.account_id, method["authentication_method_id"] - ) - acs_key = "ACS (Single Sign On / Recipient) URL" - metadata_key = "Metadata URL" - method[acs_key] = acs_url - method[metadata_key] = metadata_url - table_layout: TableLayout = [AUTHENTICATION_METHOD_COLUMNS, acs_key, metadata_key] - self.print_response(method, json=self.args.json, single_item=True, table_layout=table_layout) - - @arg.json - @arg.account_id - @arg.authentication_id - @arg("-n", "--name", help="New name for the authentication method") - @arg("--enable", help="Enable the authentication method", action="store_true") - @arg("--disable", help="Disable the authentication method", action="store_true") - @arg.config_cmdline - @arg.config_file - def account__authentication_method__update(self) -> None: - """Update an account authentication method""" - if self.args.enable and self.args.disable: - raise argx.UserError("Only set at most one of --enable and --disable") - enable = None - if self.args.enable: - enable = True - elif self.args.disable: - enable = False - options = self._parse_auth_config_options(self.args.config_cmdline, self.args.config_file) - account = self.client.update_account_authentication_method( - self.args.account_id, - self.args.authentication_id, - method_enable=enable, - method_name=self.args.name, - options=options, - ) - self.print_response( - account, - json=self.args.json, - single_item=True, - table_layout=AUTHENTICATION_METHOD_COLUMNS, - ) - - @arg.account_id - @arg.authentication_id - def account__authentication_method__delete(self) -> None: - """Delete an account authentication method""" - self.client.delete_account_authentication_method(self.args.account_id, self.args.authentication_id) - print("Deleted") - - @arg.json - @arg.account_id - def account__authentication_method__list(self) -> None: - """Lists all current account authentication methods""" - methods = self.client.get_account_authentication_methods(self.args.account_id) - self.print_response(methods, json=self.args.json, table_layout=AUTHENTICATION_METHOD_COLUMNS) - @arg.json @arg.account_id def account__team__list(self) -> None: diff --git a/aiven/client/cliarg.py b/aiven/client/cliarg.py index 3839a18..1b3ea9f 100644 --- a/aiven/client/cliarg.py +++ b/aiven/client/cliarg.py @@ -87,7 +87,6 @@ def wrapped(self: CommandLineTool) -> T: arg.account_id = arg("account_id", help="Account identifier") -arg.authentication_id = arg("authentication_id", help="Account authentication method identifier") arg.billing_address = arg("--billing-address", help="Physical billing address for invoices") arg.billing_currency = arg("--billing-currency", help="Currency for charges") arg.billing_extra_text = arg( diff --git a/aiven/client/client.py b/aiven/client/client.py index bf4867f..2454018 100644 --- a/aiven/client/client.py +++ b/aiven/client/client.py @@ -1618,42 +1618,6 @@ def update_account(self, account_id: str, account_name: str) -> Mapping: def get_accounts(self) -> Mapping: return self.verify(self.get, "/account", result_key="accounts") - def create_account_authentication_method( - self, account_id: str, method_name: str, method_type: str, options: Mapping[str, str] | None = None - ) -> dict: - body = dict(options) if options else {} - body["authentication_method_name"] = method_name - body["authentication_method_type"] = method_type - path = self.build_path("account", account_id, "authentication") - return self.verify(self.post, path, body=body, result_key="authentication_method") - - def delete_account_authentication_method(self, account_id: str, authentication_id: str) -> Mapping: - return self.verify( - self.delete, - self.build_path("account", account_id, "authentication", authentication_id), - ) - - def update_account_authentication_method( - self, - account_id: str, - authentication_id: str, - method_name: str | None = None, - method_enable: bool | None = None, - options: Mapping[str, str] | None = None, - ) -> Mapping: - body: dict[str, Any] = dict(options) if options else {} - if method_name is not None: - body["authentication_method_name"] = method_name - if method_enable is not None: - body["authentication_method_enabled"] = method_enable - - path = self.build_path("account", account_id, "authentication", authentication_id) - return self.verify(self.put, path, body=body, result_key="authentication_method") - - def get_account_authentication_methods(self, account_id: str) -> Sequence[dict[str, Any]]: - path = self.build_path("account", account_id, "authentication") - return self.verify(self.get, path, result_key="authentication_methods") - def create_project( self, project: str,