@@ -7,53 +7,39 @@ import (
77 "net/http"
88)
99
10- type AccessGroupRequest struct {
11- Name string `json:"name"`
12- Description string `json:"description,omitempty"`
13- Source []AccessItemRequest `json:"source"`
14- Destination []AccessItemRequest `json:"destination"`
10+ type AccessGroup struct {
11+ Id string `json:"id"`
12+ Name string `json:"name"`
13+ Description string `json:"description,omitempty"`
14+ Source []AccessItem `json:"source"`
15+ Destination []AccessItem `json:"destination"`
1516}
1617
17- type AccessGroupResponse struct {
18- Id string `json:"id"`
19- Name string `json:"name"`
20- Description string `json:"description"`
21- Source []AccessItemResponse `json:"source"`
22- Destination []AccessItemResponse `json:"destination"`
23- }
24-
25- type AccessItemRequest struct {
18+ type AccessItem struct {
2619 Type string `json:"type"`
2720 AllCovered bool `json:"allCovered"`
2821 Parent string `json:"parent,omitempty"`
2922 Children []string `json:"children,omitempty"`
3023}
3124
32- type AccessItemResponse struct {
33- Type string `json:"type"`
34- AllCovered bool `json:"allCovered"`
35- Parent * Item `json:"parent"`
36- Children []Item `json:"children"`
37- }
38-
3925type Item struct {
4026 Id string `json:"id"`
4127}
4228
4329type AccessGroupPageResponse struct {
44- Content []AccessGroupResponse `json:"content"`
45- NumberOfElements int `json:"numberOfElements"`
46- Page int `json:"page"`
47- Size int `json:"size"`
48- Success bool `json:"success"`
49- TotalElements int `json:"totalElements"`
50- TotalPages int `json:"totalPages"`
30+ Content []AccessGroup `json:"content"`
31+ NumberOfElements int `json:"numberOfElements"`
32+ Page int `json:"page"`
33+ Size int `json:"size"`
34+ Success bool `json:"success"`
35+ TotalElements int `json:"totalElements"`
36+ TotalPages int `json:"totalPages"`
5137}
5238
5339type AccessGroupsService service
5440
5541func (c * AccessGroupsService ) GetAccessGroupsByPage (page int , size int ) (AccessGroupPageResponse , error ) {
56- endpoint := fmt .Sprintf ("%s/api/beta/ access-groups/page ?page=%d&size=%d" , c .client .BaseURL , page , size )
42+ endpoint := fmt .Sprintf ("%s/access-groups?page=%d&size=%d" , c .client .GetV1Url () , page , size )
5743 req , err := http .NewRequest (http .MethodGet , endpoint , nil )
5844 if err != nil {
5945 return AccessGroupPageResponse {}, err
@@ -72,8 +58,8 @@ func (c *AccessGroupsService) GetAccessGroupsByPage(page int, size int) (AccessG
7258 return response , nil
7359}
7460
75- func (c * AccessGroupsService ) List () ([]AccessGroupResponse , error ) {
76- var allGroups []AccessGroupResponse
61+ func (c * AccessGroupsService ) List () ([]AccessGroup , error ) {
62+ var allGroups []AccessGroup
7763 page := 0
7864 pageSize := 10
7965
@@ -92,7 +78,7 @@ func (c *AccessGroupsService) List() ([]AccessGroupResponse, error) {
9278 return allGroups , nil
9379}
9480
95- func (c * AccessGroupsService ) Get (id string ) (* AccessGroupResponse , error ) {
81+ func (c * AccessGroupsService ) Get (id string ) (* AccessGroup , error ) {
9682 groups , err := c .List ()
9783 if err != nil {
9884 return nil , err
@@ -106,13 +92,13 @@ func (c *AccessGroupsService) Get(id string) (*AccessGroupResponse, error) {
10692 return nil , nil
10793}
10894
109- func (c * AccessGroupsService ) Create (accessGroup * AccessGroupRequest ) (* AccessGroupResponse , error ) {
95+ func (c * AccessGroupsService ) Create (accessGroup * AccessGroup ) (* AccessGroup , error ) {
11096 accessGroupJson , err := json .Marshal (accessGroup )
11197 if err != nil {
11298 return nil , err
11399 }
114100
115- endpoint := fmt .Sprintf ("%s/api/beta/ access-groups" , c .client .BaseURL )
101+ endpoint := fmt .Sprintf ("%s/access-groups" , c .client .GetV1Url () )
116102
117103 req , err := http .NewRequest (http .MethodPost , endpoint , bytes .NewBuffer (accessGroupJson ))
118104 if err != nil {
@@ -124,21 +110,21 @@ func (c *AccessGroupsService) Create(accessGroup *AccessGroupRequest) (*AccessGr
124110 return nil , err
125111 }
126112
127- var s AccessGroupResponse
113+ var s AccessGroup
128114 err = json .Unmarshal (body , & s )
129115 if err != nil {
130116 return nil , err
131117 }
132118 return & s , nil
133119}
134120
135- func (c * AccessGroupsService ) Update (id string , accessGroup * AccessGroupRequest ) (* AccessGroupResponse , error ) {
121+ func (c * AccessGroupsService ) Update (id string , accessGroup * AccessGroup ) (* AccessGroup , error ) {
136122 accessGroupJson , err := json .Marshal (accessGroup )
137123 if err != nil {
138124 return nil , err
139125 }
140126
141- endpoint := fmt .Sprintf ("%s/api/beta/ access-groups/%s" , c .client .BaseURL , id )
127+ endpoint := fmt .Sprintf ("%s/access-groups/%s" , c .client .GetV1Url () , id )
142128
143129 req , err := http .NewRequest (http .MethodPut , endpoint , bytes .NewBuffer (accessGroupJson ))
144130 if err != nil {
@@ -150,7 +136,7 @@ func (c *AccessGroupsService) Update(id string, accessGroup *AccessGroupRequest)
150136 return nil , err
151137 }
152138
153- var s AccessGroupResponse
139+ var s AccessGroup
154140 err = json .Unmarshal (body , & s )
155141 if err != nil {
156142 return nil , err
@@ -159,7 +145,7 @@ func (c *AccessGroupsService) Update(id string, accessGroup *AccessGroupRequest)
159145}
160146
161147func (c * AccessGroupsService ) Delete (id string ) error {
162- endpoint := fmt .Sprintf ("%s/api/beta/ access-groups/%s" , c .client .BaseURL , id )
148+ endpoint := fmt .Sprintf ("%s/access-groups/%s" , c .client .GetV1Url () , id )
163149 req , err := http .NewRequest (http .MethodDelete , endpoint , nil )
164150 if err != nil {
165151 return err
0 commit comments