/// <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> /// Create a new ServerEndpoint. /// </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 Server Endpoint object. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ServerEndpoint> CreateAsync(this IServerEndpointsOperations operations, string resourceGroupName, string storageSyncServiceName, string syncGroupName, string serverEndpointName, ServerEndpointCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create a new ServerEndpoint. /// </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 Server Endpoint object. /// </param> public static ServerEndpoint Create(this IServerEndpointsOperations operations, string resourceGroupName, string storageSyncServiceName, string syncGroupName, string serverEndpointName, ServerEndpointCreateParameters parameters) { return(operations.CreateAsync(resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters).GetAwaiter().GetResult()); }