Skip to content

Commit

Permalink
feat: newest config-api client
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 committed Dec 24, 2024
1 parent 5b6b4f4 commit 98ea866
Show file tree
Hide file tree
Showing 134 changed files with 9,230 additions and 1,423 deletions.
2 changes: 1 addition & 1 deletion internal/provider/resources/resource_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (r *agentResource) Delete(

request := r.client.ConfigurationAPI.AgentDelete(ctx, state.ID.ValueString())

_, response, err := util.RetryForTooManyRequests(request.Execute)
response, err := util.RetryForTooManyRequestsNoReturn(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)
if errorPresent {
if response != nil && response.StatusCode == http.StatusNotFound {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (r *agentGroupAssignmentResource) Delete(

request := r.client.ConfigurationAPI.
AgentGroupAssignmentDelete(ctx, state.ID.ValueString())
_, response, err := util.RetryForTooManyRequests(request.Execute)
response, err := util.RetryForTooManyRequestsNoReturn(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)
if errorPresent {
if response != nil && response.StatusCode == http.StatusNotFound {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resources/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (r *groupResource) Delete(

request := r.client.ConfigurationAPI.GroupDelete(ctx, state.ID.ValueString())

_, response, err := util.RetryForTooManyRequests(request.Execute)
response, err := util.RetryForTooManyRequestsNoReturn(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)
if errorPresent {
if response != nil && response.StatusCode == http.StatusNotFound {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (r *networkGroupAssignmentResource) Delete(

request := r.client.ConfigurationAPI.
NetworkGroupAssignmentDelete(ctx, state.ID.ValueString())
_, response, err := util.RetryForTooManyRequests(request.Execute)
response, err := util.RetryForTooManyRequestsNoReturn(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)
if errorPresent {
if response != nil && response.StatusCode == http.StatusNotFound {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (r *sensorGroupAssignmentResource) Delete(

request := r.client.ConfigurationAPI.
SensorGroupAssignmentDelete(ctx, state.ID.ValueString())
_, response, err := util.RetryForTooManyRequests(request.Execute)
response, err := util.RetryForTooManyRequestsNoReturn(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)
if errorPresent {
if response != nil && response.StatusCode == http.StatusNotFound {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (r *serviceTestGroupAssignmentResource) Delete(
request := r.client.ConfigurationAPI.
ServiceTestGroupAssignmentDelete(ctx, state.ID.ValueString())

_, response, err := util.RetryForTooManyRequests(request.Execute)
response, err := util.RetryForTooManyRequestsNoReturn(request.Execute)
errorPresent, errorDetail := util.RaiseForStatus(response, err)
if errorPresent {
if response != nil && response.StatusCode == http.StatusNotFound {
Expand Down
18 changes: 18 additions & 0 deletions internal/provider/util/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ import (

func RetryForTooManyRequests[T any](
f func() (T, *http.Response, error),
) (T, *http.Response, error) {
return retryForTooManyRequests(f)
}

func RetryForTooManyRequestsNoReturn(
f func() (*http.Response, error),
) (*http.Response, error) {
_, httpResponse, err := retryForTooManyRequests(func() (struct{}, *http.Response, error) {
httpResponse, err := f()

return struct{}{}, httpResponse, err
})

return httpResponse, err
}

func retryForTooManyRequests[T any](
f func() (T, *http.Response, error),
) (T, *http.Response, error) {
var result T
var err error
Expand Down
14 changes: 7 additions & 7 deletions pkg/config-api-client/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 98ea866

Please sign in to comment.