-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathassociations_api.go
132 lines (116 loc) · 5.78 KB
/
associations_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* Copyright © 2017 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: BSD-2-Clause
Generated by: https://github.com/swagger-api/swagger-codegen.git */
package nsxt
import (
"context"
"encoding/json"
"github.com/vmware/go-vmware-nsxt/association"
"net/http"
"net/url"
"strings"
)
// Linger please
var (
_ context.Context
)
type AssociationsApiService service
/* AssociationsApiService Get ResourceReference objects to which the given resource belongs to
Returns information about resources that are associated with the given resource. Id and type of the resource for which associated resources are to be fetched are to be specified as query parameter in the URI. Resource type of the associated resources must be specified as query parameter.
* @param ctx context.Context Authentication Context
@param associatedResourceType Resource type valid for use as target in association API
@param resourceId The resource for which associated resources are to be fetched
@param resourceType Resource type valid for use as source in association API
@param optional (nil or map[string]interface{}) with one or more of:
@param "cursor" (string) Opaque cursor to be used for getting next page of records (supplied by current result page)
@param "fetchAncestors" (bool) Fetch complete list of associated resources considering containment and nesting
@param "includedFields" (string) Comma separated list of fields that should be included to result of query
@param "pageSize" (int64) Maximum number of results to return in this page (server may return fewer)
@param "sortAscending" (bool)
@param "sortBy" (string) Field by which records are sorted
@return association.AssociationListResult*/
func (a *AssociationsApiService) GetAssociations(ctx context.Context, associatedResourceType string, resourceId string, resourceType string, localVarOptionals map[string]interface{}) (association.AssociationListResult, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
successPayload association.AssociationListResult
)
// create path and map variables
localVarPath := a.client.cfg.BasePath + "/associations"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if err := typeCheckParameter(localVarOptionals["cursor"], "string", "cursor"); err != nil {
return successPayload, nil, err
}
if err := typeCheckParameter(localVarOptionals["fetchAncestors"], "bool", "fetchAncestors"); err != nil {
return successPayload, nil, err
}
if err := typeCheckParameter(localVarOptionals["includedFields"], "string", "includedFields"); err != nil {
return successPayload, nil, err
}
if err := typeCheckParameter(localVarOptionals["pageSize"], "int64", "pageSize"); err != nil {
return successPayload, nil, err
}
if err := typeCheckParameter(localVarOptionals["sortAscending"], "bool", "sortAscending"); err != nil {
return successPayload, nil, err
}
if err := typeCheckParameter(localVarOptionals["sortBy"], "string", "sortBy"); err != nil {
return successPayload, nil, err
}
localVarQueryParams.Add("associated_resource_type", parameterToString(associatedResourceType, ""))
if localVarTempParam, localVarOk := localVarOptionals["cursor"].(string); localVarOk {
localVarQueryParams.Add("cursor", parameterToString(localVarTempParam, ""))
}
if localVarTempParam, localVarOk := localVarOptionals["fetchAncestors"].(bool); localVarOk {
localVarQueryParams.Add("fetch_ancestors", parameterToString(localVarTempParam, ""))
}
if localVarTempParam, localVarOk := localVarOptionals["includedFields"].(string); localVarOk {
localVarQueryParams.Add("included_fields", parameterToString(localVarTempParam, ""))
}
if localVarTempParam, localVarOk := localVarOptionals["pageSize"].(int64); localVarOk {
localVarQueryParams.Add("page_size", parameterToString(localVarTempParam, ""))
}
localVarQueryParams.Add("resource_id", parameterToString(resourceId, ""))
localVarQueryParams.Add("resource_type", parameterToString(resourceType, ""))
if localVarTempParam, localVarOk := localVarOptionals["sortAscending"].(bool); localVarOk {
localVarQueryParams.Add("sort_ascending", parameterToString(localVarTempParam, ""))
}
if localVarTempParam, localVarOk := localVarOptionals["sortBy"].(string); localVarOk {
localVarQueryParams.Add("sort_by", parameterToString(localVarTempParam, ""))
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{"application/json"}
// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
}
// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
if err != nil {
return successPayload, nil, err
}
localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return successPayload, localVarHttpResponse, err
}
defer localVarHttpResponse.Body.Close()
if localVarHttpResponse.StatusCode >= 300 {
return successPayload, localVarHttpResponse, reportError(localVarHttpResponse.Status)
}
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
return successPayload, localVarHttpResponse, err
}
return successPayload, localVarHttpResponse, err
}