1// +build go1.7
2
3// Package networksecuritygroup implements operations for managing network security groups
4// using the Service Management REST API
5//
6// https://msdn.microsoft.com/en-us/library/azure/dn913824.aspx
7package networksecuritygroup
8
9// Copyright 2017 Microsoft Corporation
10//
11//    Licensed under the Apache License, Version 2.0 (the "License");
12//    you may not use this file except in compliance with the License.
13//    You may obtain a copy of the License at
14//
15//        http://www.apache.org/licenses/LICENSE-2.0
16//
17//    Unless required by applicable law or agreed to in writing, software
18//    distributed under the License is distributed on an "AS IS" BASIS,
19//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20//    See the License for the specific language governing permissions and
21//    limitations under the License.
22
23import (
24	"encoding/xml"
25
26	"github.com/Azure/azure-sdk-for-go/services/classic/management"
27)
28
29// SecurityGroupClient is used to perform operations on network security groups
30type SecurityGroupClient struct {
31	client management.Client
32}
33
34// SecurityGroupRequest represents a network security group
35//
36// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx
37type SecurityGroupRequest struct {
38	XMLName  xml.Name `xml:"http://schemas.microsoft.com/windowsazure NetworkSecurityGroup"`
39	Name     string
40	Label    string `xml:",omitempty"`
41	Location string `xml:",omitempty"`
42}
43
44// SecurityGroupResponse represents a network security group
45//
46// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx
47type SecurityGroupResponse struct {
48	XMLName  xml.Name `xml:"http://schemas.microsoft.com/windowsazure NetworkSecurityGroup"`
49	Name     string
50	Label    string             `xml:",omitempty"`
51	Location string             `xml:",omitempty"`
52	State    SecurityGroupState `xml:",omitempty"`
53	Rules    []RuleResponse     `xml:">Rule,omitempty"`
54}
55
56// SecurityGroupList represents a list of security groups
57type SecurityGroupList []SecurityGroupResponse
58
59// SecurityGroupState represents a security group state
60type SecurityGroupState string
61
62// These constants represent the possible security group states
63const (
64	SecurityGroupStateCreated     SecurityGroupState = "Created"
65	SecurityGroupStateCreating    SecurityGroupState = "Creating"
66	SecurityGroupStateUpdating    SecurityGroupState = "Updating"
67	SecurityGroupStateDeleting    SecurityGroupState = "Deleting"
68	SecurityGroupStateUnavailable SecurityGroupState = "Unavailable"
69)
70
71// RuleRequest represents a single rule of a network security group
72//
73// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx#bk_rules
74type RuleRequest struct {
75	XMLName                  xml.Name `xml:"http://schemas.microsoft.com/windowsazure Rule"`
76	Name                     string
77	Type                     RuleType
78	Priority                 int
79	Action                   RuleAction
80	SourceAddressPrefix      string
81	SourcePortRange          string
82	DestinationAddressPrefix string
83	DestinationPortRange     string
84	Protocol                 RuleProtocol
85}
86
87// RuleResponse represents a single rule of a network security group
88//
89// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx#bk_rules
90type RuleResponse struct {
91	XMLName                  xml.Name `xml:"http://schemas.microsoft.com/windowsazure Rule"`
92	Name                     string
93	Type                     RuleType
94	Priority                 int
95	Action                   RuleAction
96	SourceAddressPrefix      string
97	SourcePortRange          string
98	DestinationAddressPrefix string
99	DestinationPortRange     string
100	Protocol                 RuleProtocol
101	State                    string `xml:",omitempty"`
102	IsDefault                bool   `xml:",omitempty"`
103}
104
105// RuleType represents a rule type
106type RuleType string
107
108// These constants represent the possible rule types
109const (
110	RuleTypeInbound  RuleType = "Inbound"
111	RuleTypeOutbound RuleType = "Outbound"
112)
113
114// RuleAction represents a rule action
115type RuleAction string
116
117// These constants represent the possible rule actions
118const (
119	RuleActionAllow RuleAction = "Allow"
120	RuleActionDeny  RuleAction = "Deny"
121)
122
123// RuleProtocol represents a rule protocol
124type RuleProtocol string
125
126// These constants represent the possible rule types
127const (
128	RuleProtocolTCP RuleProtocol = "TCP"
129	RuleProtocolUDP RuleProtocol = "UDP"
130	RuleProtocolAll RuleProtocol = "*"
131)
132