File: entities.go

package info (click to toggle)
golang-github-azure-azure-sdk-for-go 2.1.1~beta-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,596 kB
  • ctags: 7,237
  • sloc: makefile: 4
file content (115 lines) | stat: -rw-r--r-- 3,742 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Package networksecuritygroup implements operations for managing network security groups
// using the Service Management REST API
//
// https://msdn.microsoft.com/en-us/library/azure/dn913824.aspx
package networksecuritygroup

import (
	"encoding/xml"

	"github.com/Azure/azure-sdk-for-go/management"
)

// SecurityGroupClient is used to perform operations on network security groups
type SecurityGroupClient struct {
	client management.Client
}

// SecurityGroupRequest represents a network security group
//
// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx
type SecurityGroupRequest struct {
	XMLName  xml.Name `xml:"http://schemas.microsoft.com/windowsazure NetworkSecurityGroup"`
	Name     string
	Label    string `xml:",omitempty"`
	Location string `xml:",omitempty"`
}

// SecurityGroupResponse represents a network security group
//
// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx
type SecurityGroupResponse struct {
	XMLName  xml.Name `xml:"http://schemas.microsoft.com/windowsazure NetworkSecurityGroup"`
	Name     string
	Label    string             `xml:",omitempty"`
	Location string             `xml:",omitempty"`
	State    SecurityGroupState `xml:",omitempty"`
	Rules    []RuleResponse     `xml:">Rule,omitempty"`
}

// SecurityGroupList represents a list of security groups
type SecurityGroupList []SecurityGroupResponse

// SecurityGroupState represents a security group state
type SecurityGroupState string

// These constants represent the possible security group states
const (
	SecurityGroupStateCreated     SecurityGroupState = "Created"
	SecurityGroupStateCreating    SecurityGroupState = "Creating"
	SecurityGroupStateUpdating    SecurityGroupState = "Updating"
	SecurityGroupStateDeleting    SecurityGroupState = "Deleting"
	SecurityGroupStateUnavailable SecurityGroupState = "Unavailable"
)

// RuleRequest represents a single rule of a network security group
//
// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx#bk_rules
type RuleRequest struct {
	XMLName                  xml.Name `xml:"http://schemas.microsoft.com/windowsazure Rule"`
	Name                     string
	Type                     RuleType
	Priority                 int
	Action                   RuleAction
	SourceAddressPrefix      string
	SourcePortRange          string
	DestinationAddressPrefix string
	DestinationPortRange     string
	Protocol                 RuleProtocol
}

// RuleResponse represents a single rule of a network security group
//
// https://msdn.microsoft.com/en-us/library/azure/dn913821.aspx#bk_rules
type RuleResponse struct {
	XMLName                  xml.Name `xml:"http://schemas.microsoft.com/windowsazure Rule"`
	Name                     string
	Type                     RuleType
	Priority                 int
	Action                   RuleAction
	SourceAddressPrefix      string
	SourcePortRange          string
	DestinationAddressPrefix string
	DestinationPortRange     string
	Protocol                 RuleProtocol
	State                    string `xml:",omitempty"`
	IsDefault                bool   `xml:",omitempty"`
}

// RuleType represents a rule type
type RuleType string

// These constants represent the possible rule types
const (
	RuleTypeInbound  RuleType = "Inbound"
	RuleTypeOutbound RuleType = "Outbound"
)

// RuleAction represents a rule action
type RuleAction string

// These constants represent the possible rule actions
const (
	RuleActionAllow RuleAction = "Allow"
	RuleActionDeny  RuleAction = "Deny"
)

// RuleProtocol represents a rule protocol
type RuleProtocol string

// These constants represent the possible rule types
const (
	RuleProtocolTCP RuleProtocol = "TCP"
	RuleProtocolUDP RuleProtocol = "UDP"
	RuleProtocolAll RuleProtocol = "*"
)