Skip to content

Commit 6d1b5ea

Browse files
authored
Merge pull request Azure#10 from bganapa/commerce
metadata config changes, docs and tests for commerce admin module
2 parents 9b8a674 + e37ee7d commit 6d1b5ea

File tree

7 files changed

+487
-4
lines changed

7 files changed

+487
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
Module Name: Azs.Commerce.Admin
3+
Module Guid: a75cc73d-c581-48e9-be1d-df9929798e92
4+
Download Help Link: https://docs.microsoft.com/en-us/powershell/module/azs.commerce.admin
5+
Help Version: 1.0.0.0
6+
Locale: en-US
7+
---
8+
9+
# Azs.Commerce.Admin Module
10+
## Description
11+
Microsoft Azure PowerShell: Commerce cmdlets
12+
13+
## Azs.Commerce.Admin Cmdlets
14+
### [Get-AzsSubscriberUsage](Get-AzsSubscriberUsage.md)
15+
Gets a collection of SubscriberUsageAggregates, which are UsageAggregates from users.
16+
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
external help file:
3+
Module Name: Azs.Commerce.Admin
4+
online version: https://docs.microsoft.com/en-us/powershell/module/azs.commerce.admin/get-azssubscriberusage
5+
schema: 2.0.0
6+
---
7+
8+
# Get-AzsSubscriberUsage
9+
10+
## SYNOPSIS
11+
Gets a collection of SubscriberUsageAggregates, which are UsageAggregates from users.
12+
13+
## SYNTAX
14+
15+
```
16+
Get-AzsSubscriberUsage -ReportedEndTime <DateTime> -ReportedStartTime <DateTime> [-SubscriptionId <String[]>]
17+
[-AggregationGranularity <String>] [-ContinuationToken <String>] [-SubscriberId <String>]
18+
[-DefaultProfile <PSObject>] [<CommonParameters>]
19+
```
20+
21+
## DESCRIPTION
22+
Gets a collection of SubscriberUsageAggregates, which are UsageAggregates from users.
23+
24+
## EXAMPLES
25+
26+
### Example 1: {{ Add title here }}
27+
```powershell
28+
PS C:\> {{ Add code here }}
29+
30+
{{ Add output here }}
31+
```
32+
33+
{{ Add description here }}
34+
35+
### Example 2: {{ Add title here }}
36+
```powershell
37+
PS C:\> {{ Add code here }}
38+
39+
{{ Add output here }}
40+
```
41+
42+
{{ Add description here }}
43+
44+
## PARAMETERS
45+
46+
### -AggregationGranularity
47+
The aggregation granularity.
48+
49+
```yaml
50+
Type: System.String
51+
Parameter Sets: (All)
52+
Aliases:
53+
54+
Required: False
55+
Position: Named
56+
Default value: None
57+
Accept pipeline input: False
58+
Accept wildcard characters: False
59+
Dynamic: False
60+
```
61+
62+
### -ContinuationToken
63+
The continuation token.
64+
65+
```yaml
66+
Type: System.String
67+
Parameter Sets: (All)
68+
Aliases:
69+
70+
Required: False
71+
Position: Named
72+
Default value: None
73+
Accept pipeline input: False
74+
Accept wildcard characters: False
75+
Dynamic: False
76+
```
77+
78+
### -DefaultProfile
79+
The credentials, account, tenant, and subscription used for communication with Azure.
80+
81+
```yaml
82+
Type: System.Management.Automation.PSObject
83+
Parameter Sets: (All)
84+
Aliases: AzureRMContext, AzureCredential
85+
86+
Required: False
87+
Position: Named
88+
Default value: None
89+
Accept pipeline input: False
90+
Accept wildcard characters: False
91+
Dynamic: False
92+
```
93+
94+
### -ReportedEndTime
95+
The reported end time (exclusive).
96+
97+
```yaml
98+
Type: System.DateTime
99+
Parameter Sets: (All)
100+
Aliases:
101+
102+
Required: True
103+
Position: Named
104+
Default value: None
105+
Accept pipeline input: False
106+
Accept wildcard characters: False
107+
Dynamic: False
108+
```
109+
110+
### -ReportedStartTime
111+
The reported start time (inclusive).
112+
113+
```yaml
114+
Type: System.DateTime
115+
Parameter Sets: (All)
116+
Aliases:
117+
118+
Required: True
119+
Position: Named
120+
Default value: None
121+
Accept pipeline input: False
122+
Accept wildcard characters: False
123+
Dynamic: False
124+
```
125+
126+
### -SubscriberId
127+
The tenant subscription identifier.
128+
129+
```yaml
130+
Type: System.String
131+
Parameter Sets: (All)
132+
Aliases:
133+
134+
Required: False
135+
Position: Named
136+
Default value: None
137+
Accept pipeline input: False
138+
Accept wildcard characters: False
139+
Dynamic: False
140+
```
141+
142+
### -SubscriptionId
143+
Subscription credentials which uniquely identify Microsoft Azure subscription.The subscription ID forms part of the URI for every service call.
144+
145+
```yaml
146+
Type: System.String[]
147+
Parameter Sets: (All)
148+
Aliases:
149+
150+
Required: False
151+
Position: Named
152+
Default value: (Get-AzContext).Subscription.Id
153+
Accept pipeline input: False
154+
Accept wildcard characters: False
155+
Dynamic: False
156+
```
157+
158+
### CommonParameters
159+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
160+
161+
## INPUTS
162+
163+
## OUTPUTS
164+
165+
### Microsoft.Azure.PowerShell.Cmdlets.Commerce.Models.Api20150601Preview.IUsageAggregate
166+
167+
## ALIASES
168+
169+
## NOTES
170+
171+
## RELATED LINKS
172+

