Skip to content

Commit

Permalink
Migrate EventHub from generation to main (#24810)
Browse files Browse the repository at this point in the history
* Move EventHub to main

* suppress the breaking changes

* update changelog

---------

Co-authored-by: YanaXu <[email protected]>
  • Loading branch information
azure-powershell-bot and YanaXu authored May 7, 2024
1 parent 859d31d commit 0714db5
Show file tree
Hide file tree
Showing 928 changed files with 77,422 additions and 33,115 deletions.
8 changes: 4 additions & 4 deletions src/EventHub/EventHub.Autorest/Az.EventHub.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Configuration>
<ViewDefinitions>
<View>
<Name>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202301Preview.SchemaGroupProperties</Name>
<Name>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.SchemaGroupProperties</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202301Preview.SchemaGroupProperties</TypeName>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.SchemaGroupProperties#Multiple</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
Expand All @@ -24,9 +24,9 @@
</TableControl>
</View>
<View>
<Name>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api10.TrackedResourceTags</Name>
<Name>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.TrackedResourceTags</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api10.TrackedResourceTags</TypeName>
<TypeName>Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.TrackedResourceTags#Multiple</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
Expand Down
4 changes: 2 additions & 2 deletions src/EventHub/EventHub.Autorest/Az.EventHub.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.EventHub.private.dll'
FormatsToProcess = './Az.EventHub.format.ps1xml'
FunctionsToExport = 'Approve-AzEventHubPrivateEndpointConnection', 'Deny-AzEventHubPrivateEndpointConnection', 'Get-AzEventHub', 'Get-AzEventHubApplicationGroup', 'Get-AzEventHubAuthorizationRule', 'Get-AzEventHubCluster', 'Get-AzEventHubClusterNamespace', 'Get-AzEventHubClustersAvailableRegion', 'Get-AzEventHubConsumerGroup', 'Get-AzEventHubGeoDRConfiguration', 'Get-AzEventHubKey', 'Get-AzEventHubNamespace', 'Get-AzEventHubNetworkRuleSet', 'Get-AzEventHubPrivateEndpointConnection', 'Get-AzEventHubPrivateLink', 'Get-AzEventHubSchemaGroup', 'New-AzEventHub', 'New-AzEventHubApplicationGroup', 'New-AzEventHubAuthorizationRule', 'New-AzEventHubCluster', 'New-AzEventHubConsumerGroup', 'New-AzEventHubGeoDRConfiguration', 'New-AzEventHubIPRuleConfig', 'New-AzEventHubKey', 'New-AzEventHubKeyVaultPropertiesObject', 'New-AzEventHubNamespace', 'New-AzEventHubSchemaGroup', 'New-AzEventHubThrottlingPolicyConfig', 'New-AzEventHubVirtualNetworkRuleConfig', 'Remove-AzEventHub', 'Remove-AzEventHubApplicationGroup', 'Remove-AzEventHubAuthorizationRule', 'Remove-AzEventHubCluster', 'Remove-AzEventHubConsumerGroup', 'Remove-AzEventHubGeoDRConfiguration', 'Remove-AzEventHubNamespace', 'Remove-AzEventHubPrivateEndpointConnection', 'Remove-AzEventHubSchemaGroup', 'Set-AzEventHub', 'Set-AzEventHubApplicationGroup', 'Set-AzEventHubAuthorizationRule', 'Set-AzEventHubCluster', 'Set-AzEventHubConsumerGroup', 'Set-AzEventHubGeoDRConfigurationBreakPair', 'Set-AzEventHubGeoDRConfigurationFailOver', 'Set-AzEventHubNamespace', 'Set-AzEventHubNetworkRuleSet', 'Test-AzEventHubName', '*'
AliasesToExport = 'Get-AzEventHubNamespaceV2', 'New-AzEventHubNamespaceV2', 'Remove-AzEventHubNamespaceV2', 'Set-AzEventHubNamespaceV2', '*'
FunctionsToExport = 'Approve-AzEventHubPrivateEndpointConnection', 'Deny-AzEventHubPrivateEndpointConnection', 'Get-AzEventHub', 'Get-AzEventHubApplicationGroup', 'Get-AzEventHubAuthorizationRule', 'Get-AzEventHubCluster', 'Get-AzEventHubClusterNamespace', 'Get-AzEventHubClustersAvailableRegion', 'Get-AzEventHubConsumerGroup', 'Get-AzEventHubGeoDRConfiguration', 'Get-AzEventHubKey', 'Get-AzEventHubNamespace', 'Get-AzEventHubNetworkRuleSet', 'Get-AzEventHubPrivateEndpointConnection', 'Get-AzEventHubPrivateLink', 'Get-AzEventHubSchemaGroup', 'New-AzEventHub', 'New-AzEventHubApplicationGroup', 'New-AzEventHubAuthorizationRule', 'New-AzEventHubCluster', 'New-AzEventHubConsumerGroup', 'New-AzEventHubGeoDRConfiguration', 'New-AzEventHubIPRuleConfig', 'New-AzEventHubKey', 'New-AzEventHubKeyVaultPropertiesObject', 'New-AzEventHubNamespace', 'New-AzEventHubSchemaGroup', 'New-AzEventHubThrottlingPolicyConfig', 'New-AzEventHubVirtualNetworkRuleConfig', 'Remove-AzEventHub', 'Remove-AzEventHubApplicationGroup', 'Remove-AzEventHubAuthorizationRule', 'Remove-AzEventHubCluster', 'Remove-AzEventHubConsumerGroup', 'Remove-AzEventHubGeoDRConfiguration', 'Remove-AzEventHubNamespace', 'Remove-AzEventHubPrivateEndpointConnection', 'Remove-AzEventHubSchemaGroup', 'Set-AzEventHub', 'Set-AzEventHubApplicationGroup', 'Set-AzEventHubAuthorizationRule', 'Set-AzEventHubCluster', 'Set-AzEventHubConsumerGroup', 'Set-AzEventHubGeoDRConfigurationBreakPair', 'Set-AzEventHubGeoDRConfigurationFailOver', 'Set-AzEventHubNamespace', 'Set-AzEventHubNetworkRuleSet', 'Test-AzEventHubName'
AliasesToExport = 'Get-AzEventHubNamespaceV2', 'New-AzEventHubNamespaceV2', 'Remove-AzEventHubNamespaceV2', 'Set-AzEventHubNamespaceV2'
PrivateData = @{
PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'EventHub'
Expand Down
72 changes: 6 additions & 66 deletions src/EventHub/EventHub.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ subject-prefix: $(service-name)
# uncomment following line to support viaIdentity for these post APIs
resourcegroup-append: true
nested-object-to-string: 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"
keep-pec-and-plr: true
disable-transform-identity-type: true
flatten-userassignedidentity : false

directive:
- where:
variant: ^Create$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$
variant: ^Create$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$|^CreateViaJsonFilePath$|^CreateViaJsonString$
remove: true
- where:
variant: ^CreateViaIdentity$
Expand Down Expand Up @@ -456,64 +455,5 @@ directive:
suppress-format: true

- model-cmdlet:
- KeyVaultProperties

- where:
parameter-name: IdentityType
set:
breaking-change:
old-parameter-type: CaptureIdentityType
new-parameter-type: String
deprecated-by-version: 5.0.0
deprecated-by-azversion: 12.0.0
change-effective-date: 2024/05/21

- where:
parameter-name: CleanupPolicy
set:
breaking-change:
old-parameter-type: CleanupPolicyRetentionDescription
new-parameter-type: String
deprecated-by-version: 5.0.0
deprecated-by-azversion: 12.0.0
change-effective-date: 2024/05/21

- where:
parameter-name: Status
set:
breaking-change:
old-parameter-type: EntityStatus
new-parameter-type: String
deprecated-by-version: 5.0.0
deprecated-by-azversion: 12.0.0
change-effective-date: 2024/05/21

- where:
parameter-name: Encoding
set:
breaking-change:
old-parameter-type: EncodingCaptureDescription
new-parameter-type: String
deprecated-by-version: 5.0.0
deprecated-by-azversion: 12.0.0
change-effective-date: 2024/05/21

- where:
parameter-name: SchemaCompatibility
set:
breaking-change:
old-parameter-type: SchemaCompatibility
new-parameter-type: String
deprecated-by-version: 5.0.0
deprecated-by-azversion: 12.0.0
change-effective-date: 2024/05/21

- where:
parameter-name: SchemaType
set:
breaking-change:
old-parameter-type: SchemaType
new-parameter-type: String
deprecated-by-version: 5.0.0
deprecated-by-azversion: 12.0.0
change-effective-date: 2024/05/21
- model-name: KeyVaultProperties
cmdlet-name: New-AzEventHubKeyVaultPropertiesObject
16 changes: 12 additions & 4 deletions src/EventHub/EventHub.Autorest/build-module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------
param([switch]$Isolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs)
param([switch]$NotIsolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs, [switch]$UX)
$ErrorActionPreference = 'Stop'

if($PSEdition -ne 'Core') {
Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.'
}

if(-not $Isolated -and -not $Debugger) {
if(-not $NotIsolated -and -not $Debugger) {
Write-Host -ForegroundColor Green 'Creating isolated process...'
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
& "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated
& "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated

if($LastExitCode -ne 0) {
# Build failed. Don't attempt to run the module.
Expand All @@ -45,6 +45,14 @@ if(-not $Isolated -and -not $Debugger) {
}
}

if($UX) {
. (Join-Path $PSScriptRoot 'generate-portal-ux.ps1')
if($LastExitCode -ne 0) {
# UX generation failed. Don't attempt to run the module.
return
}
}

if($Pack) {
. (Join-Path $PSScriptRoot 'pack-module.ps1')
if($LastExitCode -ne 0) {
Expand Down Expand Up @@ -122,7 +130,7 @@ $examplesFolder = Join-Path $PSScriptRoot 'examples'
$null = New-Item -ItemType Directory -Force -Path $examplesFolder

Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
$modelCmdlets = @('KeyVaultProperties')
$modelCmdlets = @(@{modelName="KeyVaultProperties"; cmdletName="New-AzEventHubKeyVaultPropertiesObject"})
$modelCmdletFolder = Join-Path (Join-Path $PSScriptRoot './custom') 'autogen-model-cmdlets'
if (Test-Path $modelCmdletFolder) {
$null = Remove-Item -Force -Recurse -Path $modelCmdletFolder
Expand Down
6 changes: 3 additions & 3 deletions src/EventHub/EventHub.Autorest/check-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------
param([switch]$Isolated, [switch]$Accounts, [switch]$Pester, [switch]$Resources)
param([switch]$NotIsolated, [switch]$Accounts, [switch]$Pester, [switch]$Resources)
$ErrorActionPreference = 'Stop'

if(-not $Isolated) {
if(-not $NotIsolated) {
Write-Host -ForegroundColor Green 'Creating isolated process...'
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
& "$pwsh" -NoExit -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated
& "$pwsh" -NoExit -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated
return
}

Expand Down
105 changes: 92 additions & 13 deletions src/EventHub/EventHub.Autorest/create-model-cmdlets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

function CreateModelCmdlet {

param([string[]]$Models)
param([Hashtable[]]$Models)

if ($Models.Count -eq 0)
{
Expand All @@ -30,7 +30,6 @@ function CreateModelCmdlet {
} else {
$ModuleName = 'Az.EventHub'
}

$CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
$Content = ''
$null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
Expand All @@ -39,15 +38,34 @@ function CreateModelCmdlet {

$Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
$Nodes = $Tree.ChildNodes().ChildNodes()
$classConstantMember = @{}
foreach ($Model in $Models)
{
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$Model") }
$ModelName = $Model.modelName
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$ModelName") }
$ClassNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'class') -and ($_.Identifier.value -eq "$ModelName") }
$classConstantMember = @()
foreach ($class in $ClassNode) {
foreach ($member in $class.Members) {
$isConstant = $false
foreach ($attr in $member.AttributeLists) {
$memberName = $attr.Attributes.Name.ToString()
if ($memberName.EndsWith('.Constant')) {
$isConstant = $true
break
}
}
if (($member.Modifiers.ToString() -eq 'public') -and $isConstant) {
$classConstantMember += $member.Identifier.Value
}
}
}
if ($InterfaceNode.count -eq 0) {
continue
}
# through a queue, we iterate all the parent models.
$Queue = @($InterfaceNode)
$visited = @("I$Model")
$visited = @("I$ModelName")
$AllInterfaceNodes = @()
while ($Queue.count -ne 0)
{
Expand All @@ -65,7 +83,7 @@ function CreateModelCmdlet {
}

$Namespace = $InterfaceNode.Parent.Name
$ObjectType = $Model
$ObjectType = $ModelName
$ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
# remove duplicated module name
if ($ObjectType.StartsWith('EventHub')) {
Expand All @@ -81,10 +99,15 @@ function CreateModelCmdlet {
{
foreach ($Member in $Node.Members)
{
if ($classConstantMember.Contains($Member.Identifier.Value)) {
# skip constant member
continue
}
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
$Required = $false
$Description = ""
$Readonly = $False
$mutability = @{Read = $true; Create = $true; Update = $true}
foreach ($Argument in $Arguments)
{
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
Expand All @@ -99,15 +122,37 @@ function CreateModelCmdlet {
{
$Readonly = $Argument.Expression.Token.Value
}
if ($Argument.NameEquals.Name.Identifier.Value -eq "Read")
{
$mutability.Read = $Argument.Expression.Token.Value
}
if ($Argument.NameEquals.Name.Identifier.Value -eq "Create")
{
$mutability.Create = $Argument.Expression.Token.Value
}
if ($Argument.NameEquals.Name.Identifier.Value -eq "Update")
{
$mutability.Update = $Argument.Expression.Token.Value
}
}
if ($Readonly)
{
continue
}
$Identifier = $Member.Identifier.Value
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
if ($Type.StartsWith("System.Collections.Generic.List"))
{
# if the type is a list, we need to convert it to array
$matched = $Type -match '\<(?<Name>.+)\>$'
if ($matched)
{
$Type = $matches.Name + '[]';
}
}
$ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
if ($Required)
if ($Required -and $mutability.Create -and $mutability.Update)
{
$ParameterDefinePropertyList.Add("Mandatory")
}
Expand All @@ -117,11 +162,9 @@ function CreateModelCmdlet {
}
$ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
# check whether completer is needed
$completer = '';
if($Type.Split('.').Split('.')[-2] -eq 'Support') {
# If Type is an array, need to strip []
$strippedType = $Type.Replace('[]', '')
$completer += "`n [ArgumentCompleter([${strippedType}])]"
$completer = '';
if(IsEnumType($Member)){
$completer += GetCompleter($Member)
}
$ParameterDefineScript = "
[Parameter($ParameterDefineProperty)]${completer}
Expand All @@ -137,6 +180,12 @@ function CreateModelCmdlet {
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""

$cmdletName = "New-Az${ModulePrefix}${ObjectType}Object"
if ('' -ne $Model.cmdletName) {
$cmdletName = $Model.cmdletName
}
$OutputPath = Join-Path -ChildPath "${cmdletName}.ps1" -Path $OutputDir
$cmdletNameInLowerCase = $cmdletName.ToLower()
$Script = "
# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand All @@ -162,9 +211,9 @@ Create an in-memory object for ${ObjectType}.
.Outputs
${ObjectTypeWithNamespace}
.Link
https://learn.microsoft.com/powershell/module/${ModuleName}/new-Az${ModulePrefix}${ObjectType}Object
https://learn.microsoft.com/powershell/module/${ModuleName}/${cmdletNameInLowerCase}
#>
function New-Az${ModulePrefix}${ObjectType}Object {
function ${cmdletName} {
[OutputType('${ObjectTypeWithNamespace}')]
[CmdletBinding(PositionalBinding=`$false)]
Param(
Expand All @@ -181,3 +230,33 @@ ${ParameterAssignScript}
Set-Content -Path $OutputPath -Value $Script
}
}

function IsEnumType {
param (
[Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax]$property
)
$isEnum = $false
foreach ($attr in $property.AttributeLists) {
$attributeName = $attr.Attributes.Name.ToString()
if ($attributeName.Contains('ArgumentCompleter')) {
$isEnum = $true
break
}
}
return $isEnum;
}

function GetCompleter {
param (
[Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax]$property
)
foreach ($attr in $property.AttributeLists) {
$attributeName = $attr.Attributes.Name.ToString()
if ($attributeName.Contains('ArgumentCompleter')) {
$attributeName = $attributeName.Split("::")[-1]
$possibleValues = [System.String]::Join(", ", $attr.Attributes.ArgumentList.Arguments)
$completer += "`n [${attributeName}(${possibleValues})]"
return $completer
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Approves an EventHub PrivateEndpointConnection
#>

function Approve-AzEventHubPrivateEndpointConnection{
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202301Preview.IPrivateEndpointConnection])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.IPrivateEndpointConnection])]
[CmdletBinding(DefaultParameterSetName = 'SetExpanded', PositionalBinding = $false, ConfirmImpact = 'Medium')]
param(
[Parameter(ParameterSetName = 'SetExpanded', HelpMessage = "The name of the Private Endpoint Connection")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Denies an EventHub PrivateEndpointConnection
#>

function Deny-AzEventHubPrivateEndpointConnection{
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202301Preview.IPrivateEndpointConnection])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.IPrivateEndpointConnection])]
[CmdletBinding(DefaultParameterSetName = 'SetExpanded', PositionalBinding = $false, ConfirmImpact = 'Medium')]
param(
[Parameter(ParameterSetName = 'SetExpanded', HelpMessage = "The name of the Private Endpoint Connection")]
Expand Down
Loading

0 comments on commit 0714db5

Please sign in to comment.