/// <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.StorageSyncServiceType, parentResourceIdentifier.ResourceType, System.StringComparison.OrdinalIgnoreCase)) { throw new PSArgumentException(StorageSyncResources.MissingParentResourceIdErrorMessage); } } var resourceGroupName = ResourceGroupName ?? ParentObject?.ResourceGroupName ?? parentResourceIdentifier?.ResourceGroupName; var parentResourceName = StorageSyncServiceName ?? ParentObject?.StorageSyncServiceName ?? parentResourceIdentifier?.ResourceName; var createParameters = new SyncGroupCreateParameters(); Target = string.Join("/", resourceGroupName, parentResourceName, Name); if (ShouldProcess(Target, ActionMessage)) { StorageSyncModels.SyncGroup syncGroup = StorageSyncClientWrapper.StorageSyncManagementClient.SyncGroups.Create( resourceGroupName, parentResourceName, Name, createParameters); WriteObject(syncGroup); } }); }
/// <summary> /// Writes the object. /// </summary> /// <param name="resource">The resource.</param> protected void WriteObject(StorageSyncModels.SyncGroup resource) { WriteObject(new SyncGroupConverter().Convert(resource)); }