diff --git a/src/mongo/HISTORY.rst b/src/mongo/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/mongo/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/mongo/README.md b/src/mongo/README.md new file mode 100644 index 00000000000..aa094619e27 --- /dev/null +++ b/src/mongo/README.md @@ -0,0 +1,5 @@ +# Azure CLI Mongo Extension # +This is an extension to Azure CLI to manage Mongo resources. + +## How to use ## +Please add commands usage here. \ No newline at end of file diff --git a/src/mongo/azext_mongo/__init__.py b/src/mongo/azext_mongo/__init__.py new file mode 100644 index 00000000000..5827caeaa69 --- /dev/null +++ b/src/mongo/azext_mongo/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_mongo._help import helps # pylint: disable=unused-import + + +class MongoCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_mongo.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_mongo.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_mongo._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = MongoCommandsLoader diff --git a/src/mongo/azext_mongo/_help.py b/src/mongo/azext_mongo/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/mongo/azext_mongo/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/mongo/azext_mongo/_params.py b/src/mongo/azext_mongo/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/mongo/azext_mongo/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/mongo/azext_mongo/aaz/__init__.py b/src/mongo/azext_mongo/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/mongo/azext_mongo/aaz/latest/__init__.py b/src/mongo/azext_mongo/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/__cmd_group.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/__cmd_group.py new file mode 100644 index 00000000000..05a141022d3 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "mongo-db", +) +class __CMDGroup(AAZCommandGroup): + """Manage MongoDB + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/__init__.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/__cmd_group.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/__cmd_group.py new file mode 100644 index 00000000000..c2c0885812f --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "mongo-db atlas", +) +class __CMDGroup(AAZCommandGroup): + """Manage MongoDB Atlas + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/__init__.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/__cmd_group.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/__cmd_group.py new file mode 100644 index 00000000000..e4a2a245c69 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "mongo-db atlas organization", +) +class __CMDGroup(AAZCommandGroup): + """Manage Azure resources that represent MongoDB Atlas organizations + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/__init__.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/__init__.py new file mode 100644 index 00000000000..2d1a2078686 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._wait import * diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_create.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_create.py new file mode 100644 index 00000000000..4feb0b879a2 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_create.py @@ -0,0 +1,537 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization create", +) +class Create(AAZCommand): + """Create an Azure resource that provisions a corresponding MongoDB Atlas organization + + :example: Organizations_CreateOrUpdate + az mongo-db atlas organization create -name "MyOrganizationResourceName" --resource-group "MyResourceGroup" --location "eastus" --subscription "abcd1234-5678-90ab-cdef-12345678abcd"--user {"first-name":"John","last-name":"Doe","email-address":"test@email.com"}" --marketplace "{"subscription-id":"abcd1234-5678-90ab-cdef-12345678abcd","offer-details":{"publisher-id":"mongodb","offer-id":"mongodb_atlas_azure_native_prod","plan-id":"private_plan","plan-name":"Pay as You Go (Free) (Private)","term-unit":"P1M","term-id":"gmz7xq9ge3py"}}" --partner-properties "{"organization-name":"partner-org-name"}" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the MongoDB Atlas Organization", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + help="Name of the Azure resource group in which MongoDB Atlas resource is created", + required=True, + ) + + # define Arg Group "Identity" + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.marketplace = AAZObjectArg( + options=["--marketplace"], + arg_group="Properties", + help="Marketplace details of the resource.", + ) + _args_schema.partner_properties = AAZObjectArg( + options=["--partner-properties"], + arg_group="Properties", + help="Properties for MongoDB Atlas Organization", + ) + _args_schema.user = AAZObjectArg( + options=["--user"], + arg_group="Properties", + help="Details of the user.", + ) + + marketplace = cls._args_schema.marketplace + marketplace.offer_details = AAZObjectArg( + options=["offer-details"], + help="Offer details for MongoDB Atlas offering in Azure Marketplace", + required=True, + ) + marketplace.subscription_id = AAZStrArg( + options=["subscription-id"], + help="Azure subscription id for the the marketplace offer is purchased from", + required=True, + ) + + offer_details = cls._args_schema.marketplace.offer_details + offer_details.offer_id = AAZStrArg( + options=["offer-id"], + help="Offer Id for the marketplace offer", + required=True, + ) + offer_details.plan_id = AAZStrArg( + options=["plan-id"], + help="Plan Id for the marketplace offer", + required=True, + ) + offer_details.plan_name = AAZStrArg( + options=["plan-name"], + help="Plan Name for the marketplace offer", + ) + offer_details.publisher_id = AAZStrArg( + options=["publisher-id"], + help="Publisher Id for the marketplace offer", + required=True, + default="mongodb", + ) + offer_details.term_id = AAZStrArg( + options=["term-id"], + help="Term id for the marketplace offer", + default="gmz7xq9ge3py", + ) + offer_details.term_unit = AAZStrArg( + options=["term-unit"], + help="Term Unit for the marketplace offer", + default="P1M", + ) + + partner_properties = cls._args_schema.partner_properties + partner_properties.organization_id = AAZStrArg( + options=["organization-id"], + help="Id of the MongoDB Atlas Organization", + ) + partner_properties.organization_name = AAZStrArg( + options=["organization-name"], + help="Name of the MongoDB Atlas Organization", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9 _\\-().,:@+&',]{1,64}$", + max_length=64, + min_length=1, + ), + ) + partner_properties.redirect_url = AAZStrArg( + options=["redirect-url"], + help="Redirect URL for the MongoDB Atlas Organization", + ) + + user = cls._args_schema.user + user.company_name = AAZStrArg( + options=["company-name"], + help="Company Name", + ) + user.email_address = AAZStrArg( + options=["email-address"], + help="Email address of the user", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}$", + ), + ) + user.first_name = AAZStrArg( + options=["first-name"], + help="First name of the user", + required=True, + ) + user.last_name = AAZStrArg( + options=["last-name"], + help="Last name of the user", + required=True, + ) + user.phone_number = AAZStrArg( + options=["phone-number"], + help="User's phone number", + ) + user.upn = AAZStrArg( + options=["upn"], + help="User's principal name", + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Resource", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="MongoDB Atlas Azure Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.OrganizationsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class OrganizationsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("marketplace", AAZObjectType, ".marketplace", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("partnerProperties", AAZObjectType, ".partner_properties") + properties.set_prop("user", AAZObjectType, ".user", typ_kwargs={"flags": {"required": True}}) + + marketplace = _builder.get(".properties.marketplace") + if marketplace is not None: + marketplace.set_prop("offerDetails", AAZObjectType, ".offer_details", typ_kwargs={"flags": {"required": True}}) + marketplace.set_prop("subscriptionId", AAZStrType, ".subscription_id", typ_kwargs={"flags": {"required": True}}) + + offer_details = _builder.get(".properties.marketplace.offerDetails") + if offer_details is not None: + offer_details.set_prop("offerId", AAZStrType, ".offer_id", typ_kwargs={"flags": {"required": True}}) + offer_details.set_prop("planId", AAZStrType, ".plan_id", typ_kwargs={"flags": {"required": True}}) + offer_details.set_prop("planName", AAZStrType, ".plan_name") + offer_details.set_prop("publisherId", AAZStrType, ".publisher_id", typ_kwargs={"flags": {"required": True}}) + offer_details.set_prop("termId", AAZStrType, ".term_id") + offer_details.set_prop("termUnit", AAZStrType, ".term_unit") + + partner_properties = _builder.get(".properties.partnerProperties") + if partner_properties is not None: + partner_properties.set_prop("organizationId", AAZStrType, ".organization_id") + partner_properties.set_prop("organizationName", AAZStrType, ".organization_name", typ_kwargs={"flags": {"required": True}}) + partner_properties.set_prop("redirectUrl", AAZStrType, ".redirect_url") + + user = _builder.get(".properties.user") + if user is not None: + user.set_prop("companyName", AAZStrType, ".company_name") + user.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + user.set_prop("firstName", AAZStrType, ".first_name", typ_kwargs={"flags": {"required": True}}) + user.set_prop("lastName", AAZStrType, ".last_name", typ_kwargs={"flags": {"required": True}}) + user.set_prop("phoneNumber", AAZStrType, ".phone_number") + user.set_prop("upn", AAZStrType, ".upn") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200_201.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200_201.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200_201.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200_201.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_delete.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_delete.py new file mode 100644 index 00000000000..5745e3553a0 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_delete.py @@ -0,0 +1,169 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete the Azure resource linked to a MongoDB Atlas organization + + :example: Organizations_Delete + az mongo-db atlas organization delete --subscription "abcd1234-5678-90ab-cdef-12345678abcd" --resource-group "MyResourceGroup" -name "MyOrganizationResourceName" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the MongoDB Atlas Organization", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + help="Name of the Azure resource group in which MongoDB Atlas resource is created", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.OrganizationsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class OrganizationsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_list.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_list.py new file mode 100644 index 00000000000..a2ce12ff969 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_list.py @@ -0,0 +1,576 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization list", +) +class List(AAZCommand): + """List all Azure resources representing MongoDB Atlas organizations under the current subscription + + :example: Organizations_ListBySubscription + az mongo-db atlas organization list --subscription "abcd1234-5678-90ab-cdef-12345678abcd" --resource-group "MyResourceGroup" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/mongodb.atlas/organizations", "2024-11-18-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + help="Name of the Azure resource group in which MongoDB Atlas resource is created", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + if condition_0: + self.OrganizationsListBySubscription(ctx=self.ctx)() + if condition_1: + self.OrganizationsListByResourceGroup(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class OrganizationsListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/MongoDB.Atlas/organizations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.value.Element.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.value.Element.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.value.Element.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.value.Element.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class OrganizationsListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.value.Element.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.value.Element.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.value.Element.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.value.Element.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_show.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_show.py new file mode 100644 index 00000000000..e36e54b353a --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_show.py @@ -0,0 +1,328 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization show", +) +class Show(AAZCommand): + """Retrieve details of the Azure resource associated with a MongoDB Atlas organization + + :example: Organizations_Get + az mongo-db atlas organization show --subscription "abcd1234-5678-90ab-cdef-12345678abcd" --resource-group "MyResourceGroup" -name "MyOrganizationResourceName" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the MongoDB Atlas Organization", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + help="Name of the Azure resource group in which MongoDB Atlas resource is created", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.OrganizationsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class OrganizationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_wait.py b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_wait.py new file mode 100644 index 00000000000..b61daecdd61 --- /dev/null +++ b/src/mongo/azext_mongo/aaz/latest/mongo_db/atlas/organization/_wait.py @@ -0,0 +1,324 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the MongoDB Atlas Organization", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + help="Name of the Azure resource group in which MongoDB Atlas resource is created", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.OrganizationsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class OrganizationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/mongo/azext_mongo/azext_metadata.json b/src/mongo/azext_mongo/azext_metadata.json new file mode 100644 index 00000000000..e506328978c --- /dev/null +++ b/src/mongo/azext_mongo/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.70.0" +} \ No newline at end of file diff --git a/src/mongo/azext_mongo/commands.py b/src/mongo/azext_mongo/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/mongo/azext_mongo/commands.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/mongo/azext_mongo/custom.py b/src/mongo/azext_mongo/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/mongo/azext_mongo/custom.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__name__) diff --git a/src/mongo/azext_mongo/tests/__init__.py b/src/mongo/azext_mongo/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/mongo/azext_mongo/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/mongo/azext_mongo/tests/latest/__init__.py b/src/mongo/azext_mongo/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/mongo/azext_mongo/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/mongo/azext_mongo/tests/latest/test_mongo.py b/src/mongo/azext_mongo/tests/latest/test_mongo.py new file mode 100644 index 00000000000..b9cab2403b8 --- /dev/null +++ b/src/mongo/azext_mongo/tests/latest/test_mongo.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * + + +class MongoScenario(ScenarioTest): + # TODO: add tests here + pass diff --git a/src/mongo/setup.cfg b/src/mongo/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/mongo/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/mongo/setup.py b/src/mongo/setup.py new file mode 100644 index 00000000000..f633058d128 --- /dev/null +++ b/src/mongo/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '1.0.0b1' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='mongo', + version=VERSION, + description='Microsoft Azure Command-Line Tools Mongo Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/mongo', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_mongo': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +) diff --git a/src/mongodb/README.md b/src/mongodb/README.md new file mode 100644 index 00000000000..4833e313fb1 --- /dev/null +++ b/src/mongodb/README.md @@ -0,0 +1,61 @@ +# Azure CLI MongoDB Extension # + +This is an extension to Azure CLI to manage MongoDB resources. + +## How to use ## + +### Install the extension ### + +Install this extension using the below CLI command: +``` +az extension add --name mongo-db +``` + +### Check the version ### + +``` +az extension show --name mongo-db --query version +``` + +### Connect to Azure subscription ### + +``` +az login +az account set -s {subs_id} +``` + +### Create a resource group (or use an existing one) ### + +``` +az group create -n demoResourceGroup -l eastus +``` + +## Available Commands ## + +### Organization Commands ### + +#### Create a MongoDB Organization #### + +``` +az mongo-db organization create --resource-group {resource_group} --name {resource_name} --user '{{"first-name": "{user_first_name}", "last-name": "{user_last_name}", "email-address": "{user_email}", "company-name": "{user_company_name}", "upn": "{user_upn}", "phone-number": "{user_phone}"}}' --marketplace '{{"subscription-id": "{subscription_id}", "offer-details": {{"publisher-id": "{publisher_id}", "offer-id": "{offer_id}", "plan-id": "{plan_id}", "plan-name": "{plan_name}", "term-unit": "{term_unit}", "term-id": "{term_id}"}}}}' --partner-properties '{"organization-name": "{partner_org_name}"}' --tags "{key:value}" --location {location} +``` + +mongo-db atlas organization create -name MyOrganizationResourceName --resource-group MyResourceGroup --location "eastus" --subscription "abcd1234-5678-90ab-cdef-12345678abcd"--user {"first-name":"John","last-name":"Doe","email-address":"test@email.com"}" --marketplace "{"subscription-id":"abcd1234-5678-90ab-cdef-12345678abcd","subscription-status":"PendingFulfillmentStart","offer-details":{"publisher-id":"mongodb","offer-id":"mongodb_atlas_azure_native_prod","plan-id":"private_plan","plan-name":"Pay as You Go (Free) (Private)","term-unit":"P1M","term-id":"gmz7xq9ge3py"}}" --partner-properties "{"organization-name":"partner-org-name"}" + +#### Show a MongoDB Organization #### + +``` +az mongo-db organization show --resource-group {resource_group} --name {resource_name}``` + +#### Delete a MongoDB Organization #### + +``` +az mongo-db organization delete --resource-group {resource_group} --name {resource_name}``` + +#### List MongoDB Organizations by Subscription #### + +``` +az mongo-db organization list --subscription {subscription_id} --resource-group {resource_group} +``` + +If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. diff --git a/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_create.py b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_create.py new file mode 100644 index 00000000000..d475fb82fb6 --- /dev/null +++ b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_create.py @@ -0,0 +1,536 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization create", +) +class Create(AAZCommand): + """Create a OrganizationResource + + :example: Organizations_CreateOrUpdate + az mongo-db atlas organization create -name "MyOrganizationResourceName" --resource-group "MyResourceGroup" --location "eastus" --subscription "abcd1234-5678-90ab-cdef-12345678abcd"--user {"first-name":"John","last-name":"Doe","email-address":"test@email.com"}" --marketplace "{"subscription-id":"abcd1234-5678-90ab-cdef-12345678abcd","offer-details":{"publisher-id":"mongodb","offer-id":"mongodb_atlas_azure_native_prod","plan-id":"private_plan","plan-name":"Pay as You Go (Free) (Private)","term-unit":"P1M","term-id":"gmz7xq9ge3py"}}" --partner-properties "{"organization-name":"partner-org-name"}" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the Organization resource", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Identity" + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.marketplace = AAZObjectArg( + options=["--marketplace"], + arg_group="Properties", + help="Marketplace details of the resource.", + ) + _args_schema.partner_properties = AAZObjectArg( + options=["--partner-properties"], + arg_group="Properties", + help="MongoDB properties", + ) + _args_schema.user = AAZObjectArg( + options=["--user"], + arg_group="Properties", + help="Details of the user.", + ) + + marketplace = cls._args_schema.marketplace + marketplace.offer_details = AAZObjectArg( + options=["offer-details"], + help="Offer details for the marketplace that is selected by the user", + required=True, + ) + marketplace.subscription_id = AAZStrArg( + options=["subscription-id"], + help="Azure subscription id for the the marketplace offer is purchased from", + required=True, + ) + + offer_details = cls._args_schema.marketplace.offer_details + offer_details.offer_id = AAZStrArg( + options=["offer-id"], + help="Offer Id for the marketplace offer", + required=True, + ) + offer_details.plan_id = AAZStrArg( + options=["plan-id"], + help="Plan Id for the marketplace offer", + required=True, + ) + offer_details.plan_name = AAZStrArg( + options=["plan-name"], + help="Plan Name for the marketplace offer", + ) + offer_details.publisher_id = AAZStrArg( + options=["publisher-id"], + help="Publisher Id for the marketplace offer", + required=True, + default="mongodb", + ) + offer_details.term_id = AAZStrArg( + options=["term-id"], + help="Plan Display Name for the marketplace offer", + default="gmz7xq9ge3py", + ) + offer_details.term_unit = AAZStrArg( + options=["term-unit"], + help="Plan Display Name for the marketplace offer", + default="P1M", + ) + + partner_properties = cls._args_schema.partner_properties + partner_properties.organization_id = AAZStrArg( + options=["organization-id"], + help="Organization Id in MongoDB system", + ) + partner_properties.organization_name = AAZStrArg( + options=["organization-name"], + help="Organization name in MongoDB system", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9 _\\-().,:@+&',]{1,64}$", + max_length=64, + min_length=1, + ), + ) + partner_properties.redirect_url = AAZStrArg( + options=["redirect-url"], + help="Redirect URL for the MongoDB", + ) + + user = cls._args_schema.user + user.company_name = AAZStrArg( + options=["company-name"], + help="Company Name", + ) + user.email_address = AAZStrArg( + options=["email-address"], + help="Email address of the user", + required=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}$", + ), + ) + user.first_name = AAZStrArg( + options=["first-name"], + help="First name of the user", + required=True, + ) + user.last_name = AAZStrArg( + options=["last-name"], + help="Last name of the user", + required=True, + ) + user.phone_number = AAZStrArg( + options=["phone-number"], + help="User's phone number", + ) + user.upn = AAZStrArg( + options=["upn"], + help="User's principal name", + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Resource", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.OrganizationsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class OrganizationsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("marketplace", AAZObjectType, ".marketplace", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("partnerProperties", AAZObjectType, ".partner_properties") + properties.set_prop("user", AAZObjectType, ".user", typ_kwargs={"flags": {"required": True}}) + + marketplace = _builder.get(".properties.marketplace") + if marketplace is not None: + marketplace.set_prop("offerDetails", AAZObjectType, ".offer_details", typ_kwargs={"flags": {"required": True}}) + marketplace.set_prop("subscriptionId", AAZStrType, ".subscription_id", typ_kwargs={"flags": {"required": True}}) + + offer_details = _builder.get(".properties.marketplace.offerDetails") + if offer_details is not None: + offer_details.set_prop("offerId", AAZStrType, ".offer_id", typ_kwargs={"flags": {"required": True}}) + offer_details.set_prop("planId", AAZStrType, ".plan_id", typ_kwargs={"flags": {"required": True}}) + offer_details.set_prop("planName", AAZStrType, ".plan_name") + offer_details.set_prop("publisherId", AAZStrType, ".publisher_id", typ_kwargs={"flags": {"required": True}}) + offer_details.set_prop("termId", AAZStrType, ".term_id") + offer_details.set_prop("termUnit", AAZStrType, ".term_unit") + + partner_properties = _builder.get(".properties.partnerProperties") + if partner_properties is not None: + partner_properties.set_prop("organizationId", AAZStrType, ".organization_id") + partner_properties.set_prop("organizationName", AAZStrType, ".organization_name", typ_kwargs={"flags": {"required": True}}) + partner_properties.set_prop("redirectUrl", AAZStrType, ".redirect_url") + + user = _builder.get(".properties.user") + if user is not None: + user.set_prop("companyName", AAZStrType, ".company_name") + user.set_prop("emailAddress", AAZStrType, ".email_address", typ_kwargs={"flags": {"required": True}}) + user.set_prop("firstName", AAZStrType, ".first_name", typ_kwargs={"flags": {"required": True}}) + user.set_prop("lastName", AAZStrType, ".last_name", typ_kwargs={"flags": {"required": True}}) + user.set_prop("phoneNumber", AAZStrType, ".phone_number") + user.set_prop("upn", AAZStrType, ".upn") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZIdentityObjectType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200_201.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200_201.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200_201.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200_201.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_delete.py b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_delete.py new file mode 100644 index 00000000000..fc57478dbce --- /dev/null +++ b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_delete.py @@ -0,0 +1,168 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a OrganizationResource + + :example: Organizations_Delete + az mongo-db atlas organization delete --subscription "abcd1234-5678-90ab-cdef-12345678abcd" --resource-group "MyResourceGroup" -name "MyOrganizationResourceName" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the Organization resource", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.OrganizationsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class OrganizationsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_list.py b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_list.py new file mode 100644 index 00000000000..ec1a853f8b1 --- /dev/null +++ b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_list.py @@ -0,0 +1,574 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization list", +) +class List(AAZCommand): + """List OrganizationResource resources by subscription ID + + :example: Organizations_ListBySubscription + az mongo-db atlas organization list --subscription "abcd1234-5678-90ab-cdef-12345678abcd" --resource-group "MyResourceGroup" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/mongodb.atlas/organizations", "2024-11-18-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + if condition_0: + self.OrganizationsListBySubscription(ctx=self.ctx)() + if condition_1: + self.OrganizationsListByResourceGroup(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class OrganizationsListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/MongoDB.Atlas/organizations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.value.Element.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.value.Element.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.value.Element.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.value.Element.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class OrganizationsListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZIdentityObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.value.Element.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.value.Element.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.value.Element.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.value.Element.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_show.py b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_show.py new file mode 100644 index 00000000000..f0b29b89c57 --- /dev/null +++ b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_show.py @@ -0,0 +1,327 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization show", +) +class Show(AAZCommand): + """Get a OrganizationResource + + :example: Organizations_Get + az mongo-db atlas organization show --subscription "abcd1234-5678-90ab-cdef-12345678abcd" --resource-group "MyResourceGroup" -name "MyOrganizationResourceName" + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the Organization resource", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.OrganizationsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class OrganizationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZIdentityObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = cls._schema_on_200.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = cls._schema_on_200.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = cls._schema_on_200.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = cls._schema_on_200.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_update.py b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_update.py new file mode 100644 index 00000000000..5f45ba7799d --- /dev/null +++ b/src/mongodb/azext_mongodb/aaz/latest/mongo_db/atlas/organization/_update.py @@ -0,0 +1,526 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "mongo-db atlas organization update", +) +class Update(AAZCommand): + """Update a OrganizationResource + """ + + _aaz_info = { + "version": "2024-11-18-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/mongodb.atlas/organizations/{}", "2024-11-18-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.organization_name = AAZStrArg( + options=["-n", "--name", "--organization-name"], + help="Name of the Organization resource", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Identity" + + # define Arg Group "Properties" + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.OrganizationsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.OrganizationsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class OrganizationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_organization_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class OrganizationsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "organizationName", self.ctx.args.organization_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-11-18-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_organization_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_organization_resource_read = None + + @classmethod + def _build_schema_organization_resource_read(cls, _schema): + if cls._schema_organization_resource_read is not None: + _schema.id = cls._schema_organization_resource_read.id + _schema.identity = cls._schema_organization_resource_read.identity + _schema.location = cls._schema_organization_resource_read.location + _schema.name = cls._schema_organization_resource_read.name + _schema.properties = cls._schema_organization_resource_read.properties + _schema.system_data = cls._schema_organization_resource_read.system_data + _schema.tags = cls._schema_organization_resource_read.tags + _schema.type = cls._schema_organization_resource_read.type + return + + cls._schema_organization_resource_read = _schema_organization_resource_read = AAZObjectType() + + organization_resource_read = _schema_organization_resource_read + organization_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + organization_resource_read.identity = AAZIdentityObjectType() + organization_resource_read.location = AAZStrType( + flags={"required": True}, + ) + organization_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + organization_resource_read.properties = AAZObjectType() + organization_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + organization_resource_read.tags = AAZDictType() + organization_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_organization_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_organization_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_organization_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_organization_resource_read.properties + properties.marketplace = AAZObjectType( + flags={"required": True}, + ) + properties.partner_properties = AAZObjectType( + serialized_name="partnerProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user = AAZObjectType( + flags={"required": True}, + ) + + marketplace = _schema_organization_resource_read.properties.marketplace + marketplace.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace.subscription_id = AAZStrType( + serialized_name="subscriptionId", + flags={"required": True}, + ) + marketplace.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + flags={"read_only": True}, + ) + + offer_details = _schema_organization_resource_read.properties.marketplace.offer_details + offer_details.offer_id = AAZStrType( + serialized_name="offerId", + flags={"required": True}, + ) + offer_details.plan_id = AAZStrType( + serialized_name="planId", + flags={"required": True}, + ) + offer_details.plan_name = AAZStrType( + serialized_name="planName", + ) + offer_details.publisher_id = AAZStrType( + serialized_name="publisherId", + flags={"required": True}, + ) + offer_details.term_id = AAZStrType( + serialized_name="termId", + ) + offer_details.term_unit = AAZStrType( + serialized_name="termUnit", + ) + + partner_properties = _schema_organization_resource_read.properties.partner_properties + partner_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_properties.redirect_url = AAZStrType( + serialized_name="redirectUrl", + ) + + user = _schema_organization_resource_read.properties.user + user.company_name = AAZStrType( + serialized_name="companyName", + ) + user.email_address = AAZStrType( + serialized_name="emailAddress", + flags={"required": True}, + ) + user.first_name = AAZStrType( + serialized_name="firstName", + flags={"required": True}, + ) + user.last_name = AAZStrType( + serialized_name="lastName", + flags={"required": True}, + ) + user.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user.upn = AAZStrType() + + system_data = _schema_organization_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_organization_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_organization_resource_read.id + _schema.identity = cls._schema_organization_resource_read.identity + _schema.location = cls._schema_organization_resource_read.location + _schema.name = cls._schema_organization_resource_read.name + _schema.properties = cls._schema_organization_resource_read.properties + _schema.system_data = cls._schema_organization_resource_read.system_data + _schema.tags = cls._schema_organization_resource_read.tags + _schema.type = cls._schema_organization_resource_read.type + + +__all__ = ["Update"] diff --git a/src/service_name.json b/src/service_name.json index 637512e7e88..8df625b3260 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -419,6 +419,11 @@ "AzureServiceName": "Machine Learning", "URL": "https://learn.microsoft.com/azure/machine-learning" }, + { + "Command": "az mongo-db", + "AzureServiceName": "MongoDB", + "URL": "https://learn.microsoft.com/en-us/azure/partner-solutions/mongo-db/overview" + }, { "Command": "az monitor", "AzureServiceName": "Monitor",