Add ListResolvableAliases SDK changes (#4653)
* Add API changs for list resolvable aliases
This commit is contained in:
32 files changed
+614
-411
No files matched your search
+15
-17
@@ -30,13 +30,11 @@ type Account struct {
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
ManagedGroupIds []string `json:"managed_group_ids,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type AccountReadResult struct {
|
||||
Item *Account
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AccountReadResult) GetItem() *Account {
|
||||
@@ -44,14 +42,14 @@ func (n AccountReadResult) GetItem() *Account {
|
||||
}
|
||||
|
||||
func (n AccountReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AccountCreateResult = AccountReadResult
|
||||
type AccountUpdateResult = AccountReadResult
|
||||
|
||||
type AccountDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for AccountDeleteResult
|
||||
@@ -60,7 +58,7 @@ func (n AccountDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n AccountDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AccountListResult struct {
|
||||
@@ -69,7 +67,7 @@ type AccountListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AccountListResult) GetItems() []*Account {
|
||||
@@ -93,7 +91,7 @@ func (n AccountListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n AccountListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -154,7 +152,7 @@ func (c *Client) Create(ctx context.Context, authMethodId string, opt ...Option)
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*AccountRe
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -258,7 +256,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -299,7 +297,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Account
|
||||
}
|
||||
|
||||
target := &AccountDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -341,7 +339,7 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -399,7 +397,7 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -434,11 +432,11 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -63,6 +63,6 @@ func (c *Client) ChangePassword(ctx context.Context, accountId, currentPassword,
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -62,6 +62,6 @@ func (c *Client) SetPassword(ctx context.Context, accountId, password string, ve
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
+15
-17
@@ -31,13 +31,11 @@ type Alias struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type AliasReadResult struct {
|
||||
Item *Alias
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AliasReadResult) GetItem() *Alias {
|
||||
@@ -45,14 +43,14 @@ func (n AliasReadResult) GetItem() *Alias {
|
||||
}
|
||||
|
||||
func (n AliasReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AliasCreateResult = AliasReadResult
|
||||
type AliasUpdateResult = AliasReadResult
|
||||
|
||||
type AliasDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for AliasDeleteResult
|
||||
@@ -61,7 +59,7 @@ func (n AliasDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n AliasDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AliasListResult struct {
|
||||
@@ -70,7 +68,7 @@ type AliasListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AliasListResult) GetItems() []*Alias {
|
||||
@@ -94,7 +92,7 @@ func (n AliasListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n AliasListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -160,7 +158,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -201,7 +199,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*AliasRead
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -264,7 +262,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -305,7 +303,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*AliasDe
|
||||
}
|
||||
|
||||
target := &AliasDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -347,7 +345,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Alia
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -405,7 +403,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Alia
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -440,11 +438,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Alia
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -31,13 +31,11 @@ type AuthMethod struct {
|
||||
IsPrimary bool `json:"is_primary,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
AuthorizedCollectionActions map[string][]string `json:"authorized_collection_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type AuthMethodReadResult struct {
|
||||
Item *AuthMethod
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AuthMethodReadResult) GetItem() *AuthMethod {
|
||||
@@ -45,14 +43,14 @@ func (n AuthMethodReadResult) GetItem() *AuthMethod {
|
||||
}
|
||||
|
||||
func (n AuthMethodReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AuthMethodCreateResult = AuthMethodReadResult
|
||||
type AuthMethodUpdateResult = AuthMethodReadResult
|
||||
|
||||
type AuthMethodDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for AuthMethodDeleteResult
|
||||
@@ -61,7 +59,7 @@ func (n AuthMethodDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n AuthMethodDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AuthMethodListResult struct {
|
||||
@@ -70,7 +68,7 @@ type AuthMethodListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AuthMethodListResult) GetItems() []*AuthMethod {
|
||||
@@ -94,7 +92,7 @@ func (n AuthMethodListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n AuthMethodListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -160,7 +158,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -201,7 +199,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*AuthMetho
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -264,7 +262,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -305,7 +303,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*AuthMet
|
||||
}
|
||||
|
||||
target := &AuthMethodDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -347,7 +345,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -405,7 +403,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -440,11 +438,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -75,6 +75,6 @@ func (c *Client) ChangeState(ctx context.Context, authMethodId string, version u
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -29,13 +29,11 @@ type AuthToken struct {
|
||||
ApproximateLastUsedTime time.Time `json:"approximate_last_used_time,omitempty"`
|
||||
ExpirationTime time.Time `json:"expiration_time,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type AuthTokenReadResult struct {
|
||||
Item *AuthToken
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AuthTokenReadResult) GetItem() *AuthToken {
|
||||
@@ -43,13 +41,13 @@ func (n AuthTokenReadResult) GetItem() *AuthToken {
|
||||
}
|
||||
|
||||
func (n AuthTokenReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AuthTokenUpdateResult = AuthTokenReadResult
|
||||
|
||||
type AuthTokenDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for AuthTokenDeleteResult
|
||||
@@ -58,7 +56,7 @@ func (n AuthTokenDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n AuthTokenDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type AuthTokenListResult struct {
|
||||
@@ -67,7 +65,7 @@ type AuthTokenListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n AuthTokenListResult) GetItems() []*AuthToken {
|
||||
@@ -91,7 +89,7 @@ func (n AuthTokenListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n AuthTokenListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -149,7 +147,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*AuthToken
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -190,7 +188,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*AuthTok
|
||||
}
|
||||
|
||||
target := &AuthTokenDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -232,7 +230,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -290,7 +288,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -325,11 +323,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Auth
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -31,13 +31,11 @@ type CredentialLibrary struct {
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
CredentialType string `json:"credential_type,omitempty"`
|
||||
CredentialMappingOverrides map[string]interface{} `json:"credential_mapping_overrides,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type CredentialLibraryReadResult struct {
|
||||
Item *CredentialLibrary
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CredentialLibraryReadResult) GetItem() *CredentialLibrary {
|
||||
@@ -45,14 +43,14 @@ func (n CredentialLibraryReadResult) GetItem() *CredentialLibrary {
|
||||
}
|
||||
|
||||
func (n CredentialLibraryReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type CredentialLibraryCreateResult = CredentialLibraryReadResult
|
||||
type CredentialLibraryUpdateResult = CredentialLibraryReadResult
|
||||
|
||||
type CredentialLibraryDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for CredentialLibraryDeleteResult
|
||||
@@ -61,7 +59,7 @@ func (n CredentialLibraryDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n CredentialLibraryDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type CredentialLibraryListResult struct {
|
||||
@@ -70,7 +68,7 @@ type CredentialLibraryListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CredentialLibraryListResult) GetItems() []*CredentialLibrary {
|
||||
@@ -94,7 +92,7 @@ func (n CredentialLibraryListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n CredentialLibraryListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -160,7 +158,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, credentialStor
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -201,7 +199,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*Credentia
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -264,7 +262,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -305,7 +303,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Credent
|
||||
}
|
||||
|
||||
target := &CredentialLibraryDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -347,7 +345,7 @@ func (c *Client) List(ctx context.Context, credentialStoreId string, opt ...Opti
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -405,7 +403,7 @@ func (c *Client) List(ctx context.Context, credentialStoreId string, opt ...Opti
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -440,11 +438,11 @@ func (c *Client) List(ctx context.Context, credentialStoreId string, opt ...Opti
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -29,13 +29,11 @@ type Credential struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type CredentialReadResult struct {
|
||||
Item *Credential
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CredentialReadResult) GetItem() *Credential {
|
||||
@@ -43,14 +41,14 @@ func (n CredentialReadResult) GetItem() *Credential {
|
||||
}
|
||||
|
||||
func (n CredentialReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type CredentialCreateResult = CredentialReadResult
|
||||
type CredentialUpdateResult = CredentialReadResult
|
||||
|
||||
type CredentialDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for CredentialDeleteResult
|
||||
@@ -59,7 +57,7 @@ func (n CredentialDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n CredentialDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type CredentialListResult struct {
|
||||
@@ -68,7 +66,7 @@ type CredentialListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CredentialListResult) GetItems() []*Credential {
|
||||
@@ -92,7 +90,7 @@ func (n CredentialListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n CredentialListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -158,7 +156,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, credentialStor
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -199,7 +197,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*Credentia
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -262,7 +260,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -303,7 +301,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Credent
|
||||
}
|
||||
|
||||
target := &CredentialDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -345,7 +343,7 @@ func (c *Client) List(ctx context.Context, credentialStoreId string, opt ...Opti
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -403,7 +401,7 @@ func (c *Client) List(ctx context.Context, credentialStoreId string, opt ...Opti
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -438,11 +436,11 @@ func (c *Client) List(ctx context.Context, credentialStoreId string, opt ...Opti
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -30,13 +30,11 @@ type CredentialStore struct {
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
AuthorizedCollectionActions map[string][]string `json:"authorized_collection_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type CredentialStoreReadResult struct {
|
||||
Item *CredentialStore
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CredentialStoreReadResult) GetItem() *CredentialStore {
|
||||
@@ -44,14 +42,14 @@ func (n CredentialStoreReadResult) GetItem() *CredentialStore {
|
||||
}
|
||||
|
||||
func (n CredentialStoreReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type CredentialStoreCreateResult = CredentialStoreReadResult
|
||||
type CredentialStoreUpdateResult = CredentialStoreReadResult
|
||||
|
||||
type CredentialStoreDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for CredentialStoreDeleteResult
|
||||
@@ -60,7 +58,7 @@ func (n CredentialStoreDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n CredentialStoreDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type CredentialStoreListResult struct {
|
||||
@@ -69,7 +67,7 @@ type CredentialStoreListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CredentialStoreListResult) GetItems() []*CredentialStore {
|
||||
@@ -93,7 +91,7 @@ func (n CredentialStoreListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n CredentialStoreListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -159,7 +157,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -200,7 +198,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*Credentia
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -263,7 +261,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -304,7 +302,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Credent
|
||||
}
|
||||
|
||||
target := &CredentialStoreDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -346,7 +344,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Cred
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -404,7 +402,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Cred
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -439,11 +437,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Cred
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
+18
-20
@@ -29,13 +29,11 @@ type Group struct {
|
||||
MemberIds []string `json:"member_ids,omitempty"`
|
||||
Members []*Member `json:"members,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type GroupReadResult struct {
|
||||
Item *Group
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n GroupReadResult) GetItem() *Group {
|
||||
@@ -43,14 +41,14 @@ func (n GroupReadResult) GetItem() *Group {
|
||||
}
|
||||
|
||||
func (n GroupReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type GroupCreateResult = GroupReadResult
|
||||
type GroupUpdateResult = GroupReadResult
|
||||
|
||||
type GroupDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for GroupDeleteResult
|
||||
@@ -59,7 +57,7 @@ func (n GroupDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n GroupDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type GroupListResult struct {
|
||||
@@ -68,7 +66,7 @@ type GroupListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n GroupListResult) GetItems() []*Group {
|
||||
@@ -92,7 +90,7 @@ func (n GroupListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n GroupListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -153,7 +151,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Gr
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -194,7 +192,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*GroupRead
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -257,7 +255,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -298,7 +296,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*GroupDe
|
||||
}
|
||||
|
||||
target := &GroupDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -340,7 +338,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Grou
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -398,7 +396,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Grou
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -433,11 +431,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Grou
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
@@ -511,7 +509,7 @@ func (c *Client) AddMembers(ctx context.Context, id string, version uint32, memb
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -577,7 +575,7 @@ func (c *Client) SetMembers(ctx context.Context, id string, version uint32, memb
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -647,6 +645,6 @@ func (c *Client) RemoveMembers(ctx context.Context, id string, version uint32, m
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -35,13 +35,11 @@ type HostCatalog struct {
|
||||
SecretsHmac string `json:"secrets_hmac,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
AuthorizedCollectionActions map[string][]string `json:"authorized_collection_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type HostCatalogReadResult struct {
|
||||
Item *HostCatalog
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n HostCatalogReadResult) GetItem() *HostCatalog {
|
||||
@@ -49,14 +47,14 @@ func (n HostCatalogReadResult) GetItem() *HostCatalog {
|
||||
}
|
||||
|
||||
func (n HostCatalogReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type HostCatalogCreateResult = HostCatalogReadResult
|
||||
type HostCatalogUpdateResult = HostCatalogReadResult
|
||||
|
||||
type HostCatalogDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for HostCatalogDeleteResult
|
||||
@@ -65,7 +63,7 @@ func (n HostCatalogDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n HostCatalogDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type HostCatalogListResult struct {
|
||||
@@ -74,7 +72,7 @@ type HostCatalogListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n HostCatalogListResult) GetItems() []*HostCatalog {
|
||||
@@ -98,7 +96,7 @@ func (n HostCatalogListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n HostCatalogListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -164,7 +162,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -205,7 +203,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*HostCatal
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -268,7 +266,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -309,7 +307,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*HostCat
|
||||
}
|
||||
|
||||
target := &HostCatalogDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -351,7 +349,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Host
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -409,7 +407,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Host
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -444,11 +442,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Host
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
+15
-17
@@ -36,13 +36,11 @@ type Host struct {
|
||||
ExternalId string `json:"external_id,omitempty"`
|
||||
ExternalName string `json:"external_name,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type HostReadResult struct {
|
||||
Item *Host
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n HostReadResult) GetItem() *Host {
|
||||
@@ -50,14 +48,14 @@ func (n HostReadResult) GetItem() *Host {
|
||||
}
|
||||
|
||||
func (n HostReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type HostCreateResult = HostReadResult
|
||||
type HostUpdateResult = HostReadResult
|
||||
|
||||
type HostDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for HostDeleteResult
|
||||
@@ -66,7 +64,7 @@ func (n HostDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n HostDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type HostListResult struct {
|
||||
@@ -75,7 +73,7 @@ type HostListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n HostListResult) GetItems() []*Host {
|
||||
@@ -99,7 +97,7 @@ func (n HostListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n HostListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -160,7 +158,7 @@ func (c *Client) Create(ctx context.Context, hostCatalogId string, opt ...Option
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -201,7 +199,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*HostReadR
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -264,7 +262,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -305,7 +303,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*HostDel
|
||||
}
|
||||
|
||||
target := &HostDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -347,7 +345,7 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -405,7 +403,7 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -440,11 +438,11 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -34,13 +34,11 @@ type HostSet struct {
|
||||
SyncIntervalSeconds int32 `json:"sync_interval_seconds,omitempty"`
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type HostSetReadResult struct {
|
||||
Item *HostSet
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n HostSetReadResult) GetItem() *HostSet {
|
||||
@@ -48,14 +46,14 @@ func (n HostSetReadResult) GetItem() *HostSet {
|
||||
}
|
||||
|
||||
func (n HostSetReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type HostSetCreateResult = HostSetReadResult
|
||||
type HostSetUpdateResult = HostSetReadResult
|
||||
|
||||
type HostSetDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for HostSetDeleteResult
|
||||
@@ -64,7 +62,7 @@ func (n HostSetDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n HostSetDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type HostSetListResult struct {
|
||||
@@ -73,7 +71,7 @@ type HostSetListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n HostSetListResult) GetItems() []*HostSet {
|
||||
@@ -97,7 +95,7 @@ func (n HostSetListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n HostSetListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -158,7 +156,7 @@ func (c *Client) Create(ctx context.Context, hostCatalogId string, opt ...Option
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -199,7 +197,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*HostSetRe
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -262,7 +260,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -303,7 +301,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*HostSet
|
||||
}
|
||||
|
||||
target := &HostSetDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -345,7 +343,7 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -403,7 +401,7 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -438,11 +436,11 @@ func (c *Client) List(ctx context.Context, hostCatalogId string, opt ...Option)
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
@@ -516,7 +514,7 @@ func (c *Client) AddHosts(ctx context.Context, id string, version uint32, hostId
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -582,7 +580,7 @@ func (c *Client) SetHosts(ctx context.Context, id string, version uint32, hostId
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -652,6 +650,6 @@ func (c *Client) RemoveHosts(ctx context.Context, id string, version uint32, hos
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -30,13 +30,11 @@ type ManagedGroup struct {
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
MemberIds []string `json:"member_ids,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type ManagedGroupReadResult struct {
|
||||
Item *ManagedGroup
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n ManagedGroupReadResult) GetItem() *ManagedGroup {
|
||||
@@ -44,14 +42,14 @@ func (n ManagedGroupReadResult) GetItem() *ManagedGroup {
|
||||
}
|
||||
|
||||
func (n ManagedGroupReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type ManagedGroupCreateResult = ManagedGroupReadResult
|
||||
type ManagedGroupUpdateResult = ManagedGroupReadResult
|
||||
|
||||
type ManagedGroupDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for ManagedGroupDeleteResult
|
||||
@@ -60,7 +58,7 @@ func (n ManagedGroupDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n ManagedGroupDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type ManagedGroupListResult struct {
|
||||
@@ -69,7 +67,7 @@ type ManagedGroupListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n ManagedGroupListResult) GetItems() []*ManagedGroup {
|
||||
@@ -93,7 +91,7 @@ func (n ManagedGroupListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n ManagedGroupListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -154,7 +152,7 @@ func (c *Client) Create(ctx context.Context, authMethodId string, opt ...Option)
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*ManagedGr
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -258,7 +256,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -299,7 +297,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Managed
|
||||
}
|
||||
|
||||
target := &ManagedGroupDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -341,7 +339,7 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -399,7 +397,7 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -434,11 +432,11 @@ func (c *Client) List(ctx context.Context, authMethodId string, opt ...Option) (
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
+15
-17
@@ -29,13 +29,11 @@ type Policy struct {
|
||||
Version uint32 `json:"version,omitempty"`
|
||||
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type PolicyReadResult struct {
|
||||
Item *Policy
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n PolicyReadResult) GetItem() *Policy {
|
||||
@@ -43,14 +41,14 @@ func (n PolicyReadResult) GetItem() *Policy {
|
||||
}
|
||||
|
||||
func (n PolicyReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type PolicyCreateResult = PolicyReadResult
|
||||
type PolicyUpdateResult = PolicyReadResult
|
||||
|
||||
type PolicyDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for PolicyDeleteResult
|
||||
@@ -59,7 +57,7 @@ func (n PolicyDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n PolicyDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type PolicyListResult struct {
|
||||
@@ -68,7 +66,7 @@ type PolicyListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n PolicyListResult) GetItems() []*Policy {
|
||||
@@ -92,7 +90,7 @@ func (n PolicyListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n PolicyListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -158,7 +156,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -199,7 +197,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*PolicyRea
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -262,7 +260,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -303,7 +301,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*PolicyD
|
||||
}
|
||||
|
||||
target := &PolicyDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -345,7 +343,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Poli
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -403,7 +401,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Poli
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -438,11 +436,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Poli
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
+24
-26
@@ -33,13 +33,11 @@ type Role struct {
|
||||
GrantStrings []string `json:"grant_strings,omitempty"`
|
||||
Grants []*Grant `json:"grants,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type RoleReadResult struct {
|
||||
Item *Role
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n RoleReadResult) GetItem() *Role {
|
||||
@@ -47,14 +45,14 @@ func (n RoleReadResult) GetItem() *Role {
|
||||
}
|
||||
|
||||
func (n RoleReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type RoleCreateResult = RoleReadResult
|
||||
type RoleUpdateResult = RoleReadResult
|
||||
|
||||
type RoleDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for RoleDeleteResult
|
||||
@@ -63,7 +61,7 @@ func (n RoleDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n RoleDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type RoleListResult struct {
|
||||
@@ -72,7 +70,7 @@ type RoleListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n RoleListResult) GetItems() []*Role {
|
||||
@@ -96,7 +94,7 @@ func (n RoleListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n RoleListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -157,7 +155,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Ro
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -198,7 +196,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*RoleReadR
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -261,7 +259,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -302,7 +300,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*RoleDel
|
||||
}
|
||||
|
||||
target := &RoleDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -344,7 +342,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Role
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -402,7 +400,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Role
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -437,11 +435,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Role
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
@@ -515,7 +513,7 @@ func (c *Client) AddGrantScopes(ctx context.Context, id string, version uint32,
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -585,7 +583,7 @@ func (c *Client) AddGrants(ctx context.Context, id string, version uint32, grant
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -655,7 +653,7 @@ func (c *Client) AddPrincipals(ctx context.Context, id string, version uint32, p
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -721,7 +719,7 @@ func (c *Client) SetGrantScopes(ctx context.Context, id string, version uint32,
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -787,7 +785,7 @@ func (c *Client) SetGrants(ctx context.Context, id string, version uint32, grant
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -853,7 +851,7 @@ func (c *Client) SetPrincipals(ctx context.Context, id string, version uint32, p
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -923,7 +921,7 @@ func (c *Client) RemoveGrantScopes(ctx context.Context, id string, version uint3
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -993,7 +991,7 @@ func (c *Client) RemoveGrants(ctx context.Context, id string, version uint32, gr
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -1063,6 +1061,6 @@ func (c *Client) RemovePrincipals(ctx context.Context, id string, version uint32
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -286,7 +286,7 @@ func (c *Client) AttachStoragePolicy(ctx context.Context, scopeId string, versio
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
s.response = resp
|
||||
s.Response = resp
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@@ -350,6 +350,6 @@ func (c *Client) DetachStoragePolicy(ctx context.Context, scopeId string, versio
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
s.response = resp
|
||||
s.Response = resp
|
||||
return s, nil
|
||||
}
|
||||
+15
-17
@@ -30,13 +30,11 @@ type Scope struct {
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
AuthorizedCollectionActions map[string][]string `json:"authorized_collection_actions,omitempty"`
|
||||
StoragePolicyId string `json:"storage_policy_id,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type ScopeReadResult struct {
|
||||
Item *Scope
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n ScopeReadResult) GetItem() *Scope {
|
||||
@@ -44,14 +42,14 @@ func (n ScopeReadResult) GetItem() *Scope {
|
||||
}
|
||||
|
||||
func (n ScopeReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type ScopeCreateResult = ScopeReadResult
|
||||
type ScopeUpdateResult = ScopeReadResult
|
||||
|
||||
type ScopeDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for ScopeDeleteResult
|
||||
@@ -60,7 +58,7 @@ func (n ScopeDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n ScopeDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type ScopeListResult struct {
|
||||
@@ -69,7 +67,7 @@ type ScopeListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n ScopeListResult) GetItems() []*Scope {
|
||||
@@ -93,7 +91,7 @@ func (n ScopeListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n ScopeListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -154,7 +152,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Sc
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*ScopeRead
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -258,7 +256,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -299,7 +297,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*ScopeDe
|
||||
}
|
||||
|
||||
target := &ScopeDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -341,7 +339,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Scop
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -399,7 +397,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Scop
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -434,11 +432,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Scop
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -96,6 +96,6 @@ func (c *Client) ReApplyStoragePolicy(ctx context.Context, contentId string, opt
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -38,13 +38,11 @@ type SessionRecording struct {
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
RetainUntil time.Time `json:"retain_until,omitempty"`
|
||||
DeleteAfter time.Time `json:"delete_after,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type SessionRecordingReadResult struct {
|
||||
Item *SessionRecording
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n SessionRecordingReadResult) GetItem() *SessionRecording {
|
||||
@@ -52,11 +50,11 @@ func (n SessionRecordingReadResult) GetItem() *SessionRecording {
|
||||
}
|
||||
|
||||
func (n SessionRecordingReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type SessionRecordingDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for SessionRecordingDeleteResult
|
||||
@@ -65,7 +63,7 @@ func (n SessionRecordingDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n SessionRecordingDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type SessionRecordingListResult struct {
|
||||
@@ -74,7 +72,7 @@ type SessionRecordingListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n SessionRecordingListResult) GetItems() []*SessionRecording {
|
||||
@@ -98,7 +96,7 @@ func (n SessionRecordingListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n SessionRecordingListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -156,7 +154,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*SessionRe
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -197,7 +195,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Session
|
||||
}
|
||||
|
||||
target := &SessionRecordingDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -239,7 +237,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -297,7 +295,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -332,11 +330,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -71,6 +71,6 @@ func (c *Client) Cancel(ctx context.Context, sessionId string, version uint32, o
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
+12
-14
@@ -37,13 +37,11 @@ type Session struct {
|
||||
TerminationReason string `json:"termination_reason,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
Connections []*Connection `json:"connections,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type SessionReadResult struct {
|
||||
Item *Session
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n SessionReadResult) GetItem() *Session {
|
||||
@@ -51,14 +49,14 @@ func (n SessionReadResult) GetItem() *Session {
|
||||
}
|
||||
|
||||
func (n SessionReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type SessionCreateResult = SessionReadResult
|
||||
type SessionUpdateResult = SessionReadResult
|
||||
|
||||
type SessionDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for SessionDeleteResult
|
||||
@@ -67,7 +65,7 @@ func (n SessionDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n SessionDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type SessionListResult struct {
|
||||
@@ -76,7 +74,7 @@ type SessionListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n SessionListResult) GetItems() []*Session {
|
||||
@@ -100,7 +98,7 @@ func (n SessionListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n SessionListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -158,7 +156,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*SessionRe
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -199,7 +197,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -257,7 +255,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -292,11 +290,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Sess
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
@@ -37,13 +37,11 @@ type StorageBucket struct {
|
||||
SecretsHmac string `json:"secrets_hmac,omitempty"`
|
||||
WorkerFilter string `json:"worker_filter,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type StorageBucketReadResult struct {
|
||||
Item *StorageBucket
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n StorageBucketReadResult) GetItem() *StorageBucket {
|
||||
@@ -51,14 +49,14 @@ func (n StorageBucketReadResult) GetItem() *StorageBucket {
|
||||
}
|
||||
|
||||
func (n StorageBucketReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type StorageBucketCreateResult = StorageBucketReadResult
|
||||
type StorageBucketUpdateResult = StorageBucketReadResult
|
||||
|
||||
type StorageBucketDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for StorageBucketDeleteResult
|
||||
@@ -67,7 +65,7 @@ func (n StorageBucketDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n StorageBucketDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type StorageBucketListResult struct {
|
||||
@@ -76,7 +74,7 @@ type StorageBucketListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n StorageBucketListResult) GetItems() []*StorageBucket {
|
||||
@@ -100,7 +98,7 @@ func (n StorageBucketListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n StorageBucketListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -161,7 +159,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*St
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -202,7 +200,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*StorageBu
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -265,7 +263,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -306,7 +304,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*Storage
|
||||
}
|
||||
|
||||
target := &StorageBucketDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -348,7 +346,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Stor
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -406,7 +404,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Stor
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -441,11 +439,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Stor
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
|
||||
+21
-23
@@ -43,13 +43,11 @@ type Target struct {
|
||||
Address string `json:"address,omitempty"`
|
||||
Aliases []*Alias `json:"aliases,omitempty"`
|
||||
WithAliases []*Alias `json:"with_aliases,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type TargetReadResult struct {
|
||||
Item *Target
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n TargetReadResult) GetItem() *Target {
|
||||
@@ -57,14 +55,14 @@ func (n TargetReadResult) GetItem() *Target {
|
||||
}
|
||||
|
||||
func (n TargetReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type TargetCreateResult = TargetReadResult
|
||||
type TargetUpdateResult = TargetReadResult
|
||||
|
||||
type TargetDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for TargetDeleteResult
|
||||
@@ -73,7 +71,7 @@ func (n TargetDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n TargetDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type TargetListResult struct {
|
||||
@@ -82,7 +80,7 @@ type TargetListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n TargetListResult) GetItems() []*Target {
|
||||
@@ -106,7 +104,7 @@ func (n TargetListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n TargetListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -172,7 +170,7 @@ func (c *Client) Create(ctx context.Context, resourceType string, scopeId string
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -213,7 +211,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*TargetRea
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -276,7 +274,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -317,7 +315,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*TargetD
|
||||
}
|
||||
|
||||
target := &TargetDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -359,7 +357,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Targ
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -417,7 +415,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Targ
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -452,11 +450,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Targ
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
@@ -524,7 +522,7 @@ func (c *Client) AddCredentialSources(ctx context.Context, id string, version ui
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -594,7 +592,7 @@ func (c *Client) AddHostSources(ctx context.Context, id string, version uint32,
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -658,7 +656,7 @@ func (c *Client) SetCredentialSources(ctx context.Context, id string, version ui
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -724,7 +722,7 @@ func (c *Client) SetHostSources(ctx context.Context, id string, version uint32,
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -788,7 +786,7 @@ func (c *Client) RemoveCredentialSources(ctx context.Context, id string, version
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -858,6 +856,6 @@ func (c *Client) RemoveHostSources(ctx context.Context, id string, version uint3
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package users
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/hashicorp/boundary/api/aliases"
|
||||
)
|
||||
|
||||
// ListResolvableAliases builds and sends a request to the API for listing
|
||||
// resolvable aliases for the specified user. It retrieves all remaining pages
|
||||
// and includes in the result the list token for paginating through future
|
||||
// updates. To use the list token use the users.WithListToken option.
|
||||
func (c *Client) ListResolvableAliases(ctx context.Context, userId string, opt ...Option) (*aliases.AliasListResult, error) {
|
||||
if userId == "" {
|
||||
return nil, fmt.Errorf("empty userId value passed into ListResolvableAliases request")
|
||||
}
|
||||
if c.client == nil {
|
||||
return nil, fmt.Errorf("nil client")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("users/%s:list-resolvable-aliases", url.PathEscape(userId)), nil, apiOpts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating List request: %w", err)
|
||||
}
|
||||
|
||||
if len(opts.queryMap) > 0 {
|
||||
q := url.Values{}
|
||||
for k, v := range opts.queryMap {
|
||||
q.Add(k, v)
|
||||
}
|
||||
req.URL.RawQuery = q.Encode()
|
||||
}
|
||||
|
||||
resp, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error performing client request during List call: %w", err)
|
||||
}
|
||||
|
||||
target := new(aliases.AliasListResult)
|
||||
apiErr, err := resp.Decode(target)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
// If there are more results, automatically fetch the rest of the results.
|
||||
// idToIndex keeps a map from the ID of an item to its index in target.Items.
|
||||
// This is used to update updated items in-place and remove deleted items
|
||||
// from the result after pagination is done.
|
||||
idToIndex := map[string]int{}
|
||||
for i, item := range target.Items {
|
||||
idToIndex[item.Id] = i
|
||||
}
|
||||
// Removed IDs in the response may contain duplicates,
|
||||
// maintain a set to avoid returning duplicates to the user.
|
||||
removedIds := map[string]struct{}{}
|
||||
for {
|
||||
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("users/%s:list-resolvable-aliases", url.PathEscape(userId)), nil, apiOpts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating List request: %w", err)
|
||||
}
|
||||
|
||||
opts.queryMap["list_token"] = target.ListToken
|
||||
if len(opts.queryMap) > 0 {
|
||||
q := url.Values{}
|
||||
for k, v := range opts.queryMap {
|
||||
q.Add(k, v)
|
||||
}
|
||||
req.URL.RawQuery = q.Encode()
|
||||
}
|
||||
|
||||
resp, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error performing client request during List call: %w", err)
|
||||
}
|
||||
|
||||
page := new(aliases.AliasListResult)
|
||||
apiErr, err := resp.Decode(page)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
for _, item := range page.Items {
|
||||
if i, ok := idToIndex[item.Id]; ok {
|
||||
// Item has already been seen at index i, update in-place
|
||||
target.Items[i] = item
|
||||
} else {
|
||||
target.Items = append(target.Items, item)
|
||||
idToIndex[item.Id] = len(target.Items) - 1
|
||||
}
|
||||
}
|
||||
for _, removedId := range page.RemovedIds {
|
||||
removedIds[removedId] = struct{}{}
|
||||
}
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, removedId := range target.RemovedIds {
|
||||
if i, ok := idToIndex[removedId]; ok {
|
||||
// Remove the item at index i without preserving order
|
||||
// https://github.com/golang/go/wiki/SliceTricks#delete-without-preserving-order
|
||||
target.Items[i] = target.Items[len(target.Items)-1]
|
||||
target.Items = target.Items[:len(target.Items)-1]
|
||||
// Update the index of the last element
|
||||
idToIndex[target.Items[i].Id] = i
|
||||
}
|
||||
}
|
||||
for deletedId := range removedIds {
|
||||
target.RemovedIds = append(target.RemovedIds, deletedId)
|
||||
}
|
||||
// Sort to make response deterministic
|
||||
slices.Sort(target.RemovedIds)
|
||||
// Since we paginated to the end, we can avoid confusion
|
||||
// for the user by setting the estimated item count to the
|
||||
// length of the items slice. If we don't set this here, it
|
||||
// will equal the value returned in the last response, which is
|
||||
// often much smaller than the total number returned.
|
||||
target.EstItemCount = uint(len(target.Items))
|
||||
// Sort the results again since in-place updates and deletes
|
||||
// may have shuffled items. We sort by created time descending
|
||||
// (most recently created first), same as the API.
|
||||
slices.SortFunc(target.Items, func(i, j *aliases.Alias) int {
|
||||
return j.CreatedTime.Compare(i.CreatedTime)
|
||||
})
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.GetResponse().Body.Reset()
|
||||
if err := json.NewEncoder(target.GetResponse().Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.GetResponse().Body.Bytes(), &target.GetResponse().Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
// so it doesn't need to be updated (it will always be, and has always been, empty).
|
||||
return target, nil
|
||||
}
|
||||
+18
-20
@@ -33,13 +33,11 @@ type User struct {
|
||||
FullName string `json:"full_name,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
PrimaryAccountId string `json:"primary_account_id,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type UserReadResult struct {
|
||||
Item *User
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n UserReadResult) GetItem() *User {
|
||||
@@ -47,14 +45,14 @@ func (n UserReadResult) GetItem() *User {
|
||||
}
|
||||
|
||||
func (n UserReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type UserCreateResult = UserReadResult
|
||||
type UserUpdateResult = UserReadResult
|
||||
|
||||
type UserDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for UserDeleteResult
|
||||
@@ -63,7 +61,7 @@ func (n UserDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n UserDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type UserListResult struct {
|
||||
@@ -72,7 +70,7 @@ type UserListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n UserListResult) GetItems() []*User {
|
||||
@@ -96,7 +94,7 @@ func (n UserListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n UserListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -157,7 +155,7 @@ func (c *Client) Create(ctx context.Context, scopeId string, opt ...Option) (*Us
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -198,7 +196,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*UserReadR
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -261,7 +259,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -302,7 +300,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*UserDel
|
||||
}
|
||||
|
||||
target := &UserDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -344,7 +342,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*User
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -402,7 +400,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*User
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -437,11 +435,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*User
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
@@ -515,7 +513,7 @@ func (c *Client) AddAccounts(ctx context.Context, id string, version uint32, acc
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -581,7 +579,7 @@ func (c *Client) SetAccounts(ctx context.Context, id string, version uint32, acc
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -651,6 +649,6 @@ func (c *Client) RemoveAccounts(ctx context.Context, id string, version uint32,
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -10,13 +10,11 @@ import (
|
||||
|
||||
type CertificateAuthority struct {
|
||||
Certs []*Certificate `json:"certs,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type CertificateAuthorityReadResult struct {
|
||||
Item *CertificateAuthority
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n CertificateAuthorityReadResult) GetItem() *CertificateAuthority {
|
||||
@@ -24,5 +22,5 @@ func (n CertificateAuthorityReadResult) GetItem() *CertificateAuthority {
|
||||
}
|
||||
|
||||
func (n CertificateAuthorityReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (c *Client) ReinitializeCA(ctx context.Context, scopeId string, opt ...Opti
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -93,6 +93,6 @@ func (c *Client) ReadCA(ctx context.Context, scopeId string, opt ...Option) (*Ce
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
+19
-21
@@ -39,13 +39,11 @@ type Worker struct {
|
||||
DirectlyConnectedDownstreamWorkers []string `json:"directly_connected_downstream_workers,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
LocalStorageState string `json:"local_storage_state,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type WorkerReadResult struct {
|
||||
Item *Worker
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n WorkerReadResult) GetItem() *Worker {
|
||||
@@ -53,14 +51,14 @@ func (n WorkerReadResult) GetItem() *Worker {
|
||||
}
|
||||
|
||||
func (n WorkerReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type WorkerCreateResult = WorkerReadResult
|
||||
type WorkerUpdateResult = WorkerReadResult
|
||||
|
||||
type WorkerDeleteResult struct {
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
// GetItem will always be nil for WorkerDeleteResult
|
||||
@@ -69,7 +67,7 @@ func (n WorkerDeleteResult) GetItem() interface{} {
|
||||
}
|
||||
|
||||
func (n WorkerDeleteResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
type WorkerListResult struct {
|
||||
@@ -78,7 +76,7 @@ type WorkerListResult struct {
|
||||
RemovedIds []string `json:"removed_ids,omitempty"`
|
||||
ListToken string `json:"list_token,omitempty"`
|
||||
ResponseType string `json:"response_type,omitempty"`
|
||||
response *api.Response
|
||||
Response *api.Response
|
||||
}
|
||||
|
||||
func (n WorkerListResult) GetItems() []*Worker {
|
||||
@@ -102,7 +100,7 @@ func (n WorkerListResult) GetResponseType() string {
|
||||
}
|
||||
|
||||
func (n WorkerListResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
return n.Response
|
||||
}
|
||||
|
||||
// Client is a client for this collection
|
||||
@@ -168,7 +166,7 @@ func (c *Client) CreateWorkerLed(ctx context.Context, workerGeneratedAuthToken s
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -212,7 +210,7 @@ func (c *Client) CreateControllerLed(ctx context.Context, scopeId string, opt ..
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -253,7 +251,7 @@ func (c *Client) Read(ctx context.Context, id string, opt ...Option) (*WorkerRea
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -316,7 +314,7 @@ func (c *Client) Update(ctx context.Context, id string, version uint32, opt ...O
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -357,7 +355,7 @@ func (c *Client) Delete(ctx context.Context, id string, opt ...Option) (*WorkerD
|
||||
}
|
||||
|
||||
target := &WorkerDeleteResult{
|
||||
response: resp,
|
||||
Response: resp,
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
@@ -399,7 +397,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Work
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" || target.ResponseType == "" {
|
||||
return target, nil
|
||||
}
|
||||
@@ -457,7 +455,7 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Work
|
||||
target.EstItemCount = page.EstItemCount
|
||||
target.ListToken = page.ListToken
|
||||
target.ResponseType = page.ResponseType
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
if target.ResponseType == "complete" {
|
||||
break
|
||||
}
|
||||
@@ -492,11 +490,11 @@ func (c *Client) List(ctx context.Context, scopeId string, opt ...Option) (*Work
|
||||
// Finally, since we made at least 2 requests to the server to fulfill this
|
||||
// function call, resp.Body and resp.Map will only contain the most recent response.
|
||||
// Overwrite them with the true response.
|
||||
target.response.Body.Reset()
|
||||
if err := json.NewEncoder(target.response.Body).Encode(target); err != nil {
|
||||
target.Response.Body.Reset()
|
||||
if err := json.NewEncoder(target.Response.Body).Encode(target); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final JSON list response: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal(target.response.Body.Bytes(), &target.response.Map); err != nil {
|
||||
if err := json.Unmarshal(target.Response.Body.Bytes(), &target.Response.Map); err != nil {
|
||||
return nil, fmt.Errorf("error encoding final map list response: %w", err)
|
||||
}
|
||||
// Note: the HTTP response body is consumed by resp.Decode in the loop,
|
||||
@@ -570,7 +568,7 @@ func (c *Client) AddWorkerTags(ctx context.Context, id string, version uint32, a
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -636,7 +634,7 @@ func (c *Client) SetWorkerTags(ctx context.Context, id string, version uint32, a
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
@@ -706,6 +704,6 @@ func (c *Client) RemoveWorkerTags(ctx context.Context, id string, version uint32
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
target.Response = resp
|
||||
return target, nil
|
||||
}
|
||||
Reference in new issue
Block a user