public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var resourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceId.ResourceGroupName; this.AccountName = resourceId.GetAccountName(); this.ShareName = resourceId.GetShareName(); this.Name = resourceId.GetSynchronizationSettingName(); } if (this.Name == null) { var settingsPage = this.DataShareManagementClient.SynchronizationSettings.ListByShare( this.ResourceGroupName, accountName: this.AccountName, shareName: this.ShareName); this.WriteObject( settingsPage.AsEnumerable().Select( syncSettings => (syncSettings as ScheduledSynchronizationSetting).ToPsObject()), true); while (settingsPage.NextPageLink != null) { settingsPage = this.DataShareManagementClient.SynchronizationSettings.ListByShareNext( settingsPage.NextPageLink); this.WriteObject( settingsPage.AsEnumerable().Select( syncSettings => (syncSettings as ScheduledSynchronizationSetting).ToPsObject()), true); } } else { try { var setting = this.DataShareManagementClient.SynchronizationSettings.Get( resourceGroupName: this.ResourceGroupName, accountName: this.AccountName, shareName: this.ShareName, synchronizationSettingName: this.Name) as ScheduledSynchronizationSetting; this.WriteObject(setting.ToPsObject()); } catch (DataShareErrorException exception) when(exception.Response.StatusCode.Equals( HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.Name)); } } }
public override void ExecuteCmdlet() { string resourceId = null; if (ParameterSetNames.ResourceIdParameterSet.Equals( this.ParameterSetName, StringComparison.OrdinalIgnoreCase)) { resourceId = this.ResourceId; } if (ParameterSetNames.ObjectParameterSet.Equals(this.ParameterSetName, StringComparison.OrdinalIgnoreCase)) { resourceId = this.InputObject.Id; } if (!string.IsNullOrEmpty(resourceId)) { var parsedResourceIdentifier = new ResourceIdentifier(resourceId); this.ResourceGroupName = parsedResourceIdentifier.ResourceGroupName; this.AccountName = parsedResourceIdentifier.GetAccountName(); this.ShareName = parsedResourceIdentifier.GetShareName(); this.Name = parsedResourceIdentifier.GetSynchronizationSettingName(); } var func = (Func <string, string, string, string, OperationResponse>) this.DataShareManagementClient .SynchronizationSettings.Delete; void Action() => func(this.ResourceGroupName, this.AccountName, this.ShareName, this.Name); this.ConfirmAction( string.Format(Resources.ResourceRemovalConfirmation, this.Name), this.Name, Action); if (this.PassThru) { this.WriteObject(true); } }