# --------------------------------------------------------------------------------------------
# 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(
    "site-recovery policy create",
)
class Create(AAZCommand):
    """Create operation to create a replication policy.

    :example: policy create of type in-mage-rcm
        az site-recovery policy create -g "rg" --vault-name "vault_name" -n "policy_name" --provider-specific-input '{in-mage-rcm:{app-consistent-frequency-in-minutes:0,crash-consistent-frequency-in-minutes:5,enable-multi-vm-sync:true,recovery-point-history-in-minutes:1440}}'

    :example: policy create for type in-mage-rcm-failback
        az site-recovery policy create -g rg --vault-name vault_name -n policy_name_rcm_failback --provider-specific-input '{in-mage-rcm-failback:{app-consistent-frequency-in-minutes:60,crash-consistent-frequency-in-minutes:5}}'

    :example: policy create for A2A
        az site-recovery policy create -g rg --vault-name vault_name -n policy_name --provider-specific-input {a2a:{multi-vm-sync-status:Enable}}

    :example: policy create for hyper-v-replica-azure
        az site-recovery policy create -g "rg" --vault-name "vault_name" -n "policy_name" --provider-specific-input '{hyper-v-replica-azure:{application-consistent-snapshot-frequency-in-hours:1,recovery-point-history-duration:2,replication-interval:300}}'
    """

    _aaz_info = {
        "version": "2022-08-01",
        "resources": [
            ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.recoveryservices/vaults/{}/replicationpolicies/{}", "2022-08-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.policy_name = AAZStrArg(
            options=["-n", "--name", "--policy-name"],
            help="Replication policy name.",
            required=True,
        )
        _args_schema.resource_group = AAZResourceGroupNameArg(
            required=True,
        )
        _args_schema.vault_name = AAZStrArg(
            options=["--vault-name"],
            help="The name of the recovery services vault.",
            required=True,
        )

        # define Arg Group "Properties"

        _args_schema = cls._args_schema
        _args_schema.provider_specific_input = AAZObjectArg(
            options=["--provider-input", "--provider-specific-input"],
            arg_group="Properties",
            help="The ReplicationProviderSettings.",
        )

        provider_specific_input = cls._args_schema.provider_specific_input
        provider_specific_input.a2a = AAZObjectArg(
            options=["a2a"],
            help="A2A",
        )
        provider_specific_input.hyper_v_replica2012 = AAZObjectArg(
            options=["hyper-v-replica2012"],
        )
        provider_specific_input.hyper_v_replica2012_r2 = AAZObjectArg(
            options=["hyper-v-replica2012-r2"],
        )
        provider_specific_input.hyper_v_replica_azure = AAZObjectArg(
            options=["hyper-v-replica-azure"],
        )
        provider_specific_input.in_mage_rcm = AAZObjectArg(
            options=["in-mage-rcm"],
        )
        provider_specific_input.in_mage_rcm_failback = AAZObjectArg(
            options=["in-mage-rcm-failback"],
        )
        provider_specific_input.vmware_cbt = AAZObjectArg(
            options=["vmware-cbt"],
            help="vmware-cbt",
        )

        a2a = cls._args_schema.provider_specific_input.a2a
        a2a.app_consistent_frequency_in_minutes = AAZIntArg(
            options=["app-consistent-frequency-in-minutes"],
            help="The app consistent snapshot frequency (in minutes).",
        )
        a2a.crash_consistent_frequency_in_minutes = AAZIntArg(
            options=["crash-consistent-frequency-in-minutes"],
            help="The crash consistent snapshot frequency (in minutes).",
        )
        a2a.multi_vm_sync_status = AAZStrArg(
            options=["multi-vm-sync-status"],
            help="A value indicating whether multi-VM sync has to be enabled. Value should be 'Enable' or 'Disable'.",
            required=True,
            enum={"Disable": "Disable", "Enable": "Enable"},
        )
        a2a.recovery_point_history = AAZIntArg(
            options=["recovery-point-history"],
            help="The duration in minutes until which the recovery points need to be stored.",
        )

        hyper_v_replica2012 = cls._args_schema.provider_specific_input.hyper_v_replica2012
        hyper_v_replica2012.allowed_authentication_type = AAZIntArg(
            options=["allowed-authentication-type"],
            help="A value indicating the authentication type.",
        )
        hyper_v_replica2012.application_consistent_snapshot_frequency_in_hours = AAZIntArg(
            options=["application-consistent-snapshot-frequency-in-hours"],
            help="A value indicating the application consistent frequency.",
        )
        hyper_v_replica2012.compression = AAZStrArg(
            options=["compression"],
            help="A value indicating whether compression has to be enabled.",
        )
        hyper_v_replica2012.initial_replication_method = AAZStrArg(
            options=["initial-replication-method"],
            help="A value indicating whether IR is online.",
        )
        hyper_v_replica2012.offline_replication_export_path = AAZStrArg(
            options=["offline-replication-export-path"],
            help="A value indicating the offline IR export path.",
        )
        hyper_v_replica2012.offline_replication_import_path = AAZStrArg(
            options=["offline-replication-import-path"],
            help="A value indicating the offline IR import path.",
        )
        hyper_v_replica2012.online_replication_start_time = AAZStrArg(
            options=["online-replication-start-time"],
            help="A value indicating the online IR start time.",
        )
        hyper_v_replica2012.recovery_points = AAZIntArg(
            options=["recovery-points"],
            help="A value indicating the number of recovery points.",
        )
        hyper_v_replica2012.replica_deletion = AAZStrArg(
            options=["replica-deletion"],
            help="A value indicating whether the VM has to be auto deleted.",
        )
        hyper_v_replica2012.replication_port = AAZIntArg(
            options=["replication-port"],
            help="A value indicating the recovery HTTPS port.",
        )

        hyper_v_replica2012_r2 = cls._args_schema.provider_specific_input.hyper_v_replica2012_r2
        hyper_v_replica2012_r2.allowed_authentication_type = AAZIntArg(
            options=["allowed-authentication-type"],
            help="A value indicating the authentication type.",
        )
        hyper_v_replica2012_r2.application_consistent_snapshot_frequency_in_hours = AAZIntArg(
            options=["application-consistent-snapshot-frequency-in-hours"],
            help="A value indicating the application consistent frequency.",
        )
        hyper_v_replica2012_r2.compression = AAZStrArg(
            options=["compression"],
            help="A value indicating whether compression has to be enabled.",
        )
        hyper_v_replica2012_r2.initial_replication_method = AAZStrArg(
            options=["initial-replication-method"],
            help="A value indicating whether IR is online.",
        )
        hyper_v_replica2012_r2.offline_replication_export_path = AAZStrArg(
            options=["offline-replication-export-path"],
            help="A value indicating the offline IR export path.",
        )
        hyper_v_replica2012_r2.offline_replication_import_path = AAZStrArg(
            options=["offline-replication-import-path"],
            help="A value indicating the offline IR import path.",
        )
        hyper_v_replica2012_r2.online_replication_start_time = AAZStrArg(
            options=["online-replication-start-time"],
            help="A value indicating the online IR start time.",
        )
        hyper_v_replica2012_r2.recovery_points = AAZIntArg(
            options=["recovery-points"],
            help="A value indicating the number of recovery points.",
        )
        hyper_v_replica2012_r2.replica_deletion = AAZStrArg(
            options=["replica-deletion"],
            help="A value indicating whether the VM has to be auto deleted.",
        )
        hyper_v_replica2012_r2.replication_frequency_in_seconds = AAZIntArg(
            options=["replication-frequency-in-seconds"],
            help="A value indicating the replication interval.",
        )
        hyper_v_replica2012_r2.replication_port = AAZIntArg(
            options=["replication-port"],
            help="A value indicating the recovery HTTPS port.",
        )

        hyper_v_replica_azure = cls._args_schema.provider_specific_input.hyper_v_replica_azure
        hyper_v_replica_azure.application_consistent_snapshot_frequency_in_hours = AAZIntArg(
            options=["application-consistent-snapshot-frequency-in-hours"],
            help="The interval (in hours) at which Hyper-V Replica should create an application consistent snapshot within the VM.",
        )
        hyper_v_replica_azure.online_replication_start_time = AAZStrArg(
            options=["online-replication-start-time"],
            help="The scheduled start time for the initial replication. If this parameter is Null, the initial replication starts immediately.",
        )
        hyper_v_replica_azure.recovery_point_history_duration = AAZIntArg(
            options=["recovery-point-history-duration"],
            help="The duration (in hours) to which point the recovery history needs to be maintained.",
        )
        hyper_v_replica_azure.replication_interval = AAZIntArg(
            options=["replication-interval"],
            help="The replication interval.",
        )
        hyper_v_replica_azure.storage_accounts = AAZListArg(
            options=["storage-accounts"],
            help="The list of storage accounts to which the VMs in the primary cloud can replicate to.",
        )

        storage_accounts = cls._args_schema.provider_specific_input.hyper_v_replica_azure.storage_accounts
        storage_accounts.Element = AAZStrArg()

        in_mage_rcm = cls._args_schema.provider_specific_input.in_mage_rcm
        in_mage_rcm.app_consistent_frequency_in_minutes = AAZIntArg(
            options=["app-consistent-frequency-in-minutes"],
            help="The app consistent snapshot frequency (in minutes).",
        )
        in_mage_rcm.crash_consistent_frequency_in_minutes = AAZIntArg(
            options=["crash-consistent-frequency-in-minutes"],
            help="The crash consistent snapshot frequency (in minutes).",
        )
        in_mage_rcm.enable_multi_vm_sync = AAZStrArg(
            options=["enable-multi-vm-sync"],
            help="A value indicating whether multi-VM sync has to be enabled.",
        )
        in_mage_rcm.recovery_point_history_in_minutes = AAZIntArg(
            options=["recovery-point-history-in-minutes"],
            help="The duration in minutes until which the recovery points need to be stored.",
        )

        in_mage_rcm_failback = cls._args_schema.provider_specific_input.in_mage_rcm_failback
        in_mage_rcm_failback.app_consistent_frequency_in_minutes = AAZIntArg(
            options=["app-consistent-frequency-in-minutes"],
            help="The app consistent snapshot frequency (in minutes).",
        )
        in_mage_rcm_failback.crash_consistent_frequency_in_minutes = AAZIntArg(
            options=["crash-consistent-frequency-in-minutes"],
            help="The crash consistent snapshot frequency (in minutes).",
        )

        vmware_cbt = cls._args_schema.provider_specific_input.vmware_cbt
        vmware_cbt.app_consistent_frequency_in_minutes = AAZIntArg(
            options=["app-consistent-frequency-in-minutes"],
            help="The app consistent snapshot frequency (in minutes).",
        )
        vmware_cbt.crash_consistent_frequency_in_minutes = AAZIntArg(
            options=["crash-consistent-frequency-in-minutes"],
            help="The crash consistent snapshot frequency (in minutes).",
        )
        vmware_cbt.recovery_point_history_in_minutes = AAZIntArg(
            options=["recovery-point-history-in-minutes"],
            help="The duration in minutes until which the recovery points need to be stored.",
        )
        return cls._args_schema

    def _execute_operations(self):
        self.pre_operations()
        yield self.ReplicationPoliciesCreate(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 ReplicationPoliciesCreate(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,
                    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]:
                return self.client.build_lro_polling(
                    self.ctx.args.no_wait,
                    session,
                    self.on_200,
                    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.RecoveryServices/vaults/{resourceName}/replicationPolicies/{policyName}",
                **self.url_parameters
            )

        @property
        def method(self):
            return "PUT"

        @property
        def error_format(self):
            return "ODataV4Format"

        @property
        def url_parameters(self):
            parameters = {
                **self.serialize_url_param(
                    "policyName", self.ctx.args.policy_name,
                    required=True,
                ),
                **self.serialize_url_param(
                    "resourceGroupName", self.ctx.args.resource_group,
                    required=True,
                ),
                **self.serialize_url_param(
                    "resourceName", self.ctx.args.vault_name,
                    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", "2022-08-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("properties", AAZObjectType)

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

            provider_specific_input = _builder.get(".properties.providerSpecificInput")
            if provider_specific_input is not None:
                provider_specific_input.set_const("instanceType", "A2A", AAZStrType, ".a2a", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.set_const("instanceType", "HyperVReplica2012", AAZStrType, ".hyper_v_replica2012", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.set_const("instanceType", "HyperVReplica2012R2", AAZStrType, ".hyper_v_replica2012_r2", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.set_const("instanceType", "HyperVReplicaAzure", AAZStrType, ".hyper_v_replica_azure", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.set_const("instanceType", "InMageRcm", AAZStrType, ".in_mage_rcm", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.set_const("instanceType", "InMageRcmFailback", AAZStrType, ".in_mage_rcm_failback", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.set_const("instanceType", "VMwareCbt", AAZStrType, ".vmware_cbt", typ_kwargs={"flags": {"required": True}})
                provider_specific_input.discriminate_by("instanceType", "A2A")
                provider_specific_input.discriminate_by("instanceType", "HyperVReplica2012")
                provider_specific_input.discriminate_by("instanceType", "HyperVReplica2012R2")
                provider_specific_input.discriminate_by("instanceType", "HyperVReplicaAzure")
                provider_specific_input.discriminate_by("instanceType", "InMage")
                provider_specific_input.discriminate_by("instanceType", "InMageAzureV2")
                provider_specific_input.discriminate_by("instanceType", "InMageRcm")
                provider_specific_input.discriminate_by("instanceType", "InMageRcmFailback")
                provider_specific_input.discriminate_by("instanceType", "VMwareCbt")

            disc_a2_a = _builder.get(".properties.providerSpecificInput{instanceType:A2A}")
            if disc_a2_a is not None:
                disc_a2_a.set_prop("appConsistentFrequencyInMinutes", AAZIntType, ".a2a.app_consistent_frequency_in_minutes")
                disc_a2_a.set_prop("crashConsistentFrequencyInMinutes", AAZIntType, ".a2a.crash_consistent_frequency_in_minutes")
                disc_a2_a.set_prop("multiVmSyncStatus", AAZStrType, ".a2a.multi_vm_sync_status", typ_kwargs={"flags": {"required": True}})
                disc_a2_a.set_prop("recoveryPointHistory", AAZIntType, ".a2a.recovery_point_history")

            disc_hyper_v_replica2012 = _builder.get(".properties.providerSpecificInput{instanceType:HyperVReplica2012}")
            if disc_hyper_v_replica2012 is not None:
                disc_hyper_v_replica2012.set_prop("allowedAuthenticationType", AAZIntType, ".hyper_v_replica2012.allowed_authentication_type")
                disc_hyper_v_replica2012.set_prop("applicationConsistentSnapshotFrequencyInHours", AAZIntType, ".hyper_v_replica2012.application_consistent_snapshot_frequency_in_hours")
                disc_hyper_v_replica2012.set_prop("compression", AAZStrType, ".hyper_v_replica2012.compression")
                disc_hyper_v_replica2012.set_prop("initialReplicationMethod", AAZStrType, ".hyper_v_replica2012.initial_replication_method")
                disc_hyper_v_replica2012.set_prop("offlineReplicationExportPath", AAZStrType, ".hyper_v_replica2012.offline_replication_export_path")
                disc_hyper_v_replica2012.set_prop("offlineReplicationImportPath", AAZStrType, ".hyper_v_replica2012.offline_replication_import_path")
                disc_hyper_v_replica2012.set_prop("onlineReplicationStartTime", AAZStrType, ".hyper_v_replica2012.online_replication_start_time")
                disc_hyper_v_replica2012.set_prop("recoveryPoints", AAZIntType, ".hyper_v_replica2012.recovery_points")
                disc_hyper_v_replica2012.set_prop("replicaDeletion", AAZStrType, ".hyper_v_replica2012.replica_deletion")
                disc_hyper_v_replica2012.set_prop("replicationPort", AAZIntType, ".hyper_v_replica2012.replication_port")

            disc_hyper_v_replica2012_r2 = _builder.get(".properties.providerSpecificInput{instanceType:HyperVReplica2012R2}")
            if disc_hyper_v_replica2012_r2 is not None:
                disc_hyper_v_replica2012_r2.set_prop("allowedAuthenticationType", AAZIntType, ".hyper_v_replica2012_r2.allowed_authentication_type")
                disc_hyper_v_replica2012_r2.set_prop("applicationConsistentSnapshotFrequencyInHours", AAZIntType, ".hyper_v_replica2012_r2.application_consistent_snapshot_frequency_in_hours")
                disc_hyper_v_replica2012_r2.set_prop("compression", AAZStrType, ".hyper_v_replica2012_r2.compression")
                disc_hyper_v_replica2012_r2.set_prop("initialReplicationMethod", AAZStrType, ".hyper_v_replica2012_r2.initial_replication_method")
                disc_hyper_v_replica2012_r2.set_prop("offlineReplicationExportPath", AAZStrType, ".hyper_v_replica2012_r2.offline_replication_export_path")
                disc_hyper_v_replica2012_r2.set_prop("offlineReplicationImportPath", AAZStrType, ".hyper_v_replica2012_r2.offline_replication_import_path")
                disc_hyper_v_replica2012_r2.set_prop("onlineReplicationStartTime", AAZStrType, ".hyper_v_replica2012_r2.online_replication_start_time")
                disc_hyper_v_replica2012_r2.set_prop("recoveryPoints", AAZIntType, ".hyper_v_replica2012_r2.recovery_points")
                disc_hyper_v_replica2012_r2.set_prop("replicaDeletion", AAZStrType, ".hyper_v_replica2012_r2.replica_deletion")
                disc_hyper_v_replica2012_r2.set_prop("replicationFrequencyInSeconds", AAZIntType, ".hyper_v_replica2012_r2.replication_frequency_in_seconds")
                disc_hyper_v_replica2012_r2.set_prop("replicationPort", AAZIntType, ".hyper_v_replica2012_r2.replication_port")

            disc_hyper_v_replica_azure = _builder.get(".properties.providerSpecificInput{instanceType:HyperVReplicaAzure}")
            if disc_hyper_v_replica_azure is not None:
                disc_hyper_v_replica_azure.set_prop("applicationConsistentSnapshotFrequencyInHours", AAZIntType, ".hyper_v_replica_azure.application_consistent_snapshot_frequency_in_hours")
                disc_hyper_v_replica_azure.set_prop("onlineReplicationStartTime", AAZStrType, ".hyper_v_replica_azure.online_replication_start_time")
                disc_hyper_v_replica_azure.set_prop("recoveryPointHistoryDuration", AAZIntType, ".hyper_v_replica_azure.recovery_point_history_duration")
                disc_hyper_v_replica_azure.set_prop("replicationInterval", AAZIntType, ".hyper_v_replica_azure.replication_interval")
                disc_hyper_v_replica_azure.set_prop("storageAccounts", AAZListType, ".hyper_v_replica_azure.storage_accounts")

            storage_accounts = _builder.get(".properties.providerSpecificInput{instanceType:HyperVReplicaAzure}.storageAccounts")
            if storage_accounts is not None:
                storage_accounts.set_elements(AAZStrType, ".")

            disc_in_mage = _builder.get(".properties.providerSpecificInput{instanceType:InMage}")
            if disc_in_mage is not None:
                disc_in_mage.set_prop("appConsistentFrequencyInMinutes", AAZIntType, ".in_mage.app_consistent_frequency_in_minutes")
                disc_in_mage.set_prop("multiVmSyncStatus", AAZStrType, ".in_mage.multi_vm_sync_status", typ_kwargs={"flags": {"required": True}})
                disc_in_mage.set_prop("recoveryPointHistory", AAZIntType, ".in_mage.recovery_point_history")
                disc_in_mage.set_prop("recoveryPointThresholdInMinutes", AAZIntType, ".in_mage.recovery_point_threshold_in_minutes")

            disc_in_mage_azure_v2 = _builder.get(".properties.providerSpecificInput{instanceType:InMageAzureV2}")
            if disc_in_mage_azure_v2 is not None:
                disc_in_mage_azure_v2.set_prop("appConsistentFrequencyInMinutes", AAZIntType, ".in_mage_azure_v2.app_consistent_frequency_in_minutes")
                disc_in_mage_azure_v2.set_prop("crashConsistentFrequencyInMinutes", AAZIntType, ".in_mage_azure_v2.crash_consistent_frequency_in_minutes")
                disc_in_mage_azure_v2.set_prop("multiVmSyncStatus", AAZStrType, ".in_mage_azure_v2.multi_vm_sync_status", typ_kwargs={"flags": {"required": True}})
                disc_in_mage_azure_v2.set_prop("recoveryPointHistory", AAZIntType, ".in_mage_azure_v2.recovery_point_history")
                disc_in_mage_azure_v2.set_prop("recoveryPointThresholdInMinutes", AAZIntType, ".in_mage_azure_v2.recovery_point_threshold_in_minutes")

            disc_in_mage_rcm = _builder.get(".properties.providerSpecificInput{instanceType:InMageRcm}")
            if disc_in_mage_rcm is not None:
                disc_in_mage_rcm.set_prop("appConsistentFrequencyInMinutes", AAZIntType, ".in_mage_rcm.app_consistent_frequency_in_minutes")
                disc_in_mage_rcm.set_prop("crashConsistentFrequencyInMinutes", AAZIntType, ".in_mage_rcm.crash_consistent_frequency_in_minutes")
                disc_in_mage_rcm.set_prop("enableMultiVmSync", AAZStrType, ".in_mage_rcm.enable_multi_vm_sync")
                disc_in_mage_rcm.set_prop("recoveryPointHistoryInMinutes", AAZIntType, ".in_mage_rcm.recovery_point_history_in_minutes")

            disc_in_mage_rcm_failback = _builder.get(".properties.providerSpecificInput{instanceType:InMageRcmFailback}")
            if disc_in_mage_rcm_failback is not None:
                disc_in_mage_rcm_failback.set_prop("appConsistentFrequencyInMinutes", AAZIntType, ".in_mage_rcm_failback.app_consistent_frequency_in_minutes")
                disc_in_mage_rcm_failback.set_prop("crashConsistentFrequencyInMinutes", AAZIntType, ".in_mage_rcm_failback.crash_consistent_frequency_in_minutes")

            disc_v_mware_cbt = _builder.get(".properties.providerSpecificInput{instanceType:VMwareCbt}")
            if disc_v_mware_cbt is not None:
                disc_v_mware_cbt.set_prop("appConsistentFrequencyInMinutes", AAZIntType, ".vmware_cbt.app_consistent_frequency_in_minutes")
                disc_v_mware_cbt.set_prop("crashConsistentFrequencyInMinutes", AAZIntType, ".vmware_cbt.crash_consistent_frequency_in_minutes")
                disc_v_mware_cbt.set_prop("recoveryPointHistoryInMinutes", AAZIntType, ".vmware_cbt.recovery_point_history_in_minutes")

            return self.serialize_content(_content_value)

        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()
            _schema_on_200.name = AAZStrType(
                flags={"read_only": True},
            )
            _schema_on_200.properties = AAZObjectType()
            _schema_on_200.type = AAZStrType(
                flags={"read_only": True},
            )

            properties = cls._schema_on_200.properties
            properties.friendly_name = AAZStrType(
                serialized_name="friendlyName",
            )
            properties.provider_specific_details = AAZObjectType(
                serialized_name="providerSpecificDetails",
            )

            provider_specific_details = cls._schema_on_200.properties.provider_specific_details
            provider_specific_details.instance_type = AAZStrType(
                serialized_name="instanceType",
                flags={"required": True},
            )

            disc_a2_a = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "A2A")
            disc_a2_a.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_a2_a.crash_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="crashConsistentFrequencyInMinutes",
            )
            disc_a2_a.multi_vm_sync_status = AAZStrType(
                serialized_name="multiVmSyncStatus",
            )
            disc_a2_a.recovery_point_history = AAZIntType(
                serialized_name="recoveryPointHistory",
            )
            disc_a2_a.recovery_point_threshold_in_minutes = AAZIntType(
                serialized_name="recoveryPointThresholdInMinutes",
            )

            disc_hyper_v_replica2012 = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "HyperVReplica2012")
            disc_hyper_v_replica2012.allowed_authentication_type = AAZIntType(
                serialized_name="allowedAuthenticationType",
            )
            disc_hyper_v_replica2012.application_consistent_snapshot_frequency_in_hours = AAZIntType(
                serialized_name="applicationConsistentSnapshotFrequencyInHours",
            )
            disc_hyper_v_replica2012.compression = AAZStrType()
            disc_hyper_v_replica2012.initial_replication_method = AAZStrType(
                serialized_name="initialReplicationMethod",
            )
            disc_hyper_v_replica2012.offline_replication_export_path = AAZStrType(
                serialized_name="offlineReplicationExportPath",
            )
            disc_hyper_v_replica2012.offline_replication_import_path = AAZStrType(
                serialized_name="offlineReplicationImportPath",
            )
            disc_hyper_v_replica2012.online_replication_start_time = AAZStrType(
                serialized_name="onlineReplicationStartTime",
            )
            disc_hyper_v_replica2012.recovery_points = AAZIntType(
                serialized_name="recoveryPoints",
            )
            disc_hyper_v_replica2012.replica_deletion_option = AAZStrType(
                serialized_name="replicaDeletionOption",
            )
            disc_hyper_v_replica2012.replication_port = AAZIntType(
                serialized_name="replicationPort",
            )

            disc_hyper_v_replica2012_r2 = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "HyperVReplica2012R2")
            disc_hyper_v_replica2012_r2.allowed_authentication_type = AAZIntType(
                serialized_name="allowedAuthenticationType",
            )
            disc_hyper_v_replica2012_r2.application_consistent_snapshot_frequency_in_hours = AAZIntType(
                serialized_name="applicationConsistentSnapshotFrequencyInHours",
            )
            disc_hyper_v_replica2012_r2.compression = AAZStrType()
            disc_hyper_v_replica2012_r2.initial_replication_method = AAZStrType(
                serialized_name="initialReplicationMethod",
            )
            disc_hyper_v_replica2012_r2.offline_replication_export_path = AAZStrType(
                serialized_name="offlineReplicationExportPath",
            )
            disc_hyper_v_replica2012_r2.offline_replication_import_path = AAZStrType(
                serialized_name="offlineReplicationImportPath",
            )
            disc_hyper_v_replica2012_r2.online_replication_start_time = AAZStrType(
                serialized_name="onlineReplicationStartTime",
            )
            disc_hyper_v_replica2012_r2.recovery_points = AAZIntType(
                serialized_name="recoveryPoints",
            )
            disc_hyper_v_replica2012_r2.replica_deletion_option = AAZStrType(
                serialized_name="replicaDeletionOption",
            )
            disc_hyper_v_replica2012_r2.replication_frequency_in_seconds = AAZIntType(
                serialized_name="replicationFrequencyInSeconds",
            )
            disc_hyper_v_replica2012_r2.replication_port = AAZIntType(
                serialized_name="replicationPort",
            )

            disc_hyper_v_replica_azure = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "HyperVReplicaAzure")
            disc_hyper_v_replica_azure.active_storage_account_id = AAZStrType(
                serialized_name="activeStorageAccountId",
            )
            disc_hyper_v_replica_azure.application_consistent_snapshot_frequency_in_hours = AAZIntType(
                serialized_name="applicationConsistentSnapshotFrequencyInHours",
            )
            disc_hyper_v_replica_azure.encryption = AAZStrType()
            disc_hyper_v_replica_azure.online_replication_start_time = AAZStrType(
                serialized_name="onlineReplicationStartTime",
            )
            disc_hyper_v_replica_azure.recovery_point_history_duration_in_hours = AAZIntType(
                serialized_name="recoveryPointHistoryDurationInHours",
            )
            disc_hyper_v_replica_azure.replication_interval = AAZIntType(
                serialized_name="replicationInterval",
            )

            disc_hyper_v_replica_base_policy_details = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "HyperVReplicaBasePolicyDetails")
            disc_hyper_v_replica_base_policy_details.allowed_authentication_type = AAZIntType(
                serialized_name="allowedAuthenticationType",
            )
            disc_hyper_v_replica_base_policy_details.application_consistent_snapshot_frequency_in_hours = AAZIntType(
                serialized_name="applicationConsistentSnapshotFrequencyInHours",
            )
            disc_hyper_v_replica_base_policy_details.compression = AAZStrType()
            disc_hyper_v_replica_base_policy_details.initial_replication_method = AAZStrType(
                serialized_name="initialReplicationMethod",
            )
            disc_hyper_v_replica_base_policy_details.offline_replication_export_path = AAZStrType(
                serialized_name="offlineReplicationExportPath",
            )
            disc_hyper_v_replica_base_policy_details.offline_replication_import_path = AAZStrType(
                serialized_name="offlineReplicationImportPath",
            )
            disc_hyper_v_replica_base_policy_details.online_replication_start_time = AAZStrType(
                serialized_name="onlineReplicationStartTime",
            )
            disc_hyper_v_replica_base_policy_details.recovery_points = AAZIntType(
                serialized_name="recoveryPoints",
            )
            disc_hyper_v_replica_base_policy_details.replica_deletion_option = AAZStrType(
                serialized_name="replicaDeletionOption",
            )
            disc_hyper_v_replica_base_policy_details.replication_port = AAZIntType(
                serialized_name="replicationPort",
            )

            disc_in_mage = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "InMage")
            disc_in_mage.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_in_mage.multi_vm_sync_status = AAZStrType(
                serialized_name="multiVmSyncStatus",
            )
            disc_in_mage.recovery_point_history = AAZIntType(
                serialized_name="recoveryPointHistory",
            )
            disc_in_mage.recovery_point_threshold_in_minutes = AAZIntType(
                serialized_name="recoveryPointThresholdInMinutes",
            )

            disc_in_mage_azure_v2 = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "InMageAzureV2")
            disc_in_mage_azure_v2.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_in_mage_azure_v2.crash_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="crashConsistentFrequencyInMinutes",
            )
            disc_in_mage_azure_v2.multi_vm_sync_status = AAZStrType(
                serialized_name="multiVmSyncStatus",
            )
            disc_in_mage_azure_v2.recovery_point_history = AAZIntType(
                serialized_name="recoveryPointHistory",
            )
            disc_in_mage_azure_v2.recovery_point_threshold_in_minutes = AAZIntType(
                serialized_name="recoveryPointThresholdInMinutes",
            )

            disc_in_mage_base_policy_details = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "InMageBasePolicyDetails")
            disc_in_mage_base_policy_details.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_in_mage_base_policy_details.multi_vm_sync_status = AAZStrType(
                serialized_name="multiVmSyncStatus",
            )
            disc_in_mage_base_policy_details.recovery_point_history = AAZIntType(
                serialized_name="recoveryPointHistory",
            )
            disc_in_mage_base_policy_details.recovery_point_threshold_in_minutes = AAZIntType(
                serialized_name="recoveryPointThresholdInMinutes",
            )

            disc_in_mage_rcm = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "InMageRcm")
            disc_in_mage_rcm.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_in_mage_rcm.crash_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="crashConsistentFrequencyInMinutes",
            )
            disc_in_mage_rcm.enable_multi_vm_sync = AAZStrType(
                serialized_name="enableMultiVmSync",
            )
            disc_in_mage_rcm.recovery_point_history_in_minutes = AAZIntType(
                serialized_name="recoveryPointHistoryInMinutes",
            )

            disc_in_mage_rcm_failback = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "InMageRcmFailback")
            disc_in_mage_rcm_failback.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_in_mage_rcm_failback.crash_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="crashConsistentFrequencyInMinutes",
            )

            disc_v_mware_cbt = cls._schema_on_200.properties.provider_specific_details.discriminate_by("instance_type", "VMwareCbt")
            disc_v_mware_cbt.app_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="appConsistentFrequencyInMinutes",
            )
            disc_v_mware_cbt.crash_consistent_frequency_in_minutes = AAZIntType(
                serialized_name="crashConsistentFrequencyInMinutes",
            )
            disc_v_mware_cbt.recovery_point_history_in_minutes = AAZIntType(
                serialized_name="recoveryPointHistoryInMinutes",
            )

            return cls._schema_on_200


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


__all__ = ["Create"]
