-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed PostgreSql New-AzPostgreSqlFlexibleServer cmdlet and Added Ge…
…t-AzPostgreSqlFlexibleServerLocationBasedCapability (#13716) * Generate flexible server cmdlets (#13269) * test commit with server mgmt md files * cmdlet design draft * fixed errors for mysql md files * fixed errors for mysql md files * fixing mistakes * resolved comments * mysql cmdlets customization verified * mysql modified * postgres customized cmdlets and readme * mysql postgres customized cmdlets and docs * initial commit for mysql pg module * mysql test success * pg module * postgresql cmdlet update test fixed * example document fixed * Revert "example document fixed" This reverts commit 6c60dbf. * align single server test with flexible server * docs fixed * docs files moved from exports to upper folder * typo fixed * reverted mysql flexible server * configuration update doc resolved * cred scan fixed * copied from generation branch * Fix the format of cmdlet help files * Fixed bugs * comments resolved * initial commit for customization * test recorded * test pass fix * utils CI fix * CI test fix * postgresql comments resolved * minor fix for location capabilities * CI fixed * utils included * test fixed for live testing * customized server object * dynamically assign server name for live testing * dynamically assign live test variables * if else case consistent * comments resolved * change autorest version Co-authored-by: Jin Lei <[email protected]> Co-authored-by: msJinLei <[email protected]>
- Loading branch information
1 parent
f446f22
commit b08bf81
Showing
123 changed files
with
21,505 additions
and
882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# region Generated | ||
# Load the private module dll | ||
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.PostgreSql.private.dll') | ||
|
||
# Load the internal module | ||
$internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.PostgreSql.internal.psm1' | ||
if(Test-Path $internalModulePath) { | ||
$null = Import-Module -Name $internalModulePath | ||
} | ||
|
||
# Export nothing to clear implicit exports | ||
Export-ModuleMember | ||
|
||
# Export script cmdlets | ||
Get-ChildItem -Path $PSScriptRoot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName } | ||
Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot) -Alias (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot -AsAlias) | ||
# endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Models.Api20200214Preview | ||
{ | ||
using static Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.Extensions; | ||
using System.Security; | ||
|
||
/// <summary>Represents a server.</summary> | ||
public partial class ServerAutoGenerated | ||
{ | ||
private SecureString _SecuredPassword; | ||
// <summary> The user password in secure string. Convert the secure string into plain text if necessary. </summary> | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Origin(Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.PropertyOrigin.Inlined)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.DoNotFormat] | ||
public SecureString SecuredPassword {get => this._SecuredPassword; set => this._SecuredPassword = value;} | ||
|
||
private string _FirewallRuleName; | ||
// <summary> The name of the firewall rule of the server </summary> | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Origin(Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.PropertyOrigin.Inlined)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.DoNotFormat] | ||
public string FirewallRuleName {get => this._FirewallRuleName; set => this._FirewallRuleName = value;} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
src/PostgreSql/custom/Get-AzPostgreSqlFlexibleServerConnectionString.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# 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 | ||
Get the connection string according to client connection provider. | ||
.Description | ||
Get the connection string according to client connection provider. | ||
#> | ||
function Get-AzPostgreSqlFlexibleServerConnectionString { | ||
[OutputType([System.String])] | ||
[CmdletBinding(DefaultParameterSetName='Get', PositionalBinding=$false)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Description('Get the connection string according to client connection provider.')] | ||
param( | ||
[Parameter(ParameterSetName='Get', Mandatory, HelpMessage = 'The name of the server.')] | ||
[Alias('ServerName')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Path')] | ||
[System.String] | ||
${Name}, | ||
|
||
[Parameter(ParameterSetName='Get', Mandatory, HelpMessage = 'The name of the resource group that contains the resource, You can obtain this value from the Azure Resource Manager API or the portal.')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Path')] | ||
[System.String] | ||
${ResourceGroupName}, | ||
|
||
[Parameter(ParameterSetName='Get', HelpMessage='The subscription ID that identifies an Azure subscription.')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Path')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
[System.String] | ||
${SubscriptionId}, | ||
|
||
[Parameter(Mandatory, HelpMessage = 'Client connection provider.')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Path')] | ||
[Validateset('ADO.NET', 'C++', 'JDBC', 'Node.js', 'PHP', 'psql', 'Python', 'Ruby')] | ||
[System.String] | ||
${Client}, | ||
|
||
[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline, HelpMessage = 'The server for the connection string')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Body')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Models.Api20200214Preview.IServerAutoGenerated] | ||
${InputObject}, | ||
|
||
[Parameter(HelpMessage = 'The credentials, account, tenant, and subscription used for communication with Azure.')] | ||
[Alias('AzureRMContext', 'AzureCredential')] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Azure')] | ||
[System.Management.Automation.PSObject] | ||
${DefaultProfile}, | ||
|
||
[Parameter(DontShow, HelpMessage = 'Wait for .NET debugger to attach.')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
${Break}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be appended to the front of the pipeline. | ||
${HttpPipelineAppend}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be prepended to the front of the pipeline. | ||
${HttpPipelinePrepend}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Uri] | ||
# The URI for the proxy server to use. | ||
${Proxy}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Management.Automation.PSCredential] | ||
# Credentials for a proxy server to use for the remote call. | ||
${ProxyCredential}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Use the default credentials for the proxy. | ||
${ProxyUseDefaultCredentials} | ||
) | ||
|
||
process { | ||
$null = $PSBoundParameters.Remove('Client') | ||
$postgreSql = Az.PostgreSql\Get-AzPostgreSqlFlexibleServer @PSBoundParameters | ||
$DBHost = $postgreSql.FullyQualifiedDomainName | ||
$DBPort = 5432 | ||
$adminName = $postgreSql.AdministratorLogin | ||
|
||
$ConnectionStringMap = @{ | ||
'ADO.NET' = "Server=${DBHost};Database={your_database};Port=${DBPort};User Id=${adminName};Password={your_password};" | ||
'C++' = "host=${DBHost} port=${DBPort} dbname={your_database} user=${adminName} password={your_password}" | ||
'JDBC' = "jdbc:postgresql://${DBHost}:${DBPort}/{your_database}?user=${adminName}&password={your_password}&" | ||
'Node.js' = "host=${DBHost} port=${DBPort} dbname={your_database} user=${adminName} password={your_password}" | ||
'PHP' = "host=${DBHost} port=${DBPort} dbname={your_database} user=${adminName} password={your_password}" | ||
'psql' = "psql ""host=${DBHost} port=${DBPort} dbname={your_database} user=${adminName} password={your_password}""" | ||
'Python' = "dbname='{your_database}' user='${adminName}' host='${DBHost}' password='{your_password}' port='${DBPort}'" | ||
'Ruby' = "host=${DBHost}; dbname={your_database} user=${adminName} password={your_password} port=${DBPort}" | ||
} | ||
return $ConnectionStringMap[$Client] | ||
} | ||
} | ||
|
118 changes: 118 additions & 0 deletions
118
src/PostgreSql/custom/Get-AzPostgreSqlFlexibleServerLocationBasedCapability.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# 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 | ||
Get the available SKU information for the location | ||
.Description | ||
Get the available SKU information for the location | ||
#> | ||
|
||
function Get-AzPostgreSqlFlexibleServerLocationBasedCapability { | ||
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Models.Api20200214Preview.ICapabilityProperties])] | ||
[CmdletBinding(DefaultParameterSetName='Get', PositionalBinding=$false)] | ||
param( | ||
[Parameter(ParameterSetName='Get', Mandatory)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Path')] | ||
[System.String] | ||
# The name of the location. | ||
${Location}, | ||
|
||
[Parameter(ParameterSetName='Get')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Path')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
[System.String[]] | ||
# The ID of the target subscription. | ||
${SubscriptionId}, | ||
|
||
[Parameter()] | ||
[Alias('AzureRMContext', 'AzureCredential')] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Azure')] | ||
[System.Management.Automation.PSObject] | ||
# The credentials, account, tenant, and subscription used for communication with Azure. | ||
${DefaultProfile}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Wait for .NET debugger to attach | ||
${Break}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
${HttpPipelineAppend}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
${HttpPipelinePrepend}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Uri] | ||
# The URI for the proxy server to use | ||
${Proxy}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Management.Automation.PSCredential] | ||
# Credentials for a proxy server to use for the remote call | ||
${ProxyCredential}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Use the default credentials for the proxy | ||
${ProxyUseDefaultCredentials} | ||
) | ||
|
||
process { | ||
try { | ||
$PSBoundParameters.LocationName = $PSBoundParameters['Location'] | ||
$null = $PSBoundParameters.Remove('Location') | ||
|
||
$Result = Az.PostgreSql.internal\Get-AzPostgreSqlFlexibleServerLocationBasedCapability @PSBoundParameters | ||
Write-Host "Please refer to https://aka.ms/postgresql-pricing for pricing details" | ||
$SkusTiers = $Result[0].SupportedFlexibleServerEdition | ||
$TableResult = @() | ||
|
||
foreach ($Skus in $SkusTiers) { | ||
$TierName = $Skus.Name | ||
try { | ||
$Keys = $Skus.SupportedServerVersion[0].SupportedVcore | ||
|
||
foreach ($Key in $Keys) { | ||
$NewEntry = New-Object -TypeName PSCustomObject -Property @{SKU=$Key.Name; Tier=$TierName; vCore=$Key.Vcore; Memory=$Key.SupportedMemoryPerVcoreMb} | ||
$TableResult += $NewEntry | ||
} | ||
} | ||
catch { | ||
throw "No SKU info for this location" | ||
} | ||
} | ||
$TableResult | ||
|
||
} catch { | ||
throw | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.