@@ -7,24 +7,12 @@ import (
77)
88
99const  (
10- 	cloudAccountsPath                =  "%s/api/cloud/v2/accounts" 
11- 	cloudAccountsWithExternalIDPath  =  "%s/api/cloud/v2/accounts?includeExternalID=true&upsert=true" 
12- 	cloudAccountPath                 =  "%s/api/cloud/v2/accounts/%s" 
13- 	cloudAccountWithExternalIDPath   =  "%s/api/cloud/v2/accounts/%s?includeExternalID=true" 
14- 	providersPath                    =  "%v/api/v2/providers" 
15- 	costCloudAccountPath             =  "%s/api/cloudaccount" 
16- 	costProviderURL                  =  "%s/api/cloudaccount/features/cost/account?id=%d" 
17- 	updateCostProviderURL            =  "%s/api/cloudaccount/features/cost" 
10+ 	providersPath          =  "%v/api/v2/providers" 
11+ 	costCloudAccountPath   =  "%s/api/cloudaccount" 
12+ 	costProviderURL        =  "%s/api/cloudaccount/features/cost/account?id=%d" 
13+ 	updateCostProviderURL  =  "%s/api/cloudaccount/features/cost" 
1814)
1915
20- type  CloudAccountSecureInterface  interface  {
21- 	Base 
22- 	CreateCloudAccountSecure (ctx  context.Context , cloudAccount  * CloudAccountSecure ) (* CloudAccountSecure , error )
23- 	GetCloudAccountSecureByID (ctx  context.Context , accountID  string ) (* CloudAccountSecure , error )
24- 	DeleteCloudAccountSecure (ctx  context.Context , accountID  string ) error 
25- 	UpdateCloudAccountSecure (ctx  context.Context , accountID  string , cloudAccount  * CloudAccountSecure ) (* CloudAccountSecure , error )
26- }
27- 
2816type  CloudAccountMonitorInterface  interface  {
2917	Base 
3018	CreateCloudAccountMonitor (ctx  context.Context , provider  * CloudAccountMonitor ) (* CloudAccountMonitor , error )
@@ -36,89 +24,6 @@ type CloudAccountMonitorInterface interface {
3624	DeleteCloudAccountMonitor (ctx  context.Context , id  int ) error 
3725}
3826
39- func  (c  * Client ) CreateCloudAccountSecure (ctx  context.Context , cloudAccount  * CloudAccountSecure ) (createdAccount  * CloudAccountSecure , err  error ) {
40- 	payload , err  :=  Marshal (cloudAccount )
41- 	if  err  !=  nil  {
42- 		return  nil , err 
43- 	}
44- 
45- 	response , err  :=  c .requester .Request (ctx , http .MethodPost , c .cloudAccountsURL (true ), payload )
46- 	if  err  !=  nil  {
47- 		return  nil , err 
48- 	}
49- 	defer  func () {
50- 		if  dErr  :=  response .Body .Close (); dErr  !=  nil  {
51- 			err  =  fmt .Errorf ("unable to close response body: %w" , dErr )
52- 		}
53- 	}()
54- 
55- 	if  response .StatusCode  !=  http .StatusOK  &&  response .StatusCode  !=  http .StatusCreated  {
56- 		err  =  c .ErrorFromResponse (response )
57- 		return  nil , err 
58- 	}
59- 
60- 	return  Unmarshal [* CloudAccountSecure ](response .Body )
61- }
62- 
63- func  (c  * Client ) GetCloudAccountSecureByID (ctx  context.Context , accountID  string ) (cloudAccount  * CloudAccountSecure , err  error ) {
64- 	response , err  :=  c .requester .Request (ctx , http .MethodGet , c .cloudAccountURL (accountID , true ), nil )
65- 	if  err  !=  nil  {
66- 		return  nil , err 
67- 	}
68- 	defer  func () {
69- 		if  dErr  :=  response .Body .Close (); dErr  !=  nil  {
70- 			err  =  fmt .Errorf ("unable to close response body: %w" , dErr )
71- 		}
72- 	}()
73- 
74- 	if  response .StatusCode  !=  http .StatusOK  {
75- 		return  nil , c .ErrorFromResponse (response )
76- 	}
77- 
78- 	return  Unmarshal [* CloudAccountSecure ](response .Body )
79- }
80- 
81- func  (c  * Client ) DeleteCloudAccountSecure (ctx  context.Context , accountID  string ) (err  error ) {
82- 	response , err  :=  c .requester .Request (ctx , http .MethodDelete , c .cloudAccountURL (accountID , false ), nil )
83- 	if  err  !=  nil  {
84- 		return  err 
85- 	}
86- 	defer  func () {
87- 		if  dErr  :=  response .Body .Close (); dErr  !=  nil  {
88- 			err  =  fmt .Errorf ("unable to close response body: %w" , dErr )
89- 		}
90- 	}()
91- 
92- 	if  response .StatusCode  !=  http .StatusNoContent  &&  response .StatusCode  !=  http .StatusOK  {
93- 		return  c .ErrorFromResponse (response )
94- 	}
95- 	return  nil 
96- }
97- 
98- func  (c  * Client ) UpdateCloudAccountSecure (ctx  context.Context , accountID  string , cloudAccount  * CloudAccountSecure ) (updatedAccount  * CloudAccountSecure , err  error ) {
99- 	payload , err  :=  Marshal (cloudAccount )
100- 	if  err  !=  nil  {
101- 		return  nil , err 
102- 	}
103- 
104- 	response , err  :=  c .requester .Request (ctx , http .MethodPut , c .cloudAccountURL (accountID , true ), payload )
105- 	if  err  !=  nil  {
106- 		return  nil , err 
107- 	}
108- 	defer  func () {
109- 		if  dErr  :=  response .Body .Close (); dErr  !=  nil  {
110- 			err  =  fmt .Errorf ("unable to close response body: %w" , dErr )
111- 		}
112- 	}()
113- 
114- 	if  response .StatusCode  !=  http .StatusOK  {
115- 		err  =  c .ErrorFromResponse (response )
116- 		return  nil , err 
117- 	}
118- 
119- 	return  Unmarshal [* CloudAccountSecure ](response .Body )
120- }
121- 
12227func  (c  * Client ) CreateCloudAccountMonitor (ctx  context.Context , provider  * CloudAccountMonitor ) (createdProvider  * CloudAccountMonitor , err  error ) {
12328	payload , err  :=  Marshal (provider )
12429	if  err  !=  nil  {
@@ -295,20 +200,6 @@ func (c *Client) DeleteCloudAccountMonitor(ctx context.Context, id int) (err err
295200	return  nil 
296201}
297202
298- func  (c  * Client ) cloudAccountsURL (includeExternalID  bool ) string  {
299- 	if  includeExternalID  {
300- 		return  fmt .Sprintf (cloudAccountsWithExternalIDPath , c .config .url )
301- 	}
302- 	return  fmt .Sprintf (cloudAccountsPath , c .config .url )
303- }
304- 
305- func  (c  * Client ) cloudAccountURL (accountID  string , includeExternalID  bool ) string  {
306- 	if  includeExternalID  {
307- 		return  fmt .Sprintf (cloudAccountWithExternalIDPath , c .config .url , accountID )
308- 	}
309- 	return  fmt .Sprintf (cloudAccountPath , c .config .url , accountID )
310- }
311- 
312203func  (c  * Client ) getProviderURL (id  int ) string  {
313204	return  fmt .Sprintf ("%v/%v" , c .getProvidersURL (), id )
314205}
0 commit comments