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
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user