Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmdlets for Microsoft.Computeschedule #26896

Merged
merged 17 commits into from
Dec 20, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
18 changes: 18 additions & 0 deletions src/ComputeSchedule/ComputeSchedule.AutoRest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bin
obj
.vs
generated
internal
exports
tools
custom/*.psm1
custom/autogen-model-cmdlets
test/*-TestResults.xml
license.txt
/*.ps1
/*.psd1
/*.ps1xml
/*.psm1
/*.snk
/*.csproj
/*.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the ""License"");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ""AS IS"" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
// is regenerated.

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - ComputeSchedule")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.0.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.1.0.0")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]
238 changes: 238 additions & 0 deletions src/ComputeSchedule/ComputeSchedule.AutoRest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
<!-- region Generated -->
# Az.ComputeSchedule
This directory contains the PowerShell module for the ComputeSchedule service.

---
## Info
- Modifiable: yes
- Generated: all
- Committed: yes
- Packaged: yes

---
## Detail
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.

## Module Requirements
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater

## Authentication
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.

## Development
For information on how to develop for `Az.ComputeSchedule`, see [how-to.md](how-to.md).
<!-- endregion -->

### AutoRest Configuration
> see https://aka.ms/autorest

```yaml
# pin the swagger version by using the commit id instead of branch name
commit: edcf57995e73f9662a4060586f0308bb999d7493
tag: package-2024-10-01
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
- $(repo)/specification/computeschedule/resource-manager/readme.md
# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally
# - (this-folder)/relative-path-to-your-local-readme.md

try-require:
- $(repo)/specification/computeschedule/resource-manager/readme.powershell.md

# For new RP, the version is 0.1.0
module-version: 0.1.0
# Normally, title is the service name
title: ComputeSchedule
subject-prefix: $(service-name)

# The next three configurations are exclusive to v3, and in v4, they are activated by default. If you are still using v3, please uncomment them.
# identity-correction-for-post: true
# resourcegroup-append: true
# nested-object-to-string: true

directive:
# Following are common directives which are normally required in all the RPs
# 1. Remove the unexpanded parameter set
# 2. For New-* cmdlets, ViaIdentity is not required
# Following two directives are v4 specific
- where:
variant: ^(Create|Update|Invoke|Execute|Submit)(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true
- where:
variant: ^CreateViaIdentity.*$
remove: true
# Follow directive is v3 specific. If you are using v3, uncomment following directive and comments out two directives above
#- where:
# variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$
# remove: true

- where:
subject: ScheduledAction
variant: ^(Get)(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true

# rename camelCase properties
- from: computeschedule.json
where: "$.definitions.OperationErrorDetails.properties.timeStamp"
transform: >
$ = undefined
- from: computeschedule.json
where: "$.definitions.Schedule.properties.timeZone"
transform: >
$ = undefined
- from: computeschedule.json
where: "$.definitions.ResourceOperationDetails.properties.timeZone"
transform: >
$ = undefined
- from: computeschedule.json
where: "$.definitions.Schedule.properties.deadLine"
transform: >
$ = undefined

# Rename cmdlets to expose endpoints
- where:
verb: Get
subject: ScheduledAction
variant: GetExpanded
set:
subject: OperationError

- where:
verb: Get
subject: ScheduledAction
variant: GetExpanded1
set:
subject: OperationStatus

- where:
verb: Invoke
subject: ExecuteScheduledAction
variant: ExecuteExpanded
set:
subject: ExecuteDeallocate

- where:
verb: Invoke
subject: ExecuteScheduledAction
variant: ExecuteExpanded1
set:
subject: ExecuteHibernate

- where:
verb: Invoke
subject: ExecuteScheduledAction
variant: ExecuteExpanded2
set:
subject: ExecuteStart

- where:
verb: Submit
subject: ScheduledAction
variant: SubmitExpanded
set:
verb: Invoke
subject: SubmitDeallocate

- where:
verb: Submit
subject: ScheduledAction
variant: SubmitExpanded1
set:
verb: Invoke
subject: SubmitHibernate

- where:
verb: Submit
subject: ScheduledAction
variant: SubmitExpanded2
set:
verb: Invoke
subject: SubmitStart

- where:
verb: Stop
subject: ScheduledAction
variant: CancelViaIdentityExpanded
set:
verb: Stop
subject: Operation

# Hide initial cmdlets generated with all endpoints grouped
- where:
verb: Invoke
subject: ExecuteScheduledAction
hide: true

- where:
verb: Submit
subject: ScheduledAction
hide: true

- where:
verb: Get
subject: ScheduledAction
hide: true

# rename parameters
- where:
verb: Invoke
subject: ^(Submit|Execute)(.*)
parameter-name: RetryPolicyRetryCount
set:
parameter-name: RetryCount

- where:
verb: Invoke
subject: ^(Submit|Execute)(.*)
parameter-name: RetryPolicyRetryWindowInMinute
set:
parameter-name: RetryWindowInMinutes

- where:
verb: Invoke|Get|Stop
subject: ^(Submit|Execute|Operation|Scheduled)(.*)
parameter-name: Locationparameter
set:
parameter-name: Location

- where:
verb: Invoke|Get|Stop
subject: ^(Submit|Execute|Operation)(.*)
parameter-name: Correlationid
set:
parameter-name: CorrelationId

- where:
verb: Invoke
subject: ^(Submit)(.*)
parameter-name: ScheduleDeadLine
set:
parameter-name: Deadline

- where:
verb: Invoke
subject: ^(Submit)(.*)
parameter-name: ScheduleDeadlineType
set:
parameter-name: DeadlineType

- where:
verb: Invoke
subject: ^(Submit)(.*)
parameter-name: ScheduleTimeZone
set:
parameter-name: Timezone

# Hide OptimizationPreference paramater
- where:
verb: Invoke
subject: ^(Submit|Execute)(.*)
parameter-name: ExecutionParameterOptimizationPreference
hide: true

# Remove the set-* cmdlet
- where:
verb: Set
remove: true
```
41 changes: 41 additions & 0 deletions src/ComputeSchedule/ComputeSchedule.AutoRest/custom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Custom
This directory contains custom implementation for non-generated cmdlets for the `Az.ComputeSchedule` 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.ComputeSchedule.custom.psm1`. This file should not be modified.

## Info
- Modifiable: yes
- Generated: partial
- Committed: yes
- Packaged: yes

## Details
For `Az.ComputeSchedule` 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*.

For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.ComputeSchedule.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.

For script cmdlets, these are loaded via the `Az.ComputeSchedule.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.

## Purpose
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.

## Usage
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:
- Break
- DefaultProfile
- HttpPipelineAppend
- HttpPipelinePrepend
- Proxy
- ProxyCredential
- ProxyUseDefaultCredentials

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.ComputeSchedule`. For C#, follow the usage seen in the `ProcessRecordAsync` method.

### Attributes
For processing the cmdlets, we've created some additional attributes:
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeSchedule.DescriptionAttribute`
- 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.
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeSchedule.DoNotExportAttribute`
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.ComputeSchedule`.
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeSchedule.InternalExportAttribute`
- Used in C# cmdlets to route exported cmdlets to the `../internal`, which are *not exposed* by `Az.ComputeSchedule`. For more information, see [README.md](../internal/README.md) in the `../internal` folder.
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeSchedule.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
@@ -0,0 +1,40 @@
---
Module Name: Az.ComputeSchedule
Module Guid: 8f0c4021-6794-4351-9818-b5b1b3977774
Download Help Link: https://learn.microsoft.com/powershell/module/az.computeschedule
Help Version: 1.0.0.0
Locale: en-US
---

# Az.ComputeSchedule Module
## Description
Microsoft Azure PowerShell: ComputeSchedule cmdlets

## Az.ComputeSchedule Cmdlets
### [Get-AzComputeScheduleOperationError](Get-AzComputeScheduleOperationError.md)
VirtualMachinesGetOperationErrors: Get error details on operation errors (like transient errors encountered, additional logs) if they exist.

### [Get-AzComputeScheduleOperationStatus](Get-AzComputeScheduleOperationStatus.md)
VirtualMachinesGetOperationStatus: Polling endpoint to read status of operations performed on virtual machines

### [Invoke-AzComputeScheduleExecuteDeallocate](Invoke-AzComputeScheduleExecuteDeallocate.md)
VirtualMachinesExecuteDeallocate: Execute deallocate operation for a batch of virtual machines, this operation is triggered as soon as Computeschedule receives it.

### [Invoke-AzComputeScheduleExecuteHibernate](Invoke-AzComputeScheduleExecuteHibernate.md)
VirtualMachinesExecuteHibernate: Execute hibernate operation for a batch of virtual machines, this operation is triggered as soon as Computeschedule receives it.

### [Invoke-AzComputeScheduleExecuteStart](Invoke-AzComputeScheduleExecuteStart.md)
VirtualMachinesExecuteStart: Execute start operation for a batch of virtual machines, this operation is triggered as soon as Computeschedule receives it.

### [Invoke-AzComputeScheduleSubmitDeallocate](Invoke-AzComputeScheduleSubmitDeallocate.md)
VirtualMachinesSubmitDeallocate: Schedule deallocate operation for a batch of virtual machines at datetime in future.

### [Invoke-AzComputeScheduleSubmitHibernate](Invoke-AzComputeScheduleSubmitHibernate.md)
VirtualMachinesSubmitHibernate: Schedule hibernate operation for a batch of virtual machines at datetime in future.

### [Invoke-AzComputeScheduleSubmitStart](Invoke-AzComputeScheduleSubmitStart.md)
VirtualMachinesSubmitStart: Schedule start operation for a batch of virtual machines at datetime in future.

### [Stop-AzComputeScheduleScheduledAction](Stop-AzComputeScheduleScheduledAction.md)
VirtualMachinesCancelOperations: Cancel a previously submitted (start/deallocate/hibernate) request

Loading