# --------------------------------------------------------------------------------------------
# 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(
    "workloads monitor provider-instance create",
    is_preview=True,
)
class Create(AAZCommand):
    """Create a provider instance for the specified subscription, resource group, SAP monitor name, and resource name.

    :example: Create a provider instance for the specified subscription, resource group, SAP monitor name, and resource name.
        az workloads monitor provider-instance create --monitor-name <monitor-name> -n <provider-instamce-name> -g <RG-NAME> --provider-settings <provider-settings>
    """

    _aaz_info = {
        "version": "2023-04-01",
        "resources": [
            ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.workloads/monitors/{}/providerinstances/{}", "2023-04-01"],
        ]
    }

    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.monitor_name = AAZStrArg(
            options=["--monitor-name"],
            help="Name of the SAP monitor resource.",
            required=True,
        )
        _args_schema.provider_instance_name = AAZStrArg(
            options=["-n", "--name", "--provider-instance-name"],
            help="Name of the provider instance.",
            required=True,
        )
        _args_schema.resource_group = AAZResourceGroupNameArg(
            required=True,
        )

        # define Arg Group "Properties"

        _args_schema = cls._args_schema
        _args_schema.provider_settings = AAZObjectArg(
            options=["--provider-settings"],
            arg_group="Properties",
            help="Defines the provider specific properties.",
        )

        provider_settings = cls._args_schema.provider_settings
        provider_settings.db2 = AAZObjectArg(
            options=["db2"],
        )
        provider_settings.ms_sql_server = AAZObjectArg(
            options=["ms-sql-server"],
        )
        provider_settings.prometheus_ha_cluster = AAZObjectArg(
            options=["prometheus-ha-cluster"],
        )
        provider_settings.prometheus_os = AAZObjectArg(
            options=["prometheus-os"],
        )
        provider_settings.sap_hana = AAZObjectArg(
            options=["sap-hana"],
        )
        provider_settings.sap_net_weaver = AAZObjectArg(
            options=["sap-net-weaver"],
        )

        db2 = cls._args_schema.provider_settings.db2
        db2.db_name = AAZStrArg(
            options=["db-name"],
            help="Gets or sets the db2 database name.",
        )
        db2.db_password = AAZStrArg(
            options=["db-password"],
            help="Gets or sets the db2 database password.",
        )
        db2.db_password_uri = AAZStrArg(
            options=["db-password-uri"],
            help="Gets or sets the key vault URI to secret with the database password.",
        )
        db2.db_port = AAZStrArg(
            options=["db-port"],
            help="Gets or sets the db2 database sql port.",
        )
        db2.db_username = AAZStrArg(
            options=["db-username"],
            help="Gets or sets the db2 database user name.",
        )
        db2.hostname = AAZStrArg(
            options=["hostname"],
            help="Gets or sets the target virtual machine name.",
        )
        db2.sap_sid = AAZStrArg(
            options=["sap-sid"],
            help="Gets or sets the SAP System Identifier",
        )
        db2.ssl_certificate_uri = AAZStrArg(
            options=["ssl-certificate-uri"],
            help="Gets or sets the blob URI to SSL certificate for the DB2 Database.",
        )
        db2.ssl_preference = AAZStrArg(
            options=["ssl-preference"],
            help="Gets or sets certificate preference if secure communication is enabled.",
            enum={"Disabled": "Disabled", "RootCertificate": "RootCertificate", "ServerCertificate": "ServerCertificate"},
        )

        ms_sql_server = cls._args_schema.provider_settings.ms_sql_server
        ms_sql_server.db_password = AAZStrArg(
            options=["db-password"],
            help="Gets or sets the database password.",
        )
        ms_sql_server.db_password_uri = AAZStrArg(
            options=["db-password-uri"],
            help="Gets or sets the key vault URI to secret with the database password.",
        )
        ms_sql_server.db_port = AAZStrArg(
            options=["db-port"],
            help="Gets or sets the database sql port.",
        )
        ms_sql_server.db_username = AAZStrArg(
            options=["db-username"],
            help="Gets or sets the database user name.",
        )
        ms_sql_server.hostname = AAZStrArg(
            options=["hostname"],
            help="Gets or sets the SQL server host name.",
        )
        ms_sql_server.sap_sid = AAZStrArg(
            options=["sap-sid"],
            help="Gets or sets the SAP System Identifier",
        )
        ms_sql_server.ssl_certificate_uri = AAZStrArg(
            options=["ssl-certificate-uri"],
            help="Gets or sets the blob URI to SSL certificate for the SQL Database.",
        )
        ms_sql_server.ssl_preference = AAZStrArg(
            options=["ssl-preference"],
            help="Gets or sets certificate preference if secure communication is enabled.",
            enum={"Disabled": "Disabled", "RootCertificate": "RootCertificate", "ServerCertificate": "ServerCertificate"},
        )

        prometheus_ha_cluster = cls._args_schema.provider_settings.prometheus_ha_cluster
        prometheus_ha_cluster.cluster_name = AAZStrArg(
            options=["cluster-name"],
            help="Gets or sets the clusterName.",
        )
        prometheus_ha_cluster.hostname = AAZStrArg(
            options=["hostname"],
            help="Gets or sets the target machine name.",
        )
        prometheus_ha_cluster.prometheus_url = AAZStrArg(
            options=["prometheus-url"],
            help="URL of the Node Exporter endpoint.",
        )
        prometheus_ha_cluster.sid = AAZStrArg(
            options=["sid"],
            help="Gets or sets the cluster sid.",
        )
        prometheus_ha_cluster.ssl_certificate_uri = AAZStrArg(
            options=["ssl-certificate-uri"],
            help="Gets or sets the blob URI to SSL certificate for the HA cluster exporter.",
        )
        prometheus_ha_cluster.ssl_preference = AAZStrArg(
            options=["ssl-preference"],
            help="Gets or sets certificate preference if secure communication is enabled.",
            enum={"Disabled": "Disabled", "RootCertificate": "RootCertificate", "ServerCertificate": "ServerCertificate"},
        )

        prometheus_os = cls._args_schema.provider_settings.prometheus_os
        prometheus_os.prometheus_url = AAZStrArg(
            options=["prometheus-url"],
            help="URL of the Node Exporter endpoint",
        )
        prometheus_os.sap_sid = AAZStrArg(
            options=["sap-sid"],
            help="Gets or sets the SAP System Identifier",
        )
        prometheus_os.ssl_certificate_uri = AAZStrArg(
            options=["ssl-certificate-uri"],
            help="Gets or sets the blob URI to SSL certificate for the prometheus node exporter.",
        )
        prometheus_os.ssl_preference = AAZStrArg(
            options=["ssl-preference"],
            help="Gets or sets certificate preference if secure communication is enabled.",
            enum={"Disabled": "Disabled", "RootCertificate": "RootCertificate", "ServerCertificate": "ServerCertificate"},
        )

        sap_hana = cls._args_schema.provider_settings.sap_hana
        sap_hana.db_name = AAZStrArg(
            options=["db-name"],
            help="Gets or sets the hana database name.",
        )
        sap_hana.db_password = AAZStrArg(
            options=["db-password"],
            help="Gets or sets the database password.",
        )
        sap_hana.db_password_uri = AAZStrArg(
            options=["db-password-uri"],
            help="Gets or sets the key vault URI to secret with the database password.",
        )
        sap_hana.db_username = AAZStrArg(
            options=["db-username"],
            help="Gets or sets the database user name.",
        )
        sap_hana.hostname = AAZStrArg(
            options=["hostname"],
            help="Gets or sets the target virtual machine size.",
        )
        sap_hana.instance_number = AAZStrArg(
            options=["instance-number"],
            help="Gets or sets the database instance number.",
        )
        sap_hana.sap_sid = AAZStrArg(
            options=["sap-sid"],
            help="Gets or sets the SAP System Identifier.",
        )
        sap_hana.sql_port = AAZStrArg(
            options=["sql-port"],
            help="Gets or sets the database sql port.",
        )
        sap_hana.ssl_certificate_uri = AAZStrArg(
            options=["ssl-certificate-uri"],
            help="Gets or sets the blob URI to SSL certificate for the DB.",
        )
        sap_hana.ssl_host_name_in_certificate = AAZStrArg(
            options=["ssl-host-name-in-certificate"],
            help="Gets or sets the hostname(s) in the SSL certificate.",
        )
        sap_hana.ssl_preference = AAZStrArg(
            options=["ssl-preference"],
            help="Gets or sets certificate preference if secure communication is enabled.",
            enum={"Disabled": "Disabled", "RootCertificate": "RootCertificate", "ServerCertificate": "ServerCertificate"},
        )

        sap_net_weaver = cls._args_schema.provider_settings.sap_net_weaver
        sap_net_weaver.sap_client_id = AAZStrArg(
            options=["sap-client-id"],
            help="Gets or sets the SAP Client ID.",
        )
        sap_net_weaver.sap_host_file_entries = AAZListArg(
            options=["sap-host-file-entries"],
            help="Gets or sets the list of HostFile Entries",
        )
        sap_net_weaver.sap_hostname = AAZStrArg(
            options=["sap-hostname"],
            help="Gets or sets the target virtual machine IP Address/FQDN.",
        )
        sap_net_weaver.sap_instance_nr = AAZStrArg(
            options=["sap-instance-nr"],
            help="Gets or sets the instance number of SAP NetWeaver.",
        )
        sap_net_weaver.sap_password = AAZStrArg(
            options=["sap-password"],
            help="Sets the SAP password.",
        )
        sap_net_weaver.sap_password_uri = AAZStrArg(
            options=["sap-password-uri"],
            help="Gets or sets the key vault URI to secret with the SAP password.",
        )
        sap_net_weaver.sap_port_number = AAZStrArg(
            options=["sap-port-number"],
            help="Gets or sets the SAP HTTP port number.",
        )
        sap_net_weaver.sap_sid = AAZStrArg(
            options=["sap-sid"],
            help="Gets or sets the SAP System Identifier",
        )
        sap_net_weaver.sap_username = AAZStrArg(
            options=["sap-username"],
            help="Gets or sets the SAP user name.",
        )
        sap_net_weaver.ssl_certificate_uri = AAZStrArg(
            options=["ssl-certificate-uri"],
            help="Gets or sets the blob URI to SSL certificate for the SAP system.",
        )
        sap_net_weaver.ssl_preference = AAZStrArg(
            options=["ssl-preference"],
            help="Gets or sets certificate preference if secure communication is enabled.",
            enum={"Disabled": "Disabled", "RootCertificate": "RootCertificate", "ServerCertificate": "ServerCertificate"},
        )

        sap_host_file_entries = cls._args_schema.provider_settings.sap_net_weaver.sap_host_file_entries
        sap_host_file_entries.Element = AAZStrArg()

        # define Arg Group "ProviderInstanceParameter"

        _args_schema = cls._args_schema
        _args_schema.identity = AAZObjectArg(
            options=["--identity"],
            arg_group="ProviderInstanceParameter",
            help="[currently not in use] Managed service identity(user assigned identities)",
        )

        identity = cls._args_schema.identity
        identity.type = AAZStrArg(
            options=["type"],
            help="Type of manage identity",
            required=True,
            enum={"None": "None", "UserAssigned": "UserAssigned"},
        )
        identity.user_assigned_identities = AAZDictArg(
            options=["user-assigned-identities"],
            help="User assigned identities dictionary",
        )

        user_assigned_identities = cls._args_schema.identity.user_assigned_identities
        user_assigned_identities.Element = AAZObjectArg(
            blank={},
        )
        return cls._args_schema

    def _execute_operations(self):
        self.pre_operations()
        yield self.ProviderInstancesCreate(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 ProviderInstancesCreate(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/Microsoft.Workloads/monitors/{monitorName}/providerInstances/{providerInstanceName}",
                **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(
                    "monitorName", self.ctx.args.monitor_name,
                    required=True,
                ),
                **self.serialize_url_param(
                    "providerInstanceName", self.ctx.args.provider_instance_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", "2023-04-01",
                    required=True,
                ),
            }
            return parameters

        @property
        def header_parameters(self):
            parameters = {
                **self.serialize_header_param(
                    "Content-Type", "application/json",
                ),
                **self.serialize_header_param(
                    "Accept", "application/json",
                ),
            }
            return parameters

        @property
        def content(self):
            _content_value, _builder = self.new_content_builder(
                self.ctx.args,
                typ=AAZObjectType,
                typ_kwargs={"flags": {"required": True, "client_flatten": True}}
            )
            _builder.set_prop("identity", AAZObjectType, ".identity")
            _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})

            identity = _builder.get(".identity")
            if identity is not None:
                identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}})
                identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities")

            user_assigned_identities = _builder.get(".identity.userAssignedIdentities")
            if user_assigned_identities is not None:
                user_assigned_identities.set_elements(AAZObjectType, ".")

            properties = _builder.get(".properties")
            if properties is not None:
                properties.set_prop("providerSettings", AAZObjectType, ".provider_settings")

            provider_settings = _builder.get(".properties.providerSettings")
            if provider_settings is not None:
                provider_settings.set_const("providerType", "Db2", AAZStrType, ".db2", typ_kwargs={"flags": {"required": True}})
                provider_settings.set_const("providerType", "MsSqlServer", AAZStrType, ".ms_sql_server", typ_kwargs={"flags": {"required": True}})
                provider_settings.set_const("providerType", "PrometheusHaCluster", AAZStrType, ".prometheus_ha_cluster", typ_kwargs={"flags": {"required": True}})
                provider_settings.set_const("providerType", "PrometheusOS", AAZStrType, ".prometheus_os", typ_kwargs={"flags": {"required": True}})
                provider_settings.set_const("providerType", "SapHana", AAZStrType, ".sap_hana", typ_kwargs={"flags": {"required": True}})
                provider_settings.set_const("providerType", "SapNetWeaver", AAZStrType, ".sap_net_weaver", typ_kwargs={"flags": {"required": True}})
                provider_settings.discriminate_by("providerType", "Db2")
                provider_settings.discriminate_by("providerType", "MsSqlServer")
                provider_settings.discriminate_by("providerType", "PrometheusHaCluster")
                provider_settings.discriminate_by("providerType", "PrometheusOS")
                provider_settings.discriminate_by("providerType", "SapHana")
                provider_settings.discriminate_by("providerType", "SapNetWeaver")

            disc_db2 = _builder.get(".properties.providerSettings{providerType:Db2}")
            if disc_db2 is not None:
                disc_db2.set_prop("dbName", AAZStrType, ".db2.db_name")
                disc_db2.set_prop("dbPassword", AAZStrType, ".db2.db_password")
                disc_db2.set_prop("dbPasswordUri", AAZStrType, ".db2.db_password_uri")
                disc_db2.set_prop("dbPort", AAZStrType, ".db2.db_port")
                disc_db2.set_prop("dbUsername", AAZStrType, ".db2.db_username")
                disc_db2.set_prop("hostname", AAZStrType, ".db2.hostname")
                disc_db2.set_prop("sapSid", AAZStrType, ".db2.sap_sid")
                disc_db2.set_prop("sslCertificateUri", AAZStrType, ".db2.ssl_certificate_uri")
                disc_db2.set_prop("sslPreference", AAZStrType, ".db2.ssl_preference")

            disc_ms_sql_server = _builder.get(".properties.providerSettings{providerType:MsSqlServer}")
            if disc_ms_sql_server is not None:
                disc_ms_sql_server.set_prop("dbPassword", AAZStrType, ".ms_sql_server.db_password")
                disc_ms_sql_server.set_prop("dbPasswordUri", AAZStrType, ".ms_sql_server.db_password_uri")
                disc_ms_sql_server.set_prop("dbPort", AAZStrType, ".ms_sql_server.db_port")
                disc_ms_sql_server.set_prop("dbUsername", AAZStrType, ".ms_sql_server.db_username")
                disc_ms_sql_server.set_prop("hostname", AAZStrType, ".ms_sql_server.hostname")
                disc_ms_sql_server.set_prop("sapSid", AAZStrType, ".ms_sql_server.sap_sid")
                disc_ms_sql_server.set_prop("sslCertificateUri", AAZStrType, ".ms_sql_server.ssl_certificate_uri")
                disc_ms_sql_server.set_prop("sslPreference", AAZStrType, ".ms_sql_server.ssl_preference")

            disc_prometheus_ha_cluster = _builder.get(".properties.providerSettings{providerType:PrometheusHaCluster}")
            if disc_prometheus_ha_cluster is not None:
                disc_prometheus_ha_cluster.set_prop("clusterName", AAZStrType, ".prometheus_ha_cluster.cluster_name")
                disc_prometheus_ha_cluster.set_prop("hostname", AAZStrType, ".prometheus_ha_cluster.hostname")
                disc_prometheus_ha_cluster.set_prop("prometheusUrl", AAZStrType, ".prometheus_ha_cluster.prometheus_url")
                disc_prometheus_ha_cluster.set_prop("sid", AAZStrType, ".prometheus_ha_cluster.sid")
                disc_prometheus_ha_cluster.set_prop("sslCertificateUri", AAZStrType, ".prometheus_ha_cluster.ssl_certificate_uri")
                disc_prometheus_ha_cluster.set_prop("sslPreference", AAZStrType, ".prometheus_ha_cluster.ssl_preference")

            disc_prometheus_os = _builder.get(".properties.providerSettings{providerType:PrometheusOS}")
            if disc_prometheus_os is not None:
                disc_prometheus_os.set_prop("prometheusUrl", AAZStrType, ".prometheus_os.prometheus_url")
                disc_prometheus_os.set_prop("sapSid", AAZStrType, ".prometheus_os.sap_sid")
                disc_prometheus_os.set_prop("sslCertificateUri", AAZStrType, ".prometheus_os.ssl_certificate_uri")
                disc_prometheus_os.set_prop("sslPreference", AAZStrType, ".prometheus_os.ssl_preference")

            disc_sap_hana = _builder.get(".properties.providerSettings{providerType:SapHana}")
            if disc_sap_hana is not None:
                disc_sap_hana.set_prop("dbName", AAZStrType, ".sap_hana.db_name")
                disc_sap_hana.set_prop("dbPassword", AAZStrType, ".sap_hana.db_password")
                disc_sap_hana.set_prop("dbPasswordUri", AAZStrType, ".sap_hana.db_password_uri")
                disc_sap_hana.set_prop("dbUsername", AAZStrType, ".sap_hana.db_username")
                disc_sap_hana.set_prop("hostname", AAZStrType, ".sap_hana.hostname")
                disc_sap_hana.set_prop("instanceNumber", AAZStrType, ".sap_hana.instance_number")
                disc_sap_hana.set_prop("sapSid", AAZStrType, ".sap_hana.sap_sid")
                disc_sap_hana.set_prop("sqlPort", AAZStrType, ".sap_hana.sql_port")
                disc_sap_hana.set_prop("sslCertificateUri", AAZStrType, ".sap_hana.ssl_certificate_uri")
                disc_sap_hana.set_prop("sslHostNameInCertificate", AAZStrType, ".sap_hana.ssl_host_name_in_certificate")
                disc_sap_hana.set_prop("sslPreference", AAZStrType, ".sap_hana.ssl_preference")

            disc_sap_net_weaver = _builder.get(".properties.providerSettings{providerType:SapNetWeaver}")
            if disc_sap_net_weaver is not None:
                disc_sap_net_weaver.set_prop("sapClientId", AAZStrType, ".sap_net_weaver.sap_client_id")
                disc_sap_net_weaver.set_prop("sapHostFileEntries", AAZListType, ".sap_net_weaver.sap_host_file_entries")
                disc_sap_net_weaver.set_prop("sapHostname", AAZStrType, ".sap_net_weaver.sap_hostname")
                disc_sap_net_weaver.set_prop("sapInstanceNr", AAZStrType, ".sap_net_weaver.sap_instance_nr")
                disc_sap_net_weaver.set_prop("sapPassword", AAZStrType, ".sap_net_weaver.sap_password")
                disc_sap_net_weaver.set_prop("sapPasswordUri", AAZStrType, ".sap_net_weaver.sap_password_uri")
                disc_sap_net_weaver.set_prop("sapPortNumber", AAZStrType, ".sap_net_weaver.sap_port_number")
                disc_sap_net_weaver.set_prop("sapSid", AAZStrType, ".sap_net_weaver.sap_sid")
                disc_sap_net_weaver.set_prop("sapUsername", AAZStrType, ".sap_net_weaver.sap_username")
                disc_sap_net_weaver.set_prop("sslCertificateUri", AAZStrType, ".sap_net_weaver.ssl_certificate_uri")
                disc_sap_net_weaver.set_prop("sslPreference", AAZStrType, ".sap_net_weaver.ssl_preference")

            sap_host_file_entries = _builder.get(".properties.providerSettings{providerType:SapNetWeaver}.sapHostFileEntries")
            if sap_host_file_entries is not None:
                sap_host_file_entries.set_elements(AAZStrType, ".")

            return self.serialize_content(_content_value)

        def on_200_201(self, session):
            data = self.deserialize_http_content(session)
            self.ctx.set_var(
                "instance",
                data,
                schema_builder=self._build_schema_on_200_201
            )

        _schema_on_200_201 = None

        @classmethod
        def _build_schema_on_200_201(cls):
            if cls._schema_on_200_201 is not None:
                return cls._schema_on_200_201

            cls._schema_on_200_201 = AAZObjectType()

            _schema_on_200_201 = cls._schema_on_200_201
            _schema_on_200_201.id = AAZStrType(
                flags={"read_only": True},
            )
            _schema_on_200_201.identity = AAZObjectType()
            _schema_on_200_201.name = AAZStrType(
                flags={"read_only": True},
            )
            _schema_on_200_201.properties = AAZObjectType(
                flags={"client_flatten": True},
            )
            _schema_on_200_201.system_data = AAZObjectType(
                serialized_name="systemData",
                flags={"read_only": True},
            )
            _schema_on_200_201.type = AAZStrType(
                flags={"read_only": True},
            )

            identity = cls._schema_on_200_201.identity
            identity.type = AAZStrType(
                flags={"required": True},
            )
            identity.user_assigned_identities = AAZDictType(
                serialized_name="userAssignedIdentities",
            )

            user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities
            user_assigned_identities.Element = AAZObjectType()

            _element = cls._schema_on_200_201.identity.user_assigned_identities.Element
            _element.client_id = AAZStrType(
                serialized_name="clientId",
                flags={"read_only": True},
            )
            _element.principal_id = AAZStrType(
                serialized_name="principalId",
                flags={"read_only": True},
            )

            properties = cls._schema_on_200_201.properties
            properties.errors = AAZObjectType()
            _CreateHelper._build_schema_error_read(properties.errors)
            properties.provider_settings = AAZObjectType(
                serialized_name="providerSettings",
            )
            properties.provisioning_state = AAZStrType(
                serialized_name="provisioningState",
                flags={"read_only": True},
            )

            provider_settings = cls._schema_on_200_201.properties.provider_settings
            provider_settings.provider_type = AAZStrType(
                serialized_name="providerType",
                flags={"required": True},
            )

            disc_db2 = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "Db2")
            disc_db2.db_name = AAZStrType(
                serialized_name="dbName",
            )
            disc_db2.db_password = AAZStrType(
                serialized_name="dbPassword",
            )
            disc_db2.db_password_uri = AAZStrType(
                serialized_name="dbPasswordUri",
            )
            disc_db2.db_port = AAZStrType(
                serialized_name="dbPort",
            )
            disc_db2.db_username = AAZStrType(
                serialized_name="dbUsername",
            )
            disc_db2.hostname = AAZStrType()
            disc_db2.sap_sid = AAZStrType(
                serialized_name="sapSid",
            )
            disc_db2.ssl_certificate_uri = AAZStrType(
                serialized_name="sslCertificateUri",
            )
            disc_db2.ssl_preference = AAZStrType(
                serialized_name="sslPreference",
            )

            disc_ms_sql_server = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "MsSqlServer")
            disc_ms_sql_server.db_password = AAZStrType(
                serialized_name="dbPassword",
            )
            disc_ms_sql_server.db_password_uri = AAZStrType(
                serialized_name="dbPasswordUri",
            )
            disc_ms_sql_server.db_port = AAZStrType(
                serialized_name="dbPort",
            )
            disc_ms_sql_server.db_username = AAZStrType(
                serialized_name="dbUsername",
            )
            disc_ms_sql_server.hostname = AAZStrType()
            disc_ms_sql_server.sap_sid = AAZStrType(
                serialized_name="sapSid",
            )
            disc_ms_sql_server.ssl_certificate_uri = AAZStrType(
                serialized_name="sslCertificateUri",
            )
            disc_ms_sql_server.ssl_preference = AAZStrType(
                serialized_name="sslPreference",
            )

            disc_prometheus_ha_cluster = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "PrometheusHaCluster")
            disc_prometheus_ha_cluster.cluster_name = AAZStrType(
                serialized_name="clusterName",
            )
            disc_prometheus_ha_cluster.hostname = AAZStrType()
            disc_prometheus_ha_cluster.prometheus_url = AAZStrType(
                serialized_name="prometheusUrl",
            )
            disc_prometheus_ha_cluster.sid = AAZStrType()
            disc_prometheus_ha_cluster.ssl_certificate_uri = AAZStrType(
                serialized_name="sslCertificateUri",
            )
            disc_prometheus_ha_cluster.ssl_preference = AAZStrType(
                serialized_name="sslPreference",
            )

            disc_prometheus_os = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "PrometheusOS")
            disc_prometheus_os.prometheus_url = AAZStrType(
                serialized_name="prometheusUrl",
            )
            disc_prometheus_os.sap_sid = AAZStrType(
                serialized_name="sapSid",
            )
            disc_prometheus_os.ssl_certificate_uri = AAZStrType(
                serialized_name="sslCertificateUri",
            )
            disc_prometheus_os.ssl_preference = AAZStrType(
                serialized_name="sslPreference",
            )

            disc_sap_hana = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "SapHana")
            disc_sap_hana.db_name = AAZStrType(
                serialized_name="dbName",
            )
            disc_sap_hana.db_password = AAZStrType(
                serialized_name="dbPassword",
            )
            disc_sap_hana.db_password_uri = AAZStrType(
                serialized_name="dbPasswordUri",
            )
            disc_sap_hana.db_username = AAZStrType(
                serialized_name="dbUsername",
            )
            disc_sap_hana.hostname = AAZStrType()
            disc_sap_hana.instance_number = AAZStrType(
                serialized_name="instanceNumber",
            )
            disc_sap_hana.sap_sid = AAZStrType(
                serialized_name="sapSid",
            )
            disc_sap_hana.sql_port = AAZStrType(
                serialized_name="sqlPort",
            )
            disc_sap_hana.ssl_certificate_uri = AAZStrType(
                serialized_name="sslCertificateUri",
            )
            disc_sap_hana.ssl_host_name_in_certificate = AAZStrType(
                serialized_name="sslHostNameInCertificate",
            )
            disc_sap_hana.ssl_preference = AAZStrType(
                serialized_name="sslPreference",
            )

            disc_sap_net_weaver = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "SapNetWeaver")
            disc_sap_net_weaver.sap_client_id = AAZStrType(
                serialized_name="sapClientId",
            )
            disc_sap_net_weaver.sap_host_file_entries = AAZListType(
                serialized_name="sapHostFileEntries",
            )
            disc_sap_net_weaver.sap_hostname = AAZStrType(
                serialized_name="sapHostname",
            )
            disc_sap_net_weaver.sap_instance_nr = AAZStrType(
                serialized_name="sapInstanceNr",
            )
            disc_sap_net_weaver.sap_password = AAZStrType(
                serialized_name="sapPassword",
            )
            disc_sap_net_weaver.sap_password_uri = AAZStrType(
                serialized_name="sapPasswordUri",
            )
            disc_sap_net_weaver.sap_port_number = AAZStrType(
                serialized_name="sapPortNumber",
            )
            disc_sap_net_weaver.sap_sid = AAZStrType(
                serialized_name="sapSid",
            )
            disc_sap_net_weaver.sap_username = AAZStrType(
                serialized_name="sapUsername",
            )
            disc_sap_net_weaver.ssl_certificate_uri = AAZStrType(
                serialized_name="sslCertificateUri",
            )
            disc_sap_net_weaver.ssl_preference = AAZStrType(
                serialized_name="sslPreference",
            )

            sap_host_file_entries = cls._schema_on_200_201.properties.provider_settings.discriminate_by("provider_type", "SapNetWeaver").sap_host_file_entries
            sap_host_file_entries.Element = 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",
            )

            return cls._schema_on_200_201


