Skip to content

Commit bbe5d3c

Browse files
authored
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
2 parents 8f0d97e + 0984529 commit bbe5d3c

File tree

2 files changed

+217
-10
lines changed

2 files changed

+217
-10
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<#
2+
.Synopsis
3+
Creates or updates the specified subscription.
4+
.Description
5+
Creates or updates the specified subscription.
6+
.Example
7+
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
8+
.Inputs
9+
Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition
10+
.Outputs
11+
Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition
12+
.Notes
13+
COMPLEX PARAMETER PROPERTIES
14+
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.
15+
16+
SUBSCRIPTIONDEFINITION <ISubscriptionDefinition>: Subscription object properties.
17+
[DelegatedProviderSubscriptionId <String>]: Parent DelegatedProvider subscription identifier.
18+
[DisplayName <String>]: Subscription name.
19+
[ExternalReferenceId <String>]: External reference identifier.
20+
[Id <String>]: Fully qualified identifier.
21+
[OfferId <String>]: Identifier of the offer under the scope of a delegated provider.
22+
[Owner <String>]: Subscription owner.
23+
[RoutingResourceManagerType <ResourceManagerType?>]: Routing resource manager type.
24+
[State <SubscriptionState?>]: Subscription state.
25+
[SubscriptionId <String>]: Subscription identifier.
26+
[TenantId <String>]: Directory tenant identifier.
27+
.Link
28+
https://docs.microsoft.com/en-us/powershell/module/azs.subscriptions.admin/new-azsusersubscription
29+
#>
30+
function New-AzsUserSubscription {
31+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition])]
32+
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
33+
param(
34+
[Parameter()]
35+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Path')]
36+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='$([Guid]::NewGuid().ToString())')]
37+
[System.String]
38+
# The target subscription ID.
39+
${TargetSubscriptionId},
40+
41+
[Parameter(ParameterSetName='Create', Mandatory, ValueFromPipeline)]
42+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
43+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Models.Api20151101.ISubscriptionDefinition]
44+
# Subscription object properties.
45+
# To construct, see NOTES section for SUBSCRIPTIONDEFINITION properties and create a hash table.
46+
${SubscriptionDefinition},
47+
48+
[Parameter(ParameterSetName='CreateExpanded')]
49+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
50+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
51+
[System.String]
52+
# Parent DelegatedProvider subscription identifier.
53+
${DelegatedProviderSubscriptionId},
54+
55+
[Parameter(ParameterSetName='CreateExpanded')]
56+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
57+
[System.String]
58+
# Subscription name.
59+
${DisplayName},
60+
61+
[Parameter(ParameterSetName='CreateExpanded')]
62+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
63+
[System.String]
64+
# External reference identifier.
65+
${ExternalReferenceId},
66+
67+
[Parameter(ParameterSetName='CreateExpanded')]
68+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
69+
[System.String]
70+
# Fully qualified identifier.
71+
${Id},
72+
73+
[Parameter(ParameterSetName='CreateExpanded')]
74+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
75+
[System.String]
76+
# Identifier of the offer under the scope of a delegated provider.
77+
${OfferId},
78+
79+
[Parameter(ParameterSetName='CreateExpanded')]
80+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
81+
[System.String]
82+
# Subscription owner.
83+
${Owner},
84+
85+
[Parameter(ParameterSetName='CreateExpanded')]
86+
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.ResourceManagerType])]
87+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
88+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='Write-Output "Default"')]
89+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.ResourceManagerType]
90+
# Routing resource manager type.
91+
${RoutingResourceManagerType},
92+
93+
[Parameter(ParameterSetName='CreateExpanded')]
94+
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.SubscriptionState])]
95+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
96+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.DefaultInfo(Script='Write-Output "Enabled"')]
97+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Support.SubscriptionState]
98+
# Subscription state.
99+
${State},
100+
101+
[Parameter(ParameterSetName='CreateExpanded')]
102+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Body')]
103+
[System.String]
104+
# Directory tenant identifier.
105+
${TenantId},
106+
107+
[Parameter()]
108+
[Alias('AzureRMContext', 'AzureCredential')]
109+
[ValidateNotNull()]
110+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Azure')]
111+
[System.Management.Automation.PSObject]
112+
# The credentials, account, tenant, and subscription used for communication with Azure.
113+
${DefaultProfile},
114+
115+
[Parameter(DontShow)]
116+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')]
117+
[System.Management.Automation.SwitchParameter]
118+
# Wait for .NET debugger to attach
119+
${Break},
120+
121+
[Parameter(DontShow)]
122+
[ValidateNotNull()]
123+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')]
124+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.SendAsyncStep[]]
125+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
126+
${HttpPipelineAppend},
127+
128+
[Parameter(DontShow)]
129+
[ValidateNotNull()]
130+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')]
131+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Runtime.SendAsyncStep[]]
132+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
133+
${HttpPipelinePrepend},
134+
135+
[Parameter(DontShow)]
136+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')]
137+
[System.Uri]
138+
# The URI for the proxy server to use
139+
${Proxy},
140+
141+
[Parameter(DontShow)]
142+
[ValidateNotNull()]
143+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')]
144+
[System.Management.Automation.PSCredential]
145+
# Credentials for a proxy server to use for the remote call
146+
${ProxyCredential},
147+
148+
[Parameter(DontShow)]
149+
[Microsoft.Azure.PowerShell.Cmdlets.SubscriptionsAdmin.Category('Runtime')]
150+
[System.Management.Automation.SwitchParameter]
151+
# Use the default credentials for the proxy
152+
${ProxyUseDefaultCredentials}
153+
)
154+
155+
process {
156+
if ( $PSCmdlet.ParameterSetName -eq 'CreateExpanded' )
157+
{
158+
# SubscriptionId and DelegatedProviderSubscriptionId are duplicate parameters generated by autorest.
159+
# Set DelegatedProviderSubscriptionId as SubscriptionId
160+
if ($null -ne $PSBoundParameters['TargetSubscriptionId'])
161+
{
162+
$PSBoundParameters['SubscriptionId1'] = $PSBoundParameters['TargetSubscriptionId']
163+
}
164+
}
165+
Azs.Subscriptions.Admin.internal\New-AzsUserSubscription @PSBoundParameters
166+
}
167+
168+
}

