/// <summary> /// Executes the cmdlet. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var resourceName = default(string); var resourceGroupName = default(string); var storageSyncServiceName = default(string); var parentResourceName = default(string); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(ResourceId); resourceName = resourceIdentifier.ResourceName; resourceGroupName = resourceIdentifier.ResourceGroupName; parentResourceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0); storageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1); } else if (this.IsParameterBound(c => c.InputObject)) { resourceName = InputObject.ServerEndpointName; resourceGroupName = InputObject.ResourceGroupName; parentResourceName = InputObject.SyncGroupName; storageSyncServiceName = InputObject.StorageSyncServiceName; } else { resourceName = Name; resourceGroupName = ResourceGroupName; parentResourceName = SyncGroupName; storageSyncServiceName = StorageSyncServiceName; } var updateParameters = new ServerEndpointUpdateParameters() { CloudTiering = CloudTiering.ToBool() ? StorageSyncConstants.CloudTieringOn : StorageSyncConstants.CloudTieringOff, VolumeFreeSpacePercent = VolumeFreeSpacePercent, TierFilesOlderThanDays = TierFilesOlderThanDays, OfflineDataTransfer = OfflineDataTransfer.ToBool() ? StorageSyncConstants.OfflineDataTransferOn : StorageSyncConstants.OfflineDataTransferOff }; Target = string.Join("/", resourceGroupName, storageSyncServiceName, parentResourceName, resourceName); if (ShouldProcess(Target, ActionMessage)) { ServerEndpoint resource = StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.Update( resourceGroupName, storageSyncServiceName, parentResourceName, resourceName, updateParameters); WriteObject(resource); } }); }
/// <summary> /// Executes the cmdlet. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var parentResourceIdentifier = default(ResourceIdentifier); if (this.IsParameterBound(c => c.ParentResourceId)) { parentResourceIdentifier = new ResourceIdentifier(ParentResourceId); if (!string.Equals(StorageSyncConstants.SyncGroupType, parentResourceIdentifier.ResourceType, System.StringComparison.OrdinalIgnoreCase)) { throw new PSArgumentException(StorageSyncResources.MissingParentResourceIdErrorMessage); } } var createParameters = new ServerEndpointCreateParameters() { CloudTiering = CloudTiering.ToBool() ? StorageSyncConstants.CloudTieringOn : StorageSyncConstants.CloudTieringOff, VolumeFreeSpacePercent = VolumeFreeSpacePercent, ServerLocalPath = ServerLocalPath, ServerResourceId = ServerResourceId, TierFilesOlderThanDays = TierFilesOlderThanDays, OfflineDataTransfer = OfflineDataTransfer.ToBool() ? StorageSyncConstants.OfflineDataTransferOn : StorageSyncConstants.OfflineDataTransferOff, OfflineDataTransferShareName = OfflineDataTransferShareName }; string resourceGroupName = ResourceGroupName ?? ParentObject?.ResourceGroupName ?? parentResourceIdentifier.ResourceGroupName; string storageSyncServiceName = StorageSyncServiceName ?? ParentObject?.StorageSyncServiceName ?? parentResourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 0); string syncGroupName = SyncGroupName ?? ParentObject?.SyncGroupName ?? parentResourceIdentifier.ResourceName; Target = string.Join("/", resourceGroupName, storageSyncServiceName, syncGroupName, Name); if (ShouldProcess(Target, ActionMessage)) { ServerEndpoint resource = StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.Create( resourceGroupName, storageSyncServiceName, syncGroupName, Name, createParameters); WriteObject(resource); } }); }
/// <summary> /// Executes the cmdlet. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var resourceName = default(string); var resourceGroupName = default(string); var storageSyncServiceName = default(string); var parentResourceName = default(string); var updateParameters = new ServerEndpointUpdateParameters(); if (this.IsParameterBound(c => c.InputObject)) { resourceName = InputObject.ServerEndpointName; resourceGroupName = InputObject.ResourceGroupName; parentResourceName = InputObject.SyncGroupName; storageSyncServiceName = InputObject.StorageSyncServiceName; updateParameters.CloudTiering = InputObject.CloudTiering; updateParameters.VolumeFreeSpacePercent = InputObject.VolumeFreeSpacePercent; updateParameters.TierFilesOlderThanDays = InputObject.TierFilesOlderThanDays; updateParameters.OfflineDataTransfer = InputObject.OfflineDataTransfer; } else { if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(ResourceId); resourceName = resourceIdentifier.ResourceName; resourceGroupName = resourceIdentifier.ResourceGroupName; parentResourceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0); storageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1); } else { resourceName = Name; resourceGroupName = ResourceGroupName; parentResourceName = SyncGroupName; storageSyncServiceName = StorageSyncServiceName; } } if (this.IsParameterBound(c => c.CloudTiering)) { updateParameters.CloudTiering = CloudTiering.ToBool() ? StorageSyncConstants.CloudTieringOn : StorageSyncConstants.CloudTieringOff; } if (this.IsParameterBound(c => c.VolumeFreeSpacePercent)) { updateParameters.VolumeFreeSpacePercent = VolumeFreeSpacePercent; } if (this.IsParameterBound(c => c.TierFilesOlderThanDays)) { updateParameters.TierFilesOlderThanDays = TierFilesOlderThanDays; } if (this.IsParameterBound(c => c.OfflineDataTransfer)) { updateParameters.OfflineDataTransfer = OfflineDataTransfer.ToBool() ? StorageSyncConstants.OfflineDataTransferOn : StorageSyncConstants.OfflineDataTransferOff; } StorageSyncModels.LocalCacheMode localCacheMode; if (this.IsParameterBound(c => c.LocalCacheMode)) { if (!Enum.TryParse(LocalCacheMode, true, out localCacheMode)) { throw new PSArgumentException(StorageSyncResources.InvalidLocalCacheModeErrorMessage); } updateParameters.LocalCacheMode = localCacheMode; } Target = string.Join("/", resourceGroupName, storageSyncServiceName, parentResourceName, resourceName); if (ShouldProcess(Target, ActionMessage)) { ServerEndpoint resource = StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.Update( resourceGroupName, storageSyncServiceName, parentResourceName, resourceName, updateParameters); WriteObject(resource); } }); }