diff --git a/api/accounts/account.gen.go b/api/accounts/account.gen.go index 31a98a8f14..b3fa2abffa 100644 --- a/api/accounts/account.gen.go +++ b/api/accounts/account.gen.go @@ -2,6 +2,7 @@ package accounts import ( + "bytes" "context" "errors" "fmt" @@ -26,6 +27,17 @@ type Account struct { Type string `json:"type,omitempty"` AuthMethodId string `json:"auth_method_id,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Account) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Account) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/accounts/password_account_attributes.gen.go b/api/accounts/password_account_attributes.gen.go index 2e20d119c7..ec6f3d56c6 100644 --- a/api/accounts/password_account_attributes.gen.go +++ b/api/accounts/password_account_attributes.gen.go @@ -1,7 +1,20 @@ // Code generated by "make api"; DO NOT EDIT. package accounts +import "bytes" + type PasswordAccountAttributes struct { LoginName string `json:"login_name,omitempty"` Password string `json:"password,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n PasswordAccountAttributes) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n PasswordAccountAttributes) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/authmethods/authmethods.gen.go b/api/authmethods/authmethods.gen.go index 96146e5c7c..924b9e54f7 100644 --- a/api/authmethods/authmethods.gen.go +++ b/api/authmethods/authmethods.gen.go @@ -2,6 +2,7 @@ package authmethods import ( + "bytes" "context" "errors" "fmt" @@ -26,6 +27,17 @@ type AuthMethod struct { Version uint32 `json:"version,omitempty"` Type string `json:"type,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n AuthMethod) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n AuthMethod) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/authmethods/password_auth_method_attributes.gen.go b/api/authmethods/password_auth_method_attributes.gen.go index 32b389e633..9f1e773549 100644 --- a/api/authmethods/password_auth_method_attributes.gen.go +++ b/api/authmethods/password_auth_method_attributes.gen.go @@ -1,7 +1,20 @@ // Code generated by "make api"; DO NOT EDIT. package authmethods +import "bytes" + type PasswordAuthMethodAttributes struct { MinLoginNameLength uint32 `json:"min_login_name_length,omitempty"` MinPasswordLength uint32 `json:"min_password_length,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n PasswordAuthMethodAttributes) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n PasswordAuthMethodAttributes) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/authtokens/authtokens.gen.go b/api/authtokens/authtokens.gen.go index f496eaeb41..4fea0428f6 100644 --- a/api/authtokens/authtokens.gen.go +++ b/api/authtokens/authtokens.gen.go @@ -2,6 +2,7 @@ package authtokens import ( + "bytes" "context" "fmt" "net/http" @@ -23,6 +24,17 @@ type AuthToken struct { UpdatedTime time.Time `json:"updated_time,omitempty"` ApproximateLastUsedTime time.Time `json:"approximate_last_used_time,omitempty"` ExpirationTime time.Time `json:"expiration_time,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n AuthToken) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n AuthToken) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/error.gen.go b/api/error.gen.go index 063236c951..b40489dacd 100644 --- a/api/error.gen.go +++ b/api/error.gen.go @@ -1,9 +1,22 @@ // Code generated by "make api"; DO NOT EDIT. package api +import "bytes" + type Error struct { Status int32 `json:"status,omitempty"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` Details *ErrorDetails `json:"details,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Error) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Error) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/error_details.gen.go b/api/error_details.gen.go index fe64c3339e..0521c8cc07 100644 --- a/api/error_details.gen.go +++ b/api/error_details.gen.go @@ -1,8 +1,21 @@ // Code generated by "make api"; DO NOT EDIT. package api +import "bytes" + type ErrorDetails struct { TraceId string `json:"TraceId,omitempty"` RequestId string `json:"request_id,omitempty"` RequestFields []*FieldError `json:"request_fields,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n ErrorDetails) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n ErrorDetails) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/field_error.gen.go b/api/field_error.gen.go index 80ad728831..e79a6a374d 100644 --- a/api/field_error.gen.go +++ b/api/field_error.gen.go @@ -1,7 +1,20 @@ // Code generated by "make api"; DO NOT EDIT. package api +import "bytes" + type FieldError struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n FieldError) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n FieldError) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/groups/group.gen.go b/api/groups/group.gen.go index ff4660f727..d0b8c1ced1 100644 --- a/api/groups/group.gen.go +++ b/api/groups/group.gen.go @@ -2,6 +2,7 @@ package groups import ( + "bytes" "context" "errors" "fmt" @@ -26,6 +27,17 @@ type Group struct { Version uint32 `json:"version,omitempty"` MemberIds []string `json:"member_ids,omitempty"` Members []*Member `json:"members,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Group) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Group) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/groups/member.gen.go b/api/groups/member.gen.go index 351a66d542..4fb11fd91a 100644 --- a/api/groups/member.gen.go +++ b/api/groups/member.gen.go @@ -1,7 +1,20 @@ // Code generated by "make api"; DO NOT EDIT. package groups +import "bytes" + type Member struct { Id string `json:"id,omitempty"` ScopeId string `json:"scope_id,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Member) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Member) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/hostcatalogs/host_catalog.gen.go b/api/hostcatalogs/host_catalog.gen.go index c27079f26c..d56c0567c3 100644 --- a/api/hostcatalogs/host_catalog.gen.go +++ b/api/hostcatalogs/host_catalog.gen.go @@ -2,6 +2,7 @@ package hostcatalogs import ( + "bytes" "context" "errors" "fmt" @@ -26,6 +27,17 @@ type HostCatalog struct { Version uint32 `json:"version,omitempty"` Type string `json:"type,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n HostCatalog) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n HostCatalog) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/hosts/host.gen.go b/api/hosts/host.gen.go index e839ee515c..68b5370809 100644 --- a/api/hosts/host.gen.go +++ b/api/hosts/host.gen.go @@ -2,6 +2,7 @@ package hosts import ( + "bytes" "context" "errors" "fmt" @@ -27,6 +28,17 @@ type Host struct { Type string `json:"type,omitempty"` HostSetIds []string `json:"host_set_ids,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Host) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Host) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/hosts/static_host_attributes.gen.go b/api/hosts/static_host_attributes.gen.go index f16d271369..e7d3fdce27 100644 --- a/api/hosts/static_host_attributes.gen.go +++ b/api/hosts/static_host_attributes.gen.go @@ -1,6 +1,19 @@ // Code generated by "make api"; DO NOT EDIT. package hosts +import "bytes" + type StaticHostAttributes struct { Address string `json:"address,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n StaticHostAttributes) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n StaticHostAttributes) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/hostsets/host_set.gen.go b/api/hostsets/host_set.gen.go index 1a7d7bb87e..1d4babe5f0 100644 --- a/api/hostsets/host_set.gen.go +++ b/api/hostsets/host_set.gen.go @@ -2,6 +2,7 @@ package hostsets import ( + "bytes" "context" "errors" "fmt" @@ -27,6 +28,17 @@ type HostSet struct { HostCatalogId string `json:"host_catalog_id,omitempty"` HostIds []string `json:"host_ids,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n HostSet) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n HostSet) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/internal/genapi/templates.go b/api/internal/genapi/templates.go index 966220e93c..a33823632b 100644 --- a/api/internal/genapi/templates.go +++ b/api/internal/genapi/templates.go @@ -555,6 +555,17 @@ import ( type {{ .Name }} struct { {{ range .Fields }} {{ .Name }} {{ .FieldType }} `, "`json:\"{{ .ProtoName }},omitempty\"`", `{{ end }} + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n {{ .Name }}) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n {{ .Name }}) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } `))) diff --git a/api/response.go b/api/response.go index 72f071d055..7340867dc7 100644 --- a/api/response.go +++ b/api/response.go @@ -14,6 +14,7 @@ type Response struct { resp *http.Response Body *bytes.Buffer + Map map[string]interface{} } // HttpResponse returns the underlying HTTP response @@ -50,14 +51,21 @@ func (r *Response) Decode(inStruct interface{}) (*Error, error) { return nil, fmt.Errorf("error reading response body: %w", err) } - if r.Body.Len() != 0 { - dec := json.NewDecoder(bytes.NewReader(r.Body.Bytes())) + if r.Body.Len() > 0 { + reader := bytes.NewReader(r.Body.Bytes()) + dec := json.NewDecoder(reader) if r.resp.StatusCode >= 400 { inStruct = apiErr } + r.Map = make(map[string]interface{}) + if err := dec.Decode(&r.Map); err != nil { + return nil, fmt.Errorf("error decoding response to map: %w; response was %s", err, r.Body.String()) + } if inStruct != nil { - if err := dec.Decode(inStruct); err != nil { - return nil, fmt.Errorf("error decoding response: %w; response was %s", err, r.Body.String()) + reader.Seek(0, 0) + dec = json.NewDecoder(reader) + if err := dec.Decode(&inStruct); err != nil { + return nil, fmt.Errorf("error decoding response to struct: %w; response was %s", err, r.Body.String()) } } } diff --git a/api/roles/grant.gen.go b/api/roles/grant.gen.go index 79da581f7a..4cca2ce994 100644 --- a/api/roles/grant.gen.go +++ b/api/roles/grant.gen.go @@ -1,8 +1,21 @@ // Code generated by "make api"; DO NOT EDIT. package roles +import "bytes" + type Grant struct { Raw string `json:"raw,omitempty"` Canonical string `json:"canonical,omitempty"` Json *GrantJson `json:"json,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Grant) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Grant) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/roles/grant_json.gen.go b/api/roles/grant_json.gen.go index 310a1d0d24..32c8818ccd 100644 --- a/api/roles/grant_json.gen.go +++ b/api/roles/grant_json.gen.go @@ -1,8 +1,21 @@ // Code generated by "make api"; DO NOT EDIT. package roles +import "bytes" + type GrantJson struct { Id string `json:"id,omitempty"` Type string `json:"type,omitempty"` Actions []string `json:"actions,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n GrantJson) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n GrantJson) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/roles/principal.gen.go b/api/roles/principal.gen.go index 9419e507e4..73243448f2 100644 --- a/api/roles/principal.gen.go +++ b/api/roles/principal.gen.go @@ -1,8 +1,21 @@ // Code generated by "make api"; DO NOT EDIT. package roles +import "bytes" + type Principal struct { Id string `json:"id,omitempty"` Type string `json:"type,omitempty"` ScopeId string `json:"scope_id,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Principal) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Principal) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/roles/role.gen.go b/api/roles/role.gen.go index 05cd4d27b9..a2ebd9fed6 100644 --- a/api/roles/role.gen.go +++ b/api/roles/role.gen.go @@ -2,6 +2,7 @@ package roles import ( + "bytes" "context" "errors" "fmt" @@ -29,6 +30,17 @@ type Role struct { Principals []*Principal `json:"principals,omitempty"` GrantStrings []string `json:"grant_strings,omitempty"` Grants []*Grant `json:"grants,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Role) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Role) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/scopes/scope.gen.go b/api/scopes/scope.gen.go index 74b4294486..10d0162f92 100644 --- a/api/scopes/scope.gen.go +++ b/api/scopes/scope.gen.go @@ -2,6 +2,7 @@ package scopes import ( + "bytes" "context" "errors" "fmt" @@ -24,6 +25,17 @@ type Scope struct { UpdatedTime time.Time `json:"updated_time,omitempty"` Version uint32 `json:"version,omitempty"` Type string `json:"type,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Scope) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Scope) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/scopes/scope_info.gen.go b/api/scopes/scope_info.gen.go index 62d35119e0..f23dab05ba 100644 --- a/api/scopes/scope_info.gen.go +++ b/api/scopes/scope_info.gen.go @@ -1,10 +1,23 @@ // Code generated by "make api"; DO NOT EDIT. package scopes +import "bytes" + type ScopeInfo struct { Id string `json:"id,omitempty"` Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` ParentScopeId string `json:"parent_scope_id,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n ScopeInfo) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n ScopeInfo) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/targets/host_set.gen.go b/api/targets/host_set.gen.go index 611e11c3fb..c14141494d 100644 --- a/api/targets/host_set.gen.go +++ b/api/targets/host_set.gen.go @@ -1,7 +1,20 @@ // Code generated by "make api"; DO NOT EDIT. package targets +import "bytes" + type HostSet struct { Id string `json:"id,omitempty"` HostCatalogId string `json:"host_catalog_id,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n HostSet) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n HostSet) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } diff --git a/api/targets/target.gen.go b/api/targets/target.gen.go index 7cd14b24cc..d210947a57 100644 --- a/api/targets/target.gen.go +++ b/api/targets/target.gen.go @@ -2,6 +2,7 @@ package targets import ( + "bytes" "context" "errors" "fmt" @@ -28,6 +29,17 @@ type Target struct { HostSetIds []string `json:"host_set_ids,omitempty"` HostSets []*HostSet `json:"host_sets,omitempty"` DefaultPort uint32 `json:"default_port,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n Target) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n Target) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection diff --git a/api/users/user.gen.go b/api/users/user.gen.go index 87b2f649b9..f22465f09b 100644 --- a/api/users/user.gen.go +++ b/api/users/user.gen.go @@ -2,6 +2,7 @@ package users import ( + "bytes" "context" "errors" "fmt" @@ -24,6 +25,17 @@ type User struct { CreatedTime time.Time `json:"created_time,omitempty"` UpdatedTime time.Time `json:"updated_time,omitempty"` Version uint32 `json:"version,omitempty"` + + lastResponseBody *bytes.Buffer + lastResponseMap map[string]interface{} +} + +func (n User) LastResponseBody() *bytes.Buffer { + return n.lastResponseBody +} + +func (n User) LastResponseMap() map[string]interface{} { + return n.lastResponseMap } // Client is a client for this collection