Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Nginx/Nginx.Autorest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - Nginx")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.2.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.2.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.2.1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.2.1")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]

66 changes: 65 additions & 1 deletion src/Nginx/Nginx.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ root-module-name: $(prefix).Nginx
title: Nginx
module-version: 0.1.0
subject-prefix: Nginx
flatten-userassignedidentity: false
disable-transform-identity-type: true

directive:
# Following is two common directive which are normally required in all the RPs
Expand All @@ -50,6 +52,10 @@ directive:
subject: Configuration|Certificate|Deployment
verb: Set
remove: true
- where:
subject: Deployment
variant: CreateExpanded|UpdateExpanded|UpdateViaIdentityExpanded
hide: true
# ProvisioningState readonly
- from: swagger-document
where: $.definitions.ProvisioningState
Expand All @@ -73,7 +79,32 @@ directive:
"name": "ProvisioningState"
}
}
# Required properties for deployment
# Required properties for
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}"].put.parameters
transform: >-
return [
{
"$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/SubscriptionIdParameter"
},
{
"$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ResourceGroupNameParameter"
},
{
"$ref": "#/parameters/DeploymentNameParameter"
},
{
"$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ApiVersionParameter"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/NginxDeployment"
}
}
]
- from: swagger-document
where: $.definitions.NginxDeploymentProperties
transform: >-
Expand Down Expand Up @@ -165,6 +196,39 @@ directive:
]
}
# Required properties for Certificates
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}"].put.parameters
transform: >-
return [
{
"$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/SubscriptionIdParameter"
},
{
"$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ResourceGroupNameParameter"
},
{
"$ref": "#/parameters/DeploymentNameParameter"
},
{
"in": "path",
"name": "certificateName",
"description": "The name of certificate",
"required": true,
"type": "string"
},
{
"$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ApiVersionParameter"
},
{
"in": "body",
"name": "body",
"required": true,
"description": "The certificate",
"schema": {
"$ref": "#/definitions/NginxCertificate"
}
}
]
- from: swagger-document
where: $.definitions.NginxCertificate
transform: >-
Expand Down
256 changes: 256 additions & 0 deletions src/Nginx/Nginx.Autorest/custom/New-AzNginxDeployment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@

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

<#
.Synopsis
Create the NGINX deployment
.Description
Create the NGINX deployment
.Example
{{ Add code here }}
.Example
{{ Add code here }}

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Nginx.Models.INginxDeployment
.Notes
COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

AUTOSCALESETTINGPROFILE <IScaleProfile[]>: .
CapacityMax <Int32>: The maximum number of NCUs the deployment can be autoscaled to.
CapacityMin <Int32>: The minimum number of NCUs the deployment can be autoscaled to.
Name <String>:

NETWORKPROFILE <INginxNetworkProfile>: .
[FrontEndIPConfiguration <INginxFrontendIPConfiguration>]:
[PrivateIPAddress <List<INginxPrivateIPAddress>>]:
[PrivateIPAddress <String>]:
[PrivateIPAllocationMethod <String>]:
[SubnetId <String>]:
[PublicIPAddress <List<INginxPublicIPAddress>>]:
[Id <String>]:
[NetworkInterfaceConfiguration <INginxNetworkInterfaceConfiguration>]:
[SubnetId <String>]:
.Link
https://learn.microsoft.com/powershell/module/az.nginx/new-aznginxdeployment
#>
function New-AzNginxDeployment {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Nginx.Models.INginxDeployment])]
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory)]
[Alias('DeploymentName')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Path')]
[System.String]
# The name of targeted NGINX deployment
${Name},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Path')]
[System.String]
# The name of the resource group.
# The name is case insensitive.
${ResourceGroupName},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
# The ID of the target subscription.
${SubscriptionId},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String]
# .
${Location},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Models.INginxNetworkProfile]
# .
${NetworkProfile},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String]
# Name of the SKU.
${SkuName},

[Parameter()]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Models.IScaleProfile[]]
# .
${AutoScaleSettingProfile},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.Management.Automation.SwitchParameter]
# .
${EnableDiagnosticsSupport},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.Management.Automation.SwitchParameter]
# Determines whether to enable a system-assigned identity for the resource.
${EnableSystemAssignedIdentity},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String]
# The managed resource group to deploy VNet injection related network resources.
${ManagedResourceGroup},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.Int32]
# .
${ScalingPropertyCapacity},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String]
# .
${StorageAccountContainerName},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String]
# .
${StorageAccountName},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Nginx.Models.INginxDeploymentTags]))]
[System.Collections.Hashtable]
# Dictionary of <string>
${Tag},

[Parameter()]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String[]]
# The array of user assigned identities associated with the resource.
# The elements in array will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.'
${UserAssignedIdentity},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Body')]
[System.String]
# The preferred support contact email address of the user used for sending alerts and notification.
# Can be an empty string or a valid email address.
${UserProfilePreferredEmail},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Azure')]
[System.Management.Automation.PSObject]
# The DefaultProfile parameter is not functional.
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
${DefaultProfile},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command as a job
${AsJob},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command asynchronously
${NoWait},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.Nginx.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)
process {
if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity') -or $PSBoundParameters.ContainsKey('UserAssignedIdentity') ) {
# calculate IdentityType
$supportsSystemAssignedIdentity = $PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity')
$supportsUserAssignedIdentity = $PSBoundParameters.ContainsKey("UserAssignedIdentity") -and $UserAssignedIdentity.Length -gt 0
if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) {
$PSBoundParameters.Add("IdentityType", "SystemAssigned,UserAssigned")
}
elseif ($supportsUserAssignedIdentity -and (-not $supportsSystemAssignedIdentity)) {
$PSBoundParameters.Add("IdentityType", "UserAssigned")
}
elseif ((-not $supportsUserAssignedIdentity) -and $supportsSystemAssignedIdentity) {
$PSBoundParameters.Add("IdentityType", "SystemAssigned")
}
else {
$PSBoundParameters.Add("IdentityType", "None")
}

# remove EnableSystemAssignedIdentity
if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity')) {
$null = $PSBoundParameters.Remove("EnableSystemAssignedIdentity")
}

# If user input UserAssignedIdentity
if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) {
$userIdentityObject = [Microsoft.Azure.PowerShell.Cmdlets.Nginx.Models.IdentityPropertiesUserAssignedIdentities]::New()
$PSBoundParameters.IdentityUserAssignedIdentity = @{}
foreach ($item in $PSBoundParameters.UserAssignedIdentity) {
$PSBoundParameters.IdentityUserAssignedIdentity.Add($item, $userIdentityObject )
}

$null = $PSBoundParameters.Remove('UserAssignedIdentity')
}
}
Az.Nginx.internal\New-AzNginxDeployment @PSBoundParameters
}
}
Loading