/// <summary>
 /// Initializes a new instance of the UpdateRecoveryPlanInput class
 /// with required arguments.
 /// </summary>
 public UpdateRecoveryPlanInput(UpdateRecoveryPlanInputProperties properties)
     : this()
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Properties = properties;
 }
 /// <summary>
 /// Initializes a new instance of the UpdateRecoveryPlanInput class
 /// with required arguments.
 /// </summary>
 public UpdateRecoveryPlanInput(UpdateRecoveryPlanInputProperties properties)
     : this()
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Properties = properties;
 }
        /// <summary>
        /// Update Recovery Plan: By powerShell Recovery Plan object
        /// </summary>
        private void UpdateRecoveryPlan(ASRRecoveryPlan asrRecoveryPlan)
        {
            UpdateRecoveryPlanInputProperties updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties()
            {
                Groups = new List<RecoveryPlanGroup>(),
            };

            foreach (ASRRecoveryPlanGroup asrRecoveryPlanGroup in asrRecoveryPlan.Groups)
            {
                RecoveryPlanGroup recoveryPlanGroup = new RecoveryPlanGroup()
                {
                    GroupType = asrRecoveryPlanGroup.GroupType,

                    // Initialize ReplicationProtectedItems with empty List if asrRecoveryPlanGroup.ReplicationProtectedItems is null
                    // otherwise assign respective values
                    ReplicationProtectedItems = asrRecoveryPlanGroup.ReplicationProtectedItems == null ? new List<RecoveryPlanProtectedItem>() :
                    asrRecoveryPlanGroup.ReplicationProtectedItems.Select(item =>
                        {
                            var newItem = new RecoveryPlanProtectedItem(item.Id);

                            string VmId = null;

                            if (item.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplicaAzureReplicationDetails))
                            {
                                VmId = ((HyperVReplicaAzureReplicationDetails)item.Properties.ProviderSpecificDetails).VmId;
                            }
                            else if (item.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplica2012ReplicationDetails))
                            {
                                VmId = ((HyperVReplica2012ReplicationDetails)item.Properties.ProviderSpecificDetails).VmId;
                            }

                            newItem.VirtualMachineId = VmId;

                            return newItem;

                        }).ToList(),
                    StartGroupActions = asrRecoveryPlanGroup.StartGroupActions,
                    EndGroupActions = asrRecoveryPlanGroup.EndGroupActions
                };

                updateRecoveryPlanInputProperties.Groups.Add(recoveryPlanGroup);
            }

            UpdateRecoveryPlanInput updateRecoveryPlanInput = new UpdateRecoveryPlanInput()
            {
                Properties = updateRecoveryPlanInputProperties
            };

            UpdateRecoveryPlan(asrRecoveryPlan.Name, updateRecoveryPlanInput);
        }
        /// <summary>
        /// Update Recovery Plan: By Service object
        /// </summary>
        private void UpdateRecoveryPlan(RecoveryPlan recoveryPlan)
        {
            UpdateRecoveryPlanInputProperties updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties()
            {
                Groups = recoveryPlan.Properties.Groups,
            };

            UpdateRecoveryPlanInput updateRecoveryPlanInput = new UpdateRecoveryPlanInput()
            {
                Properties = updateRecoveryPlanInputProperties
            };

            UpdateRecoveryPlan(recoveryPlan.Name, updateRecoveryPlanInput);
        }