Skip to content

Commit

Permalink
Move kusto to release-2021-05-25 (#15046)
Browse files Browse the repository at this point in the history
* Move Kusto to release-2021-05-25

* Add change log for kusto

* Clean en-us from kusto help (#15048)

* Suppress breaking change warnings for kusto (#15051)

Co-authored-by: azurepowershell <azurepowershell@ms.com>
Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com>
  • Loading branch information
3 people authored May 19, 2021
1 parent ee8ea08 commit 90610d6
Show file tree
Hide file tree
Showing 674 changed files with 37,491 additions and 19,682 deletions.
532 changes: 432 additions & 100 deletions src/Kusto/Az.Kusto.format.ps1xml

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions src/Kusto/Az.Kusto.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 12/24/2020
# Generated on: 5/19/2021
#

@{
Expand Down Expand Up @@ -45,7 +45,7 @@ PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
Expand Down Expand Up @@ -77,27 +77,29 @@ FunctionsToExport = 'Add-AzKustoClusterLanguageExtension',
'Get-AzKustoClusterPrincipalAssignment', 'Get-AzKustoClusterSku',
'Get-AzKustoDatabase', 'Get-AzKustoDatabasePrincipal',
'Get-AzKustoDatabasePrincipalAssignment',
'Get-AzKustoDataConnection',
'Invoke-AzKustoDataConnectionValidation',
'Get-AzKustoDataConnection', 'Get-AzKustoOperationsResult',
'Get-AzKustoScript', 'Invoke-AzKustoDataConnectionValidation',
'Invoke-AzKustoDetachClusterFollowerDatabase',
'Invoke-AzKustoDiagnoseClusterVirtualNetwork',
'New-AzKustoAttachedDatabaseConfiguration', 'New-AzKustoCluster',
'New-AzKustoClusterPrincipalAssignment', 'New-AzKustoDatabase',
'New-AzKustoDatabasePrincipalAssignment',
'New-AzKustoDataConnection',
'New-AzKustoDataConnection', 'New-AzKustoScript',
'Remove-AzKustoAttachedDatabaseConfiguration',
'Remove-AzKustoCluster', 'Remove-AzKustoClusterLanguageExtension',
'Remove-AzKustoClusterPrincipalAssignment',
'Remove-AzKustoDatabase', 'Remove-AzKustoDatabasePrincipal',
'Remove-AzKustoDatabasePrincipalAssignment',
'Remove-AzKustoDataConnection', 'Start-AzKustoCluster',
'Stop-AzKustoCluster', 'Test-AzKustoClusterNameAvailability',
'Remove-AzKustoDataConnection', 'Remove-AzKustoScript',
'Start-AzKustoCluster', 'Stop-AzKustoCluster',
'Test-AzKustoClusterNameAvailability',
'Test-AzKustoClusterPrincipalAssignmentNameAvailability',
'Test-AzKustoDatabaseNameAvailability',
'Test-AzKustoDatabasePrincipalAssignmentNameAvailability',
'Test-AzKustoDataConnectionNameAvailability',
'Update-AzKustoCluster', 'Update-AzKustoDatabase',
'Update-AzKustoDataConnection'
'Test-AzKustoScriptNameAvailability', 'Update-AzKustoCluster',
'Update-AzKustoDatabase', 'Update-AzKustoDataConnection',
'Update-AzKustoScript'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down Expand Up @@ -135,7 +137,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* Updated API version to 2020-09-18.'
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''
Expand Down
10 changes: 5 additions & 5 deletions src/Kusto/Az.Kusto.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
}
}
if(-not $accountsModule) {
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.2.3' } | Measure-Object).Count -gt 0
if($hasAdequateVersion) {
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.2.3 -Scope Global -PassThru
}
}
}

if(-not $accountsModule) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
}
Write-Information "Loaded Module '$($accountsModule.Name)'"

Expand Down
1 change: 1 addition & 0 deletions src/Kusto/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Bumped API version to 2021-01-01

