Change Format of API Error (#784)

This is a wire breaking change for json errors since we have removed and renamed a few fields, and changed part of the structure of the returned json error.

* Remove redundant fields in Status, details.error_id, details.TraceId and details.request_id from API errors.

* Added wrapped errors and "ops" field to indicate the internal operation of the errors returned by the API.

* Added error cli error reporting of Op and wrapped errors.
This commit is contained in:
Todd Knight authored and GitHub committed 2020-12-07 14:25:16 -07:00
1 parent 18ea39b237
commit aa4157639c
48 files changed
+742 -728

No files matched your search

+23 -28
View File
@@ -25,22 +25,24 @@ type Account struct {
AuthMethodId string `json:"auth_method_id,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Account) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Account) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Account) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type AccountReadResult struct {
Item *Account
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Account
response *api.Response
}
func (n AccountReadResult) GetItem() interface{} {
@@ -48,33 +50,31 @@ func (n AccountReadResult) GetItem() interface{} {
}
func (n AccountReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AccountReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type AccountCreateResult = AccountReadResult
type AccountUpdateResult = AccountReadResult
type AccountDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n AccountDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AccountDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type AccountListResult struct {
Items []*Account
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Account
response *api.Response
}
func (n AccountListResult) GetItems() interface{} {
@@ -82,11 +82,11 @@ func (n AccountListResult) GetItems() interface{} {
}
func (n AccountListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AccountListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -147,8 +147,7 @@ func (c *Client) Create(ctx context.Context, authMethodId string, opt ...Option)
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -189,8 +188,7 @@ func (c *Client) Read(ctx context.Context, accountId string, opt ...Option) (*Ac
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -253,8 +251,7 @@ func (c *Client) Update(ctx context.Context, accountId string, version uint32, o
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -295,8 +292,7 @@ func (c *Client) Delete(ctx context.Context, accountId string, opt ...Option) (*
}
target := &AccountDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -338,7 +334,6 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+6 -6
View File
@@ -8,10 +8,10 @@ import (
)
var (
ErrNotFound = &Error{Status: http.StatusNotFound, Code: codes.NotFound.String()}
ErrInvalidArgument = &Error{Status: http.StatusBadRequest, Code: codes.InvalidArgument.String()}
ErrPermissionDenied = &Error{Status: http.StatusForbidden, Code: codes.PermissionDenied.String()}
ErrUnauthorized = &Error{Status: http.StatusUnauthorized, Code: codes.Unauthenticated.String()}
ErrNotFound = &Error{Kind: codes.NotFound.String(), response: &Response{resp: &http.Response{StatusCode: http.StatusNotFound}}}
ErrInvalidArgument = &Error{Kind: codes.InvalidArgument.String(), response: &Response{resp: &http.Response{StatusCode: http.StatusBadRequest}}}
ErrPermissionDenied = &Error{Kind: codes.PermissionDenied.String(), response: &Response{resp: &http.Response{StatusCode: http.StatusForbidden}}}
ErrUnauthorized = &Error{Kind: codes.Unauthenticated.String(), response: &Response{resp: &http.Response{StatusCode: http.StatusUnauthorized}}}
)
// AsServerError returns an api *Error from the provided error. If the provided error
@@ -26,11 +26,11 @@ func AsServerError(in error) *Error {
// Error satisfies the error interface.
func (e *Error) Error() string {
return e.responseBody.String()
return e.response.Body.String()
}
// Errors are considered the same iff they are both api.Errors and their statuses are the same.
func (e *Error) Is(target error) bool {
tApiErr := AsServerError(target)
return tApiErr != nil && tApiErr.Code == e.Code && tApiErr.Status == e.Status
return tApiErr != nil && tApiErr.Kind == e.Kind && e.ResponseStatus() == tApiErr.ResponseStatus()
}
+23 -28
View File
@@ -25,22 +25,24 @@ type AuthMethod struct {
Type string `json:"type,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n AuthMethod) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthMethod) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n AuthMethod) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type AuthMethodReadResult struct {
Item *AuthMethod
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *AuthMethod
response *api.Response
}
func (n AuthMethodReadResult) GetItem() interface{} {
@@ -48,33 +50,31 @@ func (n AuthMethodReadResult) GetItem() interface{} {
}
func (n AuthMethodReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthMethodReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type AuthMethodCreateResult = AuthMethodReadResult
type AuthMethodUpdateResult = AuthMethodReadResult
type AuthMethodDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n AuthMethodDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthMethodDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type AuthMethodListResult struct {
Items []*AuthMethod
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*AuthMethod
response *api.Response
}
func (n AuthMethodListResult) GetItems() interface{} {
@@ -82,11 +82,11 @@ func (n AuthMethodListResult) GetItems() interface{} {
}
func (n AuthMethodListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthMethodListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -152,8 +152,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -194,8 +193,7 @@ func (c *Client) Read(ctx context.Context, authMethodId string, opt ...Option) (
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -258,8 +256,7 @@ func (c *Client) Update(ctx context.Context, authMethodId string, version uint32
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -300,8 +297,7 @@ func (c *Client) Delete(ctx context.Context, authMethodId string, opt ...Option)
}
target := &AuthMethodDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -343,7 +339,6 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+21 -24
View File
@@ -25,22 +25,24 @@ type AuthToken struct {
ApproximateLastUsedTime time.Time `json:"approximate_last_used_time,omitempty"`
ExpirationTime time.Time `json:"expiration_time,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n AuthToken) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthToken) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n AuthToken) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type AuthTokenReadResult struct {
Item *AuthToken
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *AuthToken
response *api.Response
}
func (n AuthTokenReadResult) GetItem() interface{} {
@@ -48,33 +50,31 @@ func (n AuthTokenReadResult) GetItem() interface{} {
}
func (n AuthTokenReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthTokenReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type AuthTokenCreateResult = AuthTokenReadResult
type AuthTokenUpdateResult = AuthTokenReadResult
type AuthTokenDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n AuthTokenDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthTokenDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type AuthTokenListResult struct {
Items []*AuthToken
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*AuthToken
response *api.Response
}
func (n AuthTokenListResult) GetItems() interface{} {
@@ -82,11 +82,11 @@ func (n AuthTokenListResult) GetItems() interface{} {
}
func (n AuthTokenListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n AuthTokenListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -144,8 +144,7 @@ func (c *Client) Read(ctx context.Context, authTokenId string, opt ...Option) (*
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -186,8 +185,7 @@ func (c *Client) Delete(ctx context.Context, authTokenId string, opt ...Option)
}
target := &AuthTokenDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -229,7 +227,6 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+9 -6
View File
@@ -4,19 +4,22 @@ package api
import "bytes"
type Error struct {
Status int32 `json:"status,omitempty"`
Code string `json:"code,omitempty"`
Kind string `json:"kind,omitempty"`
Op string `json:"op,omitempty"`
Message string `json:"message,omitempty"`
Details *ErrorDetails `json:"details,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *Response
}
func (n Error) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Error) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Error) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
+2 -4
View File
@@ -2,8 +2,6 @@
package api
type ErrorDetails struct {
TraceId string `json:"TraceId,omitempty"`
RequestId string `json:"request_id,omitempty"`
ErrorId string `json:"error_id,omitempty"`
RequestFields []*FieldError `json:"request_fields,omitempty"`
RequestFields []*FieldError `json:"request_fields,omitempty"`
WrappedErrors []*WrappedError `json:"wrapped_errors,omitempty"`
}
+26 -34
View File
@@ -25,22 +25,24 @@ type Group struct {
MemberIds []string `json:"member_ids,omitempty"`
Members []*Member `json:"members,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Group) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Group) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Group) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type GroupReadResult struct {
Item *Group
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Group
response *api.Response
}
func (n GroupReadResult) GetItem() interface{} {
@@ -48,33 +50,31 @@ func (n GroupReadResult) GetItem() interface{} {
}
func (n GroupReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n GroupReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type GroupCreateResult = GroupReadResult
type GroupUpdateResult = GroupReadResult
type GroupDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n GroupDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n GroupDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type GroupListResult struct {
Items []*Group
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Group
response *api.Response
}
func (n GroupListResult) GetItems() interface{} {
@@ -82,11 +82,11 @@ func (n GroupListResult) GetItems() interface{} {
}
func (n GroupListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n GroupListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -147,8 +147,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Gr
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -189,8 +188,7 @@ func (c *Client) Read(ctx context.Context, groupId string, opt ...Option) (*Grou
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -253,8 +251,7 @@ func (c *Client) Update(ctx context.Context, groupId string, version uint32, opt
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -295,8 +292,7 @@ func (c *Client) Delete(ctx context.Context, groupId string, opt ...Option) (*Gr
}
target := &GroupDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -338,8 +334,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Grou
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -406,8 +401,7 @@ func (c *Client) AddMembers(ctx context.Context, groupId string, version uint32,
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -472,8 +466,7 @@ func (c *Client) SetMembers(ctx context.Context, groupId string, version uint32,
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -540,7 +533,6 @@ func (c *Client) RemoveMembers(ctx context.Context, groupId string, version uint
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+23 -28
View File
@@ -25,22 +25,24 @@ type HostCatalog struct {
Type string `json:"type,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n HostCatalog) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostCatalog) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n HostCatalog) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type HostCatalogReadResult struct {
Item *HostCatalog
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *HostCatalog
response *api.Response
}
func (n HostCatalogReadResult) GetItem() interface{} {
@@ -48,33 +50,31 @@ func (n HostCatalogReadResult) GetItem() interface{} {
}
func (n HostCatalogReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostCatalogReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type HostCatalogCreateResult = HostCatalogReadResult
type HostCatalogUpdateResult = HostCatalogReadResult
type HostCatalogDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n HostCatalogDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostCatalogDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type HostCatalogListResult struct {
Items []*HostCatalog
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*HostCatalog
response *api.Response
}
func (n HostCatalogListResult) GetItems() interface{} {
@@ -82,11 +82,11 @@ func (n HostCatalogListResult) GetItems() interface{} {
}
func (n HostCatalogListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostCatalogListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -152,8 +152,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -194,8 +193,7 @@ func (c *Client) Read(ctx context.Context, hostCatalogId string, opt ...Option)
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -258,8 +256,7 @@ func (c *Client) Update(ctx context.Context, hostCatalogId string, version uint3
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -300,8 +297,7 @@ func (c *Client) Delete(ctx context.Context, hostCatalogId string, opt ...Option
}
target := &HostCatalogDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -343,7 +339,6 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Host
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+23 -28
View File
@@ -26,22 +26,24 @@ type Host struct {
HostSetIds []string `json:"host_set_ids,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Host) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Host) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Host) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type HostReadResult struct {
Item *Host
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Host
response *api.Response
}
func (n HostReadResult) GetItem() interface{} {
@@ -49,33 +51,31 @@ func (n HostReadResult) GetItem() interface{} {
}
func (n HostReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type HostCreateResult = HostReadResult
type HostUpdateResult = HostReadResult
type HostDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n HostDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type HostListResult struct {
Items []*Host
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Host
response *api.Response
}
func (n HostListResult) GetItems() interface{} {
@@ -83,11 +83,11 @@ func (n HostListResult) GetItems() interface{} {
}
func (n HostListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -148,8 +148,7 @@ func (c *Client) Create(ctx context.Context, hostCatalogId string, opt ...Option
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -190,8 +189,7 @@ func (c *Client) Read(ctx context.Context, hostId string, opt ...Option) (*HostR
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -254,8 +252,7 @@ func (c *Client) Update(ctx context.Context, hostId string, version uint32, opt
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -296,8 +293,7 @@ func (c *Client) Delete(ctx context.Context, hostId string, opt ...Option) (*Hos
}
target := &HostDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -339,7 +335,6 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+26 -34
View File
@@ -26,22 +26,24 @@ type HostSet struct {
HostIds []string `json:"host_ids,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n HostSet) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostSet) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n HostSet) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type HostSetReadResult struct {
Item *HostSet
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *HostSet
response *api.Response
}
func (n HostSetReadResult) GetItem() interface{} {
@@ -49,33 +51,31 @@ func (n HostSetReadResult) GetItem() interface{} {
}
func (n HostSetReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostSetReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type HostSetCreateResult = HostSetReadResult
type HostSetUpdateResult = HostSetReadResult
type HostSetDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n HostSetDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostSetDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type HostSetListResult struct {
Items []*HostSet
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*HostSet
response *api.Response
}
func (n HostSetListResult) GetItems() interface{} {
@@ -83,11 +83,11 @@ func (n HostSetListResult) GetItems() interface{} {
}
func (n HostSetListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n HostSetListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -148,8 +148,7 @@ func (c *Client) Create(ctx context.Context, hostCatalogId string, opt ...Option
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -190,8 +189,7 @@ func (c *Client) Read(ctx context.Context, hostSetId string, opt ...Option) (*Ho
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -254,8 +252,7 @@ func (c *Client) Update(ctx context.Context, hostSetId string, version uint32, o
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -296,8 +293,7 @@ func (c *Client) Delete(ctx context.Context, hostSetId string, opt ...Option) (*
}
target := &HostSetDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -339,8 +335,7 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -407,8 +402,7 @@ func (c *Client) AddHosts(ctx context.Context, hostSetId string, version uint32,
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -473,8 +467,7 @@ func (c *Client) SetHosts(ctx context.Context, hostSetId string, version uint32,
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -541,7 +534,6 @@ func (c *Client) RemoveHosts(ctx context.Context, hostSetId string, version uint
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+7 -16
View File
@@ -33,18 +33,12 @@ func (r *Response) Decode(inStruct interface{}) (*Error, error) {
return nil, nil
}
// TODO Remove as we'll use the common err format for this
if r.resp.StatusCode == 403 {
// Nothing to be done
return &Error{
Status: http.StatusForbidden,
Message: "Forbidden",
}, nil
if r.resp.StatusCode >= 400 {
// If the status code is >= 400 the body of the response will be the
// json representation of the Error struct so we decode it as such.
inStruct = &Error{}
}
apiErr := &Error{
Status: int32(r.resp.StatusCode),
}
if r.resp.Body != nil {
r.Body = new(bytes.Buffer)
if _, err := r.Body.ReadFrom(r.resp.Body); err != nil {
@@ -55,9 +49,6 @@ func (r *Response) Decode(inStruct interface{}) (*Error, error) {
reader := bytes.NewReader(r.Body.Bytes())
dec := json.NewDecoder(reader)
dec.UseNumber()
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())
@@ -71,10 +62,10 @@ func (r *Response) Decode(inStruct interface{}) (*Error, error) {
}
}
}
if r.resp.StatusCode >= 400 {
errStruct := inStruct.(*Error)
errStruct.responseBody = r.Body
errStruct.responseMap = r.Map
apiErr := inStruct.(*Error)
apiErr.response = r
return apiErr, nil
}
+29 -40
View File
@@ -28,22 +28,24 @@ type Role struct {
GrantStrings []string `json:"grant_strings,omitempty"`
Grants []*Grant `json:"grants,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Role) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Role) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Role) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type RoleReadResult struct {
Item *Role
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Role
response *api.Response
}
func (n RoleReadResult) GetItem() interface{} {
@@ -51,33 +53,31 @@ func (n RoleReadResult) GetItem() interface{} {
}
func (n RoleReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n RoleReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type RoleCreateResult = RoleReadResult
type RoleUpdateResult = RoleReadResult
type RoleDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n RoleDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n RoleDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type RoleListResult struct {
Items []*Role
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Role
response *api.Response
}
func (n RoleListResult) GetItems() interface{} {
@@ -85,11 +85,11 @@ func (n RoleListResult) GetItems() interface{} {
}
func (n RoleListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n RoleListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -150,8 +150,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Ro
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -192,8 +191,7 @@ func (c *Client) Read(ctx context.Context, roleId string, opt ...Option) (*RoleR
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -256,8 +254,7 @@ func (c *Client) Update(ctx context.Context, roleId string, version uint32, opt
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -298,8 +295,7 @@ func (c *Client) Delete(ctx context.Context, roleId string, opt ...Option) (*Rol
}
target := &RoleDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -341,8 +337,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Role
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -409,8 +404,7 @@ func (c *Client) AddGrants(ctx context.Context, roleId string, version uint32, g
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -477,8 +471,7 @@ func (c *Client) AddPrincipals(ctx context.Context, roleId string, version uint3
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -543,8 +536,7 @@ func (c *Client) SetGrants(ctx context.Context, roleId string, version uint32, g
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -609,8 +601,7 @@ func (c *Client) SetPrincipals(ctx context.Context, roleId string, version uint3
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -677,8 +668,7 @@ func (c *Client) RemoveGrants(ctx context.Context, roleId string, version uint32
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -745,7 +735,6 @@ func (c *Client) RemovePrincipals(ctx context.Context, roleId string, version ui
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+23 -28
View File
@@ -23,22 +23,24 @@ type Scope struct {
Version uint32 `json:"version,omitempty"`
Type string `json:"type,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Scope) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Scope) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Scope) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type ScopeReadResult struct {
Item *Scope
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Scope
response *api.Response
}
func (n ScopeReadResult) GetItem() interface{} {
@@ -46,33 +48,31 @@ func (n ScopeReadResult) GetItem() interface{} {
}
func (n ScopeReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n ScopeReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type ScopeCreateResult = ScopeReadResult
type ScopeUpdateResult = ScopeReadResult
type ScopeDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n ScopeDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n ScopeDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type ScopeListResult struct {
Items []*Scope
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Scope
response *api.Response
}
func (n ScopeListResult) GetItems() interface{} {
@@ -80,11 +80,11 @@ func (n ScopeListResult) GetItems() interface{} {
}
func (n ScopeListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n ScopeListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -145,8 +145,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Sc
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -187,8 +186,7 @@ func (c *Client) Read(ctx context.Context, scopeId string, opt ...Option) (*Scop
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -251,8 +249,7 @@ func (c *Client) Update(ctx context.Context, scopeId string, version uint32, opt
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -293,8 +290,7 @@ func (c *Client) Delete(ctx context.Context, scopeId string, opt ...Option) (*Sc
}
target := &ScopeDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -336,7 +332,6 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Scop
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+1 -2
View File
@@ -68,7 +68,6 @@ func (c *Client) Cancel(ctx context.Context, sessionId string, version uint32, o
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+20 -22
View File
@@ -33,22 +33,24 @@ type Session struct {
Certificate []byte `json:"certificate,omitempty"`
TerminationReason string `json:"termination_reason,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Session) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Session) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Session) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type SessionReadResult struct {
Item *Session
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Session
response *api.Response
}
func (n SessionReadResult) GetItem() interface{} {
@@ -56,33 +58,31 @@ func (n SessionReadResult) GetItem() interface{} {
}
func (n SessionReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n SessionReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type SessionCreateResult = SessionReadResult
type SessionUpdateResult = SessionReadResult
type SessionDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n SessionDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n SessionDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type SessionListResult struct {
Items []*Session
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Session
response *api.Response
}
func (n SessionListResult) GetItems() interface{} {
@@ -90,11 +90,11 @@ func (n SessionListResult) GetItems() interface{} {
}
func (n SessionListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n SessionListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -152,8 +152,7 @@ func (c *Client) Read(ctx context.Context, sessionId string, opt ...Option) (*Se
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -194,7 +193,6 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+26 -34
View File
@@ -29,22 +29,24 @@ type Target struct {
SessionConnectionLimit int32 `json:"session_connection_limit,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n Target) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n Target) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n Target) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type TargetReadResult struct {
Item *Target
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *Target
response *api.Response
}
func (n TargetReadResult) GetItem() interface{} {
@@ -52,33 +54,31 @@ func (n TargetReadResult) GetItem() interface{} {
}
func (n TargetReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n TargetReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type TargetCreateResult = TargetReadResult
type TargetUpdateResult = TargetReadResult
type TargetDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n TargetDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n TargetDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type TargetListResult struct {
Items []*Target
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*Target
response *api.Response
}
func (n TargetListResult) GetItems() interface{} {
@@ -86,11 +86,11 @@ func (n TargetListResult) GetItems() interface{} {
}
func (n TargetListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n TargetListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -156,8 +156,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -198,8 +197,7 @@ func (c *Client) Read(ctx context.Context, targetId string, opt ...Option) (*Tar
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -262,8 +260,7 @@ func (c *Client) Update(ctx context.Context, targetId string, version uint32, op
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -304,8 +301,7 @@ func (c *Client) Delete(ctx context.Context, targetId string, opt ...Option) (*T
}
target := &TargetDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -347,8 +343,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Targ
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -415,8 +410,7 @@ func (c *Client) AddHostSets(ctx context.Context, targetId string, version uint3
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -481,8 +475,7 @@ func (c *Client) SetHostSets(ctx context.Context, targetId string, version uint3
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -549,7 +542,6 @@ func (c *Client) RemoveHostSets(ctx context.Context, targetId string, version ui
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+26 -34
View File
@@ -25,22 +25,24 @@ type User struct {
AccountIds []string `json:"account_ids,omitempty"`
Accounts []*Account `json:"accounts,omitempty"`
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n User) ResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n User) ResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
func (n User) ResponseStatus() int {
return n.response.HttpResponse().StatusCode
}
type UserReadResult struct {
Item *User
responseBody *bytes.Buffer
responseMap map[string]interface{}
Item *User
response *api.Response
}
func (n UserReadResult) GetItem() interface{} {
@@ -48,33 +50,31 @@ func (n UserReadResult) GetItem() interface{} {
}
func (n UserReadResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n UserReadResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type UserCreateResult = UserReadResult
type UserUpdateResult = UserReadResult
type UserDeleteResult struct {
responseBody *bytes.Buffer
responseMap map[string]interface{}
response *api.Response
}
func (n UserDeleteResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n UserDeleteResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
type UserListResult struct {
Items []*User
responseBody *bytes.Buffer
responseMap map[string]interface{}
Items []*User
response *api.Response
}
func (n UserListResult) GetItems() interface{} {
@@ -82,11 +82,11 @@ func (n UserListResult) GetItems() interface{} {
}
func (n UserListResult) GetResponseBody() *bytes.Buffer {
return n.responseBody
return n.response.Body
}
func (n UserListResult) GetResponseMap() map[string]interface{} {
return n.responseMap
return n.response.Map
}
// Client is a client for this collection
@@ -147,8 +147,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Us
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -189,8 +188,7 @@ func (c *Client) Read(ctx context.Context, userId string, opt ...Option) (*UserR
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -253,8 +251,7 @@ func (c *Client) Update(ctx context.Context, userId string, version uint32, opt
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -295,8 +292,7 @@ func (c *Client) Delete(ctx context.Context, userId string, opt ...Option) (*Use
}
target := &UserDeleteResult{
responseBody: resp.Body,
responseMap: resp.Map,
response: resp,
}
return target, nil
}
@@ -338,8 +334,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*User
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -406,8 +401,7 @@ func (c *Client) AddAccounts(ctx context.Context, userId string, version uint32,
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -472,8 +466,7 @@ func (c *Client) SetAccounts(ctx context.Context, userId string, version uint32,
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
@@ -540,7 +533,6 @@ func (c *Client) RemoveAccounts(ctx context.Context, userId string, version uint
if apiErr != nil {
return nil, apiErr
}
target.responseBody = resp.Body
target.responseMap = resp.Map
target.response = resp
return target, nil
}
+7
View File
@@ -0,0 +1,7 @@
// Code generated by "make api"; DO NOT EDIT.
package api
type WrappedError struct {
Op string `json:"op,omitempty"`
Message string `json:"message,omitempty"`
}