Update core-zero import client

This commit is contained in:
Joe Kralicky 2024-10-01 12:47:16 -04:00
parent 77665603ce
commit 35e4b782ea
No known key found for this signature in database
GPG key ID: 75C4875F34A9FB79
15 changed files with 122 additions and 780 deletions

View file

@ -696,7 +696,9 @@ func (r ReportClusterResourceBundleStatusResp) StatusCode() int {
type ImportConfigurationResp struct {
Body []byte
HTTPResponse *http.Response
JSON200 *ImportResponse
JSON400 *ErrorResponse
JSON403 *ErrorResponse
JSON413 *ErrorResponse
JSON500 *ErrorResponse
}
@ -1058,6 +1060,13 @@ func ParseImportConfigurationResp(rsp *http.Response) (*ImportConfigurationResp,
}
switch {
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
var dest ImportResponse
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
return nil, err
}
response.JSON200 = &dest
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
var dest ErrorResponse
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
@ -1065,6 +1074,13 @@ func ParseImportConfigurationResp(rsp *http.Response) (*ImportConfigurationResp,
}
response.JSON400 = &dest
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
var dest ErrorResponse
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
return nil, err
}
response.JSON403 = &dest
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413:
var dest ErrorResponse
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
@ -1316,6 +1332,11 @@ func (r *ImportConfigurationResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse
}
// GetValue implements apierror.APIResponse
func (r *ImportConfigurationResp) GetValue() *ImportResponse {
return r.JSON200
}
// GetBadRequestError implements apierror.APIResponse
func (r *ImportConfigurationResp) GetBadRequestError() (string, bool) {
if r.JSON400 == nil {
@ -1324,6 +1345,13 @@ func (r *ImportConfigurationResp) GetBadRequestError() (string, bool) {
return r.JSON400.Error, true
}
func (r *ImportConfigurationResp) GetForbiddenError() (string, bool) {
if r.JSON403 == nil {
return "", false
}
return r.JSON403.Error, true
}
// GetInternalServerError implements apierror.APIResponse
func (r *ImportConfigurationResp) GetInternalServerError() (string, bool) {
if r.JSON500 == nil {
@ -1332,14 +1360,6 @@ func (r *ImportConfigurationResp) GetInternalServerError() (string, bool) {
return r.JSON500.Error, true
}
// GetValue implements apierror.APIResponse
func (r *ImportConfigurationResp) GetValue() *EmptyResponse {
if r.StatusCode()/100 != 2 {
return nil
}
return &EmptyResponse{}
}
// GetHTTPResponse implements apierror.APIResponse
func (r *GetQuotasResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse