1
/* ============================================================================
2
Copyright 2014 Hewlett Packard
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
8
http://www.apache.org/licenses/LICENSE-2.0
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
============================================================================ */
17
using System.Collections.Generic;
20
using System.Management.Automation;
21
using Openstack.Client.Powershell.Cmdlets.Common;
22
using Openstack.Objects.Domain.Security;
23
using Openstack.Client.Powershell.Providers.Common;
24
using Openstack.Client.Powershell.Providers.Security;
26
namespace Openstack.Client.Powershell.Cmdlets.Security
28
[Cmdlet(VerbsCommon.New, "SecurityGroup", SupportsShouldProcess = true)]
29
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
30
public class NewSecurityGroupCmdlet : BasePSCmdlet
33
private string _description;
36
//=========================================================================================
40
//=========================================================================================
41
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "NewSecurityGroup", ValueFromPipelineByPropertyName = true, HelpMessage = "ww")]
43
[ValidateNotNullOrEmpty]
44
public string Description
46
get { return _description; }
47
set { _description = value; }
49
//=========================================================================================
53
//=========================================================================================
54
[Parameter(Position = 0, ParameterSetName = "NewSecurityGroup", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "www")]
59
set { _name = value; }
63
//=========================================================================================
67
//=========================================================================================
68
protected override void ProcessRecord()
70
NewSecurityGroup newGroup = new NewSecurityGroup();
71
newGroup.Description = this.Description;
72
newGroup.Name = this.Name;
74
SecurityGroup securityGroup = this.RepositoryFactory.CreateSecurityRepository().SaveSecurityGroup(newGroup);
75
this.UpdateCache<SecurityGroupsUIContainer>();