## Version 1.0.1
* Updated API version to 2020-09-18.
Expand Down
6 changes: 5 additions & 1 deletion src/Kusto/build-module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ $moduleName = 'Az.Kusto'
$examplesFolder = Join-Path $PSScriptRoot 'examples'
$null = New-Item -ItemType Directory -Force -Path $examplesFolder

Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
$modelCmdlets = @()
. (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1') -Models $modelCmdlets

if($NoDocs) {
Write-Host -ForegroundColor Green 'Creating exports...'
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder
} else {
Write-Host -ForegroundColor Green 'Creating exports and docs...'
$moduleDescription = 'Microsoft Azure PowerShell: Kusto cmdlets'
Expand Down
6 changes: 3 additions & 3 deletions src/Kusto/check-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ if(Test-Path -Path $localModulesPath) {
$env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
}

DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1'
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '2.2.3'
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'

$tools = Join-Path $PSScriptRoot 'tools'
$resourceDir = Join-Path $tools 'Resources'
$resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psm1'

if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) {
if ($Resources.IsPresent -and ((-not (Test-Path -Path $resourceModule)) -or $RegenerateSupportModule.IsPresent)) {
Write-Host -ForegroundColor Green "Building local Resource module used for test..."
Set-Location $resourceDir
$null = autorest-beta .\readme.md --output-folder=$HOME/.PSSharedModules/Resources
$null = autorest .\readme.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
$null = Copy-Item custom/* $HOME/.PSSharedModules/Resources/custom/
Set-Location $HOME/.PSSharedModules/Resources
$null = .\build-module.ps1
Expand Down
165 changes: 165 additions & 0 deletions src/Kusto/create-model-cmdlets.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# 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.
# ----------------------------------------------------------------------------------

param([string[]]$Models)

if ($Models.Count -eq 0)
{
return
}

$ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
$ModuleName = 'Az.Kusto'.Split(".")[1]
$OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
$null = New-Item -ItemType Directory -Force -Path $OutputDir

$CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
$Content = ''
$null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
{ $Content += get-content $_.fullname -raw
} }

$Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
$Nodes = $Tree.ChildNodes().ChildNodes()
foreach ($Model in $Models)
{
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$Model") }
if ($InterfaceNode.count -eq 0) {
continue
}
# through a queue, we iterate all the parent models.
$Queue = @($InterfaceNode)
$visited = @("I$Model")
$AllInterfaceNodes = @()
while ($Queue.count -ne 0)
{
$AllInterfaceNodes += $Queue[0]
# Baselist contains the direct parent models.
foreach ($parent in $Queue[0].BaseList.Types)
{
if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
{
$Queue = [Array]$Queue + ($Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq $parent.Type.Right.Identifier.Value) })
$visited = [Array]$visited + $parent.Type.Right.Identifier.Value
}
}
$first, $Queue = $Queue
}

$Namespace = $InterfaceNode.Parent.Name
$ObjectType = $Model
$ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
# remove duplicated module name
if ($ObjectType.StartsWith($ModuleName)) {
$ModulePrefix = ''
} else {
$ModulePrefix = $ModuleName
}
$OutputPath = Join-Path -ChildPath "New-Az${ModulePrefix}${ObjectType}Object.ps1" -Path $OutputDir

$ParameterDefineScriptList = New-Object System.Collections.Generic.List[string]
$ParameterAssignScriptList = New-Object System.Collections.Generic.List[string]
foreach ($Node in $AllInterfaceNodes)
{
foreach ($Member in $Node.Members)
{
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
$Required = $false
$Description = ""
$Readonly = $False
foreach ($Argument in $Arguments)
{
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
{
$Required = $Argument.Expression.Token.Value
}
if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
{
$Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
}
if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
{
$Readonly = $Argument.Expression.Token.Value
}
}
if ($Readonly)
{
continue
}
$Identifier = $Member.Identifier.Value
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
$ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
if ($Required)
{
$ParameterDefinePropertyList.Add("Mandatory")
}
if ($Description -ne "")
{
$ParameterDefinePropertyList.Add("HelpMessage=`"${Description}.`"")
}
$ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
$ParameterDefineScript = "
[Parameter($ParameterDefineProperty)]
[${Type}]
`$${Identifier}"
$ParameterDefineScriptList.Add($ParameterDefineScript)
$ParameterAssignScriptList.Add("
`$Object.${Identifier} = `$${Identifier}")
}
}
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""

$Script = "
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# 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.
# ----------------------------------------------------------------------------------
<#
.Synopsis
Create a in-memory object for ${ObjectType}
.Description
Create a in-memory object for ${ObjectType}
.Outputs
${ObjectTypeWithNamespace}
.Link
https://docs.microsoft.com/powershell/module/az.${ModuleName}/new-Az${ModulePrefix}${ObjectType}Object
#>
function New-Az${ModulePrefix}${ObjectType}Object {
[OutputType('${ObjectTypeWithNamespace}')]
[CmdletBinding(PositionalBinding=`$false)]
Param(
${ParameterDefineScript}
)
process {
`$Object = [${ObjectTypeWithNamespace}]::New()
${ParameterAssignScript}
return `$Object
}
}
"
Set-Content -Path $OutputPath -Value $Script
}
16 changes: 8 additions & 8 deletions src/Kusto/custom/Invoke-AzKustoDataConnectionValidation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ Checks that the data connection parameters are valid.
.Description
Checks that the data connection parameters are valid.
.Example
PS C:\> $dataConnectionProperties = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.EventHubDataConnection -Property @{Location=$location; Kind=$kind; EventHubResourceId=$eventHubResourceId; DataFormat=$dataFormat; ConsumerGroup='$Default'; Compression= "None"; TableName = $tableName; MappingRuleName = $tableMappingName}
PS C:\> $dataConnectionValidation = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.DataConnectionValidation -Property @{DataConnectionName=$dataConnectionName; Property=$dataConnectionProperties}
PS C:\> $dataConnectionProperties = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.EventHubDataConnection -Property @{Location=$location; Kind=$kind; EventHubResourceId=$eventHubResourceId; DataFormat=$dataFormat; ConsumerGroup='$Default'; Compression= "None"; TableName = $tableName; MappingRuleName = $tableMappingName}
PS C:\> $dataConnectionValidation = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.DataConnectionValidation -Property @{DataConnectionName=$dataConnectionName; Property=$dataConnectionProperties}
PS C:\> Invoke-AzKustoDataConnectionValidation -ResourceGroupName $resourceGroupName -ClusterName $clusterName -DatabaseName $databaseName -Parameter $dataConnectionValidation
ErrorMessage
------------
event hub resource id and consumer group tuple provided are already used
.Link
https://docs.microsoft.com/en-us/powershell/module/az.kusto/invoke-azkustodataconnectionvalidation
https://docs.microsoft.com/powershell/module/az.kusto/invoke-azkustodataconnectionvalidation
#>
function Invoke-AzKustoDataConnectionValidation {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.IDataConnectionValidationResult])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.IDataConnectionValidationResult])]
[CmdletBinding(DefaultParameterSetName = 'DataExpandedEventHub', PositionalBinding = $false, SupportsShouldProcess, ConfirmImpact = 'Medium')]
param(
[Parameter(ParameterSetName = 'DataExpandedEventHub', Mandatory)]
Expand Down Expand Up @@ -230,13 +230,13 @@ function Invoke-AzKustoDataConnectionValidation {

process {
try {
$Parameter = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.DataConnectionValidation]::new()
$Parameter = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.DataConnectionValidation]::new()

$Parameter.DataConnectionName = $PSBoundParameters['DataConnectionName']
$null = $PSBoundParameters.Remove('DataConnectionName')

if ($PSBoundParameters['Kind'] -eq 'EventHub') {
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.EventHubDataConnection]::new()
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.EventHubDataConnection]::new()

$Parameter.Property.EventHubResourceId = $PSBoundParameters['EventHubResourceId']
$null = $PSBoundParameters.Remove('EventHubResourceId')
Expand All @@ -252,7 +252,7 @@ function Invoke-AzKustoDataConnectionValidation {
}
}
elseif ($PSBoundParameters['Kind'] -eq 'EventGrid') {
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.EventGridDataConnection]::new()
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.EventGridDataConnection]::new()

$Parameter.Property.EventHubResourceId = $PSBoundParameters['EventHubResourceId']
$null = $PSBoundParameters.Remove('EventHubResourceId')
Expand All @@ -271,7 +271,7 @@ function Invoke-AzKustoDataConnectionValidation {
}
}
else {
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200918.IotHubDataConnection]::new()
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.IotHubDataConnection]::new()

$Parameter.Property.IotHubResourceId = $PSBoundParameters['IotHubResourceId']
$null = $PSBoundParameters.Remove('IotHubResourceId')
Expand Down
Loading

0 comments on commit 90610d6

Please sign in to comment.