-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_rolling_index.go
196 lines (169 loc) · 7.4 KB
/
api_rolling_index.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
/*
MongoDB Atlas Administration API
The MongoDB Atlas Administration API allows developers to manage all components in MongoDB Atlas. To learn more, review the [Administration API overview](https://www.mongodb.com/docs/atlas/api/atlas-admin-api/). This OpenAPI specification covers all of the collections with the exception of Alerts, Alert Configurations, and Events. Refer to the [legacy documentation](https://www.mongodb.com/docs/atlas/reference/api-resources/) for the specifications of these resources.
API version: 1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package openapi
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
// RollingIndexApiService RollingIndexApi service
type RollingIndexApiService service
type ApiCreateOneRollingIndexRequest struct {
ctx context.Context
ApiService *RollingIndexApiService
groupId string
clusterName string
apiIndexRequestView *ApiIndexRequestView
envelope *bool
pretty *bool
}
// Rolling index to create on the specified cluster.
func (r ApiCreateOneRollingIndexRequest) ApiIndexRequestView(apiIndexRequestView ApiIndexRequestView) ApiCreateOneRollingIndexRequest {
r.apiIndexRequestView = &apiIndexRequestView
return r
}
// Flag that indicates whether Application wraps the response in an `envelope` JSON object. Some API clients cannot access the HTTP response headers or status code. To remediate this, set envelope=true in the query. Endpoints that return a list of results use the results object as an envelope. Application adds the status parameter to the response body.
func (r ApiCreateOneRollingIndexRequest) Envelope(envelope bool) ApiCreateOneRollingIndexRequest {
r.envelope = &envelope
return r
}
// Flag that indicates whether the response body should be in the prettyprint format.
func (r ApiCreateOneRollingIndexRequest) Pretty(pretty bool) ApiCreateOneRollingIndexRequest {
r.pretty = &pretty
return r
}
func (r ApiCreateOneRollingIndexRequest) Execute() (*http.Response, error) {
return r.ApiService.CreateOneRollingIndexExecute(r)
}
/*
CreateOneRollingIndex Create One Rolling Index
Creates an index on the cluster identified by its name in a rolling manner. Creating the index in this way allows index builds on one replica set member as a standalone at a time, starting with the secondary members. Creating indexes in this way requires at least one replica set election. To use this resource, the requesting API Key must have the Project Data Access Admin role. This resource doesn't require the API Key to have an Access List.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param groupId Unique 24-hexadecimal digit string that identifies your project.
@param clusterName Human-readable label that identifies the cluster on which MongoDB Cloud creates an index.
@return ApiCreateOneRollingIndexRequest
*/
func (a *RollingIndexApiService) CreateOneRollingIndex(ctx context.Context, groupId string, clusterName string) ApiCreateOneRollingIndexRequest {
return ApiCreateOneRollingIndexRequest{
ApiService: a,
ctx: ctx,
groupId: groupId,
clusterName: clusterName,
}
}
// Execute executes the request
func (a *RollingIndexApiService) CreateOneRollingIndexExecute(r ApiCreateOneRollingIndexRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RollingIndexApiService.CreateOneRollingIndex")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/api/atlas/v1.0/groups/{groupId}/clusters/{clusterName}/index"
localVarPath = strings.Replace(localVarPath, "{"+"groupId"+"}", url.PathEscape(parameterToString(r.groupId, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"clusterName"+"}", url.PathEscape(parameterToString(r.clusterName, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if strlen(r.groupId) < 24 {
return nil, reportError("groupId must have at least 24 elements")
}
if strlen(r.groupId) > 24 {
return nil, reportError("groupId must have less than 24 elements")
}
if strlen(r.clusterName) < 1 {
return nil, reportError("clusterName must have at least 1 elements")
}
if strlen(r.clusterName) > 64 {
return nil, reportError("clusterName must have less than 64 elements")
}
if r.apiIndexRequestView == nil {
return nil, reportError("apiIndexRequestView is required and must be specified")
}
if r.envelope != nil {
localVarQueryParams.Add("envelope", parameterToString(*r.envelope, ""))
}
if r.pretty != nil {
localVarQueryParams.Add("pretty", parameterToString(*r.pretty, ""))
}
// 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
}
// body params
localVarPostBody = r.apiIndexRequestView
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
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.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
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.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
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.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}