Skip to content

Commit

Permalink
Merge pull request Azure#4 from Azure/user/rakku/subscription
Browse files Browse the repository at this point in the history
[Azs.Subscription.Admin]: Fix New-AzsUserSubscription cmdlet, Rename parameter PropertiesSubscriptionId to TargetSubscription for New-AzsOfferDelegation
  • Loading branch information
bganapa authored Feb 9, 2020
2 parents 8f0d97e + 0984529 commit bbe5d3c
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 10 deletions.
168 changes: 168 additions & 0 deletions src/Azs.Subscriptions.Admin/custom/New-AzsUserSubscription.ps1
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
}

}
59 changes: 49 additions & 10 deletions src/Azs.Subscriptions.Admin/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ directive:
subject: Offer
set:
subject: AdminManagedOffer
alias: ManagedOffer
alias: Get-AzsManagedOffer
- where:
verb: Get
subject: Quota
set:
subject: SubscriptionQuota
alias: SubscriptionsQuota
alias: Get-AzsSubscriptionsQuota
- where:
subject: Subscription
set:
Expand Down Expand Up @@ -122,7 +122,7 @@ directive:
subject: SubscriptionMoveSubscription
set:
subject: MoveUserSubscription
alias: MoveSubscription
alias: Test-AzsMoveSubscription
- where:
verb: Test
subject: SubscriptionNameAvailability
Expand Down Expand Up @@ -175,6 +175,12 @@ directive:
set:
parameter-name: Name
alias: Location
- where:
verb: New
subject: OfferDelegation
parameter-name: PropertiesSubscriptionId
set:
parameter-name: TargetSubscriptionId
- where:
subject: (.*)OfferDelegation$
parameter-name: OfferDelegationName
Expand Down Expand Up @@ -219,13 +225,6 @@ directive:
parameter-name: TargetDelegatedProviderOffer
set:
parameter-name: DestinationDelegatedProviderOffer
- where:
verb: New
subject: Offer
parameter-name: State
set:
default:
script: Write-Output "Private"
- where:
parameter-name: AddonPlans
set:
Expand All @@ -241,6 +240,42 @@ directive:
parameter-name: Subscription
set:
parameter-name: UserSubscriptionId
## default values
- where:
verb: New
subject: Offer
parameter-name: State
set:
default:
script: Write-Output "Private"
- where:
verb: New
subject: UserSubscription
parameter-name: TargetSubscriptionId
set:
default:
script: "$([Guid]::NewGuid().ToString())"
- where:
verb: New
subject: UserSubscription
parameter-name: DelegatedProviderSubscriptionId
set:
default:
script: '(Get-AzContext).Subscription.Id'
- where:
verb: New
subject: UserSubscription
parameter-name: State
set:
default:
script: Write-Output "Enabled"
- where:
verb: New
subject: UserSubscription
parameter-name: RoutingResourceManagerType
set:
default:
script: Write-Output "Default"
## hide autorest generated cmdlet to use the custom one
- where:
verb: New
Expand All @@ -266,4 +301,8 @@ directive:
verb: Set
subject: UserSubscription
hide: true
- where:
verb: New
subject: UserSubscription
hide: true
```

0 comments on commit bbe5d3c

Please sign in to comment.