diff --git a/src/neon/HISTORY.rst b/src/neon/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/neon/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/neon/README.md b/src/neon/README.md new file mode 100644 index 00000000000..1f4e9d3a674 --- /dev/null +++ b/src/neon/README.md @@ -0,0 +1,50 @@ + +# Azure CLI Neon Extension # +This is an extension to Azure CLI to manage Neon Postgres resources. + +## How to use ## +#### Install the extension #### +Install this extension using the below CLI command: +``` +az extension add --name neon +``` + +#### Check the version #### +``` +az extension show --name neon --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 ## + +### Create a Neon Postgres Instance ### +``` +az neon postgres create --resource-group {resource_group} --organization-name {organization_name} --user-details '{"first-name": "{user_first_name}", "last-name": "{user_last_name}", "email-address": "{user_email}", "upn": "{user_upn}", "phone-number": "{user_phone}"}' --company-details '{"company-name": "{company_name}", "office-address": "{office_address}", "country": "{country}", "domain": "{domain}", "number-of-employees": {number_of_employee}}' --partner-organization-properties '{"organization-id": "{org_id}", "organization-name": "{partner_org_name}", "single-sign-on-properties": {"single-sign-on-state": "{sso_state}", "enterprise-app-id": "{app_id}", "single-sign-on-url": "{sso_url}", "aad-domains": ["{domain}"]}}' --tags "{key:value}" --location {location} +``` + +### Show a Neon Postgres Organization ### +``` +az neon postgres organization show --resource-group {resource_group} --organization-name {organization_name} +``` + +### Delete a Neon Postgres Organization ### +``` +az neon postgres organization delete --resource-group {resource_group} --organization-name {organization_name} +``` + +### Update a Neon Postgres Organization (without location and marketplace details) ### +``` +az neon postgres organization update --resource-group {resource_group} --organization-name {organization_name} --user-details '{"first-name": "{user_first_name}", "last-name": "{user_last_name}", "email-address": "{user_email}", "upn": "{user_upn}", "phone-number": "{user_phone}"}' --company-details '{"company-name": "{company_name}", "office-address": "{office_address}", "country": "{country}", "domain": "{domain}", "number-of-employees": {number_of_employee}}' --partner-organization-properties '{"organization-id": "{org_id}", "organization-name": "{partner_org_name}", "single-sign-on-properties": {"single-sign-on-state": "{sso_state}", "enterprise-app-id": "{app_id}", "single-sign-on-url": "{sso_url}", "aad-domains": ["{domain}"]}}' --tags "{key:value}" +``` + +If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. diff --git a/src/neon/azext_neon/__init__.py b/src/neon/azext_neon/__init__.py new file mode 100644 index 00000000000..45584ca47f4 --- /dev/null +++ b/src/neon/azext_neon/__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_neon._help import helps # pylint: disable=unused-import + + +class NeonCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_neon.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_neon.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_neon._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = NeonCommandsLoader diff --git a/src/neon/azext_neon/_help.py b/src/neon/azext_neon/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/neon/azext_neon/_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/neon/azext_neon/_params.py b/src/neon/azext_neon/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/neon/azext_neon/_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/neon/azext_neon/aaz/__init__.py b/src/neon/azext_neon/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/neon/azext_neon/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/neon/azext_neon/aaz/latest/__init__.py b/src/neon/azext_neon/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/neon/azext_neon/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/neon/azext_neon/aaz/latest/neon/__cmd_group.py b/src/neon/azext_neon/aaz/latest/neon/__cmd_group.py new file mode 100644 index 00000000000..ab0d838af75 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Neon Postgres + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/neon/azext_neon/aaz/latest/neon/__init__.py b/src/neon/azext_neon/aaz/latest/neon/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/__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/neon/azext_neon/aaz/latest/neon/postgres/__cmd_group.py b/src/neon/azext_neon/aaz/latest/neon/postgres/__cmd_group.py new file mode 100644 index 00000000000..7f904f99e39 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Neon Postgres + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/neon/azext_neon/aaz/latest/neon/postgres/__init__.py b/src/neon/azext_neon/aaz/latest/neon/postgres/__init__.py new file mode 100644 index 00000000000..a6df9f5a835 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 * diff --git a/src/neon/azext_neon/aaz/latest/neon/postgres/_create.py b/src/neon/azext_neon/aaz/latest/neon/postgres/_create.py new file mode 100644 index 00000000000..521c2f9cd47 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/_create.py @@ -0,0 +1,602 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres create", + is_preview=True, +) +class Create(AAZCommand): + """Create a Neon Resource + + :example: Organizations_CreateOrUpdate + az neon postgres create --resource-group demoResourceGroup --organization-name DemoOrg --marketplace-details "{subscription-id:ae37d5a8-dff3-49a3-bfcd-139a4f7db98x,subscription-status:Active,offer-details:{publisher-id:microsoft,offer-id:standard-postgres,plan-id:basic-plan,plan-name:Basic,term-unit:year,term-id:12345}}" --user-details "{first-name:John,last-name:Doe,email-address:johndoe@example.com,upn:johndoe,phone-number:+1234567890}" --company-details "{company-name:DemoCompany,country:USA,office-address:1234 Azure Ave,business-phone:+9876543210,domain:democompany.com,number-of-employees:500}" --partner-organization-properties "{organization-id:org12345,organization-name:PartnerOrg,single-sign-on-properties:{single-sign-on-state:Active,enterprise-app-id:app12345,single-sign-on-url:https://sso.partnerorg.com,aad-domains:[partnerorg.com]}}" --tags "{environment:production}" --location eastus + """ + + _aaz_info = { + "version": "2024-08-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/neon.postgres/organizations/{}", "2024-08-01-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 Neon 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( + help="Name of the Resource Group", + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.company_details = AAZObjectArg( + options=["--company-details"], + arg_group="Properties", + help="Details of the company.", + ) + _args_schema.marketplace_details = AAZObjectArg( + options=["--marketplace-details"], + arg_group="Properties", + help="Marketplace details of the resource.", + ) + _args_schema.partner_organization_properties = AAZObjectArg( + options=["--partner-organization-properties"], + arg_group="Properties", + help="Organization properties", + ) + _args_schema.user_details = AAZObjectArg( + options=["--user-details"], + arg_group="Properties", + help="Details of the user.", + ) + + company_details = cls._args_schema.company_details + company_details.business_phone = AAZStrArg( + options=["business-phone"], + help="Business phone number of the company", + ) + company_details.company_name = AAZStrArg( + options=["company-name"], + help="Company name", + ) + company_details.country = AAZStrArg( + options=["country"], + help="Country name of the company", + ) + company_details.domain = AAZStrArg( + options=["domain"], + help="Domain of the user", + ) + company_details.number_of_employees = AAZIntArg( + options=["number-of-employees"], + help="Number of employees in the company", + ) + company_details.office_address = AAZStrArg( + options=["office-address"], + help="Office address of the company", + ) + + marketplace_details = cls._args_schema.marketplace_details + marketplace_details.offer_details = AAZObjectArg( + options=["offer-details"], + help="Offer details for the marketplace that is selected by the user", + required=True, + ) + marketplace_details.subscription_id = AAZStrArg( + options=["subscription-id"], + help="SaaS subscription id for the the marketplace offer", + ) + marketplace_details.subscription_status = AAZStrArg( + options=["subscription-status"], + help="Marketplace subscription status", + enum={"PendingFulfillmentStart": "PendingFulfillmentStart", "Subscribed": "Subscribed", "Suspended": "Suspended", "Unsubscribed": "Unsubscribed"}, + ) + + offer_details = cls._args_schema.marketplace_details.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, + ) + offer_details.term_id = AAZStrArg( + options=["term-id"], + help="Term Id for the marketplace offer", + ) + offer_details.term_unit = AAZStrArg( + options=["term-unit"], + help="Term Name for the marketplace offer", + ) + + partner_organization_properties = cls._args_schema.partner_organization_properties + partner_organization_properties.organization_id = AAZStrArg( + options=["organization-id"], + help="Organization Id in partner's system", + ) + partner_organization_properties.organization_name = AAZStrArg( + options=["organization-name"], + help="Organization name in partner's system", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + partner_organization_properties.single_sign_on_properties = AAZObjectArg( + options=["single-sign-on-properties"], + help="Single Sign On properties for the organization", + ) + + single_sign_on_properties = cls._args_schema.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListArg( + options=["aad-domains"], + help="List of AAD domains fetched from Microsoft Graph for user.", + ) + single_sign_on_properties.enterprise_app_id = AAZStrArg( + options=["enterprise-app-id"], + help="AAD enterprise application Id used to setup SSO", + ) + single_sign_on_properties.single_sign_on_state = AAZStrArg( + options=["single-sign-on-state"], + help="State of the Single Sign On for the organization", + enum={"Disable": "Disable", "Enable": "Enable", "Initial": "Initial"}, + ) + single_sign_on_properties.single_sign_on_url = AAZStrArg( + options=["single-sign-on-url"], + help="URL for SSO to be used by the partner to redirect the user to their system", + ) + + aad_domains = cls._args_schema.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrArg() + + user_details = cls._args_schema.user_details + user_details.email_address = AAZStrArg( + options=["email-address"], + help="Email address of the user", + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}$", + ), + ) + user_details.first_name = AAZStrArg( + options=["first-name"], + help="First name of the user", + ) + user_details.last_name = AAZStrArg( + options=["last-name"], + help="Last name of the user", + ) + user_details.phone_number = AAZStrArg( + options=["phone-number"], + help="User's phone number", + ) + user_details.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/Neon.Postgres/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-08-01-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("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("companyDetails", AAZObjectType, ".company_details", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("marketplaceDetails", AAZObjectType, ".marketplace_details", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("partnerOrganizationProperties", AAZObjectType, ".partner_organization_properties") + properties.set_prop("userDetails", AAZObjectType, ".user_details", typ_kwargs={"flags": {"required": True}}) + + company_details = _builder.get(".properties.companyDetails") + if company_details is not None: + company_details.set_prop("businessPhone", AAZStrType, ".business_phone") + company_details.set_prop("companyName", AAZStrType, ".company_name") + company_details.set_prop("country", AAZStrType, ".country") + company_details.set_prop("domain", AAZStrType, ".domain") + company_details.set_prop("numberOfEmployees", AAZIntType, ".number_of_employees") + company_details.set_prop("officeAddress", AAZStrType, ".office_address") + + marketplace_details = _builder.get(".properties.marketplaceDetails") + if marketplace_details is not None: + marketplace_details.set_prop("offerDetails", AAZObjectType, ".offer_details", typ_kwargs={"flags": {"required": True}}) + marketplace_details.set_prop("subscriptionId", AAZStrType, ".subscription_id") + marketplace_details.set_prop("subscriptionStatus", AAZStrType, ".subscription_status") + + offer_details = _builder.get(".properties.marketplaceDetails.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_organization_properties = _builder.get(".properties.partnerOrganizationProperties") + if partner_organization_properties is not None: + partner_organization_properties.set_prop("organizationId", AAZStrType, ".organization_id") + partner_organization_properties.set_prop("organizationName", AAZStrType, ".organization_name", typ_kwargs={"flags": {"required": True}}) + partner_organization_properties.set_prop("singleSignOnProperties", AAZObjectType, ".single_sign_on_properties") + + single_sign_on_properties = _builder.get(".properties.partnerOrganizationProperties.singleSignOnProperties") + if single_sign_on_properties is not None: + single_sign_on_properties.set_prop("aadDomains", AAZListType, ".aad_domains") + single_sign_on_properties.set_prop("enterpriseAppId", AAZStrType, ".enterprise_app_id") + single_sign_on_properties.set_prop("singleSignOnState", AAZStrType, ".single_sign_on_state") + single_sign_on_properties.set_prop("singleSignOnUrl", AAZStrType, ".single_sign_on_url") + + aad_domains = _builder.get(".properties.partnerOrganizationProperties.singleSignOnProperties.aadDomains") + if aad_domains is not None: + aad_domains.set_elements(AAZStrType, ".") + + user_details = _builder.get(".properties.userDetails") + if user_details is not None: + user_details.set_prop("emailAddress", AAZStrType, ".email_address") + user_details.set_prop("firstName", AAZStrType, ".first_name") + user_details.set_prop("lastName", AAZStrType, ".last_name") + user_details.set_prop("phoneNumber", AAZStrType, ".phone_number") + user_details.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.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}, + ) + + properties = cls._schema_on_200_201.properties + properties.company_details = AAZObjectType( + serialized_name="companyDetails", + flags={"required": True}, + ) + properties.marketplace_details = AAZObjectType( + serialized_name="marketplaceDetails", + flags={"required": True}, + ) + properties.partner_organization_properties = AAZObjectType( + serialized_name="partnerOrganizationProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user_details = AAZObjectType( + serialized_name="userDetails", + flags={"required": True}, + ) + + company_details = cls._schema_on_200_201.properties.company_details + company_details.business_phone = AAZStrType( + serialized_name="businessPhone", + ) + company_details.company_name = AAZStrType( + serialized_name="companyName", + ) + company_details.country = AAZStrType() + company_details.domain = AAZStrType() + company_details.number_of_employees = AAZIntType( + serialized_name="numberOfEmployees", + ) + company_details.office_address = AAZStrType( + serialized_name="officeAddress", + ) + + marketplace_details = cls._schema_on_200_201.properties.marketplace_details + marketplace_details.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace_details.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + marketplace_details.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + ) + + offer_details = cls._schema_on_200_201.properties.marketplace_details.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_organization_properties = cls._schema_on_200_201.properties.partner_organization_properties + partner_organization_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_organization_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_organization_properties.single_sign_on_properties = AAZObjectType( + serialized_name="singleSignOnProperties", + ) + + single_sign_on_properties = cls._schema_on_200_201.properties.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListType( + serialized_name="aadDomains", + ) + single_sign_on_properties.enterprise_app_id = AAZStrType( + serialized_name="enterpriseAppId", + ) + single_sign_on_properties.single_sign_on_state = AAZStrType( + serialized_name="singleSignOnState", + ) + single_sign_on_properties.single_sign_on_url = AAZStrType( + serialized_name="singleSignOnUrl", + ) + + aad_domains = cls._schema_on_200_201.properties.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrType() + + user_details = cls._schema_on_200_201.properties.user_details + user_details.email_address = AAZStrType( + serialized_name="emailAddress", + ) + user_details.first_name = AAZStrType( + serialized_name="firstName", + ) + user_details.last_name = AAZStrType( + serialized_name="lastName", + ) + user_details.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user_details.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/neon/azext_neon/aaz/latest/neon/postgres/organization/__cmd_group.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/__cmd_group.py new file mode 100644 index 00000000000..04caa20f8a9 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres organization", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage a Neon organization + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/neon/azext_neon/aaz/latest/neon/postgres/organization/__init__.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/__init__.py new file mode 100644 index 00000000000..f32b66e3eeb --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/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 ._delete import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_delete.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_delete.py new file mode 100644 index 00000000000..cb0408ad9f8 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_delete.py @@ -0,0 +1,170 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres organization delete", + is_preview=True, + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a Neon Resource + + :example: Organizations_Delete + az neon postgres organization delete --resource-group demoResourceGroup --organization-name DemoOrg + """ + + _aaz_info = { + "version": "2024-08-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/neon.postgres/organizations/{}", "2024-08-01-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 Neon 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( + help="Name of the Resource Group", + 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/Neon.Postgres/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-08-01-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/neon/azext_neon/aaz/latest/neon/postgres/organization/_list.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_list.py new file mode 100644 index 00000000000..4a186250ae1 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_list.py @@ -0,0 +1,575 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres organization list", + is_preview=True, +) +class List(AAZCommand): + """List Neon resources by subscription ID + + :example: Organizations_ListBySubscription + az neon postgres organization list + """ + + _aaz_info = { + "version": "2024-08-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/neon.postgres/organizations", "2024-08-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/neon.postgres/organizations", "2024-08-01-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 Resource Group", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.OrganizationsListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.OrganizationsListBySubscription(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 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/Neon.Postgres/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-08-01-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.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}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.company_details = AAZObjectType( + serialized_name="companyDetails", + flags={"required": True}, + ) + properties.marketplace_details = AAZObjectType( + serialized_name="marketplaceDetails", + flags={"required": True}, + ) + properties.partner_organization_properties = AAZObjectType( + serialized_name="partnerOrganizationProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user_details = AAZObjectType( + serialized_name="userDetails", + flags={"required": True}, + ) + + company_details = cls._schema_on_200.value.Element.properties.company_details + company_details.business_phone = AAZStrType( + serialized_name="businessPhone", + ) + company_details.company_name = AAZStrType( + serialized_name="companyName", + ) + company_details.country = AAZStrType() + company_details.domain = AAZStrType() + company_details.number_of_employees = AAZIntType( + serialized_name="numberOfEmployees", + ) + company_details.office_address = AAZStrType( + serialized_name="officeAddress", + ) + + marketplace_details = cls._schema_on_200.value.Element.properties.marketplace_details + marketplace_details.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace_details.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + marketplace_details.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + ) + + offer_details = cls._schema_on_200.value.Element.properties.marketplace_details.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_organization_properties = cls._schema_on_200.value.Element.properties.partner_organization_properties + partner_organization_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_organization_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_organization_properties.single_sign_on_properties = AAZObjectType( + serialized_name="singleSignOnProperties", + ) + + single_sign_on_properties = cls._schema_on_200.value.Element.properties.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListType( + serialized_name="aadDomains", + ) + single_sign_on_properties.enterprise_app_id = AAZStrType( + serialized_name="enterpriseAppId", + ) + single_sign_on_properties.single_sign_on_state = AAZStrType( + serialized_name="singleSignOnState", + ) + single_sign_on_properties.single_sign_on_url = AAZStrType( + serialized_name="singleSignOnUrl", + ) + + aad_domains = cls._schema_on_200.value.Element.properties.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrType() + + user_details = cls._schema_on_200.value.Element.properties.user_details + user_details.email_address = AAZStrType( + serialized_name="emailAddress", + ) + user_details.first_name = AAZStrType( + serialized_name="firstName", + ) + user_details.last_name = AAZStrType( + serialized_name="lastName", + ) + user_details.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user_details.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 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/Neon.Postgres/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-08-01-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.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}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.company_details = AAZObjectType( + serialized_name="companyDetails", + flags={"required": True}, + ) + properties.marketplace_details = AAZObjectType( + serialized_name="marketplaceDetails", + flags={"required": True}, + ) + properties.partner_organization_properties = AAZObjectType( + serialized_name="partnerOrganizationProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user_details = AAZObjectType( + serialized_name="userDetails", + flags={"required": True}, + ) + + company_details = cls._schema_on_200.value.Element.properties.company_details + company_details.business_phone = AAZStrType( + serialized_name="businessPhone", + ) + company_details.company_name = AAZStrType( + serialized_name="companyName", + ) + company_details.country = AAZStrType() + company_details.domain = AAZStrType() + company_details.number_of_employees = AAZIntType( + serialized_name="numberOfEmployees", + ) + company_details.office_address = AAZStrType( + serialized_name="officeAddress", + ) + + marketplace_details = cls._schema_on_200.value.Element.properties.marketplace_details + marketplace_details.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace_details.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + marketplace_details.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + ) + + offer_details = cls._schema_on_200.value.Element.properties.marketplace_details.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_organization_properties = cls._schema_on_200.value.Element.properties.partner_organization_properties + partner_organization_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_organization_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_organization_properties.single_sign_on_properties = AAZObjectType( + serialized_name="singleSignOnProperties", + ) + + single_sign_on_properties = cls._schema_on_200.value.Element.properties.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListType( + serialized_name="aadDomains", + ) + single_sign_on_properties.enterprise_app_id = AAZStrType( + serialized_name="enterpriseAppId", + ) + single_sign_on_properties.single_sign_on_state = AAZStrType( + serialized_name="singleSignOnState", + ) + single_sign_on_properties.single_sign_on_url = AAZStrType( + serialized_name="singleSignOnUrl", + ) + + aad_domains = cls._schema_on_200.value.Element.properties.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrType() + + user_details = cls._schema_on_200.value.Element.properties.user_details + user_details.email_address = AAZStrType( + serialized_name="emailAddress", + ) + user_details.first_name = AAZStrType( + serialized_name="firstName", + ) + user_details.last_name = AAZStrType( + serialized_name="lastName", + ) + user_details.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user_details.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/neon/azext_neon/aaz/latest/neon/postgres/organization/_show.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_show.py new file mode 100644 index 00000000000..1d6f82cde6c --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/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( + "neon postgres organization show", + is_preview=True, +) +class Show(AAZCommand): + """Get a Neon Resource + + :example: Organizations_Get + az neon postgres organization show --resource-group demoResourceGroup --organization-name DemoOrg + """ + + _aaz_info = { + "version": "2024-08-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/neon.postgres/organizations/{}", "2024-08-01-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 Neon 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( + help="Name of the Resource Group", + 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/Neon.Postgres/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-08-01-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.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}, + ) + + properties = cls._schema_on_200.properties + properties.company_details = AAZObjectType( + serialized_name="companyDetails", + flags={"required": True}, + ) + properties.marketplace_details = AAZObjectType( + serialized_name="marketplaceDetails", + flags={"required": True}, + ) + properties.partner_organization_properties = AAZObjectType( + serialized_name="partnerOrganizationProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user_details = AAZObjectType( + serialized_name="userDetails", + flags={"required": True}, + ) + + company_details = cls._schema_on_200.properties.company_details + company_details.business_phone = AAZStrType( + serialized_name="businessPhone", + ) + company_details.company_name = AAZStrType( + serialized_name="companyName", + ) + company_details.country = AAZStrType() + company_details.domain = AAZStrType() + company_details.number_of_employees = AAZIntType( + serialized_name="numberOfEmployees", + ) + company_details.office_address = AAZStrType( + serialized_name="officeAddress", + ) + + marketplace_details = cls._schema_on_200.properties.marketplace_details + marketplace_details.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace_details.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + marketplace_details.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + ) + + offer_details = cls._schema_on_200.properties.marketplace_details.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_organization_properties = cls._schema_on_200.properties.partner_organization_properties + partner_organization_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_organization_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_organization_properties.single_sign_on_properties = AAZObjectType( + serialized_name="singleSignOnProperties", + ) + + single_sign_on_properties = cls._schema_on_200.properties.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListType( + serialized_name="aadDomains", + ) + single_sign_on_properties.enterprise_app_id = AAZStrType( + serialized_name="enterpriseAppId", + ) + single_sign_on_properties.single_sign_on_state = AAZStrType( + serialized_name="singleSignOnState", + ) + single_sign_on_properties.single_sign_on_url = AAZStrType( + serialized_name="singleSignOnUrl", + ) + + aad_domains = cls._schema_on_200.properties.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrType() + + user_details = cls._schema_on_200.properties.user_details + user_details.email_address = AAZStrType( + serialized_name="emailAddress", + ) + user_details.first_name = AAZStrType( + serialized_name="firstName", + ) + user_details.last_name = AAZStrType( + serialized_name="lastName", + ) + user_details.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user_details.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/neon/azext_neon/aaz/latest/neon/postgres/organization/_update.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_update.py new file mode 100644 index 00000000000..eefe950e408 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_update.py @@ -0,0 +1,694 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres organization update", + is_preview=True, +) +class Update(AAZCommand): + """Update a Neon Resource + + :example: Organization_Update + az neon postgres organization update --resource-group demoResourceGroup --organization-name DemoOrg --user-details "{first-name:John,last-name:Doe,email-address:johndoe@example.com,upn:johndoe,phone-number:+1234567890}" --company-details "{company-name:DemoCompany,country:USA,office-address:1234 Azure Ave,business-phone:+9876543210,domain:democompany.com,number-of-employees:500}" --partner-organization-properties "{organization-id:org12345,organization-name:PartnerOrg,single-sign-on-properties:{single-sign-on-state:Active,enterprise-app-id:app12345,single-sign-on-url:https://sso.partnerorg.com,aad-domains:[partnerorg.com]}}" --tags "{environment:production}" + """ + + _aaz_info = { + "version": "2024-08-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/neon.postgres/organizations/{}", "2024-08-01-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 Neon 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( + help="Name of the Resource Group", + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.company_details = AAZObjectArg( + options=["--company-details"], + arg_group="Properties", + help="Details of the company.", + ) + _args_schema.partner_organization_properties = AAZObjectArg( + options=["--partner-organization-properties"], + arg_group="Properties", + help="Organization properties", + nullable=True, + ) + _args_schema.user_details = AAZObjectArg( + options=["--user-details"], + arg_group="Properties", + help="Details of the user.", + ) + + company_details = cls._args_schema.company_details + company_details.business_phone = AAZStrArg( + options=["business-phone"], + help="Business phone number of the company", + nullable=True, + ) + company_details.company_name = AAZStrArg( + options=["company-name"], + help="Company name", + nullable=True, + ) + company_details.country = AAZStrArg( + options=["country"], + help="Country name of the company", + nullable=True, + ) + company_details.domain = AAZStrArg( + options=["domain"], + help="Domain of the user", + nullable=True, + ) + company_details.number_of_employees = AAZIntArg( + options=["number-of-employees"], + help="Number of employees in the company", + nullable=True, + ) + company_details.office_address = AAZStrArg( + options=["office-address"], + help="Office address of the company", + nullable=True, + ) + + partner_organization_properties = cls._args_schema.partner_organization_properties + partner_organization_properties.organization_id = AAZStrArg( + options=["organization-id"], + help="Organization Id in partner's system", + nullable=True, + ) + partner_organization_properties.organization_name = AAZStrArg( + options=["organization-name"], + help="Organization name in partner's system", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9_\\-.: ]*$", + max_length=50, + min_length=1, + ), + ) + partner_organization_properties.single_sign_on_properties = AAZObjectArg( + options=["single-sign-on-properties"], + help="Single Sign On properties for the organization", + nullable=True, + ) + + single_sign_on_properties = cls._args_schema.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListArg( + options=["aad-domains"], + help="List of AAD domains fetched from Microsoft Graph for user.", + nullable=True, + ) + single_sign_on_properties.enterprise_app_id = AAZStrArg( + options=["enterprise-app-id"], + help="AAD enterprise application Id used to setup SSO", + nullable=True, + ) + single_sign_on_properties.single_sign_on_state = AAZStrArg( + options=["single-sign-on-state"], + help="State of the Single Sign On for the organization", + nullable=True, + enum={"Disable": "Disable", "Enable": "Enable", "Initial": "Initial"}, + ) + single_sign_on_properties.single_sign_on_url = AAZStrArg( + options=["single-sign-on-url"], + help="URL for SSO to be used by the partner to redirect the user to their system", + nullable=True, + ) + + aad_domains = cls._args_schema.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrArg( + nullable=True, + ) + + user_details = cls._args_schema.user_details + user_details.email_address = AAZStrArg( + options=["email-address"], + help="Email address of the user", + nullable=True, + fmt=AAZStrArgFormat( + pattern="^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}$", + ), + ) + user_details.first_name = AAZStrArg( + options=["first-name"], + help="First name of the user", + nullable=True, + ) + user_details.last_name = AAZStrArg( + options=["last-name"], + help="Last name of the user", + nullable=True, + ) + user_details.phone_number = AAZStrArg( + options=["phone-number"], + help="User's phone number", + nullable=True, + ) + user_details.upn = AAZStrArg( + options=["upn"], + help="User's principal name", + nullable=True, + ) + + # 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/Neon.Postgres/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-08-01-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/Neon.Postgres/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-08-01-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("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("companyDetails", AAZObjectType, ".company_details", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("partnerOrganizationProperties", AAZObjectType, ".partner_organization_properties") + properties.set_prop("userDetails", AAZObjectType, ".user_details", typ_kwargs={"flags": {"required": True}}) + + company_details = _builder.get(".properties.companyDetails") + if company_details is not None: + company_details.set_prop("businessPhone", AAZStrType, ".business_phone") + company_details.set_prop("companyName", AAZStrType, ".company_name") + company_details.set_prop("country", AAZStrType, ".country") + company_details.set_prop("domain", AAZStrType, ".domain") + company_details.set_prop("numberOfEmployees", AAZIntType, ".number_of_employees") + company_details.set_prop("officeAddress", AAZStrType, ".office_address") + + partner_organization_properties = _builder.get(".properties.partnerOrganizationProperties") + if partner_organization_properties is not None: + partner_organization_properties.set_prop("organizationId", AAZStrType, ".organization_id") + partner_organization_properties.set_prop("organizationName", AAZStrType, ".organization_name", typ_kwargs={"flags": {"required": True}}) + partner_organization_properties.set_prop("singleSignOnProperties", AAZObjectType, ".single_sign_on_properties") + + single_sign_on_properties = _builder.get(".properties.partnerOrganizationProperties.singleSignOnProperties") + if single_sign_on_properties is not None: + single_sign_on_properties.set_prop("aadDomains", AAZListType, ".aad_domains") + single_sign_on_properties.set_prop("enterpriseAppId", AAZStrType, ".enterprise_app_id") + single_sign_on_properties.set_prop("singleSignOnState", AAZStrType, ".single_sign_on_state") + single_sign_on_properties.set_prop("singleSignOnUrl", AAZStrType, ".single_sign_on_url") + + aad_domains = _builder.get(".properties.partnerOrganizationProperties.singleSignOnProperties.aadDomains") + if aad_domains is not None: + aad_domains.set_elements(AAZStrType, ".") + + user_details = _builder.get(".properties.userDetails") + if user_details is not None: + user_details.set_prop("emailAddress", AAZStrType, ".email_address") + user_details.set_prop("firstName", AAZStrType, ".first_name") + user_details.set_prop("lastName", AAZStrType, ".last_name") + user_details.set_prop("phoneNumber", AAZStrType, ".phone_number") + user_details.set_prop("upn", AAZStrType, ".upn") + + 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.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.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}, + ) + + properties = _schema_organization_resource_read.properties + properties.company_details = AAZObjectType( + serialized_name="companyDetails", + flags={"required": True}, + ) + properties.marketplace_details = AAZObjectType( + serialized_name="marketplaceDetails", + flags={"required": True}, + ) + properties.partner_organization_properties = AAZObjectType( + serialized_name="partnerOrganizationProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user_details = AAZObjectType( + serialized_name="userDetails", + flags={"required": True}, + ) + + company_details = _schema_organization_resource_read.properties.company_details + company_details.business_phone = AAZStrType( + serialized_name="businessPhone", + ) + company_details.company_name = AAZStrType( + serialized_name="companyName", + ) + company_details.country = AAZStrType() + company_details.domain = AAZStrType() + company_details.number_of_employees = AAZIntType( + serialized_name="numberOfEmployees", + ) + company_details.office_address = AAZStrType( + serialized_name="officeAddress", + ) + + marketplace_details = _schema_organization_resource_read.properties.marketplace_details + marketplace_details.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace_details.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + marketplace_details.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + ) + + offer_details = _schema_organization_resource_read.properties.marketplace_details.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_organization_properties = _schema_organization_resource_read.properties.partner_organization_properties + partner_organization_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_organization_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_organization_properties.single_sign_on_properties = AAZObjectType( + serialized_name="singleSignOnProperties", + ) + + single_sign_on_properties = _schema_organization_resource_read.properties.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListType( + serialized_name="aadDomains", + ) + single_sign_on_properties.enterprise_app_id = AAZStrType( + serialized_name="enterpriseAppId", + ) + single_sign_on_properties.single_sign_on_state = AAZStrType( + serialized_name="singleSignOnState", + ) + single_sign_on_properties.single_sign_on_url = AAZStrType( + serialized_name="singleSignOnUrl", + ) + + aad_domains = _schema_organization_resource_read.properties.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrType() + + user_details = _schema_organization_resource_read.properties.user_details + user_details.email_address = AAZStrType( + serialized_name="emailAddress", + ) + user_details.first_name = AAZStrType( + serialized_name="firstName", + ) + user_details.last_name = AAZStrType( + serialized_name="lastName", + ) + user_details.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user_details.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.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/neon/azext_neon/aaz/latest/neon/postgres/organization/_wait.py b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_wait.py new file mode 100644 index 00000000000..d9c6a784e97 --- /dev/null +++ b/src/neon/azext_neon/aaz/latest/neon/postgres/organization/_wait.py @@ -0,0 +1,323 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "neon postgres 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/neon.postgres/organizations/{}", "2024-08-01-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 Neon 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( + help="Name of the Resource Group", + 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/Neon.Postgres/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-08-01-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.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}, + ) + + properties = cls._schema_on_200.properties + properties.company_details = AAZObjectType( + serialized_name="companyDetails", + flags={"required": True}, + ) + properties.marketplace_details = AAZObjectType( + serialized_name="marketplaceDetails", + flags={"required": True}, + ) + properties.partner_organization_properties = AAZObjectType( + serialized_name="partnerOrganizationProperties", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.user_details = AAZObjectType( + serialized_name="userDetails", + flags={"required": True}, + ) + + company_details = cls._schema_on_200.properties.company_details + company_details.business_phone = AAZStrType( + serialized_name="businessPhone", + ) + company_details.company_name = AAZStrType( + serialized_name="companyName", + ) + company_details.country = AAZStrType() + company_details.domain = AAZStrType() + company_details.number_of_employees = AAZIntType( + serialized_name="numberOfEmployees", + ) + company_details.office_address = AAZStrType( + serialized_name="officeAddress", + ) + + marketplace_details = cls._schema_on_200.properties.marketplace_details + marketplace_details.offer_details = AAZObjectType( + serialized_name="offerDetails", + flags={"required": True}, + ) + marketplace_details.subscription_id = AAZStrType( + serialized_name="subscriptionId", + ) + marketplace_details.subscription_status = AAZStrType( + serialized_name="subscriptionStatus", + ) + + offer_details = cls._schema_on_200.properties.marketplace_details.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_organization_properties = cls._schema_on_200.properties.partner_organization_properties + partner_organization_properties.organization_id = AAZStrType( + serialized_name="organizationId", + ) + partner_organization_properties.organization_name = AAZStrType( + serialized_name="organizationName", + flags={"required": True}, + ) + partner_organization_properties.single_sign_on_properties = AAZObjectType( + serialized_name="singleSignOnProperties", + ) + + single_sign_on_properties = cls._schema_on_200.properties.partner_organization_properties.single_sign_on_properties + single_sign_on_properties.aad_domains = AAZListType( + serialized_name="aadDomains", + ) + single_sign_on_properties.enterprise_app_id = AAZStrType( + serialized_name="enterpriseAppId", + ) + single_sign_on_properties.single_sign_on_state = AAZStrType( + serialized_name="singleSignOnState", + ) + single_sign_on_properties.single_sign_on_url = AAZStrType( + serialized_name="singleSignOnUrl", + ) + + aad_domains = cls._schema_on_200.properties.partner_organization_properties.single_sign_on_properties.aad_domains + aad_domains.Element = AAZStrType() + + user_details = cls._schema_on_200.properties.user_details + user_details.email_address = AAZStrType( + serialized_name="emailAddress", + ) + user_details.first_name = AAZStrType( + serialized_name="firstName", + ) + user_details.last_name = AAZStrType( + serialized_name="lastName", + ) + user_details.phone_number = AAZStrType( + serialized_name="phoneNumber", + ) + user_details.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/neon/azext_neon/azext_metadata.json b/src/neon/azext_neon/azext_metadata.json new file mode 100644 index 00000000000..b1e08d1f4b1 --- /dev/null +++ b/src/neon/azext_neon/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.61.0" +} \ No newline at end of file diff --git a/src/neon/azext_neon/commands.py b/src/neon/azext_neon/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/neon/azext_neon/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/neon/azext_neon/custom.py b/src/neon/azext_neon/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/neon/azext_neon/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/neon/azext_neon/tests/__init__.py b/src/neon/azext_neon/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/neon/azext_neon/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/neon/azext_neon/tests/latest/__init__.py b/src/neon/azext_neon/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/neon/azext_neon/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/neon/azext_neon/tests/latest/test_neon.py b/src/neon/azext_neon/tests/latest/test_neon.py new file mode 100644 index 00000000000..f1b7183cc1e --- /dev/null +++ b/src/neon/azext_neon/tests/latest/test_neon.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 NeonScenario(ScenarioTest): + # TODO: add tests here + pass diff --git a/src/neon/setup.cfg b/src/neon/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/neon/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/neon/setup.py b/src/neon/setup.py new file mode 100644 index 00000000000..1466fddd9d9 --- /dev/null +++ b/src/neon/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='neon', + version=VERSION, + description='Microsoft Azure Command-Line Tools Neon 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/neon', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_neon': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +)