/// <summary> /// Transforms the specified source. /// </summary> /// <param name="source">The source.</param> /// <returns>PSServerEndpoint.</returns> protected override PSServerEndpoint Transform(StorageSyncModels.ServerEndpoint source) { PSServerEndpointHealth syncStatus = source.SyncStatus != null ? new ServerEndpointHealthConverter().Convert(source.SyncStatus) : null; PSServerEndpointCloudTieringStatus cloudTieringStatus = source.CloudTieringStatus != null ? new ServerEndpointCloudTieringStatusConverter().Convert(source.CloudTieringStatus) : null; PSServerEndpointRecallStatus recallStatus = source.RecallStatus != null ? new ServerEndpointRecallStatusConverter().Convert(source.RecallStatus) : null; var resourceIdentifier = new ResourceIdentifier(source.Id); return(new PSServerEndpoint() { ResourceId = source.Id, SyncGroupName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0), StorageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1), ServerEndpointName = source.Name, ResourceGroupName = resourceIdentifier.ResourceGroupName, Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.ServerEndpointType, ServerLocalPath = source.ServerLocalPath, ServerResourceId = source.ServerResourceId, ProvisioningState = source.ProvisioningState, SyncStatus = syncStatus, FriendlyName = source.FriendlyName, LastOperationName = source.LastOperationName, LastWorkflowId = source.LastWorkflowId, CloudTiering = source.CloudTiering, VolumeFreeSpacePercent = source.VolumeFreeSpacePercent, TierFilesOlderThanDays = source.TierFilesOlderThanDays, InitialDownloadPolicy = source.InitialDownloadPolicy, LocalCacheMode = source.LocalCacheMode, InitialUploadPolicy = source.InitialUploadPolicy, CloudTieringStatus = cloudTieringStatus, RecallStatus = recallStatus, ServerName = source.ServerName }); }
/// <summary> /// Transforms the specified source. /// </summary> /// <param name="source">The source.</param> /// <returns>PSServerEndpoint.</returns> protected override PSServerEndpoint Transform(StorageSyncModels.ServerEndpoint source) { var resourceIdentifier = new ResourceIdentifier(source.Id); return(new PSServerEndpoint() { ResourceId = source.Id, SyncGroupName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0), StorageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1), ServerEndpointName = source.Name, ResourceGroupName = resourceIdentifier.ResourceGroupName, Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.ServerEndpointType, ServerLocalPath = source.ServerLocalPath, ServerResourceId = source.ServerResourceId, ProvisioningState = source.ProvisioningState, SyncStatus = new ServerEndpointHealthConverter().Convert(source.SyncStatus), FriendlyName = source.FriendlyName, LastOperationName = source.LastOperationName, LastWorkflowId = source.LastWorkflowId, CloudTiering = source.CloudTiering, VolumeFreeSpacePercent = source.VolumeFreeSpacePercent, TierFilesOlderThanDays = source.TierFilesOlderThanDays, OfflineDataTransfer = source.OfflineDataTransfer, OfflineDataTransferShareName = source.OfflineDataTransferShareName, OfflineDataTransferStorageAccountResourceId = source.OfflineDataTransferStorageAccountResourceId, OfflineDataTransferStorageAccountTenantId = source.OfflineDataTransferStorageAccountTenantId, InitialDownloadPolicy = source.InitialDownloadPolicy.HasValue ? source.InitialDownloadPolicy.Value.ToString() : null, LocalCacheMode = source.LocalCacheMode.HasValue ? source.LocalCacheMode.Value.ToString() : null }); }
/// <summary> /// Transforms the specified source. /// </summary> /// <param name="source">The source.</param> /// <returns>PSCloudEndpoint.</returns> protected override PSCloudEndpoint Transform(StorageSyncModels.CloudEndpoint source) { PSCloudEndpointChangeEnumerationStatus changeEnumerationStatus = source.ChangeEnumerationStatus != null ? new CloudEndpointChangeEnumerationStatusConverter().Convert(source.ChangeEnumerationStatus) : null; var resourceIdentifier = new ResourceIdentifier(source.Id); return(new PSCloudEndpoint() { ResourceId = source.Id, CloudEndpointName = source.Name, SyncGroupName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0), StorageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1), ResourceGroupName = resourceIdentifier.ResourceGroupName, Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.CloudEndpointType, FriendlyName = source.FriendlyName, StorageAccountResourceId = source.StorageAccountResourceId, AzureFileShareName = source.AzureFileShareName, StorageAccountTenantId = source.StorageAccountTenantId, BackupEnabled = System.Convert.ToBoolean(source.BackupEnabled), LastWorkflowId = source.LastWorkflowId, LastOperationName = source.LastOperationName, PartnershipId = source.PartnershipId, ProvisioningState = source.ProvisioningState, ChangeEnumerationStatus = changeEnumerationStatus }); }
/// <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 recallActionParameters = new RecallActionParameters() { Pattern = Pattern, RecallPath = RecallPath }; Target = string.Join("/", resourceGroupName, storageSyncServiceName, parentResourceName, resourceName); if (ShouldProcess(Target, ActionMessage)) { StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.RecallAction( resourceGroupName, storageSyncServiceName, parentResourceName, resourceName, recallActionParameters); } }); if (PassThru.IsPresent) { WriteObject(true); } }
/// <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.IsPresent ? StorageSyncConstants.CloudTieringOn : StorageSyncConstants.CloudTieringOff, VolumeFreeSpacePercent = VolumeFreeSpacePercent, TierFilesOlderThanDays = TierFilesOlderThanDays, OfflineDataTransfer = OfflineDataTransfer.IsPresent ? "on" : "off" }; 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 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.CloudEndpointName; resourceGroupName = InputObject.ResourceGroupName; parentResourceName = InputObject.SyncGroupName; storageSyncServiceName = InputObject.StorageSyncServiceName; } else { resourceName = Name; resourceGroupName = ResourceGroupName; parentResourceName = SyncGroupName; storageSyncServiceName = StorageSyncServiceName; } Target = string.Join("/", resourceGroupName, storageSyncServiceName, parentResourceName, resourceName); ActionMessage = StorageSyncResources.RemoveCloudEndpointActionMessage; if (ShouldProcess(Target, ActionMessage)) { if (Force || ShouldContinue(string.Format(StorageSyncResources.RemoveCloudEndpointPromptFormat, Target), string.Empty)) { StorageSyncClientWrapper.StorageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceName, parentResourceName, resourceName); } } }); if (PassThru.IsPresent) { WriteObject(true); } }
/// <summary> /// Transforms the specified source. /// </summary> /// <param name="source">The source.</param> /// <returns>PSRegisteredServer.</returns> protected override PSRegisteredServer Transform(StorageSyncModels.RegisteredServer source) { var resourceIdentifier = new ResourceIdentifier(source.Id); return(new PSRegisteredServer() { ResourceId = source.Id, StorageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 0), ServerId = source.ServerId, ResourceGroupName = resourceIdentifier.ResourceGroupName, Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.RegisteredServerType, AgentVersion = source.AgentVersion, ClusterId = source.ClusterId, ProvisioningState = source.ProvisioningState, ClusterName = source.ClusterName, DiscoveryEndpointUri = source.DiscoveryEndpointUri, FriendlyName = source.FriendlyName, LastHeartBeat = source.LastHeartBeat, LastOperationName = source.LastOperationName, LastWorkflowId = source.LastWorkflowId, ManagementEndpointUri = source.ManagementEndpointUri, MonitoringEndpointUri = source.MonitoringEndpointUri, ResourceLocation = source.ResourceLocation, ServerCertificate = source.ServerCertificate, ServerManagementErrorCode = source.ServerManagementErrorCode, ServerOSVersion = source.ServerOSVersion, ServerRole = source.ServerRole, ServiceLocation = source.ServiceLocation, StorageSyncServiceUid = source.StorageSyncServiceUid, MonitoringConfiguration = source.MonitoringConfiguration, ServerName = source.ServerName }); }
/// <summary> /// Executes the cmdlet. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var resourceName = default(string); var resourceGroupName = default(string); var parentResourceName = default(string); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(ResourceId); if (!string.Equals(StorageSyncConstants.RegisteredServerType, resourceIdentifier.ResourceType, System.StringComparison.OrdinalIgnoreCase)) { throw new PSArgumentException(nameof(ResourceId)); } resourceName = resourceIdentifier.ResourceName; resourceGroupName = resourceIdentifier.ResourceGroupName; parentResourceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName); } else if (this.IsParameterBound(c => c.InputObject)) { resourceName = InputObject.ServerId; resourceGroupName = InputObject.ResourceGroupName; parentResourceName = InputObject.StorageSyncServiceName; } else { resourceName = ServerId.ToString(); resourceGroupName = ResourceGroupName; parentResourceName = StorageSyncServiceName; } Target = string.Join("/", resourceGroupName, parentResourceName, resourceName); ActionMessage = StorageSyncResources.UnregisterServerActionMessage; if (ShouldProcess(Target, ActionMessage)) { if (Force || ShouldContinue(string.Format("Remove Sync Server '{0}' and all content in it", resourceName), "")) { StorageSyncClientWrapper.StorageSyncManagementClient.RegisteredServers.Delete(resourceGroupName, parentResourceName, resourceName); } } }); if (PassThru.IsPresent) { WriteObject(true); } }
/// <summary> /// Executes the cmdlet. /// </summary> public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var resourceName = default(string); var resourceGroupName = default(string); var parentResourceName = default(string); if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(ResourceId); if (!string.Equals(StorageSyncConstants.SyncGroupType, resourceIdentifier.ResourceType, System.StringComparison.OrdinalIgnoreCase)) { throw new PSArgumentException(StorageSyncResources.MissingResourceIdErrorMessage); } resourceName = resourceIdentifier.ResourceName; resourceGroupName = resourceIdentifier.ResourceGroupName; parentResourceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName); } else if (this.IsParameterBound(c => c.InputObject)) { resourceName = InputObject.SyncGroupName; resourceGroupName = InputObject.ResourceGroupName; parentResourceName = InputObject.StorageSyncServiceName; } else { resourceName = Name; resourceGroupName = ResourceGroupName; parentResourceName = StorageSyncServiceName; } Target = string.Join("/", resourceGroupName, parentResourceName, resourceName); ActionMessage = StorageSyncResources.RemoveSyncGroupActionMessage; if (ShouldProcess(Target, ActionMessage)) { if (Force || ShouldContinue(string.Format(StorageSyncResources.RemoveSyncGroupPromptFormat, Target), string.Empty)) { StorageSyncClientWrapper.StorageSyncManagementClient.SyncGroups.Delete(resourceGroupName, parentResourceName, resourceName); } } }); if (PassThru.IsPresent) { WriteObject(true); } }
/// <summary> /// Transforms the specified source. /// </summary> /// <param name="source">The source.</param> /// <returns>PSSyncGroup.</returns> protected override PSSyncGroup Transform(StorageSyncModels.SyncGroup source) { var resourceIdentifier = new ResourceIdentifier(source.Id); return(new PSSyncGroup() { ResourceId = source.Id, SyncGroupName = source.Name, StorageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 0), ResourceGroupName = resourceIdentifier.ResourceGroupName, Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.SyncGroupType, UniqueId = source.UniqueId, SyncGroupStatus = source.SyncGroupStatus }); }
/// <summary> /// Transforms the specified source. /// </summary> /// <param name="source">The source.</param> /// <returns>PSServerEndpoint.</returns> protected override PSServerEndpoint Transform(StorageSyncModels.ServerEndpoint source) { var resourceIdentifier = new ResourceIdentifier(source.Id); return(new PSServerEndpoint() { ResourceId = source.Id, SyncGroupName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.SyncGroupTypeName, 0), StorageSyncServiceName = resourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 1), ServerEndpointName = source.Name, ResourceGroupName = resourceIdentifier.ResourceGroupName, Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.ServerEndpointType, ServerLocalPath = source.ServerLocalPath, ServerResourceId = source.ServerResourceId, ProvisioningState = source.ProvisioningState, SyncStatus = new ServerEndpointHealthConverter().Convert(source.SyncStatus), FriendlyName = source.FriendlyName, LastOperationName = source.LastOperationName, LastWorkflowId = source.LastWorkflowId, CloudTiering = source.CloudTiering, VolumeFreeSpacePercent = source.VolumeFreeSpacePercent, TierFilesOlderThanDays = source.TierFilesOlderThanDays }); }
/// <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.CloudEndpointName; resourceGroupName = InputObject.ResourceGroupName; parentResourceName = InputObject.SyncGroupName; storageSyncServiceName = InputObject.StorageSyncServiceName; } else { resourceName = Name; resourceGroupName = ResourceGroupName; parentResourceName = SyncGroupName; storageSyncServiceName = StorageSyncServiceName; } var triggerChangeDetectionParameters = new TriggerChangeDetectionParameters(); if (this.IsParameterBound(c => c.DirectoryPath)) { if (this.DirectoryPath == null) { throw new PSArgumentException(nameof(this.DirectoryPath)); } triggerChangeDetectionParameters.DirectoryPath = this.DirectoryPath; triggerChangeDetectionParameters.ChangeDetectionMode = this.Recursive.IsPresent ? ChangeDetectionMode.Recursive : ChangeDetectionMode.Default; } else if (this.IsParameterBound(c => c.Path)) { if (this.Path == null || this.Path.Length == 0) { throw new PSArgumentException(nameof(this.Path)); } triggerChangeDetectionParameters.Paths = this.Path.ToList(); } string target = string.Join("/", resourceGroupName, storageSyncServiceName, parentResourceName, resourceName); if (ShouldProcess(target, ActionMessage)) { StorageSyncClientWrapper.StorageSyncManagementClient.CloudEndpoints.TriggerChangeDetection( resourceGroupName: resourceGroupName, storageSyncServiceName: storageSyncServiceName, syncGroupName: parentResourceName, cloudEndpointName: resourceName, parameters: triggerChangeDetectionParameters); } }); if (PassThru.IsPresent) { WriteObject(true); } }
/// <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; } if (this.IsParameterBound(c => c.LocalCacheMode)) { 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); } }); }