1
+ // Package cloudconnexa provides a Go client library for the CloudConnexa API.
2
+ // It offers comprehensive functionality for managing VPN networks, hosts, connectors,
3
+ // routes, users, and other CloudConnexa resources through a simple Go interface.
1
4
package cloudconnexa
2
5
3
6
import (
@@ -7,6 +10,8 @@ import (
7
10
"net/http"
8
11
)
9
12
13
+ // AccessGroup represents a group of access rules that define network access permissions.
14
+ // It contains source and destination rules that determine what resources can access each other.
10
15
type AccessGroup struct {
11
16
ID string `json:"id"`
12
17
Name string `json:"name"`
@@ -15,17 +20,22 @@ type AccessGroup struct {
15
20
Destination []AccessItem `json:"destination"`
16
21
}
17
22
23
+ // AccessItem represents a single access rule item that can be either a source or destination.
24
+ // It defines what resources are covered by the access rule and their relationships.
18
25
type AccessItem struct {
19
26
Type string `json:"type"`
20
27
AllCovered bool `json:"allCovered"`
21
28
Parent string `json:"parent,omitempty"`
22
29
Children []string `json:"children,omitempty"`
23
30
}
24
31
32
+ // Item represents a basic resource with an identifier.
25
33
type Item struct {
26
34
ID string `json:"id"`
27
35
}
28
36
37
+ // AccessGroupPageResponse represents a paginated response from the CloudConnexa API
38
+ // containing a list of access groups and pagination metadata.
29
39
type AccessGroupPageResponse struct {
30
40
Content []AccessGroup `json:"content"`
31
41
NumberOfElements int `json:"numberOfElements"`
@@ -36,8 +46,11 @@ type AccessGroupPageResponse struct {
36
46
TotalPages int `json:"totalPages"`
37
47
}
38
48
49
+ // AccessGroupsService handles communication with the CloudConnexa API for access group operations.
39
50
type AccessGroupsService service
40
51
52
+ // GetAccessGroupsByPage retrieves a paginated list of access groups from the CloudConnexa API.
53
+ // It returns the access groups for the specified page and page size.
41
54
func (c * AccessGroupsService ) GetAccessGroupsByPage (page int , size int ) (AccessGroupPageResponse , error ) {
42
55
endpoint := fmt .Sprintf ("%s/access-groups?page=%d&size=%d" , c .client .GetV1Url (), page , size )
43
56
req , err := http .NewRequest (http .MethodGet , endpoint , nil )
@@ -58,6 +71,8 @@ func (c *AccessGroupsService) GetAccessGroupsByPage(page int, size int) (AccessG
58
71
return response , nil
59
72
}
60
73
74
+ // List retrieves all access groups from the CloudConnexa API.
75
+ // It handles pagination internally and returns a complete list of access groups.
61
76
func (c * AccessGroupsService ) List () ([]AccessGroup , error ) {
62
77
var allGroups []AccessGroup
63
78
page := 0
@@ -78,6 +93,7 @@ func (c *AccessGroupsService) List() ([]AccessGroup, error) {
78
93
return allGroups , nil
79
94
}
80
95
96
+ // Get retrieves a specific access group by its ID from the CloudConnexa API.
81
97
func (c * AccessGroupsService ) Get (id string ) (* AccessGroup , error ) {
82
98
endpoint := fmt .Sprintf ("%s/access-groups/%s" , c .client .GetV1Url (), id )
83
99
req , err := http .NewRequest (http .MethodGet , endpoint , nil )
@@ -98,6 +114,8 @@ func (c *AccessGroupsService) Get(id string) (*AccessGroup, error) {
98
114
return & accessGroup , nil
99
115
}
100
116
117
+ // Create creates a new access group in the CloudConnexa API.
118
+ // It returns the created access group with its assigned ID.
101
119
func (c * AccessGroupsService ) Create (accessGroup * AccessGroup ) (* AccessGroup , error ) {
102
120
accessGroupJSON , err := json .Marshal (accessGroup )
103
121
if err != nil {
@@ -124,6 +142,8 @@ func (c *AccessGroupsService) Create(accessGroup *AccessGroup) (*AccessGroup, er
124
142
return & s , nil
125
143
}
126
144
145
+ // Update updates an existing access group in the CloudConnexa API.
146
+ // It returns the updated access group.
127
147
func (c * AccessGroupsService ) Update (id string , accessGroup * AccessGroup ) (* AccessGroup , error ) {
128
148
accessGroupJSON , err := json .Marshal (accessGroup )
129
149
if err != nil {
@@ -150,6 +170,7 @@ func (c *AccessGroupsService) Update(id string, accessGroup *AccessGroup) (*Acce
150
170
return & s , nil
151
171
}
152
172
173
+ // Delete removes an access group from the CloudConnexa API by its ID.
153
174
func (c * AccessGroupsService ) Delete (id string ) error {
154
175
endpoint := fmt .Sprintf ("%s/access-groups/%s" , c .client .GetV1Url (), id )
155
176
req , err := http .NewRequest (http .MethodDelete , endpoint , nil )
0 commit comments