-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathapi_support_bundle.go
199 lines (166 loc) · 6.8 KB
/
api_support_bundle.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
* NSX-T Manager API
*
* VMware NSX-T Manager REST API
*
* API version: 3.2.0.0.0
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package nsxt
import (
"context"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/antihax/optional"
"github.com/vmware/go-vmware-nsxt/supportbundle"
)
// Linger please
var (
_ context.Context
)
type SupportBundleApiService service
/*
SupportBundleApiService Collect support bundles from registered cluster and fabric nodes
Collect support bundles from registered cluster and fabric nodes.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param supportBundleRequest
* @param optional nil or *SupportBundleApiCollectSupportBundlesCollectOpts - Optional Parameters:
* @param "OverrideAsyncResponse" (optional.Bool) - Override any existing support bundle async response
* @param "RequireDeleteOrOverrideAsyncResponse" (optional.Bool) - Suppress auto-deletion of generated support bundle
@return SupportBundleResult
*/
type SupportBundleApiCollectSupportBundlesCollectOpts struct {
OverrideAsyncResponse optional.Bool
RequireDeleteOrOverrideAsyncResponse optional.Bool
}
func (a *SupportBundleApiService) CollectSupportBundlesCollect(ctx context.Context, supportBundleRequest supportbundle.SupportBundleRequest, localVarOptionals *SupportBundleApiCollectSupportBundlesCollectOpts) (supportbundle.SupportBundleResult, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
localVarReturnValue supportbundle.SupportBundleResult
)
// create path and map variables
localVarPath := a.client.cfg.BasePath + "/administration/support-bundles?action=collect"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if localVarOptionals != nil && localVarOptionals.OverrideAsyncResponse.IsSet() {
localVarQueryParams.Add("override_async_response", parameterToString(localVarOptionals.OverrideAsyncResponse.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.RequireDeleteOrOverrideAsyncResponse.IsSet() {
localVarQueryParams.Add("require_delete_or_override_async_response", parameterToString(localVarOptionals.RequireDeleteOrOverrideAsyncResponse.Value(), ""))
}
// 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", "application/octet-stream"}
// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// body params
localVarPostBody = &supportBundleRequest
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, localVarHttpResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, localVarHttpResponse, err
}
if localVarHttpResponse.StatusCode < 300 {
// If we succeed, return the data, otherwise pass on to decode error.
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
return localVarReturnValue, localVarHttpResponse, err
}
if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericSwaggerError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
var v ApiError
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
return localVarReturnValue, localVarHttpResponse, nil
}
/*
SupportBundleApiService Delete existing support bundles waiting to be downloaded
Delete existing support bundles waiting to be downloaded.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
*/
func (a *SupportBundleApiService) DeleteSupportBundlesAsyncResponseDeleteAsyncResponse(ctx context.Context) (*http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFileName string
localVarFileBytes []byte
)
// create path and map variables
localVarPath := a.client.cfg.BasePath + "/administration/support-bundles?action=delete_async_response"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// 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 nil, err
}
localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarHttpResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarHttpResponse, err
}
if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericSwaggerError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
var v ApiError
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHttpResponse, newErr
}
newErr.model = v
return localVarHttpResponse, newErr
}
return localVarHttpResponse, nil
}