public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(ParameterSetNames.ProviderShareSubscriptionIdParameterSet)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.AccountName = parsedResourceId.GetAccountName(); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ShareName = parsedResourceId.GetShareName(); } if (this.ShareSubscriptionId != null) { try { ProviderShareSubscription providerShareSubscription = this.DataShareManagementClient.ProviderShareSubscriptions.GetByShare( this.ResourceGroupName, this.AccountName, this.ShareName, this.ShareSubscriptionId); this.WriteObject(providerShareSubscription.ToPsObject()); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.ShareSubscriptionId)); } } else { string nextPageLink = null; List <ProviderShareSubscription> providerShareSubscriptionList = new List <ProviderShareSubscription>(); do { IPage <ProviderShareSubscription> providerShareSubscriptionPage = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.ProviderShareSubscriptions.ListByShare( this.ResourceGroupName, this.AccountName, this.ShareName) : this.DataShareManagementClient.ProviderShareSubscriptions.ListByShareNext( nextPageLink); providerShareSubscriptionList.AddRange(providerShareSubscriptionPage.AsEnumerable()); nextPageLink = providerShareSubscriptionPage.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShareProviderShareSubscription> providerShareSubscriptions = providerShareSubscriptionList.Select( providerShareSubscription => providerShareSubscription.ToPsObject()); this.WriteObject(providerShareSubscriptions.ToArray(), true); } }
public static PSDataShareProviderShareSubscription ToPsObject(this ProviderShareSubscription providerShareSubscription) { return(new PSDataShareProviderShareSubscription { Id = providerShareSubscription.Id, Name = providerShareSubscription.Name, Type = providerShareSubscription.Type, Company = providerShareSubscription.ConsumerTenantName, CreatedAt = providerShareSubscription.CreatedAt, CreatedBy = providerShareSubscription.ConsumerEmail ?? providerShareSubscription.ConsumerName, SharedAt = providerShareSubscription.SharedAt, SharedBy = providerShareSubscription.ProviderEmail ?? providerShareSubscription.ProviderName, ShareSubscriptionObjectId = providerShareSubscription.ShareSubscriptionObjectId, ShareSubscriptionStatus = providerShareSubscription.ShareSubscriptionStatus }); }
public override void ExecuteCmdlet() { if (this.ShouldProcess(this.ShareSubscriptionId, Resources.RevokeShareSubscriptionAccess)) { if (this.ParameterSetName.Equals(ParameterSetNames.ProviderShareSubscriptionIdParameterSet)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.AccountName = parsedResourceId.GetAccountName(); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ShareName = parsedResourceId.GetShareName(); } ProviderShareSubscription providerShareSubscription = this.DataShareManagementClient.ProviderShareSubscriptions.Revoke( resourceGroupName: this.ResourceGroupName, accountName: this.AccountName, shareName: this.ShareName, providerShareSubscriptionId: this.ShareSubscriptionId); this.WriteObject(providerShareSubscription.ToPsObject()); } }
/// <summary> /// Adjust the expiration date of a share subscription in a provider share. /// </summary> /// <remarks> /// Adjust a share subscription's expiration date in a provider share /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='accountName'> /// The name of the share account. /// </param> /// <param name='shareName'> /// The name of the share. /// </param> /// <param name='providerShareSubscriptionId'> /// To locate shareSubscription /// </param> /// <param name='providerShareSubscription'> /// The provider share subscription /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ProviderShareSubscription> AdjustAsync(this IProviderShareSubscriptionsOperations operations, string resourceGroupName, string accountName, string shareName, string providerShareSubscriptionId, ProviderShareSubscription providerShareSubscription, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.AdjustWithHttpMessagesAsync(resourceGroupName, accountName, shareName, providerShareSubscriptionId, providerShareSubscription, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Adjust the expiration date of a share subscription in a provider share. /// </summary> /// <remarks> /// Adjust a share subscription's expiration date in a provider share /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='accountName'> /// The name of the share account. /// </param> /// <param name='shareName'> /// The name of the share. /// </param> /// <param name='providerShareSubscriptionId'> /// To locate shareSubscription /// </param> /// <param name='providerShareSubscription'> /// The provider share subscription /// </param> public static ProviderShareSubscription Adjust(this IProviderShareSubscriptionsOperations operations, string resourceGroupName, string accountName, string shareName, string providerShareSubscriptionId, ProviderShareSubscription providerShareSubscription) { return(operations.AdjustAsync(resourceGroupName, accountName, shareName, providerShareSubscriptionId, providerShareSubscription).GetAwaiter().GetResult()); }