forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#4 from Azure/user/rakku/subscription
[Azs.Subscription.Admin]: Fix New-AzsUserSubscription cmdlet, Rename parameter PropertiesSubscriptionId to TargetSubscription for New-AzsOfferDelegation
- Loading branch information
Showing
2 changed files
with
217 additions
and
10 deletions.
There are no files selected for viewing
168 changes: 168 additions & 0 deletions
168
src/Azs.Subscriptions.Admin/custom/New-AzsUserSubscription.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<# | ||
.Synopsis | ||
Creates or updates the specified subscription. | ||
.Description | ||
Creates or updates the specified subscription. | ||
.Example | ||
To view examples, please use the -Online parameter with Get-Help or navigate to: https://docs.microsoft.com/en-us/powershell/module/azs.subscriptions.admin/new-azsusersubscription | ||
.Inputs | ||
Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition | ||
.Outputs | ||
Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition | ||
.Notes | ||
COMPLEX PARAMETER PROPERTIES | ||
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. | ||
SUBSCRIPTIONDEFINITION <ISubscriptionDefinition>: Subscription object properties. | ||
[DelegatedProviderSubscriptionId <String>]: Parent DelegatedProvider subscription identifier. | ||
[DisplayName <String>]: Subscription name. | ||
[ExternalReferenceId <String>]: External reference identifier. | ||
[Id <String>]: Fully qualified identifier. | ||
[OfferId <String>]: Identifier of the offer under the scope of a delegated provider. | ||
[Owner <String>]: Subscription owner. | ||
[RoutingResourceManagerType <ResourceManagerType?>]: Routing resource manager type. | ||
[State <SubscriptionState?>]: Subscription state. | ||
[SubscriptionId <String>]: Subscription identifier. | ||
[TenantId <String>]: Directory tenant identifier. | ||
.Link | ||
https://docs.microsoft.com/en-us/powershell/module/azs.subscriptions.admin/new-azsusersubscription | ||
#> | ||
function New-AzsUserSubscription { | ||
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition])] | ||
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] | ||
param( | ||
[Parameter()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Path')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='$([Guid]::NewGuid().ToString())')] | ||
[System.String] | ||
# The target subscription ID. | ||
${TargetSubscriptionId}, | ||
|
||
[Parameter(ParameterSetName='Create', Mandatory, ValueFromPipeline)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition] | ||
# Subscription object properties. | ||
# To construct, see NOTES section for SUBSCRIPTIONDEFINITION properties and create a hash table. | ||
${SubscriptionDefinition}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
[System.String] | ||
# Parent DelegatedProvider subscription identifier. | ||
${DelegatedProviderSubscriptionId}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[System.String] | ||
# Subscription name. | ||
${DisplayName}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[System.String] | ||
# External reference identifier. | ||
${ExternalReferenceId}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[System.String] | ||
# Fully qualified identifier. | ||
${Id}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[System.String] | ||
# Identifier of the offer under the scope of a delegated provider. | ||
${OfferId}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[System.String] | ||
# Subscription owner. | ||
${Owner}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.ResourceManagerType])] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='Write-Output "Default"')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.ResourceManagerType] | ||
# Routing resource manager type. | ||
${RoutingResourceManagerType}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.SubscriptionState])] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='Write-Output "Enabled"')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.SubscriptionState] | ||
# Subscription state. | ||
${State}, | ||
|
||
[Parameter(ParameterSetName='CreateExpanded')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')] | ||
[System.String] | ||
# Directory tenant identifier. | ||
${TenantId}, | ||
|
||
[Parameter()] | ||
[Alias('AzureRMContext', 'AzureCredential')] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Azure')] | ||
[System.Management.Automation.PSObject] | ||
# The credentials, account, tenant, and subscription used for communication with Azure. | ||
${DefaultProfile}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Wait for .NET debugger to attach | ||
${Break}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
${HttpPipelineAppend}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
${HttpPipelinePrepend}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')] | ||
[System.Uri] | ||
# The URI for the proxy server to use | ||
${Proxy}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')] | ||
[System.Management.Automation.PSCredential] | ||
# Credentials for a proxy server to use for the remote call | ||
${ProxyCredential}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Use the default credentials for the proxy | ||
${ProxyUseDefaultCredentials} | ||
) | ||
|
||
process { | ||
if ( $PSCmdlet.ParameterSetName -eq 'CreateExpanded' ) | ||
{ | ||
# SubscriptionId and DelegatedProviderSubscriptionId are duplicate parameters generated by autorest. | ||
# Set DelegatedProviderSubscriptionId as SubscriptionId | ||
if ($null -ne $PSBoundParameters['TargetSubscriptionId']) | ||
{ | ||
$PSBoundParameters['SubscriptionId1'] = $PSBoundParameters['TargetSubscriptionId'] | ||
} | ||
} | ||
Azs.Subscriptions.Admin.internal\New-AzsUserSubscription @PSBoundParameters | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters