|
| 1 | +// Code based on the AtlasAPI V2 OpenAPI file |
| 2 | + |
| 3 | +package admin |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "io" |
| 8 | + "net/http" |
| 9 | + "net/url" |
| 10 | +) |
| 11 | + |
| 12 | +type OpenAPIApi interface { |
| 13 | + |
| 14 | + /* |
| 15 | + GetOpenapiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification. |
| 16 | +
|
| 17 | + This resource returns general information about the MongoDB Atlas Administration API OpenAPI Specification. Deprecated versions: v2-{2024-05-30} |
| 18 | +
|
| 19 | + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). |
| 20 | + @return GetOpenapiInfoApiRequest |
| 21 | + */ |
| 22 | + GetOpenapiInfo(ctx context.Context) GetOpenapiInfoApiRequest |
| 23 | + /* |
| 24 | + GetOpenapiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification. |
| 25 | +
|
| 26 | +
|
| 27 | + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). |
| 28 | + @param GetOpenapiInfoApiParams - Parameters for the request |
| 29 | + @return GetOpenapiInfoApiRequest |
| 30 | + */ |
| 31 | + GetOpenapiInfoWithParams(ctx context.Context, args *GetOpenapiInfoApiParams) GetOpenapiInfoApiRequest |
| 32 | + |
| 33 | + // Method available only for mocking purposes |
| 34 | + GetOpenapiInfoExecute(r GetOpenapiInfoApiRequest) (*OpenApiInfo, *http.Response, error) |
| 35 | + |
| 36 | + /* |
| 37 | + ListOpenapiVersions Provides a list of versions for a given environment. |
| 38 | +
|
| 39 | + API that provides a list of available versionsfor a given environment. |
| 40 | +
|
| 41 | + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). |
| 42 | + @return ListOpenapiVersionsApiRequest |
| 43 | + */ |
| 44 | + ListOpenapiVersions(ctx context.Context) ListOpenapiVersionsApiRequest |
| 45 | + /* |
| 46 | + ListOpenapiVersions Provides a list of versions for a given environment. |
| 47 | +
|
| 48 | +
|
| 49 | + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). |
| 50 | + @param ListOpenapiVersionsApiParams - Parameters for the request |
| 51 | + @return ListOpenapiVersionsApiRequest |
| 52 | + */ |
| 53 | + ListOpenapiVersionsWithParams(ctx context.Context, args *ListOpenapiVersionsApiParams) ListOpenapiVersionsApiRequest |
| 54 | + |
| 55 | + // Method available only for mocking purposes |
| 56 | + ListOpenapiVersionsExecute(r ListOpenapiVersionsApiRequest) (*PaginatedApiVersions, *http.Response, error) |
| 57 | +} |
| 58 | + |
| 59 | +// OpenAPIApiService OpenAPIApi service |
| 60 | +type OpenAPIApiService service |
| 61 | + |
| 62 | +type GetOpenapiInfoApiRequest struct { |
| 63 | + ctx context.Context |
| 64 | + ApiService OpenAPIApi |
| 65 | +} |
| 66 | + |
| 67 | +type GetOpenapiInfoApiParams struct { |
| 68 | +} |
| 69 | + |
| 70 | +func (a *OpenAPIApiService) GetOpenapiInfoWithParams(ctx context.Context, args *GetOpenapiInfoApiParams) GetOpenapiInfoApiRequest { |
| 71 | + return GetOpenapiInfoApiRequest{ |
| 72 | + ApiService: a, |
| 73 | + ctx: ctx, |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +func (r GetOpenapiInfoApiRequest) Execute() (*OpenApiInfo, *http.Response, error) { |
| 78 | + return r.ApiService.GetOpenapiInfoExecute(r) |
| 79 | +} |
| 80 | + |
| 81 | +/* |
| 82 | +GetOpenapiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification. |
| 83 | +
|
| 84 | +This resource returns general information about the MongoDB Atlas Administration API OpenAPI Specification. Deprecated versions: v2-{2024-05-30} |
| 85 | +
|
| 86 | + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). |
| 87 | + @return GetOpenapiInfoApiRequest |
| 88 | +*/ |
| 89 | +func (a *OpenAPIApiService) GetOpenapiInfo(ctx context.Context) GetOpenapiInfoApiRequest { |
| 90 | + return GetOpenapiInfoApiRequest{ |
| 91 | + ApiService: a, |
| 92 | + ctx: ctx, |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +// GetOpenapiInfoExecute executes the request |
| 97 | +// |
| 98 | +// @return OpenApiInfo |
| 99 | +func (a *OpenAPIApiService) GetOpenapiInfoExecute(r GetOpenapiInfoApiRequest) (*OpenApiInfo, *http.Response, error) { |
| 100 | + var ( |
| 101 | + localVarHTTPMethod = http.MethodGet |
| 102 | + localVarPostBody any |
| 103 | + formFiles []formFile |
| 104 | + localVarReturnValue *OpenApiInfo |
| 105 | + ) |
| 106 | + |
| 107 | + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenAPIApiService.GetOpenapiInfo") |
| 108 | + if err != nil { |
| 109 | + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} |
| 110 | + } |
| 111 | + |
| 112 | + localVarPath := localBasePath + "/api/atlas/v2/openapi/info" |
| 113 | + |
| 114 | + localVarHeaderParams := make(map[string]string) |
| 115 | + localVarQueryParams := url.Values{} |
| 116 | + localVarFormParams := url.Values{} |
| 117 | + |
| 118 | + // to determine the Content-Type header |
| 119 | + localVarHTTPContentTypes := []string{} |
| 120 | + |
| 121 | + // set Content-Type header |
| 122 | + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) |
| 123 | + if localVarHTTPContentType != "" { |
| 124 | + localVarHeaderParams["Content-Type"] = localVarHTTPContentType |
| 125 | + } |
| 126 | + |
| 127 | + // to determine the Accept header (only first one) |
| 128 | + localVarHTTPHeaderAccepts := []string{"application/vnd.atlas.2024-08-05+json"} |
| 129 | + |
| 130 | + // set Accept header |
| 131 | + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) |
| 132 | + if localVarHTTPHeaderAccept != "" { |
| 133 | + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept |
| 134 | + } |
| 135 | + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) |
| 136 | + if err != nil { |
| 137 | + return localVarReturnValue, nil, err |
| 138 | + } |
| 139 | + |
| 140 | + localVarHTTPResponse, err := a.client.callAPI(req) |
| 141 | + if err != nil || localVarHTTPResponse == nil { |
| 142 | + return localVarReturnValue, localVarHTTPResponse, err |
| 143 | + } |
| 144 | + |
| 145 | + if localVarHTTPResponse.StatusCode >= 300 { |
| 146 | + newErr := a.client.makeApiError(localVarHTTPResponse, localVarHTTPMethod, localVarPath) |
| 147 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 148 | + } |
| 149 | + |
| 150 | + err = a.client.decode(&localVarReturnValue, localVarHTTPResponse.Body, localVarHTTPResponse.Header.Get("Content-Type")) |
| 151 | + if err != nil { |
| 152 | + defer localVarHTTPResponse.Body.Close() |
| 153 | + buf, readErr := io.ReadAll(localVarHTTPResponse.Body) |
| 154 | + if readErr != nil { |
| 155 | + err = readErr |
| 156 | + } |
| 157 | + newErr := &GenericOpenAPIError{ |
| 158 | + body: buf, |
| 159 | + error: err.Error(), |
| 160 | + } |
| 161 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 162 | + } |
| 163 | + |
| 164 | + return localVarReturnValue, localVarHTTPResponse, nil |
| 165 | +} |
| 166 | + |
| 167 | +type ListOpenapiVersionsApiRequest struct { |
| 168 | + ctx context.Context |
| 169 | + ApiService OpenAPIApi |
| 170 | + itemsPerPage *int |
| 171 | + pageNum *int |
| 172 | + env *string |
| 173 | +} |
| 174 | + |
| 175 | +type ListOpenapiVersionsApiParams struct { |
| 176 | + ItemsPerPage *int |
| 177 | + PageNum *int |
| 178 | + Env *string |
| 179 | +} |
| 180 | + |
| 181 | +func (a *OpenAPIApiService) ListOpenapiVersionsWithParams(ctx context.Context, args *ListOpenapiVersionsApiParams) ListOpenapiVersionsApiRequest { |
| 182 | + return ListOpenapiVersionsApiRequest{ |
| 183 | + ApiService: a, |
| 184 | + ctx: ctx, |
| 185 | + itemsPerPage: args.ItemsPerPage, |
| 186 | + pageNum: args.PageNum, |
| 187 | + env: args.Env, |
| 188 | + } |
| 189 | +} |
| 190 | + |
| 191 | +// Number of items that the response returns per page. |
| 192 | +func (r ListOpenapiVersionsApiRequest) ItemsPerPage(itemsPerPage int) ListOpenapiVersionsApiRequest { |
| 193 | + r.itemsPerPage = &itemsPerPage |
| 194 | + return r |
| 195 | +} |
| 196 | + |
| 197 | +// Number of the page that displays the current set of the total objects that the response returns. |
| 198 | +func (r ListOpenapiVersionsApiRequest) PageNum(pageNum int) ListOpenapiVersionsApiRequest { |
| 199 | + r.pageNum = &pageNum |
| 200 | + return r |
| 201 | +} |
| 202 | + |
| 203 | +// The environment to get the versions from. If not provided, it returnsthe versions for the given MongoDB URL. (E.g. prod for cloud.mongodb.com). |
| 204 | +func (r ListOpenapiVersionsApiRequest) Env(env string) ListOpenapiVersionsApiRequest { |
| 205 | + r.env = &env |
| 206 | + return r |
| 207 | +} |
| 208 | + |
| 209 | +func (r ListOpenapiVersionsApiRequest) Execute() (*PaginatedApiVersions, *http.Response, error) { |
| 210 | + return r.ApiService.ListOpenapiVersionsExecute(r) |
| 211 | +} |
| 212 | + |
| 213 | +/* |
| 214 | +ListOpenapiVersions Provides a list of versions for a given environment. |
| 215 | +
|
| 216 | +API that provides a list of available versionsfor a given environment. |
| 217 | +
|
| 218 | + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). |
| 219 | + @return ListOpenapiVersionsApiRequest |
| 220 | +*/ |
| 221 | +func (a *OpenAPIApiService) ListOpenapiVersions(ctx context.Context) ListOpenapiVersionsApiRequest { |
| 222 | + return ListOpenapiVersionsApiRequest{ |
| 223 | + ApiService: a, |
| 224 | + ctx: ctx, |
| 225 | + } |
| 226 | +} |
| 227 | + |
| 228 | +// ListOpenapiVersionsExecute executes the request |
| 229 | +// |
| 230 | +// @return PaginatedApiVersions |
| 231 | +func (a *OpenAPIApiService) ListOpenapiVersionsExecute(r ListOpenapiVersionsApiRequest) (*PaginatedApiVersions, *http.Response, error) { |
| 232 | + var ( |
| 233 | + localVarHTTPMethod = http.MethodGet |
| 234 | + localVarPostBody any |
| 235 | + formFiles []formFile |
| 236 | + localVarReturnValue *PaginatedApiVersions |
| 237 | + ) |
| 238 | + |
| 239 | + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenAPIApiService.ListOpenapiVersions") |
| 240 | + if err != nil { |
| 241 | + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} |
| 242 | + } |
| 243 | + |
| 244 | + localVarPath := localBasePath + "/api/atlas/v2/unauth/openapi/versions" |
| 245 | + |
| 246 | + localVarHeaderParams := make(map[string]string) |
| 247 | + localVarQueryParams := url.Values{} |
| 248 | + localVarFormParams := url.Values{} |
| 249 | + |
| 250 | + if r.itemsPerPage != nil { |
| 251 | + parameterAddToHeaderOrQuery(localVarQueryParams, "itemsPerPage", r.itemsPerPage, "") |
| 252 | + } else { |
| 253 | + var defaultValue int = 100 |
| 254 | + r.itemsPerPage = &defaultValue |
| 255 | + parameterAddToHeaderOrQuery(localVarQueryParams, "itemsPerPage", r.itemsPerPage, "") |
| 256 | + } |
| 257 | + if r.pageNum != nil { |
| 258 | + parameterAddToHeaderOrQuery(localVarQueryParams, "pageNum", r.pageNum, "") |
| 259 | + } else { |
| 260 | + var defaultValue int = 1 |
| 261 | + r.pageNum = &defaultValue |
| 262 | + parameterAddToHeaderOrQuery(localVarQueryParams, "pageNum", r.pageNum, "") |
| 263 | + } |
| 264 | + if r.env != nil { |
| 265 | + parameterAddToHeaderOrQuery(localVarQueryParams, "env", r.env, "") |
| 266 | + } |
| 267 | + // to determine the Content-Type header |
| 268 | + localVarHTTPContentTypes := []string{} |
| 269 | + |
| 270 | + // set Content-Type header |
| 271 | + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) |
| 272 | + if localVarHTTPContentType != "" { |
| 273 | + localVarHeaderParams["Content-Type"] = localVarHTTPContentType |
| 274 | + } |
| 275 | + |
| 276 | + // to determine the Accept header (only first one) |
| 277 | + localVarHTTPHeaderAccepts := []string{"application/vnd.atlas.2024-08-05+json"} |
| 278 | + |
| 279 | + // set Accept header |
| 280 | + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) |
| 281 | + if localVarHTTPHeaderAccept != "" { |
| 282 | + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept |
| 283 | + } |
| 284 | + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) |
| 285 | + if err != nil { |
| 286 | + return localVarReturnValue, nil, err |
| 287 | + } |
| 288 | + |
| 289 | + localVarHTTPResponse, err := a.client.callAPI(req) |
| 290 | + if err != nil || localVarHTTPResponse == nil { |
| 291 | + return localVarReturnValue, localVarHTTPResponse, err |
| 292 | + } |
| 293 | + |
| 294 | + if localVarHTTPResponse.StatusCode >= 300 { |
| 295 | + newErr := a.client.makeApiError(localVarHTTPResponse, localVarHTTPMethod, localVarPath) |
| 296 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 297 | + } |
| 298 | + |
| 299 | + err = a.client.decode(&localVarReturnValue, localVarHTTPResponse.Body, localVarHTTPResponse.Header.Get("Content-Type")) |
| 300 | + if err != nil { |
| 301 | + defer localVarHTTPResponse.Body.Close() |
| 302 | + buf, readErr := io.ReadAll(localVarHTTPResponse.Body) |
| 303 | + if readErr != nil { |
| 304 | + err = readErr |
| 305 | + } |
| 306 | + newErr := &GenericOpenAPIError{ |
| 307 | + body: buf, |
| 308 | + error: err.Error(), |
| 309 | + } |
| 310 | + return localVarReturnValue, localVarHTTPResponse, newErr |
| 311 | + } |
| 312 | + |
| 313 | + return localVarReturnValue, localVarHTTPResponse, nil |
| 314 | +} |
0 commit comments