Skip to content

[PS] SpringCloud module migrate to autorest v4 #27531

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

Merged
merged 4 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 26 additions & 0 deletions src/SpringCloud/SpringCloud.Autorest/Properties/AssemblyInfo.cs
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 - SpringCloud")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.3.2")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.3.2")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]
125 changes: 66 additions & 59 deletions src/SpringCloud/SpringCloud.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This directory contains the PowerShell module for the SpringCloud service.

---

## Info
- Modifiable: yes
- Generated: all
Expand Down Expand Up @@ -53,15 +52,22 @@ input-file:

title: SpringCloud
module-version: 0.1.0
resourcegroup-append: true
nested-object-to-string: true
identity-correction-for-post: true

# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
use-extension:
"@autorest/powershell": "3.x"
disable-transform-identity-type-for-operation:
- Apps_Update
ps-pipeline-input-disable-getByIteself-and-enable-listByParent: false

directive:
# TODO: retire on March 31, 2028
- where:
verb: (.*)
set:
breaking-change:
deprecated-by-version: 0.3.2
deprecated-by-azversion: 19.3.0
change-effective-date: 2028/03/31
change-description: Azure Spring Apps, including the Standard consumption and dedicated (currently in Public Preview only), Basic, Standard, and Enterprise plans, will be retired, please see details on https://aka.ms/asaretirement.

