-
Notifications
You must be signed in to change notification settings - Fork 8
/
security_ip_lists.go
115 lines (100 loc) · 4.2 KB
/
security_ip_lists.go
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 compute
// SecurityIPListsClient is a client for the Security IP List functions of the Compute API.
type SecurityIPListsClient struct {
ResourceClient
}
// SecurityIPLists obtains a SecurityIPListsClient which can be used to access to the
// Security IP List functions of the Compute API
func (c *Client) SecurityIPLists() *SecurityIPListsClient {
return &SecurityIPListsClient{
ResourceClient: ResourceClient{
Client: c,
ResourceDescription: "security ip list",
ContainerPath: "/seciplist/",
ResourceRootPath: "/seciplist",
}}
}
// SecurityIPListInfo describes an existing security IP list.
type SecurityIPListInfo struct {
// A description of the security IP list.
Description string `json:"description"`
// Fully Qualified Domain Name
FQDN string `json:"name"`
// The name of the object
Name string
// A comma-separated list of the subnets (in CIDR format) or IPv4 addresses for which you want to create this security IP list.
SecIPEntries []string `json:"secipentries"`
// Uniform Resource Identifier
URI string `json:"uri"`
}
// CreateSecurityIPListInput defines a security IP list to be created.
type CreateSecurityIPListInput struct {
// A description of the security IP list.
// Optional
Description string `json:"description"`
// The three-part name of the object (/Compute-identity_domain/user/object).
// Object names can contain only alphanumeric characters, hyphens, underscores, and periods. Object names are case-sensitive.
// Required
Name string `json:"name"`
// A comma-separated list of the subnets (in CIDR format) or IPv4 addresses for which you want to create this security IP list.
// Required
SecIPEntries []string `json:"secipentries"`
}
// CreateSecurityIPList creates a security IP list with the given name and entries.
func (c *SecurityIPListsClient) CreateSecurityIPList(createInput *CreateSecurityIPListInput) (*SecurityIPListInfo, error) {
createInput.Name = c.getQualifiedName(createInput.Name)
var listInfo SecurityIPListInfo
if err := c.createResource(createInput, &listInfo); err != nil {
return nil, err
}
return c.success(&listInfo)
}
// GetSecurityIPListInput describes the Security IP List to obtain
type GetSecurityIPListInput struct {
// The three-part name of the object (/Compute-identity_domain/user/object).
// Required
Name string `json:"name"`
}
// GetSecurityIPList gets the security IP list with the given name.
func (c *SecurityIPListsClient) GetSecurityIPList(getInput *GetSecurityIPListInput) (*SecurityIPListInfo, error) {
var listInfo SecurityIPListInfo
if err := c.getResource(getInput.Name, &listInfo); err != nil {
return nil, err
}
return c.success(&listInfo)
}
// UpdateSecurityIPListInput describes the security ip list to update
type UpdateSecurityIPListInput struct {
// A description of the security IP list.
// Optional
Description string `json:"description"`
// The three-part name of the object (/Compute-identity_domain/user/object).
// Required
Name string `json:"name"`
// A comma-separated list of the subnets (in CIDR format) or IPv4 addresses for which you want to create this security IP list.
// Required
SecIPEntries []string `json:"secipentries"`
}
// UpdateSecurityIPList modifies the entries in the security IP list with the given name.
func (c *SecurityIPListsClient) UpdateSecurityIPList(updateInput *UpdateSecurityIPListInput) (*SecurityIPListInfo, error) {
updateInput.Name = c.getQualifiedName(updateInput.Name)
var listInfo SecurityIPListInfo
if err := c.updateResource(updateInput.Name, updateInput, &listInfo); err != nil {
return nil, err
}
return c.success(&listInfo)
}
// DeleteSecurityIPListInput describes the security ip list to delete.
type DeleteSecurityIPListInput struct {
// The three-part name of the object (/Compute-identity_domain/user/object).
// Required
Name string `json:"name"`
}
// DeleteSecurityIPList deletes the security IP list with the given name.
func (c *SecurityIPListsClient) DeleteSecurityIPList(deleteInput *DeleteSecurityIPListInput) error {
return c.deleteResource(deleteInput.Name)
}
func (c *SecurityIPListsClient) success(listInfo *SecurityIPListInfo) (*SecurityIPListInfo, error) {
listInfo.Name = c.getUnqualifiedName(listInfo.FQDN)
return listInfo, nil
}