/// <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); } }
public void ServerEndpointAllOperationsTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { IResourceManagementClient resourcesClient = StorageSyncManagementTestUtilities.GetResourceManagementClient(context, handler); IStorageSyncManagementClient storageSyncManagementClient = StorageSyncManagementTestUtilities.GetStorageSyncManagementClient(context, handler); // Create ResourceGroup string resourceGroupName = StorageSyncManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create ServerEndpoint string storageSyncServiceName = TestUtilities.GenerateName("sss-sepall"); string syncGroupName = TestUtilities.GenerateName("sg-sepall"); string resourceName = TestUtilities.GenerateName("sepall"); var storageSyncServiceParameters = StorageSyncManagementTestUtilities.GetDefaultStorageSyncServiceParameters(); var syncGroupParameters = StorageSyncManagementTestUtilities.GetDefaultSyncGroupParameters(); var cloudEndpointParameters = StorageSyncManagementTestUtilities.GetDefaultCloudEndpointParameters(); StorageSyncService storageSyncServiceResource = storageSyncManagementClient.StorageSyncServices.Create(resourceGroupName, storageSyncServiceName, storageSyncServiceParameters); Assert.NotNull(storageSyncServiceResource); StorageSyncManagementTestUtilities.VerifyStorageSyncServiceProperties(storageSyncServiceResource, true); SyncGroup syncGroupResource = storageSyncManagementClient.SyncGroups.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, syncGroupParameters); Assert.NotNull(syncGroupResource); StorageSyncManagementTestUtilities.VerifySyncGroupProperties(syncGroupResource, true); CloudEndpoint cloudEndpointResource = storageSyncManagementClient.CloudEndpoints.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, cloudEndpointParameters); Assert.NotNull(cloudEndpointResource); StorageSyncManagementTestUtilities.VerifyCloudEndpointProperties(cloudEndpointResource, true); RegisteredServer registeredServerResource = EnsureRegisteredServerResource(storageSyncManagementClient, resourceGroupName, storageSyncServiceName, syncGroupName, storageSyncServiceResource); Assert.NotNull(registeredServerResource); StorageSyncManagementTestUtilities.VerifyRegisteredServerProperties(registeredServerResource, true); var serverEndpointParameters = StorageSyncManagementTestUtilities.GetDefaultServerEndpointParameters(registeredServerResource.Id); var serverEndpointUpdateParameters = StorageSyncManagementTestUtilities.GetDefaultServerEndpointUpdateParameters(); // Delete Test before it exists. storageSyncManagementClient.ServerEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName); ServerEndpoint serverEndpointResource = storageSyncManagementClient.ServerEndpoints.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, serverEndpointParameters); Assert.NotNull(serverEndpointResource); StorageSyncManagementTestUtilities.VerifyServerEndpointProperties(serverEndpointResource, true); // GET Test serverEndpointResource = storageSyncManagementClient.ServerEndpoints.Get(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName); Assert.NotNull(serverEndpointResource); StorageSyncManagementTestUtilities.VerifyServerEndpointProperties(serverEndpointResource, true); // List Test IEnumerable <ServerEndpoint> serverEndpoints = storageSyncManagementClient.ServerEndpoints.ListBySyncGroup(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name); Assert.Single(serverEndpoints); Assert.NotNull(serverEndpoints.Single()); StorageSyncManagementTestUtilities.VerifyServerEndpointProperties(serverEndpoints.Single(), true); // Recall Test RecallActionParameters recallActionParameters = StorageSyncManagementTestUtilities.GetDefaultRecallActionParameters(); ServerEndpointsRecallActionHeaders serverEndpointsRecallActionHeaders = storageSyncManagementClient.ServerEndpoints.RecallAction(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, recallActionParameters); Assert.NotNull(serverEndpointsRecallActionHeaders); Assert.NotEmpty(serverEndpointsRecallActionHeaders.XMsCorrelationRequestId); Assert.NotEmpty(serverEndpointsRecallActionHeaders.XMsRequestId); // Update Test serverEndpointResource = storageSyncManagementClient.ServerEndpoints.Update(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, serverEndpointUpdateParameters); Assert.NotNull(serverEndpointResource); StorageSyncManagementTestUtilities.VerifyServerEndpointUpdateProperties(serverEndpointResource, true); // Delete Test storageSyncManagementClient.ServerEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName); storageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, resourceName); storageSyncManagementClient.SyncGroups.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName); storageSyncManagementClient.RegisteredServers.Delete(resourceGroupName, storageSyncServiceResource.Name, registeredServerResource.ServerId.Trim('"')); storageSyncManagementClient.StorageSyncServices.Delete(resourceGroupName, storageSyncServiceResource.Name); StorageSyncManagementTestUtilities.RemoveResourceGroup(resourcesClient, resourceGroupName); } }
/// <summary> /// Recall a server endpoint. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='storageSyncServiceName'> /// Name of Storage Sync Service resource. /// </param> /// <param name='syncGroupName'> /// Name of Sync Group resource. /// </param> /// <param name='serverEndpointName'> /// Name of Server Endpoint object. /// </param> /// <param name='parameters'> /// Body of Recall Action object. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ServerEndpointsRecallActionHeaders> BeginRecallActionAsync(this IServerEndpointsOperations operations, string resourceGroupName, string storageSyncServiceName, string syncGroupName, string serverEndpointName, RecallActionParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginRecallActionWithHttpMessagesAsync(resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Headers); } }
/// <summary> /// Recall a server endpoint. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='storageSyncServiceName'> /// Name of Storage Sync Service resource. /// </param> /// <param name='syncGroupName'> /// Name of Sync Group resource. /// </param> /// <param name='serverEndpointName'> /// Name of Server Endpoint object. /// </param> /// <param name='parameters'> /// Body of Recall Action object. /// </param> public static ServerEndpointsRecallActionHeaders BeginRecallAction(this IServerEndpointsOperations operations, string resourceGroupName, string storageSyncServiceName, string syncGroupName, string serverEndpointName, RecallActionParameters parameters) { return(operations.BeginRecallActionAsync(resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters).GetAwaiter().GetResult()); }