src/Azs.Commerce.Admin/docs/readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Docs
2+
This directory contains the documentation of the cmdlets for the `Azs.Commerce.Admin` module. To run documentation generation, use the `generate-help.ps1` script at the root module folder. Files in this folder will *always be overriden on regeneration*. To update documentation examples, please use the `..\examples` folder.
3+
4+
## Info
5+
- Modifiable: no
6+
- Generated: all
7+
- Committed: yes
8+
- Packaged: yes
9+
10+
## Details
11+
The process of documentation generation loads `Azs.Commerce.Admin` and analyzes the exported cmdlets from the module. It recognizes the [help comments](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help) that are generated into the scripts in the `..\exports` folder. Additionally, when writing custom cmdlets in the `..\custom` folder, you can use the help comments syntax, which decorate the exported scripts at build-time. The documentation examples are taken from the `..\examples` folder.

src/Azs.Commerce.Admin/readme.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- region Generated -->
22
# Azs.Commerce.Admin
3-
This directory contains the PowerShell module for the CommerceAdmin service.
3+
This directory contains the PowerShell module for the Commerce service.
44

55
---
66
## Status
@@ -48,14 +48,32 @@ In this directory, run AutoRest:
4848
``` yaml
4949
require:
5050
- $(this-folder)/../readme.azurestack.md
51-
- $(repo)/specification/azsadmin/resource-manager/commerce/readme.azsautogen.md
52-
- $(repo)/specification/azsadmin/resource-manager/commerce/readme.md
51+
52+
input-file:
53+
- $(repo)/specification/azsadmin/resource-manager/commerce/Microsoft.Commerce.Admin/preview/2015-06-01-preview/Commerce.json
5354

5455
subject-prefix: ''
5556
module-version: 0.0.1
56-
57+
```
5758
### File Renames
59+
``` yaml
5860
module-name: Azs.Commerce.Admin
5961
csproj: Azs.Commerce.Admin.csproj
6062
psd1: Azs.Commerce.Admin.psd1
6163
psm1: Azs.Commerce.Admin.psm1
64+
```
65+
66+
### Parameter default values
67+
``` yaml
68+
directive:
69+
# Remove UpdateEncryption cmdlets
70+
- where:
71+
subject: CommerceEncryption
72+
remove: true
73+
# Rename cmdlet from Get-AzsSubscriberUsageAggregate to Get-AzsSubscriberUsage
74+
- where:
75+
verb: Get
76+
subject: SubscriberUsageAggregate
77+
set:
78+
subject: SubscriberUsage
79+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$global:SkippedTests = @(
2+
)
3+
4+
$global:ReportedStartTime = "2019-12-10T11:00:00.0000000-08:00"
5+
$global:ReportedEndTime = "2019-12-10T12:00:00.0000000-08:00"
6+
$global:AggregationGranularity = "Hourly"
7+
8+
function ValidateAzsSubscriberUsage {
9+
param(
10+
[Parameter(Mandatory = $true)]
11+
$usageRecords
12+
)
13+
14+
$usageRecords.Count | Should BeGreaterThan 0
15+
foreach ($record in $usageRecords)
16+
{
17+
$record.UsageStartTime | Should Not Be $null
18+
$record.UsageEndTime | Should Not Be $null
19+
## TODO: Current quantity is not picked up
20+
## Pester v3 does not support BeGreaterOrEqual
21+
#$record.Quantity -ge 0 | Should Be $true
22+
$record.MeterId | Should Not Be $null
23+
$record.SubscriptionId | Should Not Be $null
24+
25+
# resource data is stored as a JSON inside InstanceData.
26+
$resource = ($record.InstanceData | ConvertFrom-Json).'Microsoft.Resources'
27+
$resource | Should Not Be $null
28+
$resource.resourceUri | Should Not Be $null
29+
$resource.location | Should Not Be $null
30+
31+
# tags and additionalInfo value can be empty but should still exist
32+
$resource | Get-Member "tags" | Should Not Be $null
33+
$resource | Get-Member "additionalInfo" | Should Not Be $null
34+
}
35+
}

src/Azs.Commerce.Admin/test/Get-AzsSubscriberUsage.Recording.json

Lines changed: 197 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
2+
if (-Not (Test-Path -Path $loadEnvPath)) {
3+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
4+
}
5+
. ($loadEnvPath)
6+
$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzsSubscriberUsage.Recording.json'
7+
$currentPath = $PSScriptRoot
8+
while(-not $mockingPath) {
9+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
10+
$currentPath = Split-Path -Path $currentPath -Parent
11+
}
12+
. ($mockingPath | Select-Object -First 1).FullName
13+
14+
15+
16+
17+
Describe 'Get-AzsSubscriberUsage' {
18+
19+
. $PSScriptRoot\Common.ps1
20+
21+
AfterEach {
22+
$global:Client = $null
23+
}
24+
25+
It 'TestGetAzsSubscriberUsage' -Skip:$('TestGetAzsSubscriberUsage' -in $Global:SkippedTests) {
26+
$Global:TestName = 'TestGetAzsSubscriberUsage'
27+
$usageRecords = Get-AzsSubscriberUsage `
28+
-ReportedStartTime $global:ReportedStartTime `
29+
-ReportedEndTime $global:ReportedEndTime `
30+
-AggregationGranularity $global:AggregationGranularity
31+
32+
ValidateAzsSubscriberUsage $usageRecords
33+
}
34+
}

0 commit comments

Comments
 (0)