# --------------------------------------------------------------------------------------------
# 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 *


class Show(AAZCommand):
    """Get information about the model view or the instance view of a hybrid machine.
    """

    _aaz_info = {
        "version": "2022-11-10",
        "resources": [
            ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.hybridcompute/machines/{}", "2022-11-10"],
        ]
    }

    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.machine_name = AAZStrArg(
            options=["-n", "--name", "--machine-name"],
            help="The name of the hybrid machine.",
            required=True,
            id_part="name",
        )
        _args_schema.resource_group = AAZResourceGroupNameArg(
            required=True,
        )
        _args_schema.expand = AAZStrArg(
            options=["--expand"],
            help="The expand expression to apply on the operation.",
            enum={"instanceView": "instanceView"},
        )
        return cls._args_schema

    def _execute_operations(self):
        self.pre_operations()
        self.MachinesGet(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 MachinesGet(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/Microsoft.HybridCompute/machines/{machineName}",
                **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(
                    "machineName", self.ctx.args.machine_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(
                    "$expand", self.ctx.args.expand,
                ),
                **self.serialize_query_param(
                    "api-version", "2022-11-10",
                    required=True,
                ),
            }
            return parameters

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

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

        _schema_on_200 = None

        @classmethod
        def _build_schema_on_200(cls):
            if cls._schema_on_200 is not None:
                return cls._schema_on_200

            cls._schema_on_200 = AAZObjectType()

            _schema_on_200 = cls._schema_on_200
            _schema_on_200.id = AAZStrType(
                flags={"read_only": True},
            )
            _schema_on_200.identity = AAZObjectType()
            _schema_on_200.location = AAZStrType(
                flags={"required": True},
            )
            _schema_on_200.name = AAZStrType(
                flags={"read_only": True},
            )
            _schema_on_200.properties = AAZObjectType(
                flags={"client_flatten": True},
            )
            _schema_on_200.resources = AAZListType(
                flags={"read_only": True},
            )
            _schema_on_200.system_data = AAZObjectType(
                serialized_name="systemData",
                flags={"read_only": True},
            )
            _ShowHelper._build_schema_system_data_read(_schema_on_200.system_data)
            _schema_on_200.tags = AAZDictType()
            _schema_on_200.type = AAZStrType(
                flags={"read_only": True},
            )

            identity = cls._schema_on_200.identity
            identity.principal_id = AAZStrType(
                serialized_name="principalId",
                flags={"read_only": True},
            )
            identity.tenant_id = AAZStrType(
                serialized_name="tenantId",
                flags={"read_only": True},
            )
            identity.type = AAZStrType()

            properties = cls._schema_on_200.properties
            properties.ad_fqdn = AAZStrType(
                serialized_name="adFqdn",
                flags={"read_only": True},
            )
            properties.agent_configuration = AAZObjectType(
                serialized_name="agentConfiguration",
                flags={"read_only": True},
            )
            properties.agent_version = AAZStrType(
                serialized_name="agentVersion",
                flags={"read_only": True},
            )
            properties.client_public_key = AAZStrType(
                serialized_name="clientPublicKey",
            )
            properties.cloud_metadata = AAZObjectType(
                serialized_name="cloudMetadata",
            )
            properties.detected_properties = AAZDictType(
                serialized_name="detectedProperties",
                flags={"read_only": True},
            )
            properties.display_name = AAZStrType(
                serialized_name="displayName",
                flags={"read_only": True},
            )
            properties.dns_fqdn = AAZStrType(
                serialized_name="dnsFqdn",
                flags={"read_only": True},
            )
            properties.domain_name = AAZStrType(
                serialized_name="domainName",
                flags={"read_only": True},
            )
            properties.error_details = AAZListType(
                serialized_name="errorDetails",
                flags={"read_only": True},
            )
            properties.extensions = AAZListType()
            properties.last_status_change = AAZStrType(
                serialized_name="lastStatusChange",
                flags={"read_only": True},
            )
            properties.location_data = AAZObjectType(
                serialized_name="locationData",
            )
            properties.machine_fqdn = AAZStrType(
                serialized_name="machineFqdn",
                flags={"read_only": True},
            )
            properties.mssql_discovered = AAZStrType(
                serialized_name="mssqlDiscovered",
            )
            properties.os_name = AAZStrType(
                serialized_name="osName",
                flags={"read_only": True},
            )
            properties.os_profile = AAZObjectType(
                serialized_name="osProfile",
            )
            properties.os_sku = AAZStrType(
                serialized_name="osSku",
                flags={"read_only": True},
            )
            properties.os_type = AAZStrType(
                serialized_name="osType",
            )
            properties.os_version = AAZStrType(
                serialized_name="osVersion",
                flags={"read_only": True},
            )
            properties.parent_cluster_resource_id = AAZStrType(
                serialized_name="parentClusterResourceId",
            )
            properties.private_link_scope_resource_id = AAZStrType(
                serialized_name="privateLinkScopeResourceId",
            )
            properties.provisioning_state = AAZStrType(
                serialized_name="provisioningState",
                flags={"read_only": True},
            )
            properties.service_statuses = AAZObjectType(
                serialized_name="serviceStatuses",
            )
            properties.status = AAZStrType(
                flags={"read_only": True},
            )
            properties.vm_id = AAZStrType(
                serialized_name="vmId",
            )
            properties.vm_uuid = AAZStrType(
                serialized_name="vmUuid",
                flags={"read_only": True},
            )

            agent_configuration = cls._schema_on_200.properties.agent_configuration
            agent_configuration.config_mode = AAZStrType(
                serialized_name="configMode",
                flags={"read_only": True},
            )
            agent_configuration.extensions_allow_list = AAZListType(
                serialized_name="extensionsAllowList",
                flags={"read_only": True},
            )
            agent_configuration.extensions_block_list = AAZListType(
                serialized_name="extensionsBlockList",
                flags={"read_only": True},
            )
            agent_configuration.extensions_enabled = AAZStrType(
                serialized_name="extensionsEnabled",
                flags={"read_only": True},
            )
            agent_configuration.guest_configuration_enabled = AAZStrType(
                serialized_name="guestConfigurationEnabled",
                flags={"read_only": True},
            )
            agent_configuration.incoming_connections_ports = AAZListType(
                serialized_name="incomingConnectionsPorts",
                flags={"read_only": True},
            )
            agent_configuration.proxy_bypass = AAZListType(
                serialized_name="proxyBypass",
                flags={"read_only": True},
            )
            agent_configuration.proxy_url = AAZStrType(
                serialized_name="proxyUrl",
                flags={"read_only": True},
            )

            extensions_allow_list = cls._schema_on_200.properties.agent_configuration.extensions_allow_list
            extensions_allow_list.Element = AAZObjectType()
            _ShowHelper._build_schema_configuration_extension_read(extensions_allow_list.Element)

            extensions_block_list = cls._schema_on_200.properties.agent_configuration.extensions_block_list
            extensions_block_list.Element = AAZObjectType()
            _ShowHelper._build_schema_configuration_extension_read(extensions_block_list.Element)

            incoming_connections_ports = cls._schema_on_200.properties.agent_configuration.incoming_connections_ports
            incoming_connections_ports.Element = AAZStrType()

            proxy_bypass = cls._schema_on_200.properties.agent_configuration.proxy_bypass
            proxy_bypass.Element = AAZStrType()

            cloud_metadata = cls._schema_on_200.properties.cloud_metadata
            cloud_metadata.provider = AAZStrType(
                flags={"read_only": True},
            )

            detected_properties = cls._schema_on_200.properties.detected_properties
            detected_properties.Element = AAZStrType()

            error_details = cls._schema_on_200.properties.error_details
            error_details.Element = AAZObjectType()
            _ShowHelper._build_schema_error_detail_read(error_details.Element)

            extensions = cls._schema_on_200.properties.extensions
            extensions.Element = AAZObjectType()
            _ShowHelper._build_schema_machine_extension_instance_view_read(extensions.Element)

            location_data = cls._schema_on_200.properties.location_data
            location_data.city = AAZStrType()
            location_data.country_or_region = AAZStrType(
                serialized_name="countryOrRegion",
            )
            location_data.district = AAZStrType()
            location_data.name = AAZStrType(
                flags={"required": True},
            )

            os_profile = cls._schema_on_200.properties.os_profile
            os_profile.computer_name = AAZStrType(
                serialized_name="computerName",
                flags={"read_only": True},
            )
            os_profile.linux_configuration = AAZObjectType(
                serialized_name="linuxConfiguration",
            )
            os_profile.windows_configuration = AAZObjectType(
                serialized_name="windowsConfiguration",
            )

            linux_configuration = cls._schema_on_200.properties.os_profile.linux_configuration
            linux_configuration.patch_settings = AAZObjectType(
                serialized_name="patchSettings",
                flags={"client_flatten": True},
            )
            _ShowHelper._build_schema_patch_settings_read(linux_configuration.patch_settings)

            windows_configuration = cls._schema_on_200.properties.os_profile.windows_configuration
            windows_configuration.patch_settings = AAZObjectType(
                serialized_name="patchSettings",
                flags={"client_flatten": True},
            )
            _ShowHelper._build_schema_patch_settings_read(windows_configuration.patch_settings)

            service_statuses = cls._schema_on_200.properties.service_statuses
            service_statuses.extension_service = AAZObjectType(
                serialized_name="extensionService",
            )
            _ShowHelper._build_schema_service_status_read(service_statuses.extension_service)
            service_statuses.guest_configuration_service = AAZObjectType(
                serialized_name="guestConfigurationService",
            )
            _ShowHelper._build_schema_service_status_read(service_statuses.guest_configuration_service)

            resources = cls._schema_on_200.resources
            resources.Element = AAZObjectType()

            _element = cls._schema_on_200.resources.Element
            _element.id = AAZStrType(
                flags={"read_only": True},
            )
            _element.location = AAZStrType(
                flags={"required": True},
            )
            _element.name = AAZStrType(
                flags={"read_only": True},
            )
            _element.properties = AAZObjectType(
                flags={"client_flatten": True},
            )
            _element.system_data = AAZObjectType(
                serialized_name="systemData",
                flags={"read_only": True},
            )
            _ShowHelper._build_schema_system_data_read(_element.system_data)
            _element.tags = AAZDictType()
            _element.type = AAZStrType(
                flags={"read_only": True},
            )

            properties = cls._schema_on_200.resources.Element.properties
            properties.auto_upgrade_minor_version = AAZBoolType(
                serialized_name="autoUpgradeMinorVersion",
            )
            properties.enable_automatic_upgrade = AAZBoolType(
                serialized_name="enableAutomaticUpgrade",
            )
            properties.force_update_tag = AAZStrType(
                serialized_name="forceUpdateTag",
            )
            properties.instance_view = AAZObjectType(
                serialized_name="instanceView",
            )
            _ShowHelper._build_schema_machine_extension_instance_view_read(properties.instance_view)
            properties.protected_settings = AAZFreeFormDictType(
                serialized_name="protectedSettings",
            )
            properties.provisioning_state = AAZStrType(
                serialized_name="provisioningState",
                flags={"read_only": True},
            )
            properties.publisher = AAZStrType()
            properties.settings = AAZFreeFormDictType()
            properties.type = AAZStrType()
            properties.type_handler_version = AAZStrType(
                serialized_name="typeHandlerVersion",
            )

            tags = cls._schema_on_200.resources.Element.tags
            tags.Element = AAZStrType()

            tags = cls._schema_on_200.tags
            tags.Element = AAZStrType()

            return cls._schema_on_200


class _ShowHelper:
    """Helper class for Show"""

    _schema_configuration_extension_read = None

    @classmethod
    def _build_schema_configuration_extension_read(cls, _schema):
        if cls._schema_configuration_extension_read is not None:
            _schema.publisher = cls._schema_configuration_extension_read.publisher
            _schema.type = cls._schema_configuration_extension_read.type
            return

        cls._schema_configuration_extension_read = _schema_configuration_extension_read = AAZObjectType()

        configuration_extension_read = _schema_configuration_extension_read
        configuration_extension_read.publisher = AAZStrType(
            flags={"read_only": True},
        )
        configuration_extension_read.type = AAZStrType(
            flags={"read_only": True},
        )

        _schema.publisher = cls._schema_configuration_extension_read.publisher
        _schema.type = cls._schema_configuration_extension_read.type

    _schema_error_detail_read = None

    @classmethod
    def _build_schema_error_detail_read(cls, _schema):
        if cls._schema_error_detail_read is not None:
            _schema.additional_info = cls._schema_error_detail_read.additional_info
            _schema.code = cls._schema_error_detail_read.code
            _schema.details = cls._schema_error_detail_read.details
            _schema.message = cls._schema_error_detail_read.message
            _schema.target = cls._schema_error_detail_read.target
            return

        cls._schema_error_detail_read = _schema_error_detail_read = AAZObjectType()

        error_detail_read = _schema_error_detail_read
        error_detail_read.additional_info = AAZListType(
            serialized_name="additionalInfo",
            flags={"read_only": True},
        )
        error_detail_read.code = AAZStrType(
            flags={"read_only": True},
        )
        error_detail_read.details = AAZListType(
            flags={"read_only": True},
        )
        error_detail_read.message = AAZStrType(
            flags={"read_only": True},
        )
        error_detail_read.target = AAZStrType(
            flags={"read_only": True},
        )

        additional_info = _schema_error_detail_read.additional_info
        additional_info.Element = AAZObjectType()

        _element = _schema_error_detail_read.additional_info.Element
        _element.type = AAZStrType(
            flags={"read_only": True},
        )

        details = _schema_error_detail_read.details
        details.Element = AAZObjectType()
        cls._build_schema_error_detail_read(details.Element)

        _schema.additional_info = cls._schema_error_detail_read.additional_info
        _schema.code = cls._schema_error_detail_read.code
        _schema.details = cls._schema_error_detail_read.details
        _schema.message = cls._schema_error_detail_read.message
        _schema.target = cls._schema_error_detail_read.target

    _schema_machine_extension_instance_view_read = None

    @classmethod
    def _build_schema_machine_extension_instance_view_read(cls, _schema):
        if cls._schema_machine_extension_instance_view_read is not None:
            _schema.name = cls._schema_machine_extension_instance_view_read.name
            _schema.status = cls._schema_machine_extension_instance_view_read.status
            _schema.type = cls._schema_machine_extension_instance_view_read.type
            _schema.type_handler_version = cls._schema_machine_extension_instance_view_read.type_handler_version
            return

        cls._schema_machine_extension_instance_view_read = _schema_machine_extension_instance_view_read = AAZObjectType()

        machine_extension_instance_view_read = _schema_machine_extension_instance_view_read
        machine_extension_instance_view_read.name = AAZStrType()
        machine_extension_instance_view_read.status = AAZObjectType()
        machine_extension_instance_view_read.type = AAZStrType()
        machine_extension_instance_view_read.type_handler_version = AAZStrType(
            serialized_name="typeHandlerVersion",
        )

        status = _schema_machine_extension_instance_view_read.status
        status.code = AAZStrType()
        status.display_status = AAZStrType(
            serialized_name="displayStatus",
        )
        status.level = AAZStrType()
        status.message = AAZStrType()
        status.time = AAZStrType()

        _schema.name = cls._schema_machine_extension_instance_view_read.name
        _schema.status = cls._schema_machine_extension_instance_view_read.status
        _schema.type = cls._schema_machine_extension_instance_view_read.type
        _schema.type_handler_version = cls._schema_machine_extension_instance_view_read.type_handler_version

    _schema_patch_settings_read = None

    @classmethod
    def _build_schema_patch_settings_read(cls, _schema):
        if cls._schema_patch_settings_read is not None:
            _schema.assessment_mode = cls._schema_patch_settings_read.assessment_mode
            _schema.patch_mode = cls._schema_patch_settings_read.patch_mode
            return

        cls._schema_patch_settings_read = _schema_patch_settings_read = AAZObjectType()

        patch_settings_read = _schema_patch_settings_read
        patch_settings_read.assessment_mode = AAZStrType(
            serialized_name="assessmentMode",
        )
        patch_settings_read.patch_mode = AAZStrType(
            serialized_name="patchMode",
        )

        _schema.assessment_mode = cls._schema_patch_settings_read.assessment_mode
        _schema.patch_mode = cls._schema_patch_settings_read.patch_mode

    _schema_service_status_read = None

    @classmethod
    def _build_schema_service_status_read(cls, _schema):
        if cls._schema_service_status_read is not None:
            _schema.startup_type = cls._schema_service_status_read.startup_type
            _schema.status = cls._schema_service_status_read.status
            return

        cls._schema_service_status_read = _schema_service_status_read = AAZObjectType()

        service_status_read = _schema_service_status_read
        service_status_read.startup_type = AAZStrType(
            serialized_name="startupType",
        )
        service_status_read.status = AAZStrType()

        _schema.startup_type = cls._schema_service_status_read.startup_type
        _schema.status = cls._schema_service_status_read.status

    _schema_system_data_read = None

    @classmethod
    def _build_schema_system_data_read(cls, _schema):
        if cls._schema_system_data_read is not None:
            _schema.created_at = cls._schema_system_data_read.created_at
            _schema.created_by = cls._schema_system_data_read.created_by
            _schema.created_by_type = cls._schema_system_data_read.created_by_type
            _schema.last_modified_at = cls._schema_system_data_read.last_modified_at
            _schema.last_modified_by = cls._schema_system_data_read.last_modified_by
            _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type
            return

        cls._schema_system_data_read = _schema_system_data_read = AAZObjectType(
            flags={"read_only": True}
        )

        system_data_read = _schema_system_data_read
        system_data_read.created_at = AAZStrType(
            serialized_name="createdAt",
        )
        system_data_read.created_by = AAZStrType(
            serialized_name="createdBy",
        )
        system_data_read.created_by_type = AAZStrType(
            serialized_name="createdByType",
        )
        system_data_read.last_modified_at = AAZStrType(
            serialized_name="lastModifiedAt",
        )
        system_data_read.last_modified_by = AAZStrType(
            serialized_name="lastModifiedBy",
        )
        system_data_read.last_modified_by_type = AAZStrType(
            serialized_name="lastModifiedByType",
        )

        _schema.created_at = cls._schema_system_data_read.created_at
        _schema.created_by = cls._schema_system_data_read.created_by
        _schema.created_by_type = cls._schema_system_data_read.created_by_type
        _schema.last_modified_at = cls._schema_system_data_read.last_modified_at
        _schema.last_modified_by = cls._schema_system_data_read.last_modified_by
        _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type


__all__ = ["Show"]
