private void SetParametersIfNeeded() { string resourceId = null; if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { resourceId = this.ResourceId; } if (this.ParameterSetName.Equals(ParameterSetNames.ObjectParameterSet, StringComparison.OrdinalIgnoreCase)) { resourceId = this.InputObject.Id; } if (resourceId != null) { var parsedResourceId = new ResourceIdentifier(resourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.AccountName = parsedResourceId.GetAccountName(); this.ShareSubscriptionName = parsedResourceId.GetShareSubscriptionName(); this.Name = parsedResourceId.GetTriggerName(); } }
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() { string resourceId = null; if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { resourceId = this.ResourceId; } if (this.ParameterSetName.Equals(ParameterSetNames.ObjectParameterSet, StringComparison.OrdinalIgnoreCase)) { resourceId = this.InputObject.Id; } if (!string.IsNullOrEmpty(resourceId)) { var parsedResourceId = new ResourceIdentifier(resourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.Name = parsedResourceId.GetAccountName(); } this.ConfirmAction( this.Force, string.Format(Resources.ResourceRemovalConfirmation, this.Name), string.Format(Resources.ResourceRemovedMessage, this.Name), this.Name, () => this.DataShareManagementClient.Accounts.Delete(this.ResourceGroupName, this.Name)); if (this.PassThru) { this.WriteObject(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() { string resourceId = null; if (this.ParameterSetName.Equals( ParameterSetNames.ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { resourceId = this.ResourceId; } if (this.ParameterSetName.Equals(ParameterSetNames.ObjectParameterSet, StringComparison.OrdinalIgnoreCase)) { if (this.Name == null) { throw new PSArgumentNullException( string.Format(CultureInfo.InvariantCulture, Resources.ResourceArgumentInvalid)); } resourceId = this.InputObject.Id; } if (!string.IsNullOrEmpty(resourceId)) { var parseResourceId = new ResourceIdentifier(resourceId); this.ResourceGroupName = parseResourceId.ResourceGroupName; this.AccountName = parseResourceId.GetAccountName(); this.Name = parseResourceId.GetShareName(); } Share existingShare = null; try { existingShare = this.DataShareManagementClient.Shares.Get( this.ResourceGroupName, this.AccountName, this.Name); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.Name)); } if (this.Description != null || this.TermsOfUse != null) { this.ConfirmAction( Resources.ResourceUpdataConfirmation, this.Name, () => this.UpdateShare(existingShare)); } else { this.WriteObject(existingShare.ToPsObject()); } }
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 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() { 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); } } }
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(); this.Name = parsedResourceId.GetTriggerName(); } if (this.Name != null) { try { var trigger = this.DataShareManagementClient.Triggers.Get( resourceGroupName: this.ResourceGroupName, accountName: this.AccountName, shareSubscriptionName: this.ShareSubscriptionName, triggerName: this.Name) as ScheduledTrigger; this.WriteObject(trigger.ToPsObject()); } catch (DataShareErrorException ex) when(ex.Response.StatusCode.Equals(HttpStatusCode.NotFound)) { throw new PSArgumentException(string.Format(Resources.ResourceNotFoundMessage, this.Name)); } } else { var triggersPage = this.DataShareManagementClient.Triggers.ListByShareSubscription( resourceGroupName: this.ResourceGroupName, accountName: this.AccountName, shareSubscriptionName: this.ShareSubscriptionName); this.WriteTriggerPageToConsole(triggersPage); while (triggersPage.NextPageLink != null) { triggersPage = this.DataShareManagementClient.Triggers.ListByShareSubscriptionNext(triggersPage.NextPageLink); this.WriteTriggerPageToConsole(triggersPage); } } }
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); } }
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()); } }
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)); } } } }
public override void ExecuteCmdlet() { var parsedStorageResourceId = new ResourceIdentifier(this.StorageAccountResourceId); string storageSubscriptionId = parsedStorageResourceId.Subscription; string storageResourceGroup = parsedStorageResourceId.ResourceGroupName; string storageAccountName = parsedStorageResourceId.GetStorageAccountName(); if (this.ParameterSetName.Equals( ParameterSetNames.BlobDataSetParameterSet, StringComparison.OrdinalIgnoreCase)) { if (this.ShouldProcess(this.Name, string.Format(Resources.ResourceCreateMessage, NewAzDataShareDataSet.ResourceType))) { if (this.FilePath != null) { var newDataSet = (BlobDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new BlobDataSet() { ContainerName = this.Container, FilePath = this.FilePath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } else if (this.FolderPath != null) { var newDataSet = (BlobFolderDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new BlobFolderDataSet() { ContainerName = this.Container, Prefix = this.FolderPath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } else { var newDataSet = (BlobContainerDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new BlobContainerDataSet() { ContainerName = this.Container, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } } } if (this.ParameterSetName.Equals( ParameterSetNames.AdlsGen2DataSetParameterSet, StringComparison.OrdinalIgnoreCase)) { if (this.ShouldProcess(this.Name, string.Format(Resources.ResourceCreateMessage, NewAzDataShareDataSet.ResourceType))) { if (this.FilePath != null) { var newDataSet = (ADLSGen2FileDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new ADLSGen2FileDataSet() { FileSystem = this.FileSystem, FilePath = this.FilePath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } else if (this.FolderPath != null) { var newDataSet = (ADLSGen2FolderDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new ADLSGen2FolderDataSet() { FileSystem = this.FileSystem, FolderPath = this.FolderPath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } else { var newDataSet = (ADLSGen2FileSystemDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new ADLSGen2FileSystemDataSet() { FileSystem = this.FileSystem, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } } } if (this.ParameterSetName.Equals( ParameterSetNames.AdlsGen1DataSetParameterSet, StringComparison.OrdinalIgnoreCase)) { storageAccountName = parsedStorageResourceId.GetAccountName(); if (this.ShouldProcess(this.Name, string.Format(Resources.ResourceCreateMessage, NewAzDataShareDataSet.ResourceType))) { if (this.FileName != null) { var newDataSet = (ADLSGen1FileDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new ADLSGen1FileDataSet() { FileName = this.FileName, FolderPath = this.AdlsGen1FolderPath, ResourceGroup = storageResourceGroup, AccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } else { var newDataSet = (ADLSGen1FolderDataSet)this.DataShareManagementClient.DataSets.Create( this.ResourceGroupName, this.AccountName, this.ShareName, this.Name, new ADLSGen1FolderDataSet() { FolderPath = this.AdlsGen1FolderPath, ResourceGroup = storageResourceGroup, AccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSet.ToPsObject()); } } } }