/// <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 StorageSyncModels.ServerEndpointCreateParameters() { CloudTiering = CloudTiering.ToBool() ? StorageSyncConstants.CloudTieringOn : StorageSyncConstants.CloudTieringOff, VolumeFreeSpacePercent = VolumeFreeSpacePercent, ServerLocalPath = ServerLocalPath, ServerResourceId = ServerResourceId, TierFilesOlderThanDays = TierFilesOlderThanDays }; if (this.IsParameterBound(c => c.InitialDownloadPolicy)) { createParameters.InitialDownloadPolicy = InitialDownloadPolicy; } if (this.IsParameterBound(c => c.LocalCacheMode)) { createParameters.LocalCacheMode = LocalCacheMode; } if (this.IsParameterBound(c => c.InitialUploadPolicy)) { createParameters.InitialUploadPolicy = InitialUploadPolicy; } 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)) { StorageSyncModels.ServerEndpoint resource = StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.Create( resourceGroupName, storageSyncServiceName, syncGroupName, Name, createParameters); WriteObject(resource); } }); }
/// <summary> /// Writes the object. /// </summary> /// <param name="resource">The resource.</param> protected void WriteObject(StorageSyncModels.ServerEndpoint resource) { WriteObject(new ServerEndpointConverter().Convert(resource)); }