- where:
verb: Set
subject: BuildServiceAgentPoolPut
Expand All @@ -82,12 +88,12 @@ directive:
# First rename parameter of the Get-AzSpringCloudService, then rename cmdlet to Get-AzSpringCloud.
- where:
subject: ^Service$
variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$
variant: ^(Create|Update)(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true

- where:
subject: ^Service$
variant: ^Update$|^UpdateViaIdentity$
variant: ^CreateViaIdentity$|^CreateViaIdentityExpanded$
remove: true

- where:
Expand All @@ -113,7 +119,7 @@ directive:
parameter-name: NetworkProfileServiceRuntimeSubnetId
set:
parameter-name: NetworkProfileServiceSubnetId
# Customization for add default locatio value when not pass location parameter
# Customization for add default location value when not pass location parameter
- where:
verb: New
subject: ^Service$
Expand Down Expand Up @@ -185,70 +191,58 @@ directive:
subject: AppDeploymentThreadDump
remove: true
# remove variant
# |Certificate|ConfigurationService
- where:
subject: ^App$|^AppBinding$|^AppDeployment$|^AppCustomDomain$|^|BuildpackBinding$|^BuildServiceBuild$|^BuildServiceBuilder$
variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$
subject: ^App$|^AppBinding$|^AppDeployment$|^AppCustomDomain$|^BuildpackBinding$|^BuildServiceBuild$|^BuildServiceBuilder$|^TestKey$|^ConfigServer$|^MonitoringSetting$|^BuildServiceAgentPool$|Certificate|ConfigurationService
variant: ^(Create|Update|Generate)(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true
- where:
subject: ^AppDeploymentHeapDump$|^AppDeploymentThreadDump$|^TestKey$
variant: ^Generate$|^GenerateViaIdentity$|^GenerateViaIdentityExpanded$
remove: true

- where:
verb: Get
subject: BuildServiceBuildResultLog
variant: GetViaIdentity
subject: ^App$|^AppBinding$|^AppDeployment$|^AppCustomDomain$|^BuildpackBinding$|^BuildServiceBuild$|^BuildServiceBuilder$|^TestKey$|Certificate|ConfigurationService
variant: ^CreateViaIdentity$|^CreateViaIdentityExpanded$
remove: true

- where:
verb: Get
subject: ^Registry$|^BuildService$|^BuildServiceAgentPool$|^ConfigurationService$
variant: List
remove: true


- where:
subject: ^TestKey$
variant: ^Regenerate$|^RegenerateViaIdentity$|^RegenerateViaIdentityExpanded$
variant: ^Regenerate(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true

- where:
subject: ^AppActiveDeployment$
variant: ^SetViaIdentity$|^Set$
remove: true

- where:
subject: ^DeploymentJfr$
variant: ^Start$|^StartViaIdentity$
remove: true

- where:
verb: Test
subject: ^AppCustomDomain$
variant: ^Validate$|^ValidateViaIdentity$
variant: ^(Set)(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true

- where:
verb: Test
subject: ^ConfigServer$|^ConfigurationService$
variant: ^Validate$|^ValidateViaIdentity$
subject: ^AppCustomDomain$|^ConfigServer$|^ConfigurationService$
variant: ^(Validate)(?!.*?(Expanded|JsonFilePath|JsonString))|^ValidateViaIdentity$
remove: true

- where:
verb: Test
subject: ^NameAvailability$
variant: ^Check$|^CheckViaIdentity$|^CheckViaIdentityExpanded$
variant: ^(Check)(?!.*?Expanded)|^CheckViaIdentityExpanded$|^CheckViaIdentity$
remove: true

- where:
subject: ^AppDeploymentJfr$
variant: ^Start$|^StartViaIdentity$
variant: ^(Start)(?!.*?Expanded)$
remove: true

- where:
subject: ^App$|^AppBinding$|^AppDeployment$|^AppCustomDomain$|^ConfigServer$|^MonitoringSetting$|^BuildServiceAgentPool$
variant: ^Update$|^UpdateViaIdentity$
# Disable parent resource variant of default child name
- where:
verb: Get
subject: ^BuildServiceAgentPool$|^ConfigurationService$|^Registry$
variant: ^GetViaIdentitySpring$|^DeleteViaIdentitySpring$
remove: true
- where:
verb: Get
subject: ^BuildServiceAgentPool$|^BuildService$|^BuildServiceBuilder$|^BuildServiceSupportedBuildpack$|^BuildServiceSupportedStack$|^BuildpackBinding$
variant: ^GetViaIdentityBuildService$|^DeleteViaIdentityBuildService$
remove: true

# rename parameter
Expand Down Expand Up @@ -423,6 +417,10 @@ directive:
subject: ^BuildServiceResourceUploadUrl$
hide: true

- where:
verb: Update
subject: ^BuildService$
hide: true
- where:
subject: ^BuildServiceBuild$
hide: true
Expand All @@ -433,7 +431,7 @@ directive:
subject: ^BuildServiceBuildResultLog$
hide: true

# Customization for add default locatio value when not pass location parameter
# Customization for add default location value when not pass location parameter
- where:
verb: New
subject: ^App$
Expand Down Expand Up @@ -539,22 +537,31 @@ directive:
- UserSourceInfo
- CertificateProperties

- model-cmdlet:
# - BuildpacksGroupProperties
# - BuildpackProperties
- ConfigurationServiceGitRepository
- GitPatternRepository
# - KeyVaultCertificateProperties
# - ContentCertificateProperties
# - LoadedCertificate
# --> rename New-AzSpringCloudLoadedCertificateObject New-AzSpringCloudAppLoadedCertificateObject
# - JarUploadedUserSourceInfo
# --> rename New-AzSpringCloudDeploymentJarUploadedObject --> New-AzSpringCloudAppDeploymentJarUploadedObject
# - NetCoreZipUploadedUserSourceInfo
# --> rename New-AzSpringCloudDeploymentNetCoreZipUploadedObject --> New-AzSpringCloudAppDeploymentNetCoreZipUploadedObject
# - SourceUploadedUserSourceInfo
# --> rename New-AzSpringCloudDeploymentSourceUploadedObject --> New-AzSpringCloudAppDeploymentSourceUploadedObject
# - BuildResultUserSourceInfo --> New-AzSpringCloudAppDeploymentBuildResultObject
# add retirement message
# - model-cmdlet:
# - model-name: BuildpacksGroupProperties
# cmdlet-name: New-AzSpringCloudBuildpacksGroupObject
# - model-name: BuildpackProperties
# cmdlet-name: New-AzSpringCloudBuildpackObject
# - model-name: ConfigurationServiceGitRepository
# - model-name: GitPatternRepository
# - model-name: ContentCertificateProperties
# cmdlet-name: New-AzSpringCloudContentCertificateObject
# - model-name: LoadedCertificate
# cmdlet-name: New-AzSpringCloudAppLoadedCertificateObject
# Customized parameter names
# - model-name: KeyVaultCertificateProperties
# cmdlet-name: New-AzSpringCloudKeyVaultCertificateObject
# Customized RelativePath with '<default>' value
# - model-name: JarUploadedUserSourceInfo
# cmdlet-name: New-AzSpringCloudAppDeploymentJarUploadedObject
# - model-name: NetCoreZipUploadedUserSourceInfo
# cmdlet-name: New-AzSpringCloudAppDeploymentNetCoreZipUploadedObject
# - model-name: SourceUploadedUserSourceInfo
# cmdlet-name: New-AzSpringCloudAppDeploymentSourceUploadedObject
# Customized BuildResultId with '<default>' value
# - model-name: BuildResultUserSourceInfo
# cmdlet-name: New-AzSpringCloudAppDeploymentBuildResultObject

- where:
subject-prefix: SpringCloud
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ PS C:\> {{ Add code here }}
{{ Add output here }}

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.IAppResource
Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.IAppResource
.Link
https://learn.microsoft.com/powershell/module/az.SpringCloud/deploy-azSpringCloudapp
#>
function Deploy-AzSpringCloudApp {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.IAppResource])]
[CmdletBinding(DefaultParameterSetName='DeployAppForStandard', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Runtime.CmdletBreakingChange("19.3.0", "0.3.2", "2028/03/31", ChangeDescription = "Azure Spring Apps, including the Standard consumption and dedicated (currently in Public Preview only), Basic, Standard, and Enterprise plans, will be retired, please see details on https://aka.ms/asaretirement.")]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.IAppResource])]
[CmdletBinding(DefaultParameterSetName='DeployAppForStandard', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory)]
[Alias('AppName')]
Expand Down Expand Up @@ -240,19 +241,19 @@ function DeployStandardSpringCloudApp {
$deployment = Get-AzSpringCloudAppDeployment -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName -AppName $AppName -Name $DeploymentName @DeployPSBoundParameters
if ($deployment.Source.Type -eq 'Jar')
{
$source = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.JarUploadedUserSourceInfo]::New()
$source = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.JarUploadedUserSourceInfo]::New()
$source.RelativePath = $RelativePath
$source.Type = $deployment.Source.Type
}
if ($deployment.Source.Type -eq 'NetCoreZip')
{
$source = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.NetCoreZipUploadedUserSourceInfo]::New()
$source = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.NetCoreZipUploadedUserSourceInfo]::New()
$source.RelativePath = $RelativePath
$source.Type = $deployment.Source.Type
}
if ($deployment.Source.Type -eq 'Source')
{
$source = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.SourceUploadedUserSourceInfo]::New()
$source = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.SourceUploadedUserSourceInfo]::New()
$source.RelativePath = $RelativePath
$source.Type = $deployment.Source.Type
}
Expand Down Expand Up @@ -297,7 +298,7 @@ function DeployEnterpriseSpringCloudApp {
throw "Service build failed, Log file url: $resultFailedLog"
}
} until ($result.ProvisioningState -eq 'Succeeded')
$buildResult = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.BuildResultUserSourceInfo]::New()
$buildResult = [Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.BuildResultUserSourceInfo]::New()
$buildResult.Type = "BuildResult"
$buildResult.BuildResultId = $result.Id
$null = Update-AzSpringCloudAppDeployment -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName -AppName $AppName -Name $DeploymentName -Source $buildResult @DeployPSBoundParameters
Expand Down
18 changes: 10 additions & 8 deletions src/SpringCloud/SpringCloud.Autorest/custom/New-AzSpringCloud.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@