src/Azs.Subscriptions.Admin/readme.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ directive:
8888
subject: Offer
8989
set:
9090
subject: AdminManagedOffer
91-
alias: ManagedOffer
91+
alias: Get-AzsManagedOffer
9292
- where:
9393
verb: Get
9494
subject: Quota
9595
set:
9696
subject: SubscriptionQuota
97-
alias: SubscriptionsQuota
97+
alias: Get-AzsSubscriptionsQuota
9898
- where:
9999
subject: Subscription
100100
set:
@@ -122,7 +122,7 @@ directive:
122122
subject: SubscriptionMoveSubscription
123123
set:
124124
subject: MoveUserSubscription
125-
alias: MoveSubscription
125+
alias: Test-AzsMoveSubscription
126126
- where:
127127
verb: Test
128128
subject: SubscriptionNameAvailability
@@ -175,6 +175,12 @@ directive:
175175
set:
176176
parameter-name: Name
177177
alias: Location
178+
- where:
179+
verb: New
180+
subject: OfferDelegation
181+
parameter-name: PropertiesSubscriptionId
182+
set:
183+
parameter-name: TargetSubscriptionId
178184
- where:
179185
subject: (.*)OfferDelegation$
180186
parameter-name: OfferDelegationName
@@ -219,13 +225,6 @@ directive:
219225
parameter-name: TargetDelegatedProviderOffer
220226
set:
221227
parameter-name: DestinationDelegatedProviderOffer
222-
- where:
223-
verb: New
224-
subject: Offer
225-
parameter-name: State
226-
set:
227-
default:
228-
script: Write-Output "Private"
229228
- where:
230229
parameter-name: AddonPlans
231230
set:
@@ -241,6 +240,42 @@ directive:
241240
parameter-name: Subscription
242241
set:
243242
parameter-name: UserSubscriptionId
243+
## default values
244+
- where:
245+
verb: New
246+
subject: Offer
247+
parameter-name: State
248+
set:
249+
default:
250+
script: Write-Output "Private"
251+
- where:
252+
verb: New
253+
subject: UserSubscription
254+
parameter-name: TargetSubscriptionId
255+
set:
256+
default:
257+
script: "$([Guid]::NewGuid().ToString())"
258+
- where:
259+
verb: New
260+
subject: UserSubscription
261+
parameter-name: DelegatedProviderSubscriptionId
262+
set:
263+
default:
264+
script: '(Get-AzContext).Subscription.Id'
265+
- where:
266+
verb: New
267+
subject: UserSubscription
268+
parameter-name: State
269+
set:
270+
default:
271+
script: Write-Output "Enabled"
272+
- where:
273+
verb: New
274+
subject: UserSubscription
275+
parameter-name: RoutingResourceManagerType
276+
set:
277+
default:
278+
script: Write-Output "Default"
244279
## hide autorest generated cmdlet to use the custom one
245280
- where:
246281
verb: New
@@ -266,4 +301,8 @@ directive:
266301
verb: Set
267302
subject: UserSubscription
268303
hide: true
304+
- where:
305+
verb: New
306+
subject: UserSubscription
307+
hide: true
269308
```

0 commit comments

Comments
 (0)