|
| 1 | +// ---------------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// Copyright Microsoft Corporation |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | +// ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +using Microsoft.Azure.Commands.Network.Models; |
| 16 | +using System.Management.Automation; |
| 17 | + |
| 18 | +namespace Microsoft.Azure.Commands.Network |
| 19 | +{ |
| 20 | + public class AzureVirtualNetworkGatewayIpConfigBase : NetworkBaseCmdlet |
| 21 | + { |
| 22 | + [Parameter( |
| 23 | + Mandatory = false, |
| 24 | + HelpMessage = "The name of the FrontendIpConfiguration")] |
| 25 | + [ValidateNotNullOrEmpty] |
| 26 | + public virtual string Name { get; set; } |
| 27 | + |
| 28 | + [Parameter( |
| 29 | + Mandatory = false, |
| 30 | + HelpMessage = "The private ip address of the frontendIpConfiguration " + |
| 31 | + "if static allocation is specified.")] |
| 32 | + public string PrivateIpAddress { get; set; } |
| 33 | + |
| 34 | + [Parameter( |
| 35 | + ParameterSetName = "SetByResourceId", |
| 36 | + HelpMessage = "SubnetId")] |
| 37 | + [ValidateNotNullOrEmpty] |
| 38 | + public string SubnetId { get; set; } |
| 39 | + |
| 40 | + [Parameter( |
| 41 | + ParameterSetName = "SetByResource", |
| 42 | + HelpMessage = "Subnet")] |
| 43 | + public PSSubnet Subnet { get; set; } |
| 44 | + |
| 45 | + [Parameter( |
| 46 | + ParameterSetName = "SetByResourceId", |
| 47 | + HelpMessage = "PublicIpAddressId")] |
| 48 | + public string PublicIpAddressId { get; set; } |
| 49 | + |
| 50 | + [Parameter( |
| 51 | + ParameterSetName = "SetByResource", |
| 52 | + HelpMessage = "PublicIpAddress")] |
| 53 | + public PSPublicIpAddress PublicIpAddress { get; set; } |
| 54 | + |
| 55 | + public override void ExecuteCmdlet() |
| 56 | + { |
| 57 | + base.ExecuteCmdlet(); |
| 58 | + |
| 59 | + if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource)) |
| 60 | + { |
| 61 | + if (this.Subnet != null) |
| 62 | + { |
| 63 | + this.SubnetId = this.Subnet.Id; |
| 64 | + } |
| 65 | + |
| 66 | + if (this.PublicIpAddress != null) |
| 67 | + { |
| 68 | + this.PublicIpAddressId = this.PublicIpAddress.Id; |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | +} |
0 commit comments