Skip to content

Commit

Permalink
Using the latest version of autorest to generate code for 'costmanage…
Browse files Browse the repository at this point in the history
…ment' (#14048)

* Move CostManagement to master

* update the changelog

* update the changelog file

Co-authored-by: azurepowershell <[email protected]>
  • Loading branch information
Youri970410 and azurepowershell authored Feb 1, 2021
1 parent b1f6084 commit b07aa0b
Show file tree
Hide file tree
Showing 252 changed files with 2,658 additions and 2,599 deletions.
8 changes: 4 additions & 4 deletions src/CostManagement/Az.CostManagement.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1466,9 +1466,9 @@
</TableControl>
</View>
<View>
<Name>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1</Name>
<Name>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAutoGenerated</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1</TypeName>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAutoGenerated</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
Expand Down Expand Up @@ -1538,9 +1538,9 @@
</TableControl>
</View>
<View>
<Name>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition1</Name>
<Name>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinitionAutoGenerated</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition1</TypeName>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinitionAutoGenerated</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
Expand Down
4 changes: 2 additions & 2 deletions src/CostManagement/Az.CostManagement.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 2020-12-02
# Generated on: 1/28/2021
#

@{
Expand Down Expand Up @@ -113,7 +113,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* First preview release for module Az.CostManagement.'
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''
Expand Down
10 changes: 5 additions & 5 deletions src/CostManagement/Az.CostManagement.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
}
}
if(-not $accountsModule) {
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.2.3' } | Measure-Object).Count -gt 0
if($hasAdequateVersion) {
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.2.3 -Scope Global -PassThru
}
}
}

if(-not $accountsModule) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
}
Write-Information "Loaded Module '$($accountsModule.Name)'"

Expand Down
1 change: 1 addition & 0 deletions src/CostManagement/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fixed an error that the CostmanagementExport could not be updated correctly

## Version 0.1.0
* First preview release for module Az.CostManagement
Expand Down
2 changes: 1 addition & 1 deletion src/CostManagement/build-module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $null = New-Item -ItemType Directory -Force -Path $examplesFolder

