From 4ec5df085cfae33b620b705e4b89749cd3dd1447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=87a=C4=9Fatay?= Date: Wed, 8 Nov 2023 15:13:41 +0100 Subject: [PATCH 1/5] Add ignore for ruff and pytest cache folders Pytest (`.pytest_cache`) and Ruff (`.ruff_cache`) cache directories are added to the `.gitignore`. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b4ee9785..402c2983 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,7 @@ Pipfile* /rpms/ __pycache__/ .mypy_cache/ +.pytest_cache/ +.ruff_cache/ .vscode venv From 5665bcec34f39742c3e4c0dea5fc69011937be26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=87a=C4=9Fatay?= Date: Wed, 8 Nov 2023 15:31:20 +0100 Subject: [PATCH 2/5] Remove deprecated avn card command completely [EH-766] User credit cards API was deprecated and *avn card* command and subcommands (`add`, `list`, `remove`, `update`) are removed from CLI client. [EH-766] --- aiven/client/cli.py | 82 ------------------------------------------ aiven/client/client.py | 28 --------------- 2 files changed, 110 deletions(-) diff --git a/aiven/client/cli.py b/aiven/client/cli.py index b92e2df4..c1b698da 100644 --- a/aiven/client/cli.py +++ b/aiven/client/cli.py @@ -4882,88 +4882,6 @@ def pre_run(self, func: Callable[[], int | None]) -> None: elif not getattr(func, "optional_auth", False): raise argx.UserError("not authenticated: please login first with 'avn user login'") - @arg.json - def card__list(self) -> None: - """List credit cards""" - layout = [["card_id", "name", "country", "exp_year", "exp_month", "last4"]] - self.print_response(self.client.get_cards(), json=self.args.json, table_layout=layout) - - def _card_get_stripe_token( - self, stripe_publishable_key: str, name: str, number: str, exp_month: int, exp_year: int, cvc: str - ) -> str: - data = { - "card[name]": name, - "card[number]": number, - "card[exp_month]": exp_month, - "card[exp_year]": exp_year, - "card[cvc]": cvc, - "key": stripe_publishable_key, - } - response = requests.post("https://api.stripe.com/v1/tokens", data=data, timeout=30) - if not response.ok: - print(response.text) - response.raise_for_status() - return response.json()["id"] - - @arg.json - @arg("--cvc", help="Credit card security code", required=True) - @arg("--exp-month", help="Card expiration month (1-12)", type=int, required=True) - @arg("--exp-year", help="Card expiration year", type=int, required=True) - @arg("--name", help="Name on card", required=True) - @arg("--number", help="Credit card number", type=int, required=True) - @arg("--update-project", help="Assign card to project") - def card__add(self) -> None: - """Add a credit card""" - self.print_boxed( - [ - "avn card add has been deprecated and will be removed in the next major release.", - "Please use `avn organization --organization-id organization_id card create`", - ] - ) - - stripe_key = self.client.get_stripe_key() - stripe_token = self._card_get_stripe_token( - stripe_key, - self.args.name, - self.args.number, - self.args.exp_month, - self.args.exp_year, - self.args.cvc, - ) - card = self.client.add_card(stripe_token) - if self.args.json: - self.print_response(card, json=True) - - if self.args.update_project: - self.client.update_project( - project=self.args.update_project, - card_id=card["card_id"], - ) - - @arg.json - @arg("card-id", help="Card ID") - @arg("--exp-month", help="Card expiration month (1-12)", type=int) - @arg("--exp-year", help="Card expiration year", type=int) - @arg("--name", help="Name on card") - def card__update(self) -> None: - """Update credit card information""" - card = self.client.update_card( - card_id=getattr(self.args, "card-id"), - exp_month=self.args.exp_month, - exp_year=self.args.exp_year, - name=self.args.name, - ) - if self.args.json: - self.print_response(card, json=True) - - @arg.json - @arg("card-id", help="Card ID") - def card__remove(self) -> None: - """Remove a credit card""" - result = self.client.remove_card(card_id=getattr(self.args, "card-id")) - if self.args.json: - self.print_response(result, json=True) - @arg.json @arg.project def credits__list(self) -> None: diff --git a/aiven/client/client.py b/aiven/client/client.py index 9e502f84..40d69bf9 100644 --- a/aiven/client/client.py +++ b/aiven/client/client.py @@ -1833,34 +1833,6 @@ def get_events(self, project: str, limit: int = 100) -> Sequence[dict[str, Any]] result_key="events", ) - def get_cards(self) -> Sequence[dict[str, Any]]: - return self.verify(self.get, "/card", result_key="cards") - - def add_card(self, stripe_token: str) -> Mapping: - request = { - "stripe_token": stripe_token, - } - return self.verify(self.post, "/card", body=request, result_key="card") - - def update_card(self, card_id: str, **kwargs: Any) -> Mapping: - keys = {"exp_month", "exp_year", "name"} - wrong = set(kwargs) - keys - assert not wrong, "invalid arguments to update_card: {!r}".format(wrong) - request: dict[str, Any] = {} - for key in keys: - value = kwargs.get(key) - if value is not None: - expected: type = int if key in {"exp_month", "exp_year"} else str - - assert isinstance(value, expected), "expected '{}' type for argument '{}'".format(expected, key) - - request[key] = value - - return self.verify(self.put, self.build_path("card", card_id), body=request, result_key="card") - - def remove_card(self, card_id: str) -> Mapping: - return self.verify(self.delete, self.build_path("card", card_id)) - def get_stripe_key(self) -> str: return self.verify(self.get, self.build_path("config", "stripe_key"), result_key="stripe_key") From a3e7355fa35d06da5d1e2838c5a081ee3ba64d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=87a=C4=9Fatay?= Date: Thu, 9 Nov 2023 10:25:31 +0100 Subject: [PATCH 3/5] Replace account-id with parent-id parameter for project create/update [EH-766] - Deprecated `account-id` parameter is removed from `project create/update`. - `parent-id` replaces `account-id`. - `parent-id` is made required when creating projects. [EH-766] --- aiven/client/argx.py | 16 ++++ aiven/client/cli.py | 34 +++---- aiven/client/cliarg.py | 1 + aiven/client/client.py | 5 +- tests/test_cli.py | 204 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 235 insertions(+), 25 deletions(-) diff --git a/aiven/client/argx.py b/aiven/client/argx.py index b3096a33..4b54fa5c 100644 --- a/aiven/client/argx.py +++ b/aiven/client/argx.py @@ -78,6 +78,22 @@ def __call__( class NextReleaseDeprecationNotice(ArgumentDeprecationNotice): + """Action class for CLI parameters that will be deprecated in the next major release. + + Parameters: + deprecation_message_hint: (Optional) Shows the message when you use the parameter. + deprecation_help_hint: (Optional) Shows the message on help text. + + Example Usage: + @arg( + "--account-id", + help="Account ID of the project", + action=argx.NextReleaseDeprecationNotice, + deprecation_message_hint="Please use `--parent-id` instead, which will be mandatory in the next release.", + deprecation_help_hint="Will be replaced by `--parent-id` in the next release.", + ) + """ + message = "Argument `%s` is deprecated and will be removed in the next release." diff --git a/aiven/client/cli.py b/aiven/client/cli.py index c1b698da..7f3bf0aa 100644 --- a/aiven/client/cli.py +++ b/aiven/client/cli.py @@ -4310,14 +4310,15 @@ def _show_projects(self, projects: Sequence[dict[str, Any]], verbose: bool = Tru layout = [["project_name", "default_cloud", "credit_card"]] self.print_response(projects, json=getattr(self.args, "json", False), table_layout=layout) + def _resolve_parent_id(self, parent_id: str) -> str: + """Resolves parent id to an account id, if parent id was an organization id""" + + if parent_id.startswith("org"): + org_info = self.client.get_organization(parent_id) + return org_info["account_id"] + return parent_id + @arg("project_name", help="Project name") - @arg( - "--account-id", - help="Account ID of the project", - action=argx.NextReleaseDeprecationNotice, - deprecation_message_hint="Please use `--parent-id` instead, which will be mandatory in the next release.", - deprecation_help_hint="Will be replaced by `--parent-id` in the next release.", - ) @arg("--billing-group-id", help="Billing group ID of the project") @arg.card_id @arg.cloud @@ -4349,23 +4350,12 @@ def _show_projects(self, projects: Sequence[dict[str, Any]], verbose: bool = Tru @arg.vat_id @arg.billing_email @arg.tech_email - @arg.parent_id + @arg.parent_id_mandatory def project__create(self) -> None: """Create a project""" - - if self.args.parent_id is not None and self.args.account_id is not None: - raise argx.UserError("`--parent-id` and `--account-id` cannot be specified together.") - - account_id = self.args.parent_id or self.args.account_id - - # If parent id was an organization id, resolve to root account id - if account_id.startswith("org"): - org_info = self.client.get_organization(self.args.parent_id) - account_id = org_info["account_id"] - try: project = self.client.create_project( - account_id=account_id, + account_id=self._resolve_parent_id(self.args.parent_id), billing_address=self.args.billing_address, billing_currency=self.args.billing_currency, billing_extra_text=self.args.billing_extra_text, @@ -4413,8 +4403,8 @@ def project__list(self) -> None: @arg.project @arg("--name", help="New project name") - @arg("--account-id", help="Account ID of the project") @arg("--card-id", help="Card ID") + @arg.parent_id @arg.cloud @arg.country_code @arg.billing_address @@ -4429,7 +4419,7 @@ def project__update(self) -> None: try: project = self.client.update_project( new_project_name=self.args.name, - account_id=self.args.account_id, + account_id=self._resolve_parent_id(self.args.parent_id) if self.args.parent_id else None, billing_address=self.args.billing_address, billing_currency=self.args.billing_currency, billing_extra_text=self.args.billing_extra_text, diff --git a/aiven/client/cliarg.py b/aiven/client/cliarg.py index 081c4a43..3839a18c 100644 --- a/aiven/client/cliarg.py +++ b/aiven/client/cliarg.py @@ -137,6 +137,7 @@ def wrapped(self: CommandLineTool) -> T: arg.organization_id = arg("--organization-id", required=True, help="Organization identifier") arg.organization_id_positional = arg("organization_id", help="Organization identifier") arg.parent_id = arg("--parent-id", help="Organization or account identifier") +arg.parent_id_mandatory = arg("--parent-id", required=True, help="Organization or account identifier") arg.partitions = arg("--partitions", type=int, required=True, help="Number of partitions") arg.project = arg( "--project", diff --git a/aiven/client/client.py b/aiven/client/client.py index 40d69bf9..1690eef8 100644 --- a/aiven/client/client.py +++ b/aiven/client/client.py @@ -1639,7 +1639,7 @@ def get_account_authentication_methods(self, account_id: str) -> Sequence[dict[s def create_project( self, project: str, - account_id: str | None = None, + account_id: str, billing_group_id: str | None = None, card_id: str | None = None, cloud: str | None = None, @@ -1657,9 +1657,8 @@ def create_project( "card_id": card_id, "cloud": cloud, "project": project, + "account_id": account_id, } - if account_id is not None: - body["account_id"] = account_id if billing_group_id is not None: body["billing_group_id"] = billing_group_id if copy_from_project is not None: diff --git a/tests/test_cli.py b/tests/test_cli.py index fafaef45..d52a3a61 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -23,6 +23,8 @@ import string import uuid +EXIT_CODE_INVALID_USAGE = 2 + def test_cli() -> None: with pytest.raises(SystemExit) as excinfo: @@ -1291,3 +1293,205 @@ def test_organizations_list(capsys: CaptureFixture[str]) -> None: captured = capsys.readouterr() assert "My Org" in captured.out assert "business" in captured.out + + +def test_project_create__parent_id_required() -> None: + aiven_client = mock.Mock(spec_set=AivenClient) + + with pytest.raises(SystemExit) as excinfo: + build_aiven_cli(aiven_client).run( + args=[ + "project", + "create", + "new-project", + ] + ) + assert excinfo.value.code == EXIT_CODE_INVALID_USAGE + + +def test_project_create__parent_id_requested_correctly() -> None: + aiven_client = mock.Mock(spec_set=AivenClient) + account_id = "a1231231" + project_name = "new-project" + + aiven_client.create_project.return_value = { + "project_id": "p123123124", + "project_name": project_name, + "default_cloud": "my-default-cloud", + "billing_currency": "USD", + "vat_id": "", + "billing_extra_text": "", + } + + build_aiven_cli(aiven_client).run( + args=[ + "project", + "create", + "--parent-id", + account_id, + project_name, + ] + ) + aiven_client.create_project.assert_called_with( + account_id=account_id, + project=project_name, + billing_address=None, + billing_currency=None, + billing_extra_text=None, + billing_group_id=None, + card_id=None, + cloud=None, + copy_from_project=None, + country_code=None, + vat_id=None, + billing_emails=None, + tech_emails=None, + use_source_project_billing_group=False, + ) + + +def test_project_create__parent_id_as_org_id_requested_correctly() -> None: + aiven_client = mock.Mock(spec_set=AivenClient) + organization_id = "org2131231" + account_id = "a1231231" + project_name = "new-project-name" + + aiven_client.get_organization.return_value = { + "organization_id": organization_id, + "organization_name": "My Org", + "account_id": account_id, + "tier": "business", + "create_time": "2023-07-13T08:00:45Z", + "update_time": "2023-07-13T08:00:45Z", + } + + aiven_client.create_project.return_value = { + "project_id": "p123123124", + "project_name": project_name, + "default_cloud": "my-default-cloud", + "billing_currency": "USD", + "vat_id": "", + "billing_extra_text": "", + } + + build_aiven_cli(aiven_client).run( + args=[ + "project", + "create", + "--parent-id", + organization_id, + project_name, + ] + ) + aiven_client.create_project.assert_called_with( + account_id=account_id, + project=project_name, + billing_address=None, + billing_currency=None, + billing_extra_text=None, + billing_group_id=None, + card_id=None, + cloud=None, + copy_from_project=None, + country_code=None, + vat_id=None, + billing_emails=None, + tech_emails=None, + use_source_project_billing_group=False, + ) + + +def test_project_update__parent_id_requested_correctly() -> None: + aiven_client = mock.Mock(spec_set=AivenClient) + account_id = "a1231231" + project_name = "my-project-name" + new_project_name = "new-project-name" + + aiven_client.update_project.return_value = { + "project_id": "p123123124", + "project_name": new_project_name, + "default_cloud": "my-default-cloud", + "billing_currency": "USD", + "vat_id": "", + "billing_extra_text": "", + } + + build_aiven_cli(aiven_client).run( + args=[ + "project", + "update", + "--project", + project_name, + "--parent-id", + account_id, + "--name", + new_project_name, + ] + ) + aiven_client.update_project.assert_called_with( + new_project_name=new_project_name, + account_id=account_id, + billing_address=None, + billing_currency=None, + billing_extra_text=None, + card_id=None, + cloud=None, + country_code=None, + project=project_name, + vat_id=None, + billing_emails=None, + tech_emails=None, + ) + + +def test_project_update__parent_id_as_org_id_requested_correctly() -> None: + aiven_client = mock.Mock(spec_set=AivenClient) + organization_id = "org2131231" + account_id = "a1231231" + project_name = "my-project-name" + new_project_name = "new-project-name" + + aiven_client.get_organization.return_value = { + "organization_id": organization_id, + "organization_name": "My Org", + "account_id": account_id, + "tier": "business", + "create_time": "2023-07-13T08:00:45Z", + "update_time": "2023-07-13T08:00:45Z", + } + + aiven_client.update_project.return_value = { + "project_id": "p123123124", + "project_name": new_project_name, + "default_cloud": "my-default-cloud", + "billing_currency": "USD", + "vat_id": "", + "billing_extra_text": "", + } + + build_aiven_cli(aiven_client).run( + args=[ + "project", + "update", + "--project", + project_name, + "--parent-id", + organization_id, + "--name", + new_project_name, + ] + ) + aiven_client.update_project.assert_called_with( + new_project_name=new_project_name, + account_id=account_id, + billing_address=None, + billing_currency=None, + billing_extra_text=None, + card_id=None, + cloud=None, + country_code=None, + project=project_name, + vat_id=None, + billing_emails=None, + tech_emails=None, + ) From bff14501b3c0e1068dccd4563b38c61232be70de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=87a=C4=9Fatay?= Date: Thu, 9 Nov 2023 13:54:40 +0100 Subject: [PATCH 4/5] Remove billing related properties from project details [EH-766] The following fields are removed from displayed project details and, replaced with `billing_group_id` and `billing_group_name`. (e.g. by `project list`) - `credit_card` - `billing_address` - `country_code` - `billing_currency` - `vat_id` [EH-766] --- aiven/client/cli.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/aiven/client/cli.py b/aiven/client/cli.py index 7f3bf0aa..92cca33d 100644 --- a/aiven/client/cli.py +++ b/aiven/client/cli.py @@ -4295,19 +4295,14 @@ def _format_card_info(cls, project: Mapping[str, Any]) -> str: return "{}/{}".format(project["card_info"]["user_email"], project["card_info"]["card_id"]) def _show_projects(self, projects: Sequence[dict[str, Any]], verbose: bool = True) -> None: - for project in projects: - project["credit_card"] = self._format_card_info(project) if verbose: layout: list = [ - ["project_name", "default_cloud", "billing_currency", "vat_id"], - "credit_card", - "billing_address", - "country_code", + ["project_name", "default_cloud"], + "billing_group_id", + "billing_group_name", ] - if any(project["billing_extra_text"] for project in projects): - layout.append("billing_extra_text") else: - layout = [["project_name", "default_cloud", "credit_card"]] + layout = [["project_name", "default_cloud"]] self.print_response(projects, json=getattr(self.args, "json", False), table_layout=layout) def _resolve_parent_id(self, parent_id: str) -> str: From 94328e1b413166b06e4bcec8e3666e76aedb63fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=87a=C4=9Fatay?= Date: Thu, 9 Nov 2023 14:03:58 +0100 Subject: [PATCH 5/5] Remove parameters related to billing from avn project create/update commands [EH-766] The following parameters are removed from `avn project create/update` commands. - `country-code` - `billing-address` - `billing-extra-text` - `billing-currency` - `vat-id` - `billing-email` - `card-id` [EH-766] --- aiven/client/cli.py | 41 +++++++++-------------------------------- aiven/client/client.py | 41 ----------------------------------------- tests/test_cli.py | 28 ---------------------------- 3 files changed, 9 insertions(+), 101 deletions(-) diff --git a/aiven/client/cli.py b/aiven/client/cli.py index 92cca33d..26b95b3c 100644 --- a/aiven/client/cli.py +++ b/aiven/client/cli.py @@ -4295,14 +4295,19 @@ def _format_card_info(cls, project: Mapping[str, Any]) -> str: return "{}/{}".format(project["card_info"]["user_email"], project["card_info"]["card_id"]) def _show_projects(self, projects: Sequence[dict[str, Any]], verbose: bool = True) -> None: + for project in projects: + project["credit_card"] = self._format_card_info(project) if verbose: layout: list = [ - ["project_name", "default_cloud"], - "billing_group_id", - "billing_group_name", + ["project_name", "default_cloud", "billing_currency", "vat_id"], + "credit_card", + "billing_address", + "country_code", ] + if any(project["billing_extra_text"] for project in projects): + layout.append("billing_extra_text") else: - layout = [["project_name", "default_cloud"]] + layout = [["project_name", "default_cloud", "credit_card"]] self.print_response(projects, json=getattr(self.args, "json", False), table_layout=layout) def _resolve_parent_id(self, parent_id: str) -> str: @@ -4315,7 +4320,6 @@ def _resolve_parent_id(self, parent_id: str) -> str: @arg("project_name", help="Project name") @arg("--billing-group-id", help="Billing group ID of the project") - @arg.card_id @arg.cloud @arg( "--no-fail-if-exists", @@ -4338,12 +4342,6 @@ def _resolve_parent_id(self, parent_id: str) -> str: "used by source project instead of creating a new one" ), ) - @arg.country_code - @arg.billing_address - @arg.billing_extra_text - @arg.billing_currency - @arg.vat_id - @arg.billing_email @arg.tech_email @arg.parent_id_mandatory def project__create(self) -> None: @@ -4351,17 +4349,10 @@ def project__create(self) -> None: try: project = self.client.create_project( account_id=self._resolve_parent_id(self.args.parent_id), - billing_address=self.args.billing_address, - billing_currency=self.args.billing_currency, - billing_extra_text=self.args.billing_extra_text, billing_group_id=self.args.billing_group_id, - card_id=self.args.card_id, cloud=self.args.cloud, copy_from_project=self.args.copy_from_project, - country_code=self.args.country_code, project=self.args.project_name, - vat_id=self.args.vat_id, - billing_emails=self.args.billing_email, tech_emails=self.args.tech_email, use_source_project_billing_group=self.args.use_source_project_billing_group, ) @@ -4398,15 +4389,8 @@ def project__list(self) -> None: @arg.project @arg("--name", help="New project name") - @arg("--card-id", help="Card ID") @arg.parent_id @arg.cloud - @arg.country_code - @arg.billing_address - @arg.billing_extra_text - @arg.billing_currency - @arg.vat_id - @arg.billing_email @arg.tech_email def project__update(self) -> None: """Update a project""" @@ -4415,15 +4399,8 @@ def project__update(self) -> None: project = self.client.update_project( new_project_name=self.args.name, account_id=self._resolve_parent_id(self.args.parent_id) if self.args.parent_id else None, - billing_address=self.args.billing_address, - billing_currency=self.args.billing_currency, - billing_extra_text=self.args.billing_extra_text, - card_id=self.args.card_id, cloud=self.args.cloud, - country_code=self.args.country_code, project=project_name, - vat_id=self.args.vat_id, - billing_emails=self.args.billing_email, tech_emails=self.args.tech_email, ) except client.Error as ex: diff --git a/aiven/client/client.py b/aiven/client/client.py index 1690eef8..b45e6443 100644 --- a/aiven/client/client.py +++ b/aiven/client/client.py @@ -1641,20 +1641,12 @@ def create_project( project: str, account_id: str, billing_group_id: str | None = None, - card_id: str | None = None, cloud: str | None = None, copy_from_project: str | None = None, - country_code: str | None = None, - billing_address: str | None = None, - billing_currency: str | None = None, - billing_extra_text: str | None = None, - vat_id: str | None = None, - billing_emails: Sequence[str] | None = None, tech_emails: Sequence[str] | None = None, use_source_project_billing_group: bool | None = None, ) -> Mapping: body: dict[str, Any] = { - "card_id": card_id, "cloud": cloud, "project": project, "account_id": account_id, @@ -1663,18 +1655,6 @@ def create_project( body["billing_group_id"] = billing_group_id if copy_from_project is not None: body["copy_from_project"] = copy_from_project - if country_code is not None: - body["country_code"] = country_code - if billing_address is not None: - body["billing_address"] = billing_address - if billing_currency is not None: - body["billing_currency"] = billing_currency - if billing_extra_text is not None: - body["billing_extra_text"] = billing_extra_text - if vat_id is not None: - body["vat_id"] = vat_id - if billing_emails is not None: - body["billing_emails"] = [{"email": email} for email in billing_emails] if tech_emails is not None: body["tech_emails"] = [{"email": email} for email in tech_emails] if use_source_project_billing_group is not None: @@ -1696,14 +1676,7 @@ def update_project( project: str, new_project_name: str | None = None, account_id: str | None = None, - card_id: str | None = None, cloud: str | None = None, - country_code: str | None = None, - billing_address: str | None = None, - billing_currency: str | None = None, - billing_extra_text: str | None = None, - vat_id: str | None = None, - billing_emails: Sequence[str] | None = None, tech_emails: Sequence[str] | None = None, ) -> Mapping: body: dict[str, Any] = {} @@ -1711,22 +1684,8 @@ def update_project( body["project_name"] = new_project_name if account_id is not None: body["account_id"] = account_id - if card_id is not None: - body["card_id"] = card_id if cloud is not None: body["cloud"] = cloud - if country_code is not None: - body["country_code"] = country_code - if billing_address is not None: - body["billing_address"] = billing_address - if billing_currency is not None: - body["billing_currency"] = billing_currency - if billing_extra_text is not None: - body["billing_extra_text"] = billing_extra_text - if vat_id is not None: - body["vat_id"] = vat_id - if billing_emails is not None: - body["billing_emails"] = [{"email": email} for email in billing_emails] if tech_emails is not None: body["tech_emails"] = [{"email": email} for email in tech_emails] diff --git a/tests/test_cli.py b/tests/test_cli.py index d52a3a61..334f0d2d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1335,16 +1335,9 @@ def test_project_create__parent_id_requested_correctly() -> None: aiven_client.create_project.assert_called_with( account_id=account_id, project=project_name, - billing_address=None, - billing_currency=None, - billing_extra_text=None, billing_group_id=None, - card_id=None, cloud=None, copy_from_project=None, - country_code=None, - vat_id=None, - billing_emails=None, tech_emails=None, use_source_project_billing_group=False, ) @@ -1386,16 +1379,9 @@ def test_project_create__parent_id_as_org_id_requested_correctly() -> None: aiven_client.create_project.assert_called_with( account_id=account_id, project=project_name, - billing_address=None, - billing_currency=None, - billing_extra_text=None, billing_group_id=None, - card_id=None, cloud=None, copy_from_project=None, - country_code=None, - vat_id=None, - billing_emails=None, tech_emails=None, use_source_project_billing_group=False, ) @@ -1431,15 +1417,8 @@ def test_project_update__parent_id_requested_correctly() -> None: aiven_client.update_project.assert_called_with( new_project_name=new_project_name, account_id=account_id, - billing_address=None, - billing_currency=None, - billing_extra_text=None, - card_id=None, cloud=None, - country_code=None, project=project_name, - vat_id=None, - billing_emails=None, tech_emails=None, ) @@ -1484,14 +1463,7 @@ def test_project_update__parent_id_as_org_id_requested_correctly() -> None: aiven_client.update_project.assert_called_with( new_project_name=new_project_name, account_id=account_id, - billing_address=None, - billing_currency=None, - billing_extra_text=None, - card_id=None, cloud=None, - country_code=None, project=project_name, - vat_id=None, - billing_emails=None, tech_emails=None, )