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.
14package cloudconnexa
25
36import (
@@ -7,6 +10,8 @@ import (
710 "net/http"
811)
912
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.
1015type AccessGroup struct {
1116 ID string `json:"id"`
1217 Name string `json:"name"`
@@ -15,17 +20,22 @@ type AccessGroup struct {
1520 Destination []AccessItem `json:"destination"`
1621}
1722
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.
1825type AccessItem struct {
1926 Type string `json:"type"`
2027 AllCovered bool `json:"allCovered"`
2128 Parent string `json:"parent,omitempty"`
2229 Children []string `json:"children,omitempty"`
2330}
2431
32+ // Item represents a basic resource with an identifier.
2533type Item struct {
2634 ID string `json:"id"`
2735}
2836
37+ // AccessGroupPageResponse represents a paginated response from the CloudConnexa API
38+ // containing a list of access groups and pagination metadata.
2939type AccessGroupPageResponse struct {
3040 Content []AccessGroup `json:"content"`
3141 NumberOfElements int `json:"numberOfElements"`
@@ -36,8 +46,11 @@ type AccessGroupPageResponse struct {
3646 TotalPages int `json:"totalPages"`
3747}
3848
49+ // AccessGroupsService handles communication with the CloudConnexa API for access group operations.
3950type AccessGroupsService service
4051
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.
4154func (c * AccessGroupsService ) GetAccessGroupsByPage (page int , size int ) (AccessGroupPageResponse , error ) {
4255 endpoint := fmt .Sprintf ("%s/access-groups?page=%d&size=%d" , c .client .GetV1Url (), page , size )
4356 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
@@ -58,6 +71,8 @@ func (c *AccessGroupsService) GetAccessGroupsByPage(page int, size int) (AccessG
5871 return response , nil
5972}
6073
74+ // List retrieves all access groups from the CloudConnexa API.
75+ // It handles pagination internally and returns a complete list of access groups.
6176func (c * AccessGroupsService ) List () ([]AccessGroup , error ) {
6277 var allGroups []AccessGroup
6378 page := 0
@@ -78,6 +93,7 @@ func (c *AccessGroupsService) List() ([]AccessGroup, error) {
7893 return allGroups , nil
7994}
8095
96+ // Get retrieves a specific access group by its ID from the CloudConnexa API.
8197func (c * AccessGroupsService ) Get (id string ) (* AccessGroup , error ) {
8298 endpoint := fmt .Sprintf ("%s/access-groups/%s" , c .client .GetV1Url (), id )
8399 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
@@ -98,6 +114,8 @@ func (c *AccessGroupsService) Get(id string) (*AccessGroup, error) {
98114 return & accessGroup , nil
99115}
100116
117+ // Create creates a new access group in the CloudConnexa API.
118+ // It returns the created access group with its assigned ID.
101119func (c * AccessGroupsService ) Create (accessGroup * AccessGroup ) (* AccessGroup , error ) {
102120 accessGroupJSON , err := json .Marshal (accessGroup )
103121 if err != nil {
@@ -124,6 +142,8 @@ func (c *AccessGroupsService) Create(accessGroup *AccessGroup) (*AccessGroup, er
124142 return & s , nil
125143}
126144
145+ // Update updates an existing access group in the CloudConnexa API.
146+ // It returns the updated access group.
127147func (c * AccessGroupsService ) Update (id string , accessGroup * AccessGroup ) (* AccessGroup , error ) {
128148 accessGroupJSON , err := json .Marshal (accessGroup )
129149 if err != nil {
@@ -150,6 +170,7 @@ func (c *AccessGroupsService) Update(id string, accessGroup *AccessGroup) (*Acce
150170 return & s , nil
151171}
152172
173+ // Delete removes an access group from the CloudConnexa API by its ID.
153174func (c * AccessGroupsService ) Delete (id string ) error {
154175 endpoint := fmt .Sprintf ("%s/access-groups/%s" , c .client .GetV1Url (), id )
155176 req , err := http .NewRequest (http .MethodDelete , endpoint , nil )
0 commit comments