if($NoDocs) {
Write-Host -ForegroundColor Green 'Creating exports...'
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder
} else {
Write-Host -ForegroundColor Green 'Creating exports and docs...'
$moduleDescription = 'Microsoft Azure PowerShell: Cost cmdlets'
Expand Down
4 changes: 2 additions & 2 deletions src/CostManagement/check-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if(Test-Path -Path $localModulesPath) {
$env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
}

DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1'
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '2.2.3'
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'

$tools = Join-Path $PSScriptRoot 'tools'
Expand All @@ -56,7 +56,7 @@ $resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestS
if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) {
Write-Host -ForegroundColor Green "Building local Resource module used for test..."
Set-Location $resourceDir
$null = autorest-beta .\readme.md --output-folder=$HOME/.PSSharedModules/Resources
$null = autorest .\readme.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
$null = Copy-Item custom/* $HOME/.PSSharedModules/Resources/custom/
Set-Location $HOME/.PSSharedModules/Resources
$null = .\build-module.ps1
Expand Down
7 changes: 0 additions & 7 deletions src/CostManagement/custom/New-AzCostManagementExport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ param(
# The name of the directory where exports will be uploaded.
${DestinationRootFolderPath},

# [Parameter()]
# [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')]
# [System.String]
# # eTag of the resource.
# # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
# ${ETag},

[Parameter()]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])]
[Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ function New-AzCostManagementQueryComparisonExpressionObject {
$Object = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression]::New()

$Object.Name = $Name
$Object.Operator = $Operator
# Description: The type of the Operator is enum,but it only contains one value,so the parameter is not exposed now.
# $Object.Operator = $Operator
$Object.Value = $Value
return $Object
}
Expand Down
16 changes: 13 additions & 3 deletions src/CostManagement/custom/Update-AzCostManagementExport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,26 @@ param(

process {
try {
$getExport
$CommonPSBoundParameters = @{}
if ($PSBoundParameters.ContainsKey('HttpPipelineAppend')) {
$CommonPSBoundParameters['HttpPipelineAppend'] = $HttpPipelineAppend
}
if ($PSBoundParameters.ContainsKey('HttpPipelinePrepend')) {
$CommonPSBoundParameters['HttpPipelinePrepend'] = $HttpPipelinePrepend
}
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
$CommonPSBoundParameters['SubscriptionId'] = $SubscriptionId
}
if($PSBoundParameters['InputObject'] -ne $null)
{
$InputExportObject = $PSBoundParameters['InputObject']
$getExport = Get-AzCostManagementExport -InputObject $InputExportObject
$getExport = Get-AzCostManagementExport -InputObject $InputExportObject @CommonPSBoundParameters
}else{
$InputExportScope = $PSBoundParameters['Scope']
$InputExportName = $PSBoundParameters['Name']
$getExport = Get-AzCostManagementExport -Scope $InputExportScope -Name $InputExportName
$getExport = Get-AzCostManagementExport -Scope $InputExportScope -Name $InputExportName @CommonPSBoundParameters
}

$null = $PSBoundParameters.Add("ETag",$getExport.Etag)
if($PSBoundParameters['DataSetGranularity'] -eq $null)
{
Expand Down
8 changes: 4 additions & 4 deletions src/CostManagement/custom/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ These provide functionality to our HTTP pipeline and other useful features. In s

### Attributes
For processing the cmdlets, we've created some additional attributes:
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.DescriptionAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DescriptionAttribute`
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.DoNotExportAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotExportAttribute`
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.CostManagement`.
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.InternalExportAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.InternalExportAttribute`
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.CostManagement`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder.
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ProfileAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ProfileAttribute`
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Invoke AzCostManagementQuery by Scope

### Example 2: Invoke AzCostManagementQuery by Scope with Dimensions
```powershell
PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator 'In' -Value 'API'
PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Value 'API'
$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions
Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Example 1: Create a comparison expression object of query for cost management export
```powershell
PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe')
PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Value @('East US', 'West Europe')
Name Operator Value
---- -------- -----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Example 1: Create a filter object of query for cost management export
```powershell
PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe')
PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod')
PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Value @('East US', 'West Europe')
PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Value @('UAT', 'Prod')
PS C:\> New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag))
And :
Expand Down
3 changes: 1 addition & 2 deletions src/CostManagement/exports/Invoke-AzCostManagementQuery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Column Row
------ ---
{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…}
.Example
PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator 'In' -Value 'API'
PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Value 'API'
$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions
Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug
Expand All @@ -45,7 +45,6 @@ DATASETFILTER <IQueryFilter>: Has filter expression to use in the query.
[And <IQueryFilter[]>]: The logical "AND" expression. Must have at least 2 items.
[Dimensions <IQueryComparisonExpression>]: Has comparison expression for a dimension
Name <String>: The name of the column to use in comparison.
Operator <OperatorType>: The operator to use for comparison.
Value <String[]>: Array of values to use for comparison
[Not <IQueryFilter>]: The logical "NOT" expression.
[Or <IQueryFilter[]>]: The logical "OR" expression. Must have at least 2 items.
Expand Down
6 changes: 0 additions & 6 deletions src/CostManagement/exports/New-AzCostManagementExport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ param(
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])]
[Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType]
# [Parameter()]
# [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')]
# [System.String]
# # eTag of the resource.
# # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
# ${ETag},
# The format of the export being delivered.
# Currently only 'Csv' is supported.
${Format},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Create a in-memory object for QueryComparisonExpression
.Description
Create a in-memory object for QueryComparisonExpression
.Example
PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe')
PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Value @('East US', 'West Europe')
Name Operator Value
---- -------- -----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Create a in-memory object for QueryFilter
.Description
Create a in-memory object for QueryFilter
.Example
PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe')
PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod')
PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Value @('East US', 'West Europe')
PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Value @('UAT', 'Prod')
PS C:\> New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag))
And :
Expand All @@ -40,22 +40,19 @@ AND <IQueryFilter[]>: The logical "AND" expression. Must have at least 2 items.
[And <IQueryFilter[]>]: The logical "AND" expression. Must have at least 2 items.
[Dimensions <IQueryComparisonExpression>]: Has comparison expression for a dimension
Name <String>: The name of the column to use in comparison.
Operator <OperatorType>: The operator to use for comparison.
Value <String[]>: Array of values to use for comparison
[Not <IQueryFilter>]: The logical "NOT" expression.
[Or <IQueryFilter[]>]: The logical "OR" expression. Must have at least 2 items.
[Tag <IQueryComparisonExpression>]: Has comparison expression for a tag
DIMENSIONS <IQueryComparisonExpression>: Has comparison expression for a dimensions.
Name <String>: The name of the column to use in comparison.
Operator <OperatorType>: The operator to use for comparison.
Value <String[]>: Array of values to use for comparison
NOT <IQueryFilter>: The logical "NOT" expression.
[And <IQueryFilter[]>]: The logical "AND" expression. Must have at least 2 items.
[Dimensions <IQueryComparisonExpression>]: Has comparison expression for a dimension
Name <String>: The name of the column to use in comparison.
Operator <OperatorType>: The operator to use for comparison.
Value <String[]>: Array of values to use for comparison
[Not <IQueryFilter>]: The logical "NOT" expression.
[Or <IQueryFilter[]>]: The logical "OR" expression. Must have at least 2 items.
Expand All @@ -65,15 +62,13 @@ OR <IQueryFilter[]>: The logical "OR" expression. Must have at least 2 items.
[And <IQueryFilter[]>]: The logical "AND" expression. Must have at least 2 items.
[Dimensions <IQueryComparisonExpression>]: Has comparison expression for a dimension
Name <String>: The name of the column to use in comparison.
Operator <OperatorType>: The operator to use for comparison.
Value <String[]>: Array of values to use for comparison
[Not <IQueryFilter>]: The logical "NOT" expression.
[Or <IQueryFilter[]>]: The logical "OR" expression. Must have at least 2 items.
[Tag <IQueryComparisonExpression>]: Has comparison expression for a tag
TAG <IQueryComparisonExpression>: Has comparison expression for a tag.
Name <String>: The name of the column to use in comparison.
Operator <OperatorType>: The operator to use for comparison.
Value <String[]>: Array of values to use for comparison
.Link
https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryFilterObject
Expand Down
Loading

0 comments on commit b07aa0b

Please sign in to comment.