# --------------------------------------------------------------------------------------------
# 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(
    "networkfabric acl show",
)
class Show(AAZCommand):
    """Show details of the provided Access Control List resource

    :example: Show the Access Control List
        az networkfabric acl show --resource-group "example-rg" --resource-name "example-acl"
    """

    _aaz_info = {
        "version": "2023-06-15",
        "resources": [
            ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.managednetworkfabric/accesscontrollists/{}", "2023-06-15"],
        ]
    }

    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.resource_name = AAZStrArg(
            options=["--resource-name"],
            help="Name of the Access Control List",
            required=True,
            id_part="name",
        )
        _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.AccessControlListsGet(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 AccessControlListsGet(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.ManagedNetworkFabric/accessControlLists/{accessControlListName}",
                **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(
                    "accessControlListName", self.ctx.args.resource_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-06-15",
                    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(
                flags={"required": True, "client_flatten": True},
            )
            _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.acls_url = AAZStrType(
                serialized_name="aclsUrl",
            )
            properties.administrative_state = AAZStrType(
                serialized_name="administrativeState",
                flags={"read_only": True},
            )
            properties.annotation = AAZStrType()
            properties.configuration_state = AAZStrType(
                serialized_name="configurationState",
                flags={"read_only": True},
            )
            properties.configuration_type = AAZStrType(
                serialized_name="configurationType",
                flags={"required": True},
            )
            properties.default_action = AAZStrType(
                serialized_name="defaultAction",
            )
            properties.dynamic_match_configurations = AAZListType(
                serialized_name="dynamicMatchConfigurations",
            )
            properties.last_synced_time = AAZStrType(
                serialized_name="lastSyncedTime",
                flags={"read_only": True},
            )
            properties.match_configurations = AAZListType(
                serialized_name="matchConfigurations",
            )
            properties.provisioning_state = AAZStrType(
                serialized_name="provisioningState",
                flags={"read_only": True},
            )

            dynamic_match_configurations = cls._schema_on_200.properties.dynamic_match_configurations
            dynamic_match_configurations.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.dynamic_match_configurations.Element
            _element.ip_groups = AAZListType(
                serialized_name="ipGroups",
            )
            _element.port_groups = AAZListType(
                serialized_name="portGroups",
            )
            _element.vlan_groups = AAZListType(
                serialized_name="vlanGroups",
            )

            ip_groups = cls._schema_on_200.properties.dynamic_match_configurations.Element.ip_groups
            ip_groups.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.dynamic_match_configurations.Element.ip_groups.Element
            _element.ip_address_type = AAZStrType(
                serialized_name="ipAddressType",
            )
            _element.ip_prefixes = AAZListType(
                serialized_name="ipPrefixes",
            )
            _element.name = AAZStrType()

            ip_prefixes = cls._schema_on_200.properties.dynamic_match_configurations.Element.ip_groups.Element.ip_prefixes
            ip_prefixes.Element = AAZStrType()

            port_groups = cls._schema_on_200.properties.dynamic_match_configurations.Element.port_groups
            port_groups.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.dynamic_match_configurations.Element.port_groups.Element
            _element.name = AAZStrType()
            _element.ports = AAZListType()

            ports = cls._schema_on_200.properties.dynamic_match_configurations.Element.port_groups.Element.ports
            ports.Element = AAZStrType()

            vlan_groups = cls._schema_on_200.properties.dynamic_match_configurations.Element.vlan_groups
            vlan_groups.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.dynamic_match_configurations.Element.vlan_groups.Element
            _element.name = AAZStrType()
            _element.vlans = AAZListType()

            vlans = cls._schema_on_200.properties.dynamic_match_configurations.Element.vlan_groups.Element.vlans
            vlans.Element = AAZStrType()

            match_configurations = cls._schema_on_200.properties.match_configurations
            match_configurations.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.match_configurations.Element
            _element.actions = AAZListType()
            _element.ip_address_type = AAZStrType(
                serialized_name="ipAddressType",
            )
            _element.match_conditions = AAZListType(
                serialized_name="matchConditions",
            )
            _element.match_configuration_name = AAZStrType(
                serialized_name="matchConfigurationName",
            )
            _element.sequence_number = AAZIntType(
                serialized_name="sequenceNumber",
            )

            actions = cls._schema_on_200.properties.match_configurations.Element.actions
            actions.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.match_configurations.Element.actions.Element
            _element.counter_name = AAZStrType(
                serialized_name="counterName",
            )
            _element.type = AAZStrType()

            match_conditions = cls._schema_on_200.properties.match_configurations.Element.match_conditions
            match_conditions.Element = AAZObjectType()

            _element = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element
            _element.dscp_markings = AAZListType(
                serialized_name="dscpMarkings",
            )
            _element.ether_types = AAZListType(
                serialized_name="etherTypes",
            )
            _element.fragments = AAZListType()
            _element.ip_condition = AAZObjectType(
                serialized_name="ipCondition",
            )
            _element.ip_lengths = AAZListType(
                serialized_name="ipLengths",
            )
            _element.port_condition = AAZObjectType(
                serialized_name="portCondition",
            )
            _element.protocol_types = AAZListType(
                serialized_name="protocolTypes",
            )
            _element.ttl_values = AAZListType(
                serialized_name="ttlValues",
            )
            _element.vlan_match_condition = AAZObjectType(
                serialized_name="vlanMatchCondition",
            )

            dscp_markings = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.dscp_markings
            dscp_markings.Element = AAZStrType()

            ether_types = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.ether_types
            ether_types.Element = AAZStrType()

            fragments = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.fragments
            fragments.Element = AAZStrType()

            ip_condition = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.ip_condition
            ip_condition.ip_group_names = AAZListType(
                serialized_name="ipGroupNames",
            )
            ip_condition.ip_prefix_values = AAZListType(
                serialized_name="ipPrefixValues",
            )
            ip_condition.prefix_type = AAZStrType(
                serialized_name="prefixType",
            )
            ip_condition.type = AAZStrType()

            ip_group_names = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.ip_condition.ip_group_names
            ip_group_names.Element = AAZStrType()

            ip_prefix_values = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.ip_condition.ip_prefix_values
            ip_prefix_values.Element = AAZStrType()

            ip_lengths = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.ip_lengths
            ip_lengths.Element = AAZStrType()

            port_condition = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.port_condition
            port_condition.flags = AAZListType()
            port_condition.layer4_protocol = AAZStrType(
                serialized_name="layer4Protocol",
                flags={"required": True},
            )
            port_condition.port_group_names = AAZListType(
                serialized_name="portGroupNames",
            )
            port_condition.port_type = AAZStrType(
                serialized_name="portType",
            )
            port_condition.ports = AAZListType()

            flags = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.port_condition.flags
            flags.Element = AAZStrType()

            port_group_names = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.port_condition.port_group_names
            port_group_names.Element = AAZStrType()

            ports = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.port_condition.ports
            ports.Element = AAZStrType()

            protocol_types = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.protocol_types
            protocol_types.Element = AAZStrType()

            ttl_values = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.ttl_values
            ttl_values.Element = AAZStrType()

            vlan_match_condition = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.vlan_match_condition
            vlan_match_condition.inner_vlans = AAZListType(
                serialized_name="innerVlans",
            )
            vlan_match_condition.vlan_group_names = AAZListType(
                serialized_name="vlanGroupNames",
            )
            vlan_match_condition.vlans = AAZListType()

            inner_vlans = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.vlan_match_condition.inner_vlans
            inner_vlans.Element = AAZStrType()

            vlan_group_names = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.vlan_match_condition.vlan_group_names
            vlan_group_names.Element = AAZStrType()

            vlans = cls._schema_on_200.properties.match_configurations.Element.match_conditions.Element.vlan_match_condition.vlans
            vlans.Element = 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"]
