/// <summary>
 /// Creates a profile
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IProtectionProfileOperations.
 /// </param>
 /// <param name='name'>
 /// Required. Input to associate profile
 /// </param>
 /// <param name='input'>
 /// Required. Input to associate profile
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResponse Associate(this IProtectionProfileOperations operations, string name, ProtectionProfileAssociationInput input, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IProtectionProfileOperations)s).AssociateAsync(name, input, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Initializes a new instance of the
 /// CreateAndAssociateProtectionProfileInput class with required
 /// arguments.
 /// </summary>
 public CreateAndAssociateProtectionProfileInput(ProtectionProfileAssociationInput associationInput)
     : this()
 {
     if (associationInput == null)
     {
         throw new ArgumentNullException("associationInput");
     }
     this.AssociationInput = associationInput;
 }
 /// <summary>
 /// Associates Azure Site Recovery Protection Profile.
 /// </summary>
 /// <param name="ProtectionProfileAssociationInput">Protection Profile association input</param>
 /// <returns>Long running operation response</returns>
 public LongRunningOperationResponse AssociateAzureSiteRecoveryProtectionProfile(
     string profileName,
     ProtectionProfileAssociationInput protectionProfileAssociationInput)
 {
     return this.GetSiteRecoveryClient().ProtectionProfile.BeginAssociating(
         profileName,
         protectionProfileAssociationInput,
         this.GetRequestHeaders());
 }
 /// <summary>
 /// Initializes a new instance of the
 /// CreateAndAssociateProtectionProfileInput class with required
 /// arguments.
 /// </summary>
 public CreateAndAssociateProtectionProfileInput(ProtectionProfileAssociationInput associationInput)
     : this()
 {
     if (associationInput == null)
     {
         throw new ArgumentNullException("associationInput");
     }
     this.AssociationInput = associationInput;
 }
        /// <summary>
        /// Associates protection profile with enterprise based protection containers
        /// </summary>
        private void EnterpriseToEnterpriseAssociation()
        {
            if (string.Compare(
                this.ProtectionProfile.ReplicationProvider,
                Constants.HyperVReplica,
                StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                    string.Format(
                    Properties.Resources.IncorrectReplicationProvider,
                    this.ProtectionProfile.ReplicationProvider));
            }

            ProtectionProfileAssociationInput protectionProfileAssociationInput =
                new ProtectionProfileAssociationInput(
                    this.PrimaryProtectionContainer.Name,
                    this.RecoveryProtectionContainer.Name);

            LongRunningOperationResponse response = RecoveryServicesClient.AssociateAzureSiteRecoveryProtectionProfile(
                this.ProtectionProfile.Name,
                protectionProfileAssociationInput);

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

            this.WriteObject(new ASRJob(jobResponse.Job));
        }
 /// <summary>
 /// Creates a profile
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IProtectionProfileOperations.
 /// </param>
 /// <param name='name'>
 /// Required. Input to associate profile
 /// </param>
 /// <param name='input'>
 /// Required. Input to associate profile
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task<LongRunningOperationResponse> AssociateAsync(this IProtectionProfileOperations operations, string name, ProtectionProfileAssociationInput input, CustomRequestHeaders customRequestHeaders)
 {
     return operations.AssociateAsync(name, input, customRequestHeaders, CancellationToken.None);
 }