Skip to content

Commit 6b92d44

Browse files
author
Maddie Clayton
authored
Merge pull request #7077 from deathly809/User-Subscriptions1.5.0
[Azure Stack][Tenant] Subscriptions for Azure Stack 1.5.0
2 parents a4d660e + e5505a3 commit 6b92d44

File tree

14 files changed

+112
-86
lines changed

14 files changed

+112
-86
lines changed

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Azs.Subscriptions.psd1

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Licensed under the MIT License. See License.txt in the project root for license
1717
RootModule = 'Azs.Subscriptions.psm1'
1818

1919
# Version number of this module.
20-
ModuleVersion = '0.1.1'
20+
ModuleVersion = '0.2.0'
2121

2222
# Supported PSEditions
2323
# CompatiblePSEditions = @()
@@ -29,7 +29,7 @@ Licensed under the MIT License. See License.txt in the project root for license
2929
Author = 'Microsoft'
3030

3131
# Company or vendor of this module
32-
CompanyName = 'Unknown'
32+
CompanyName = 'Microsoft'
3333

3434
# Copyright statement for this module
3535
Copyright = '(c) 2018 Microsoft. All rights reserved.'
@@ -38,7 +38,7 @@ Licensed under the MIT License. See License.txt in the project root for license
3838
Description = 'Subscriptions Management Client'
3939

4040
# Minimum version of the Windows PowerShell engine required by this module
41-
# PowerShellVersion = ''
41+
PowerShellVersion = '5.0'
4242

4343
# Name of the Windows PowerShell host required by this module
4444
# PowerShellHostName = ''
@@ -56,8 +56,8 @@ Licensed under the MIT License. See License.txt in the project root for license
5656
# ProcessorArchitecture = ''
5757

5858
# Modules that must be imported into the global environment prior to importing this module
59-
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; RequiredVersion = '3.4.1'; },
60-
@{ModuleName = 'AzureRM.Resources'; RequiredVersion = '4.4.1'; })
59+
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.5.1'; },
60+
@{ModuleName = 'AzureRM.Resources'; ModuleVersion = '6.0.2'; })
6161

