Skip to content

Commit 355a6c8

Browse files
JoyerJindolauli
andauthored
[Azure Monitor] Metrics Data Plane API 2023-10-01 (#23695)
* Azure Monitor Metrics Data Plane API 2023-05-01-Preview Client tools * [MetricBatch] change the module name Make module name the same as folder name * Update README.md * Update to stable version * CI failure Test * Remove Metric manage plane --------- Co-authored-by: Xiaogang <[email protected]>
1 parent 8264e8f commit 355a6c8

19 files changed

+2092
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bin
2+
obj
3+
.vs
4+
generated
5+
internal
6+
exports
7+
tools
8+
custom/*.psm1
9+
custom/autogen-model-cmdlets
10+
test/*-TestResults.xml
11+
/*.ps1
12+
/*.ps1xml
13+
/*.psm1
14+
/*.snk
15+
/*.csproj
16+
/*.nuspec
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@{
2+
GUID = '405fa9b2-77ec-4b07-8793-e29abba71a28'
3+
RootModule = './Az.Metric.psm1'
4+
ModuleVersion = '0.1.0'
5+
CompatiblePSEditions = 'Core', 'Desktop'
6+
Author = 'Microsoft Corporation'
7+
CompanyName = 'Microsoft Corporation'
8+
Copyright = 'Microsoft Corporation. All rights reserved.'
9+
Description = 'Microsoft Azure PowerShell: Metric cmdlets'
10+
PowerShellVersion = '5.1'
11+
DotNetFrameworkVersion = '4.7.2'
12+
RequiredAssemblies = './bin/Az.Metric.private.dll'
13+
FormatsToProcess = './Az.Metric.format.ps1xml'
14+
FunctionsToExport = 'Get-AzMetricsBatch'
15+
PrivateData = @{
16+
PSData = @{
17+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'Metric'
18+
LicenseUri = 'https://aka.ms/azps-license'
19+
ProjectUri = 'https://github.com/Azure/azure-powershell'
20+
ReleaseNotes = ''
21+
}
22+
}
23+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!-- region Generated -->
2+
# Az.Metric
3+
This directory contains the PowerShell module for the Metric service.
4+
5+
---
6+
## Status
7+
[![Az.Metric](https://img.shields.io/powershellgallery/v/Az.Metric.svg?style=flat-square&label=Az.Metric "Az.Metric")](https://www.powershellgallery.com/packages/Az.Metric/)
8+
9+
## Info
10+
- Modifiable: yes
11+
- Generated: all
12+
- Committed: yes
13+
- Packaged: yes
14+
15+
---
16+
## Detail
17+
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
18+
19+
## Module Requirements
20+
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater
21+
22+
## Authentication
23+
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.
24+
25+
## Development
26+
For information on how to develop for `Az.Metric`, see [how-to.md](how-to.md).
27+
<!-- endregion -->
28+
29+
### AutoRest Configuration
30+
> see https://aka.ms/autorest
31+
32+
```yaml
33+
# pin the swagger version by using the commit id instead of branch name
34+
require:
35+
# readme.azure.noprofile.md is the common configuration file
36+
- $(this-folder)/../../readme.azure.noprofile.md
37+
commit: 0373f0edc4414fd402603fac51d0df93f1f70507
38+
39+
input-file:
40+
- $(repo)/specification/monitor/data-plane/Microsoft.Insights/stable/2023-10-01/metricBatch.json
41+
42+
root-module-name: $(prefix).Monitor
43+
title: Metric
44+
module-name: Az.Metric
45+
module-version: 0.1.0
46+
subject-prefix: ""
47+
48+
directive:
49+
- where:
50+
subject: BatchMetricsBatch
51+
verb: Invoke
52+
set:
53+
verb: Get
54+
subject: MetricsBatch
55+
- where:
56+
subject: MetricsBatch
57+
variant: ^(Batch)(?!.*?Expanded)
58+
remove: true
59+
# Case Sensitive
60+
- where:
61+
parameter-name: Metricname
62+
set:
63+
parameter-name: Name
64+
alias: MetricName
65+
- where:
66+
parameter-name: Metricnamespace
67+
set:
68+
parameter-name: Namespace
69+
alias: MetricNamespace
70+
- where:
71+
subject: MetricsBatch
72+
parameter-name: Starttime
73+
set:
74+
parameter-name: StartTime
75+
- where:
76+
subject: MetricsBatch
77+
parameter-name: Endtime
78+
set:
79+
parameter-name: EndTime
80+
- where:
81+
subject: MetricsBatch
82+
parameter-name: Resourceid
83+
set:
84+
parameter-name: ResourceId
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Custom
2+
This directory contains custom implementation for non-generated cmdlets for the `Az.Metric` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Az.Metric.custom.psm1`. This file should not be modified.
3+
4+
## Info
5+
- Modifiable: yes
6+
- Generated: partial
7+
- Committed: yes
8+
- Packaged: yes
9+
10+
## Details
11+
For `Az.Metric` to use custom cmdlets, it does this two different ways. We **highly recommend** creating script cmdlets, as they are easier to write and allow access to the other exported cmdlets. C# cmdlets *cannot access exported cmdlets*.
12+
13+
For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.Metric.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder.
14+
15+
For script cmdlets, these are loaded via the `Az.Metric.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.
16+
17+
## Purpose
18+
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder.
19+
20+
## Usage
21+
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
22+
- Break
23+
- DefaultProfile
24+
- HttpPipelineAppend
25+
- HttpPipelinePrepend
26+
- Proxy
27+
- ProxyCredential
28+
- ProxyUseDefaultCredentials
29+
30+
These provide functionality to our HTTP pipeline and other useful features. In script, you can forward these parameters using `$PSBoundParameters` to the other cmdlets you're calling within `Az.Metric`. For C#, follow the usage seen in the `ProcessRecordAsync` method.
31+
32+
### Attributes
33+
For processing the cmdlets, we've created some additional attributes:
34+
- `Microsoft.Azure.PowerShell.Cmdlets.Metric.DescriptionAttribute`
35+
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
36+
- `Microsoft.Azure.PowerShell.Cmdlets.Metric.DoNotExportAttribute`
37+
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.Metric`.
38+
- `Microsoft.Azure.PowerShell.Cmdlets.Metric.InternalExportAttribute`
39+
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.Metric`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
40+
- `Microsoft.Azure.PowerShell.Cmdlets.Metric.ProfileAttribute`
41+
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
Module Name: Az.Metric
3+
Module Guid: 405fa9b2-77ec-4b07-8793-e29abba71a28
4+
Download Help Link: https://learn.microsoft.com/powershell/module/az.metric
5+
Help Version: 1.0.0.0
6+
Locale: en-US
7+
---
8+
9+
# Az.Metric Module
10+
## Description
11+
Microsoft Azure PowerShell: Metric cmdlets
12+
13+
## Az.Metric Cmdlets
14+
### [Get-AzMetricsBatch](Get-AzMetricsBatch.md)
15+
Lists the metric values for multiple resources.
16+

0 commit comments

Comments
 (0)