public override void ExecuteCmdlet() { if (this.InvitationId != null && this.Location != null) { try { ConsumerInvitation ConsumerInvitation = this.DataShareManagementClient.ConsumerInvitations.Get(this.Location, this.InvitationId); this.WriteObject(ConsumerInvitation.ToPsObject()); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.InvitationId)); } } else { string nextPageLink = null; List <ConsumerInvitation> invitationList = new List <ConsumerInvitation>(); do { IPage <ConsumerInvitation> invitations = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.ConsumerInvitations.ListInvitations() : this.DataShareManagementClient.ConsumerInvitations.ListInvitationsNext(nextPageLink); invitationList.AddRange(invitations.AsEnumerable()); nextPageLink = invitations.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShareConsumerInvitation> consumerInvitations = invitationList.Select(invitation => invitation.ToPsObject()); this.WriteObject(consumerInvitations, true); } }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var parsedResourceId = new ResourceIdentifier(this.ShareSubscriptionResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.AccountName = parsedResourceId.GetAccountName(); this.ShareSubscriptionName = parsedResourceId.GetShareSubscriptionName(); } string nextPageLink = null; var consumerSourceDataSetList = new List <ConsumerSourceDataSet>(); do { IPage <ConsumerSourceDataSet> sourceDataSets = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.ConsumerSourceDataSets.ListByShareSubscription( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName) : this.DataShareManagementClient.ConsumerSourceDataSets.ListByShareSubscriptionNext( nextPageLink); consumerSourceDataSetList.AddRange(sourceDataSets.AsEnumerable()); nextPageLink = sourceDataSets.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShareSourceDataSet> dataSetsInShareSubscription = consumerSourceDataSetList.Select(dataSet => dataSet.ToPsObject()); this.WriteObject(dataSetsInShareSubscription, true); }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.AccountName = parsedResourceId.GetAccountName(); this.ShareName = parsedResourceId.GetShareName(); } string nextPageLink = null; List <ShareSynchronization> shareSynchronizationsList = new List <ShareSynchronization>(); do { IPage <ShareSynchronization> shareSynchronizations = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.Shares.ListSynchronizations(this.ResourceGroupName, this.AccountName, this.ShareName) : this.DataShareManagementClient.Shares.ListSynchronizationsNext(nextPageLink); shareSynchronizationsList.AddRange(shareSynchronizations.AsEnumerable()); nextPageLink = shareSynchronizations.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShareSynchronization> synchronizationsInShare = shareSynchronizationsList.Select(shareSynchronization => shareSynchronization.ToPsObject()); this.WriteObject(synchronizationsInShare, true); }
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 override void ExecuteCmdlet() { if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.AccountName = parsedResourceId.GetAccountName(); this.ShareSubscriptionName = parsedResourceId.GetShareSubscriptionName(); } try { string nextPageLink = null; List <SynchronizationDetails> shareSubscriptionSynchronizationDetailsList = new List <SynchronizationDetails>(); do { IPage <SynchronizationDetails> shareSubscriptionSynchronizationDetails = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.ShareSubscriptions.ListSynchronizationDetails( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, new ShareSubscriptionSynchronization() { SynchronizationId = this.SynchronizationId }) : this.DataShareManagementClient.ShareSubscriptions .ListSynchronizationDetailsNext(nextPageLink); shareSubscriptionSynchronizationDetailsList.AddRange( shareSubscriptionSynchronizationDetails.AsEnumerable()); nextPageLink = shareSubscriptionSynchronizationDetails.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShareSynchronizationDetail> synchronizationDetailsInShareSubscription = shareSubscriptionSynchronizationDetailsList.Select( shareSubscriptionSynchronizationDetails => shareSubscriptionSynchronizationDetails.ToPsObject()); this.WriteObject(synchronizationDetailsInShareSubscription, true); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.ShareSubscriptionName)); } }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.AccountName = parsedResourceId.GetAccountName(); this.Name = parsedResourceId.GetShareName(); } if (this.AccountName != null && this.ResourceGroupName != null) { if (this.Name != null) { try { Share share = this.DataShareManagementClient.Shares.Get( this.ResourceGroupName, this.AccountName, this.Name); this.WriteObject(share.ToPsObject()); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.Name)); } } else { string nextPageLink = null; List <Share> shareList = new List <Share>(); do { IPage <Share> shares = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.Shares.ListByAccount(this.ResourceGroupName, this.AccountName) : this.DataShareManagementClient.Shares.ListByAccountNext(nextPageLink); shareList.AddRange(shares.AsEnumerable()); nextPageLink = shares.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShare> sharesInAccount = shareList.Select(share => share.ToPsObject()); this.WriteObject(sharesInAccount, true); } } }
/// <summary> /// Returns the azure resource groups for given subscription /// </summary> private async Task <IEnumerable <Subscription> > GetSubscriptionsAsync(SubscriptionClient subscriptionClient) { try { if (subscriptionClient != null) { IPage <Subscription> subscriptionList = await ExecuteCloudRequest( () => subscriptionClient.Subscriptions.ListAsync(), SR.FailedToGetAzureSubscriptionsErrorMessage); if (subscriptionList != null) { return(subscriptionList.AsEnumerable()); } } return(Enumerable.Empty <Subscription>()); } catch (Exception ex) { TraceException(TraceEventType.Error, (int)TraceId.AzureResource, ex, "Failed to get azure resource groups"); throw; } }
public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.Name = parsedResourceId.GetAccountName(); } if (this.ResourceGroupName == null) { string nextPageLink = null; List <Account> accountList = new List <Account>(); do { IPage <Account> accounts = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.Accounts.ListBySubscription() : this.DataShareManagementClient.Accounts.ListBySubscriptionNext(nextPageLink); accountList.AddRange(accounts.AsEnumerable()); nextPageLink = accounts.NextPageLink; } while (nextPageLink != null); // List by subscription. IEnumerable <PSDataShareAccount> accountsInSubscription = accountList.Select(account => account.ToPsObject()); this.WriteObject(accountsInSubscription, true); } else { if (this.Name == null) { // List by Resource Group name. string nextPageLink = null; List <Account> accountList = new List <Account>(); do { IPage <Account> accounts = string.IsNullOrEmpty(nextPageLink) ? this.DataShareManagementClient.Accounts.ListByResourceGroup(this.ResourceGroupName) : this.DataShareManagementClient.Accounts.ListByResourceGroupNext(nextPageLink); accountList.AddRange(accounts.AsEnumerable()); nextPageLink = accounts.NextPageLink; } while (nextPageLink != null); IEnumerable <PSDataShareAccount> accountsInResourceGroup = accountList.Select(account => account.ToPsObject()); this.WriteObject(accountsInResourceGroup, true); } else { try { // Get by both Profile Name and Resource Group Name. var account = this.DataShareManagementClient.Accounts.Get(this.ResourceGroupName, this.Name); this.WriteObject(account.ToPsObject()); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.Name)); } } } }
private void WriteTriggerPageToConsole(IPage <Trigger> triggersPage) { this.WriteObject(triggersPage.AsEnumerable().Select(trigger => (trigger as ScheduledTrigger).ToPsObject())); }