forked from vmware/go-vmware-nsxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalization_api.go
125 lines (109 loc) · 5.41 KB
/
normalization_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
/* 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/normalization"
"net/http"
"net/url"
"strings"
)
// Linger please
var (
_ context.Context
)
type NormalizationApiService service
/* NormalizationApiService Get normalizations based on the query parameters
Returns the list of normalized resources based on the query parameters. Id and Type of the resource on which the normalizations is to be performed, are to be specified as query parameters in the URI. The target resource types to which normalization is to be done should also be specified as query parameter.
* @param ctx context.Context Authentication Context
@param preferredNormalizationType Resource type valid for use as target in normalization API.
@param resourceId Identifier of the resource on which normalization is to be performed
@param resourceType Resource type valid for use as source in normalization 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 "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 normalization.NormalizedResourceListResult*/
func (a *NormalizationApiService) GetNormalizations(ctx context.Context, preferredNormalizationType string, resourceId string, resourceType string, localVarOptionals map[string]interface{}) (normalization.NormalizedResourceListResult, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
successPayload normalization.NormalizedResourceListResult
)
// create path and map variables
localVarPath := a.client.cfg.BasePath + "/normalizations"
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["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
}
if localVarTempParam, localVarOk := localVarOptionals["cursor"].(string); localVarOk {
localVarQueryParams.Add("cursor", 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("preferred_normalization_type", parameterToString(preferredNormalizationType, ""))
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
}