<#
.Synopsis
Create a new Service or update an exiting Service.
create a new Service or update an exiting Service.
.Description
Create a new Service or update an exiting Service.
create a new Service or update an exiting Service.
.Example
New-AzSpringCloud -ResourceGroupName spring-cloud-rp -name spring-cloud-service -Location eastus

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.IServiceResource
Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.IServiceResource
.Link
https://learn.microsoft.com/powershell/module/az.springcloud/new-azspringcloud
#>
function New-AzSpringCloud {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.IServiceResource])]
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Runtime.CmdletBreakingChange("19.3.0", "0.3.2", "2028/03/31", ChangeDescription = "Azure Spring Apps, including the Standard consumption and dedicated (currently in Public Preview only), Basic, Standard, and Enterprise plans, will be retired, please see details on https://aka.ms/asaretirement.")]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.IServiceResource])]
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory)]
[Alias('ServiceName')]
Expand Down Expand Up @@ -109,7 +110,7 @@ param(

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.Api20220401.ITrackedResourceTags]))]
[Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Models.ITrackedResourceTags]))]
[System.Collections.Hashtable]
# Tags of the service which is a list of key value pairs that describe the resource.
${Tag},
Expand All @@ -125,7 +126,8 @@ param(
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.SpringCloud.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
# The DefaultProfile parameter is not functional.
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
${DefaultProfile},

[Parameter()]
Expand Down Expand Up @@ -186,5 +188,5 @@ param(
$PSBoundParameters.Add('Location', $ResourceGroup.Location)
}
Az.SpringCloud.internal\New-AzSpringCloud @PSBoundParameters
}
}
}
Loading