|
| 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-AzMySqlServer { |
| 17 | + [OutputType([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IServer])] |
| 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(Mandatory, 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 = 'The location the resource resides in.')] |
| 44 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 45 | + [System.String] |
| 46 | + ${AdministratorUserName}, |
| 47 | + |
| 48 | + [Parameter(Mandatory, HelpMessage = 'The location the resource resides in.')] |
| 49 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 50 | + [System.Security.SecureString] |
| 51 | + [ValidateNotNullOrEmpty()] |
| 52 | + ${AdministratorLoginPassword}, |
| 53 | + |
| 54 | + [Parameter(Mandatory, HelpMessage = 'The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.')] |
| 55 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 56 | + [System.String] |
| 57 | + ${Sku}, |
| 58 | + |
| 59 | + [Parameter(HelpMessage = 'Enable ssl enforcement or not when connect to server.')] |
| 60 | + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SslEnforcementEnum])] |
| 61 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 62 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SslEnforcementEnum] |
| 63 | + ${SslEnforcement}, |
| 64 | + |
| 65 | + [Parameter(HelpMessage = "Backup retention days for the server. Day count is between 7 and 35.")] |
| 66 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 67 | + [System.Int32] |
| 68 | + ${BackupRetentionDay}, |
| 69 | + |
| 70 | + [Parameter(HelpMessage = 'Enable Geo-redundant or not for server backup.')] |
| 71 | + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.GeoRedundantBackup])] |
| 72 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 73 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.GeoRedundantBackup] |
| 74 | + ${GeoRedundantBackup}, |
| 75 | + |
| 76 | + [Parameter(HelpMessage = 'Enable Storage Auto Grow.')] |
| 77 | + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.StorageAutogrow])] |
| 78 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 79 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.StorageAutogrow] |
| 80 | + ${StorageAutogrow}, |
| 81 | + |
| 82 | + [Parameter(HelpMessage = 'Max storage allowed for a server.')] |
| 83 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 84 | + [System.Int32] |
| 85 | + ${StorageInMb}, |
| 86 | + |
| 87 | + [Parameter(HelpMessage = 'Application-specific metadata in the form of key-value pairs.')] |
| 88 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 89 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IServerForCreateTags]))] |
| 90 | + [System.Collections.Hashtable] |
| 91 | + ${Tag}, |
| 92 | + |
| 93 | + [Parameter(HelpMessage = 'Server version.')] |
| 94 | + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.ServerVersion])] |
| 95 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')] |
| 96 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.ServerVersion] |
| 97 | + ${Version}, |
| 98 | + |
| 99 | + [Parameter(HelpMessage = 'The credentials, account, tenant, and subscription used for communication with Azure.')] |
| 100 | + [Alias('AzureRMContext', 'AzureCredential')] |
| 101 | + [ValidateNotNull()] |
| 102 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Azure')] |
| 103 | + [System.Management.Automation.PSObject] |
| 104 | + ${DefaultProfile}, |
| 105 | + |
| 106 | + [Parameter(HelpMessage = 'Run the command as a job.')] |
| 107 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 108 | + [System.Management.Automation.SwitchParameter] |
| 109 | + ${AsJob}, |
| 110 | + |
| 111 | + [Parameter(DontShow, HelpMessage = 'Wait for .NET debugger to attach.')] |
| 112 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 113 | + [System.Management.Automation.SwitchParameter] |
| 114 | + ${Break}, |
| 115 | + |
| 116 | + [Parameter(DontShow)] |
| 117 | + [ValidateNotNull()] |
| 118 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 119 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]] |
| 120 | + # SendAsync Pipeline Steps to be appended to the front of the pipeline. |
| 121 | + ${HttpPipelineAppend}, |
| 122 | + |
| 123 | + [Parameter(DontShow)] |
| 124 | + [ValidateNotNull()] |
| 125 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 126 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]] |
| 127 | + # SendAsync Pipeline Steps to be prepended to the front of the pipeline. |
| 128 | + ${HttpPipelinePrepend}, |
| 129 | + |
| 130 | + [Parameter(HelpMessage = 'Run the command asynchronously.')] |
| 131 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 132 | + [System.Management.Automation.SwitchParameter] |
| 133 | + ${NoWait}, |
| 134 | + |
| 135 | + [Parameter(DontShow)] |
| 136 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 137 | + [System.Uri] |
| 138 | + # The URI for the proxy server to use. |
| 139 | + ${Proxy}, |
| 140 | + |
| 141 | + [Parameter(DontShow)] |
| 142 | + [ValidateNotNull()] |
| 143 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 144 | + [System.Management.Automation.PSCredential] |
| 145 | + # Credentials for a proxy server to use for the remote call. |
| 146 | + ${ProxyCredential}, |
| 147 | + |
| 148 | + [Parameter(DontShow)] |
| 149 | + [Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')] |
| 150 | + [System.Management.Automation.SwitchParameter] |
| 151 | + # Use the default credentials for the proxy. |
| 152 | + ${ProxyUseDefaultCredentials} |
| 153 | + ) |
| 154 | + |
| 155 | + process { |
| 156 | + try { |
| 157 | + $Parameter = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.ServerForCreate]::new() |
| 158 | + $Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.ServerPropertiesForDefaultCreate]::new() |
| 159 | + |
| 160 | + if ($PSBoundParameters.ContainsKey('Location')) { |
| 161 | + $Parameter.Location = $PSBoundParameters['Location'] |
| 162 | + $null = $PSBoundParameters.Remove('Location') |
| 163 | + } |
| 164 | + |
| 165 | + if ($PSBoundParameters.ContainsKey('Sku')) { |
| 166 | + $Parameter.SkuName = $PSBoundParameters['Sku'] |
| 167 | + $null = $PSBoundParameters.Remove('Sku') |
| 168 | + } |
| 169 | + |
| 170 | + if ($PSBoundParameters.ContainsKey('SslEnforcement')) { |
| 171 | + $Parameter.SslEnforcement = $PSBoundParameters['SslEnforcement'] |
| 172 | + $null = $PSBoundParameters.Remove('SslEnforcement') |
| 173 | + } |
| 174 | + else |
| 175 | + { |
| 176 | + $Parameter.SslEnforcement = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SslEnforcementEnum]::Enable |
| 177 | + } |
| 178 | + |
| 179 | + if ($PSBoundParameters.ContainsKey('BackupRetentionDay')) { |
| 180 | + $Parameter.StorageProfileBackupRetentionDay = $PSBoundParameters['BackupRetentionDay'] |
| 181 | + $null = $PSBoundParameters.Remove('BackupRetentionDay') |
| 182 | + } |
| 183 | + |
| 184 | + if ($PSBoundParameters.ContainsKey('GeoRedundantBackup')) { |
| 185 | + $Parameter.StorageProfileGeoRedundantBackup = $PSBoundParameters['GeoRedundantBackup'] |
| 186 | + $null = $PSBoundParameters.Remove('GeoRedundantBackup') |
| 187 | + } |
| 188 | + |
| 189 | + if ($PSBoundParameters.ContainsKey('StorageAutogrow')) { |
| 190 | + $Parameter.StorageProfileStorageAutogrow = $PSBoundParameters['StorageAutogrow'] |
| 191 | + $null = $PSBoundParameters.Remove('StorageAutogrow') |
| 192 | + } |
| 193 | + |
| 194 | + if ($PSBoundParameters.ContainsKey('StorageInMb')) { |
| 195 | + $Parameter.StorageProfileStorageMb = $PSBoundParameters['StorageInMb'] |
| 196 | + $null = $PSBoundParameters.Remove('StorageInMb') |
| 197 | + } |
| 198 | + |
| 199 | + if ($PSBoundParameters.ContainsKey('Tag')) { |
| 200 | + $Parameter.Tag = $PSBoundParameters['Tag'] |
| 201 | + $null = $PSBoundParameters.Remove('Tag') |
| 202 | + } |
| 203 | + |
| 204 | + if ($PSBoundParameters.ContainsKey('Version')) { |
| 205 | + $Parameter.Version = $PSBoundParameters['Version'] |
| 206 | + $null = $PSBoundParameters.Remove('Version') |
| 207 | + } |
| 208 | + |
| 209 | + $Parameter.CreateMode = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.CreateMode]::Default |
| 210 | + |
| 211 | + $Parameter.Property.AdministratorLogin = $PSBoundParameters['AdministratorUserName'] |
| 212 | + $null = $PSBoundParameters.Remove('AdministratorUserName') |
| 213 | + |
| 214 | + $Parameter.Property.AdministratorLoginPassword = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($PSBoundParameters['AdministratorLoginPassword'])) |
| 215 | + $null = $PSBoundParameters.Remove('AdministratorLoginPassword') |
| 216 | + |
| 217 | + $PSBoundParameters.Add('Parameter', $Parameter) |
| 218 | + Az.MySql.internal\New-AzMySqlServer @PSBoundParameters |
| 219 | + } catch { |
| 220 | + throw |
| 221 | + } |
| 222 | + } |
| 223 | +} |
| 224 | + |
| 225 | + |
0 commit comments