Skip to content

Commit ef83b1a

Browse files
JoyerJinYanaXu
andauthored
[StorageAction] onboard StorageAction with autorest (#24841)
* feature storage action 20240131 * Storage Action feature test cases and examples * Storage Action test added * Added swagger fix * Update commit id from swagger main * Update commit * Update example * Update src/StorageAction/StorageAction.Autorest/docs/New-AzStorageActionTask.md * Update src/StorageAction/StorageAction.Autorest/docs/New-AzStorageActionTask.md * Update example --------- Co-authored-by: Yan Xu <[email protected]>
1 parent fff8899 commit ef83b1a

File tree

54 files changed

+4884
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4884
-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 = 'cc1d1de1-1601-4440-82c6-76c6673d8aba'
3+
RootModule = './Az.StorageAction.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: StorageAction cmdlets'
10+
PowerShellVersion = '5.1'
11+
DotNetFrameworkVersion = '4.7.2'
12+
RequiredAssemblies = './bin/Az.StorageAction.private.dll'
13+
FormatsToProcess = './Az.StorageAction.format.ps1xml'
14+
FunctionsToExport = 'Get-AzStorageActionTask', 'Get-AzStorageActionTaskAssignment', 'Get-AzStorageActionTasksReport', 'Invoke-AzStorageActionTaskPreviewAction', 'New-AzStorageActionTask', 'New-AzStorageActionTaskOperationObject', 'New-AzStorageActionTaskPreviewBlobPropertiesObject', 'New-AzStorageActionTaskPreviewKeyValuePropertiesObject', 'Remove-AzStorageActionTask', 'Update-AzStorageActionTask'
15+
PrivateData = @{
16+
PSData = @{
17+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'StorageAction'
18+
LicenseUri = 'https://aka.ms/azps-license'
19+
ProjectUri = 'https://github.com/Azure/azure-powershell'
20+
ReleaseNotes = ''
21+
}
22+
}
23+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!-- region Generated -->
2+
# Az.StorageAction
3+
This directory contains the PowerShell module for the StorageAction service.
4+
5+
---
6+
## Info
7+
- Modifiable: yes
8+
- Generated: all
9+
- Committed: yes
10+
- Packaged: yes
11+
12+
---
13+
## Detail
14+
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
15+
16+
## Module Requirements
17+
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater
18+
19+
## Authentication
20+
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.
21+
22+
## Development
23+
For information on how to develop for `Az.StorageAction`, see [how-to.md](how-to.md).
24+
<!-- endregion -->
25+
26+
### AutoRest Configuration
27+
> see https://aka.ms/autorest
28+
29+
```yaml
30+
# pin the swagger version by using the commit id instead of branch name
31+
commit: 8f196886782fc5b48b75322944dc60d1cafaf7fa
32+
tag: package-2023-01-01
33+
require:
34+
# readme.azure.noprofile.md is the common configuration file
35+
- $(this-folder)/../../readme.azure.noprofile.md
36+
- $(repo)/specification/storageactions/resource-manager/readme.md
37+
# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally
38+
# - (this-folder)/relative-path-to-your-local-readme.md
39+
40+
try-require:
41+
- $(repo)/specification/storageactions/resource-manager/readme.powershell.md
42+
43+
# The next three configurations are activated by default.
44+
# identity-correction-for-post: true
45+
# resourcegroup-append: true
46+
# nested-object-to-string: true
47+
48+
# For new RP, the version is 0.1.0
49+
module-version: 0.1.0
50+
# Normally, title is the service name
51+
title: StorageAction
52+
subject-prefix: $(service-name)
53+
54+
directive:
55+
# # Following are common directives which are normally required in all the RPs
56+
# # 1. Remove the unexpanded parameter set
57+
# # 2. For New-* cmdlets, ViaIdentity is not required
58+
# # Following two directives are v4 specific
59+
- where:
60+
variant: ^(Create|Update|Preview)(?!.*?(Expanded|JsonFilePath|JsonString))
61+
remove: true
62+
- where:
63+
variant: ^CreateViaIdentity.*$
64+
remove: true
65+
# Rename commands
66+
- where:
67+
subject: StorageTask
68+
set:
69+
subject: Task
70+
- where:
71+
verb: Invoke
72+
subject: PreviewStorageTaskAction
73+
set:
74+
subject: TaskPreviewAction
75+
- where:
76+
subject: StorageTaskAssignment
77+
set:
78+
subject: TaskAssignment
79+
- where:
80+
subject: StorageTasksReport
81+
set:
82+
subject: TasksReport
83+
# Add model
84+
- model-cmdlet:
85+
- model-name: StorageTaskOperation
86+
cmdlet-name: New-AzStorageActionTaskOperationObject
87+
- model-name: StorageTaskPreviewBlobProperties
88+
cmdlet-name: New-AzStorageActionTaskPreviewBlobPropertiesObject
89+
- model-name: StorageTaskPreviewKeyValueProperties
90+
cmdlet-name: New-AzStorageActionTaskPreviewKeyValuePropertiesObject
91+
```
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"resourceType": "storageTasks",
3+
"apiVersion": "2023-01-01",
4+
"learnMore": {
5+
"url": "https://learn.microsoft.com/powershell/module/az.storageaction"
6+
},
7+
"commands": [
8+
{
9+
"name": "Get-AzStorageActionTask",
10+
"description": "Get the storage task properties",
11+
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}",
12+
"help": {
13+
"learnMore": {
14+
"url": "https://learn.microsoft.com/powershell/module/az.storageaction/get-azstorageactiontask"
15+
},
16+
"parameterSets": [
17+
{
18+
"parameters": [
19+
"-Name <String>",
20+
"-ResourceGroupName <String>",
21+
"[-SubscriptionId <String[]>]"
22+
]
23+
}
24+
]
25+
},
26+
"examples": [
27+
{
28+
"description": "Get the storage task properties",
29+
"parameters": [
30+
{
31+
"name": "-Name",
32+
"value": "[Path.storageTaskName]"
33+
},
34+
{
35+
"name": "-ResourceGroupName",
36+
"value": "[Path.resourceGroupName]"
37+
},
38+
{
39+
"name": "-SubscriptionId",
40+
"value": "[Path.subscriptionId]"
41+
}
42+
]
43+
}
44+
]
45+
},
46+
{
47+
"name": "Remove-AzStorageActionTask",
48+
"description": "Delete the storage task resource.",
49+
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageActions/storageTasks/{storageTaskName}",
50+
"help": {
51+
"learnMore": {
52+
"url": "https://learn.microsoft.com/powershell/module/az.storageaction/remove-azstorageactiontask"
53+
},
54+
"parameterSets": [
55+
{
56+
"parameters": [
57+
"-Name <String>",
58+
"-ResourceGroupName <String>",
59+
"[-SubscriptionId <String>]"
60+
]
61+
}
62+
]
63+
},
64+
"examples": [
65+
{
66+
"description": "Delete the storage task resource.",
67+
"parameters": [
68+
{
69+
"name": "-Name",
70+
"value": "[Path.storageTaskName]"
71+
},
72+
{
73+
"name": "-ResourceGroupName",
74+
"value": "[Path.resourceGroupName]"
75+
},
76+
{
77+
"name": "-SubscriptionId",
78+
"value": "[Path.subscriptionId]"
79+
}
80+
]
81+
}
82+
]
83+
}
84+
]
85+
}
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.StorageAction` 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.StorageAction.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.StorageAction` 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.StorageAction.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.StorageAction.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.StorageAction`. 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.StorageAction.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.StorageAction.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.StorageAction`.
38+
- `Microsoft.Azure.PowerShell.Cmdlets.StorageAction.InternalExportAttribute`
39+
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.StorageAction`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
40+
- `Microsoft.Azure.PowerShell.Cmdlets.StorageAction.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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
Module Name: Az.StorageAction
3+
Module Guid: cc1d1de1-1601-4440-82c6-76c6673d8aba
4+
Download Help Link: https://learn.microsoft.com/powershell/module/az.storageaction
5+
Help Version: 1.0.0.0
6+
Locale: en-US
7+
---
8+
9+
# Az.StorageAction Module
10+
## Description
11+
Microsoft Azure PowerShell: StorageAction cmdlets
12+
13+
## Az.StorageAction Cmdlets
14+
### [Get-AzStorageActionTask](Get-AzStorageActionTask.md)
15+
Get the storage task properties
16+
17+
### [Get-AzStorageActionTaskAssignment](Get-AzStorageActionTaskAssignment.md)
18+
Lists Resource IDs of the Storage Task Assignments associated with this Storage Task.
19+
20+
### [Get-AzStorageActionTasksReport](Get-AzStorageActionTasksReport.md)
21+
Fetch the storage tasks run report summary for each assignment.
22+
23+
### [Invoke-AzStorageActionTaskPreviewAction](Invoke-AzStorageActionTaskPreviewAction.md)
24+
Runs the input conditions against input object metadata properties and designates matched objects in response.
25+
26+
### [New-AzStorageActionTask](New-AzStorageActionTask.md)
27+
Asynchronously creates a new storage task resource with the specified parameters.
28+
If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated.
29+
If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed.
30+
31+
### [New-AzStorageActionTaskOperationObject](New-AzStorageActionTaskOperationObject.md)
32+
Create an in-memory object for StorageTaskOperation.
33+
34+
### [New-AzStorageActionTaskPreviewBlobPropertiesObject](New-AzStorageActionTaskPreviewBlobPropertiesObject.md)
35+
Create an in-memory object for StorageTaskPreviewBlobProperties.
36+
37+
### [New-AzStorageActionTaskPreviewKeyValuePropertiesObject](New-AzStorageActionTaskPreviewKeyValuePropertiesObject.md)
38+
Create an in-memory object for StorageTaskPreviewKeyValueProperties.
39+
40+
### [Remove-AzStorageActionTask](Remove-AzStorageActionTask.md)
41+
Delete the storage task resource.
42+
43+
### [Update-AzStorageActionTask](Update-AzStorageActionTask.md)
44+
Asynchronously creates a new storage task resource with the specified parameters.
45+
If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated.
46+
If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed.
47+

0 commit comments

Comments
 (0)