class _CreateHelper:
    """Helper class for Create"""

    _schema_error_read = None

    @classmethod
    def _build_schema_error_read(cls, _schema):
        if cls._schema_error_read is not None:
            _schema.code = cls._schema_error_read.code
            _schema.details = cls._schema_error_read.details
            _schema.inner_error = cls._schema_error_read.inner_error
            _schema.message = cls._schema_error_read.message
            _schema.target = cls._schema_error_read.target
            return

        cls._schema_error_read = _schema_error_read = AAZObjectType()

        error_read = _schema_error_read
        error_read.code = AAZStrType(
            flags={"read_only": True},
        )
        error_read.details = AAZListType(
            flags={"read_only": True},
        )
        error_read.inner_error = AAZObjectType(
            serialized_name="innerError",
            flags={"read_only": True},
        )
        error_read.message = AAZStrType(
            flags={"read_only": True},
        )
        error_read.target = AAZStrType(
            flags={"read_only": True},
        )

        details = _schema_error_read.details
        details.Element = AAZObjectType()
        cls._build_schema_error_read(details.Element)

        inner_error = _schema_error_read.inner_error
        inner_error.inner_error = AAZObjectType(
            serialized_name="innerError",
        )
        cls._build_schema_error_read(inner_error.inner_error)

        _schema.code = cls._schema_error_read.code
        _schema.details = cls._schema_error_read.details
        _schema.inner_error = cls._schema_error_read.inner_error
        _schema.message = cls._schema_error_read.message
        _schema.target = cls._schema_error_read.target


__all__ = ["Create"]
