/// <summary>
 /// Creates Azure Site Recovery Protection Profile.
 /// </summary>
 /// <param name="createAndAssociateProtectionProfileInput">Protection Profile Input</param>
 /// <returns>Long operation response</returns>
 public LongRunningOperationResponse CreateProtectionProfile(
     CreateProtectionProfileInput createProtectionProfileInput)
 {
     return this.GetSiteRecoveryClient().ProtectionProfile.BeginCreating(
         createProtectionProfileInput,
         this.GetRequestHeaders());
 }
        /// <summary>
        /// Creates an E2A Protection Profile Object
        /// </summary>
        private void EnterpriseToAzureProtectionProfileObject()
        {
            if (string.Compare(this.ReplicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                    string.Format(
                    Properties.Resources.IncorrectReplicationProvider,
                    this.ReplicationProvider));
            }

            PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime);

            ushort replicationFrequencyInSeconds =
                PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds);

            HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput =
                new HyperVReplicaAzureProtectionProfileInput()
                {
                    ApplicationConsistentSnapshotFrequencyInHours =
                        this.ApplicationConsistentSnapshotFrequencyInHours,
                    ReplicationInterval = replicationFrequencyInSeconds,
                    RecoveryPointHistoryDuration = this.RecoveryPoints,
                    OnlineReplicationStartTime = this.ReplicationStartTime,
                    Encryption = "Disable"
                };

            var storageAccount = new CustomerStorageAccount();
            storageAccount.StorageAccountName = this.RecoveryAzureStorageAccount;
            storageAccount.SubscriptionId = this.RecoveryAzureSubscription;

            hyperVReplicaAzureProtectionProfileInput.StorageAccounts =
                new System.Collections.Generic.List<CustomerStorageAccount>();
            hyperVReplicaAzureProtectionProfileInput.StorageAccounts.Add(storageAccount);

            CreateProtectionProfileInput createProtectionProfileInput =
                new CreateProtectionProfileInput();
            createProtectionProfileInput.Name = this.Name;
            createProtectionProfileInput.ReplicationProvider = this.ReplicationProvider;
            createProtectionProfileInput.ReplicationProviderSettings =
                hyperVReplicaAzureProtectionProfileInput;

            LongRunningOperationResponse response = 
                RecoveryServicesClient.CreateProtectionProfile(createProtectionProfileInput);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
        /// <summary>
        /// Creates an E2E Protection Profile object
        /// </summary>
        private void EnterpriseToEnterpriseProtectionProfileObject()
        {
            if (string.Compare(this.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                    string.Format(
                    Properties.Resources.IncorrectReplicationProvider,
                    this.ReplicationProvider));
            }

            PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime);

            ushort replicationFrequencyInSeconds =
                PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds);

            HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
                    = new HyperVReplicaProtectionProfileInput()
                    {
                        ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours,
                        ReplicationFrequencyInSeconds = replicationFrequencyInSeconds,
                        OnlineReplicationStartTime = this.ReplicationStartTime,
                        Compression = this.CompressionEnabled == true ? "Enable" : "Disable",
                        InitialReplicationMethod =
                            (string.Compare(this.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? "OverNetwork" : "Offline",
                        RecoveryPoints = this.RecoveryPoints,
                        ReplicationPort = this.ReplicationPort,
                        ReplicaDeletion = this.AllowReplicaDeletion == true ? "Required" : "NotRequired",
                        AllowedAuthenticationType =
                            (ushort)((string.Compare(this.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2)
                    };

            CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput();
            createProtectionProfileInput.Name = this.Name;
            createProtectionProfileInput.ReplicationProvider = this.ReplicationProvider;
            createProtectionProfileInput.ReplicationProviderSettings =
                hyperVReplicaProtectionProfileInput;

            LongRunningOperationResponse response =
                RecoveryServicesClient.CreateProtectionProfile(createProtectionProfileInput);

            JobResponse jobResponse =
                RecoveryServicesClient
                .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            WriteObject(new ASRJob(jobResponse.Job));
        }
 /// <summary>
 /// Creates a profile
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IProtectionProfileOperations.
 /// </param>
 /// <param name='input'>
 /// Required. Input to create profile
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task<LongRunningOperationResponse> CreateAsync(this IProtectionProfileOperations operations, CreateProtectionProfileInput input, CustomRequestHeaders customRequestHeaders)
 {
     return operations.CreateAsync(input, customRequestHeaders, CancellationToken.None);
 }
 /// <summary>
 /// Creates a profile
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IProtectionProfileOperations.
 /// </param>
 /// <param name='input'>
 /// Required. Input to create profile
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResponse Create(this IProtectionProfileOperations operations, CreateProtectionProfileInput input, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IProtectionProfileOperations)s).CreateAsync(input, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }