Skip to content

Commit 4fd9e51

Browse files
DaeunYimmsJinLeimsJinLei
authored
Add flexible commands to MySql modules (#13551)
* 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 * revert postgresql * configuration fixed * cred scan added * cred scan issue resolved * Regenerate doc of the MySql * comments resolved Co-authored-by: Jin Lei <[email protected]> Co-authored-by: msJinLei <[email protected]>
1 parent 289466e commit 4fd9e51

File tree

144 files changed

+18541
-2547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+18541
-2547
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# region Generated
2+
# Load the private module dll
3+
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.MySql.private.dll')
4+
5+
# Load the internal module
6+
$internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.MySql.internal.psm1'
7+
if(Test-Path $internalModulePath) {
8+
$null = Import-Module -Name $internalModulePath
9+
}
10+
11+
# Export nothing to clear implicit exports
12+
Export-ModuleMember
13+
14+
# Export script cmdlets
15+
Get-ChildItem -Path $PSScriptRoot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
16+
Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot) -Alias (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot -AsAlias)
17+
# endregion
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
function New-AzMySqlFlexibleServer {
17+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20200701Preview.IServerAutoGenerated])]
18+
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
19+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Description('Creates a new server.')]
20+
param(
21+
[Parameter(Mandatory, HelpMessage = 'The name of the server.')]
22+
[Alias('ServerName')]
23+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
24+
[System.String]
25+
${Name},
26+
27+
[Parameter(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.')]
28+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
29+
[System.String]
30+
${ResourceGroupName},
31+
32+
[Parameter(HelpMessage='The subscription ID that identifies an Azure subscription.')]
33+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
34+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
35+
[System.String]
36+
${SubscriptionId},
37+
38+
[Parameter(HelpMessage = 'The location the resource resides in.')]
39+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
40+
[System.String]
41+
${Location},
42+
43+
[Parameter(Mandatory, HelpMessage = 'Administrator username for the server. Once set, it cannot be changed.')]
44+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
45+
[System.String]
46+
${AdministratorUserName},
47+
48+
[Parameter(Mandatory, HelpMessage = 'The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.')]
49+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
50+
[System.Security.SecureString]
51+
[ValidateNotNullOrEmpty()]
52+
${AdministratorLoginPassword},
53+
54+
[Parameter(HelpMessage = 'The name of the sku, typically, tier + family + cores, e.g. Standard_B1ms, Standard_D2ds_v4.')]
55+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
56+
[System.String]
57+
${Sku},
58+
59+
[Parameter(HelpMessage = 'Compute tier of the server. Accepted values: Burstable, GeneralPurpose, Memory Optimized. Default: Burstable.')]
60+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
61+
[System.String]
62+
${SkuTier},
63+
64+
[Parameter(HelpMessage = "Backup retention days for the server. Day count is between 7 and 35.")]
65+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
66+
[System.Int32]
67+
${BackupRetentionDay},
68+
69+
[Parameter(HelpMessage = 'Max storage allowed for a server.')]
70+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
71+
[System.Int32]
72+
${StorageInMb},
73+
74+
[Parameter(HelpMessage = 'Application-specific metadata in the form of key-value pairs.')]
75+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
76+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IServerForCreateTags]))]
77+
[System.Collections.Hashtable]
78+
${Tag},
79+
80+
[Parameter(HelpMessage = 'Server version.')]
81+
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.ServerVersion])]
82+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
83+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.ServerVersion]
84+
${Version},
85+
86+
[Parameter(HelpMessage = 'The credentials, account, tenant, and subscription used for communication with Azure.')]
87+
[Alias('AzureRMContext', 'AzureCredential')]
88+
[ValidateNotNull()]
89+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Azure')]
90+
[System.Management.Automation.PSObject]
91+
${DefaultProfile},
92+
93+
[Parameter(HelpMessage = 'Run the command as a job.')]
94+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
95+
[System.Management.Automation.SwitchParameter]
96+
${AsJob},
97+
98+
[Parameter(DontShow, HelpMessage = 'Wait for .NET debugger to attach.')]
99+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
100+
[System.Management.Automation.SwitchParameter]
101+
${Break},
102+
103+
[Parameter(DontShow)]
104+
[ValidateNotNull()]
105+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
106+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]]
107+
# SendAsync Pipeline Steps to be appended to the front of the pipeline.
108+
${HttpPipelineAppend},
109+
110+
[Parameter(DontShow)]
111+
[ValidateNotNull()]
112+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
113+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]]
114+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline.
115+
${HttpPipelinePrepend},
116+
117+
[Parameter(HelpMessage = 'Run the command asynchronously.')]
118+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
119+
[System.Management.Automation.SwitchParameter]
120+
${NoWait},
121+
122+
[Parameter(DontShow)]
123+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
124+
[System.Uri]
125+
# The URI for the proxy server to use.
126+
${Proxy},
127+
128+
[Parameter(DontShow)]
129+
[ValidateNotNull()]
130+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
131+
[System.Management.Automation.PSCredential]
132+
# Credentials for a proxy server to use for the remote call.
133+
${ProxyCredential},
134+
135+
[Parameter(DontShow)]
136+
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
137+
[System.Management.Automation.SwitchParameter]
138+
# Use the default credentials for the proxy.
139+
${ProxyUseDefaultCredentials}
140+
)
141+
142+
process {
143+
try {
144+
if ($PSBoundParameters.ContainsKey('Name')) {
145+
$PSBoundParameters.ServerName = $PSBoundParameters['Name']
146+
$null = $PSBoundParameters.Remove('Name')
147+
}
148+
149+
if ($PSBoundParameters.ContainsKey('Sku')) {
150+
$PSBoundParameters.SkuName = $PSBoundParameters['Sku']
151+
$null = $PSBoundParameters.Remove('Sku')
152+
}
153+
else {
154+
$PSBoundParameters.SkuName = 'Standard_B1ms'
155+
}
156+
157+
if ($PSBoundParameters.ContainsKey('BackupRetentionDay')) {
158+
$PSBoundParameters.StorageProfileBackupRetentionDay = $PSBoundParameters['BackupRetentionDay']
159+
$null = $PSBoundParameters.Remove('BackupRetentionDay')
160+
}
161+
else {
162+
$PSBoundParameters.StorageProfileBackupRetentionDay = 7
163+
}
164+
165+
if ($PSBoundParameters.ContainsKey('StorageInMb')) {
166+
$PSBoundParameters.StorageProfileStorageMb = $PSBoundParameters['StorageInMb']
167+
$null = $PSBoundParameters.Remove('StorageInMb')
168+
}
169+
else {
170+
$PSBoundParameters.StorageProfileStorageMb = 10240
171+
}
172+
173+
if (!$PSBoundParameters.ContainsKey('Version')) {
174+
$PSBoundParameters.Version = '5.7'
175+
}
176+
177+
if (!$PSBoundParameters.ContainsKey('SkuTier')) {
178+
$PSBoundParameters.SkuTier = 'Burstable'
179+
}
180+
181+
if (!$PSBoundParameters.ContainsKey('Location')) {
182+
$PSBoundParameters.Location = 'westus2'
183+
}
184+
185+
if ($PSBoundParameters.ContainsKey('AdministratorUserName')) {
186+
$PSBoundParameters.AdministratorLogin = $PSBoundParameters['AdministratorUserName']
187+
$null = $PSBoundParameters.Remove('AdministratorUserName')
188+
}
189+
190+
$PSBoundParameters.CreateMode = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.CreateMode]::Default
191+
$PSBoundParameters.AdministratorLoginPassword = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['AdministratorLoginPassword']
192+
193+
Az.MySql.internal\New-AzMySqlFlexibleServer @PSBoundParameters
194+
} catch {
195+
throw
196+
}
197+
}
198+
}
199+
200+

0 commit comments

Comments
 (0)