6262
# Assemblies that must be loaded prior to importing this module
6363
# RequiredAssemblies = @()
@@ -103,19 +103,27 @@ Licensed under the MIT License. See License.txt in the project root for license
103103
PSData = @{
104104

105105
# Tags applied to this module. These help with module discovery in online galleries.
106-
# Tags = @()
106+
Tags = @('AzureStack', 'Azure Stack', 'Tenant', 'Subscriptions', 'Azure Stack Tenant Subscription')
107107

108108
# A URL to the license for this module.
109-
# LicenseUri = ''
109+
LicenseUri = 'https://aka.ms/azps-license'
110110

111111
# A URL to the main website for this project.
112-
# ProjectUri = ''
112+
ProjectUri = 'https://github.com/Azure/azure-powershell'
113113

114114
# A URL to an icon representing this module.
115115
# IconUri = ''
116116

117117
# ReleaseNotes of this module
118-
# ReleaseNotes = ''
118+
ReleaseNotes = '## 2018.8.12
119+
* Module dependencies updated
120+
* AzureRM.Profile
121+
* AzureRM.Resources
122+
* Deprecations
123+
* Get-AzsDelegatedProviderOffer, the parameter OfferName is now an alias for Offer
124+
* Bug fixes
125+
* Handle ErrrorAction correctly now
126+
'
119127

120128
} # End of PSData hashtable
121129

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Azs.Subscriptions.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ if (Test-Path -Path $ClrPath -PathType Container) {
2929
. (Join-Path -Path $PSScriptRoot -ChildPath 'Get-ApplicableFilters.ps1')
3030
. (Join-Path -Path $PSScriptRoot -ChildPath 'Test-FilteredResult.ps1')
3131
. (Join-Path -Path $PSScriptRoot -ChildPath 'Get-ArmResourceIdParameterValue.ps1')
32+
. (Join-Path -Path $PSScriptRoot -ChildPath 'Get-ResourceNameSuffix.ps1')
3233
$allPs1FilesPath = Join-Path -Path $PSScriptRoot -ChildPath 'Generated.PowerShell.Commands' | Join-Path -ChildPath '*.ps1'
3334
Get-ChildItem -Path $allPs1FilesPath -Recurse -File | ForEach-Object { . $_.FullName}

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsDelegatedProviderOffer.ps1

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Licensed under the MIT License. See License.txt in the project root for license
1010
.DESCRIPTION
1111
Get the list of offers for the specified delegated provider.
1212
13-
.PARAMETER OfferName
13+
.PARAMETER Name
1414
Name of the offer.
1515
1616
.PARAMETER Skip
@@ -28,15 +28,15 @@ Licensed under the MIT License. See License.txt in the project root for license
2828
2929
Get the list of offers for the specified delegated provider.
3030
#>
31-
function Get-AzsDelegatedProviderOffer
32-
{
31+
function Get-AzsDelegatedProviderOffer {
3332
[OutputType([Microsoft.AzureStack.Management.Subscription.Models.Offer])]
34-
[CmdletBinding(DefaultParameterSetName='List')]
33+
[CmdletBinding(DefaultParameterSetName = 'List')]
3534
param(
3635
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
3736
[ValidateNotNullOrEmpty()]
37+
[Alias('OfferName')]
3838
[System.String]
39-
$OfferName,
39+
$Name,
4040

4141
[Parameter(Mandatory = $true, ParameterSetName = 'List')]
4242
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
@@ -55,76 +55,79 @@ function Get-AzsDelegatedProviderOffer
5555
$Top = -1
5656
)
5757

58-
Begin
59-
{
60-
Initialize-PSSwaggerDependencies -Azure
58+
Begin {
59+
Initialize-PSSwaggerDependencies -Azure
6160
$tracerObject = $null
6261
if (('continue' -eq $DebugPreference) -or ('inquire' -eq $DebugPreference)) {
6362
$oldDebugPreference = $global:DebugPreference
64-
$global:DebugPreference = "continue"
63+
$global:DebugPreference = "continue"
6564
$tracerObject = New-PSSwaggerClientTracing
6665
Register-PSSwaggerClientTracing -TracerObject $tracerObject
6766
}
68-
}
67+
}
6968

7069
Process {
7170

71+
if ($PSBoundParameters.ContainsKey('Name')) {
72+
if ( $MyInvocation.Line -match "\s-OfferName\s") {
73+
Write-Warning -Message "The parameter alias OfferName will be deprecated in future release. Please use the parameter Name instead"
74+
}
75+
}
7276

77+
$NewServiceClient_params = @{
78+
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscription.SubscriptionClient'
79+
}
7380

74-
$NewServiceClient_params = @{
75-
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscription.SubscriptionClient'
76-
}
77-
78-
$GlobalParameterHashtable = @{}
79-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
80-
81-
$SubscriptionClient = New-ServiceClient @NewServiceClient_params
81+
$GlobalParameterHashtable = @{}
82+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
8283

84+
$SubscriptionClient = New-ServiceClient @NewServiceClient_params
8385

84-
if ('List' -eq $PsCmdlet.ParameterSetName) {
85-
Write-Verbose -Message 'Performing operation ListWithHttpMessagesAsync on $SubscriptionClient.'
86-
$TaskResult = $SubscriptionClient.DelegatedProviderOffers.ListWithHttpMessagesAsync($DelegatedProviderId)
87-
} elseif ('Get' -eq $PsCmdlet.ParameterSetName) {
88-
Write-Verbose -Message 'Performing operation GetWithHttpMessagesAsync on $SubscriptionClient.'
89-
$TaskResult = $SubscriptionClient.DelegatedProviderOffers.GetWithHttpMessagesAsync($DelegatedProviderId, $OfferName)
90-
} else {
91-
Write-Verbose -Message 'Failed to map parameter set to operation method.'
92-
throw 'Module failed to find operation to execute.'
93-
}
9486

95-
if ($TaskResult) {
96-
$GetTaskResult_params = @{
97-
TaskResult = $TaskResult
87+
if ('List' -eq $PsCmdlet.ParameterSetName) {
88+
Write-Verbose -Message 'Performing operation ListWithHttpMessagesAsync on $SubscriptionClient.'
89+
$TaskResult = $SubscriptionClient.DelegatedProviderOffers.ListWithHttpMessagesAsync($DelegatedProviderId)
90+
} elseif ('Get' -eq $PsCmdlet.ParameterSetName) {
91+
Write-Verbose -Message 'Performing operation GetWithHttpMessagesAsync on $SubscriptionClient.'
92+
$TaskResult = $SubscriptionClient.DelegatedProviderOffers.GetWithHttpMessagesAsync($DelegatedProviderId, $Name)
93+
} else {
94+
Write-Verbose -Message 'Failed to map parameter set to operation method.'
95+
throw 'Module failed to find operation to execute.'
9896
}
9997

100-
$TopInfo = @{
101-
'Count' = 0
102-
'Max' = $Top
103-
}
104-
$GetTaskResult_params['TopInfo'] = $TopInfo
105-
$SkipInfo = @{
106-
'Count' = 0
107-
'Max' = $Skip
108-
}
109-
$GetTaskResult_params['SkipInfo'] = $SkipInfo
110-
$PageResult = @{
111-
'Result' = $null
112-
}
113-
$GetTaskResult_params['PageResult'] = $PageResult
114-
$GetTaskResult_params['PageType'] = 'Array' -as [Type]
115-
Get-TaskResult @GetTaskResult_params
116-
117-
Write-Verbose -Message 'Flattening paged results.'
118-
while ($PageResult -and ($PageResult.ContainsKey('Page')) -and (Get-Member -InputObject $PageResult.Page -Name 'nextPageLink') -and $PageResult.Page.'nextPageLink' -and (($TopInfo -eq $null) -or ($TopInfo.Max -eq -1) -or ($TopInfo.Count -lt $TopInfo.Max))) {
119-
Write-Debug -Message "Retrieving next page: $($PageResult.Page.'nextPageLink')"
120-
$TaskResult = $SubscriptionClient.DelegatedProviderOffers.ListNextWithHttpMessagesAsync($PageResult.Page.'nextPageLink')
121-
$PageResult.Page = $null
122-
$GetTaskResult_params['TaskResult'] = $TaskResult
98+
if ($TaskResult) {
99+
$GetTaskResult_params = @{
100+
TaskResult = $TaskResult
101+
}
102+
103+
$TopInfo = @{
104+
'Count' = 0
105+
'Max' = $Top
106+
}
107+
$GetTaskResult_params['TopInfo'] = $TopInfo
108+
$SkipInfo = @{
109+
'Count' = 0
110+
'Max' = $Skip
111+
}
112+
$GetTaskResult_params['SkipInfo'] = $SkipInfo
113+
$PageResult = @{
114+
'Result' = $null
115+
}
123116
$GetTaskResult_params['PageResult'] = $PageResult
117+
$GetTaskResult_params['PageType'] = 'Array' -as [Type]
124118
Get-TaskResult @GetTaskResult_params
119+
120+
Write-Verbose -Message 'Flattening paged results.'
121+
while ($PageResult -and ($PageResult.ContainsKey('Page')) -and (Get-Member -InputObject $PageResult.Page -Name 'nextPageLink') -and $PageResult.Page.'nextPageLink' -and (($TopInfo -eq $null) -or ($TopInfo.Max -eq -1) -or ($TopInfo.Count -lt $TopInfo.Max))) {
122+
Write-Debug -Message "Retrieving next page: $($PageResult.Page.'nextPageLink')"
123+
$TaskResult = $SubscriptionClient.DelegatedProviderOffers.ListNextWithHttpMessagesAsync($PageResult.Page.'nextPageLink')
124+
$PageResult.Page = $null
125+
$GetTaskResult_params['TaskResult'] = $TaskResult
126+
$GetTaskResult_params['PageResult'] = $PageResult
127+
Get-TaskResult @GetTaskResult_params
128+
}
125129
}
126130
}
127-
}
128131

129132
End {
130133
if ($tracerObject) {

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsSubscription.ps1

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,10 @@ function New-AzsSubscription {
106106

107107
if ($PSCmdlet.ShouldProcess("$SubscriptionId", "Create new subscription")) {
108108

109-
# Validate this resource does not exist.
110-
$_objectCheck = $null
111-
try {
112-
$_objectCheck = Get-AzsSubscription -SubscriptionId $SubscriptionId
113-
} catch {
114-
# No op
115-
} finally {
116-
if ($_objectCheck -ne $null) {
117-
throw "A subscription with identifier $SubscriptionId already exists."
118-
}
109+
# Validate this resource does not exist
110+
if ($null -ne (Get-AzsSubscription -SubscriptionId $SubscriptionId -ErrorAction SilentlyContinue)) {
111+
Write-Error "A subscription with identifier $SubscriptionId already exists."
112+
return
119113
}
120114

121115
$NewServiceClient_params = @{

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Generated.PowerShell.Commands/SwaggerPathCommands/Set-AzsSubscription.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ function Set-AzsSubscription {
113113

114114
Process {
115115

116-
117-
118116
if ($PSBoundParameters.ContainsKey('Location')) {
119117
if ( $MyInvocation.Line -match "\s-ArmLocation\s") {
120118
Write-Warning -Message "The parameter alias ArmLocation will be deprecated in future release. Please use the parameter Location instead"

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Get-ApplicableFilters.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Get-ApplicableFilters {
2121
$Filters
2222
)
2323

24-
$ErrorActionPreference = 'Stop'
24+
2525
foreach ($filter in $Filters) {
2626
$res = @{
2727
Filter = $filter
@@ -31,7 +31,7 @@ function Get-ApplicableFilters {
3131
if (Test-WildcardFilter -Filter $filter) {
3232
$res['Strict'] = $true
3333
}
34-
}
34+
}
3535
elseif ($filter.Type -eq 'equalityOperator') {
3636
if (Test-EqualityFilter -Filter $filter) {
3737
$res['Strict'] = $true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
function Get-ResourceNameSuffix {
3+
param(
4+
[string]$ResourceName
5+
)
6+
if ($null -ne $ResourceName -and $ResourceName.Contains('/')) {
7+
$ResourceName = $ResourceName.Split("/")[-1]
8+
}
9+
return $ResourceName
10+
}

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Get-TaskResult.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ function Get-TaskResult {
5959
} catch {
6060
# Catch exception so no output.
6161
} finally {
62-
throw $Exception
62+
Write-Error -Exception $Exception
6363
}
6464
}
6565

66-
$ErrorActionPreference = 'Stop'
66+
6767
$null = $TaskResult.AsyncWaitHandle.WaitOne()
6868
Write-Debug -Message "$($TaskResult | Out-String)"
6969

src/StackAdmin/Azs.Subscriptions/Module/Azs.Subscriptions/Test-FilteredResult.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Test-FilteredResult {
2727
$Filter
2828
)
2929

30-
$ErrorActionPreference = 'Stop'
30+
3131
if ($Filter.Type -eq 'wildcard') {
3232
Test-WildcardFilterOnResult -Filter $Filter -Result $Result
3333
} elseif ($Filter.Type -eq 'equalityOperator') {

src/StackAdmin/Azs.Subscriptions/Tests/Azs.Subscriptions.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@
7070
</ProjectReference>
7171
</ItemGroup>
7272
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
73-
</Project>
73+
</Project>
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.AzureStack.Management.Subscription" version="0.1.0-preview" targetFramework="net45" />
4-
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.6.0" targetFramework="net45" />
5-
6-
</packages>
4+
</packages>

src/StackAdmin/Azs.Subscriptions/Tests/src/Common.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
$global:SkippedTests = @()
16+
17+
$global:Client = $null
1518

1619
if (-not $global:RunRaw) {
1720
# Load the script block
1821
$scriptBlock = {
19-
Get-MockClient -ClassName 'SubscriptionsClient' -TestName $global:TestName
22+
if ($null -eq $global:Client) {
23+
$global:Client = Get-MockClient -ClassName 'SubscriptionsClient' -TestName $global:TestName
24+
}
25+
$global:Client
2026
}
2127
Mock New-ServiceClient $scriptBlock -ModuleName $global:ModuleName
2228
}

src/StackAdmin/Azs.Subscriptions/Tests/src/Offer.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ InModuleScope Azs.Subscriptions {
9090
}
9191
}
9292

93+
AfterEach {
94+
$global:Client = $null
95+
}
96+
9397
it "TestListRootOffers" -Skip:$('TestListRootOffers' -in $global:SkippedTests) {
9498
$global:TestName = 'TestListRootOffers'
9599

src/StackAdmin/Azs.Subscriptions/Tests/src/Subscriptions.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ InModuleScope Azs.Subscriptions {
9999
}
100100
}
101101

102+
AfterEach {
103+
$global:Client = $null
104+
}
105+
102106

103107
it "TestListSubscriptions" -Skip:$('TestListSubscriptions' -in $global:SkippedTests) {
104108
$global:TestName = 'TestListSubscriptions'

0 commit comments

Comments
 (0)