Skip to content

Commit 36607df

Browse files
authored
Merge pull request Azure#39 from hannah-murphy-0/dev
Adding Completed Compute Tests and ReadMe File Edits
2 parents 0a40376 + d6b6e3e commit 36607df

Some content is hidden

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

41 files changed

+9804
-138
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//---------------------------------------------------------------------------------------------
2+
/// Copyright (c) Microsoft Corporation. All rights reserved.
3+
/// Licensed under the MIT License. See License.txt in the project root for license information.
4+
//---------------------------------------------------------------------------------------------
5+
6+
namespace Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.Api20151201Preview
7+
{
8+
using System;
9+
10+
public partial class PlatformImage
11+
{
12+
private string _publisher = null;
13+
14+
private string _offer = null;
15+
16+
private string _sku = null;
17+
18+
private string _version = null;
19+
20+
public string Publisher
21+
{
22+
get {
23+
if (_publisher == null)
24+
{
25+
var idArray = this.Id.Split('/');
26+
_publisher = idArray[Array.IndexOf(idArray, "publishers")+1];
27+
}
28+
29+
return _publisher;
30+
}
31+
}
32+
33+
public string Offer
34+
{
35+
get {
36+
if (_offer == null)
37+
{
38+
var idArray = this.Id.Split('/');
39+
_offer = idArray[Array.IndexOf(idArray, "offers")+1];
40+
}
41+
42+
return _offer;
43+
}
44+
}
45+
46+
public string Sku
47+
{
48+
get {
49+
if (_sku == null)
50+
{
51+
var idArray = this.Id.Split('/');
52+
_sku = idArray[Array.IndexOf(idArray, "skus")+1];
53+
}
54+
55+
return _sku;
56+
}
57+
}
58+
59+
public string Version
60+
{
61+
get {
62+
if (_version == null)
63+
{
64+
var idArray = this.Id.Split('/');
65+
_version = idArray[Array.IndexOf(idArray, "versions")+1];
66+
}
67+
68+
return _version;
69+
}
70+
}
71+
}
72+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//---------------------------------------------------------------------------------------------
2+
/// Copyright (c) Microsoft Corporation. All rights reserved.
3+
/// Licensed under the MIT License. See License.txt in the project root for license information.
4+
//---------------------------------------------------------------------------------------------
5+
6+
namespace Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.Api20151201Preview
7+
{
8+
using System;
9+
10+
public partial class VMExtension
11+
{
12+
// private string _publisher = null;
13+
14+
private string _extensionType = null;
15+
16+
private string _typeHandlerVersion = null;
17+
18+
/*
19+
public string Publisher
20+
{
21+
get {
22+
if (_publisher == null)
23+
{
24+
var idArray = this.Id.Split('/');
25+
_publisher = idArray[Array.IndexOf(idArray, "publishers")+1];
26+
}
27+
28+
return _publisher;
29+
}
30+
}
31+
*/
32+
33+
public string ExtensionType
34+
{
35+
get {
36+
if (_extensionType == null)
37+
{
38+
var idArray = this.Id.Split('/');
39+
_extensionType = idArray[Array.IndexOf(idArray, "types")+1];
40+
}
41+
42+
return _extensionType;
43+
}
44+
}
45+
46+
public string TypeHandlerVersion
47+
{
48+
get {
49+
if (_typeHandlerVersion == null)
50+
{
51+
var idArray = this.Id.Split('/');
52+
_typeHandlerVersion = idArray[Array.IndexOf(idArray, "versions")+1];
53+
}
54+
55+
return _typeHandlerVersion;
56+
}
57+
}
58+
}
59+
}
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 `Azs.Compute.Admin` 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 `Azs.Compute.Admin.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 `Azs.Compute.Admin` 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/Azs.Compute.Admin.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 `Azs.Compute.Admin.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundemental 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 `Azs.Compute.Admin`. 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.ComputeAdmin.Models.DescriptionAttribute`
35+
- 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.
36+
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.DoNotExportAttribute`
37+
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Azs.Compute.Admin`.
38+
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.InternalExportAttribute`
39+
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Azs.Compute.Admin`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder.
40+
- `Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.ProfileAttribute`
41+
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.

0 commit comments

Comments
 (0)