|  | 
|  | 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 | +		GetApiVersions Provides a list of versions for a given environment. | 
|  | 16 | +
 | 
|  | 17 | +		API that provides a list of available versionsfor a given environment. | 
|  | 18 | +
 | 
|  | 19 | +		@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | 
|  | 20 | +		@return GetApiVersionsApiRequest | 
|  | 21 | +	*/ | 
|  | 22 | +	GetApiVersions(ctx context.Context) GetApiVersionsApiRequest | 
|  | 23 | +	/* | 
|  | 24 | +		GetApiVersions Provides a list of versions for a given environment. | 
|  | 25 | +
 | 
|  | 26 | +
 | 
|  | 27 | +		@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | 
|  | 28 | +		@param GetApiVersionsApiParams - Parameters for the request | 
|  | 29 | +		@return GetApiVersionsApiRequest | 
|  | 30 | +	*/ | 
|  | 31 | +	GetApiVersionsWithParams(ctx context.Context, args *GetApiVersionsApiParams) GetApiVersionsApiRequest | 
|  | 32 | + | 
|  | 33 | +	// Method available only for mocking purposes | 
|  | 34 | +	GetApiVersionsExecute(r GetApiVersionsApiRequest) (*PaginatedApiVersions, *http.Response, error) | 
|  | 35 | + | 
|  | 36 | +	/* | 
|  | 37 | +		GetOpenApiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification. | 
|  | 38 | +
 | 
|  | 39 | +		This resource returns general information about the MongoDB Atlas Administration API OpenAPI Specification. Deprecated versions: v2-{2024-05-30} | 
|  | 40 | +
 | 
|  | 41 | +		@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | 
|  | 42 | +		@return GetOpenApiInfoApiRequest | 
|  | 43 | +	*/ | 
|  | 44 | +	GetOpenApiInfo(ctx context.Context) GetOpenApiInfoApiRequest | 
|  | 45 | +	/* | 
|  | 46 | +		GetOpenApiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification. | 
|  | 47 | +
 | 
|  | 48 | +
 | 
|  | 49 | +		@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | 
|  | 50 | +		@param GetOpenApiInfoApiParams - Parameters for the request | 
|  | 51 | +		@return GetOpenApiInfoApiRequest | 
|  | 52 | +	*/ | 
|  | 53 | +	GetOpenApiInfoWithParams(ctx context.Context, args *GetOpenApiInfoApiParams) GetOpenApiInfoApiRequest | 
|  | 54 | + | 
|  | 55 | +	// Method available only for mocking purposes | 
|  | 56 | +	GetOpenApiInfoExecute(r GetOpenApiInfoApiRequest) (*OpenApiInfo, *http.Response, error) | 
|  | 57 | +} | 
|  | 58 | + | 
|  | 59 | +// OpenAPIApiService OpenAPIApi service | 
|  | 60 | +type OpenAPIApiService service | 
|  | 61 | + | 
|  | 62 | +type GetApiVersionsApiRequest struct { | 
|  | 63 | +	ctx          context.Context | 
|  | 64 | +	ApiService   OpenAPIApi | 
|  | 65 | +	itemsPerPage *int | 
|  | 66 | +	pageNum      *int | 
|  | 67 | +	env          *string | 
|  | 68 | +} | 
|  | 69 | + | 
|  | 70 | +type GetApiVersionsApiParams struct { | 
|  | 71 | +	ItemsPerPage *int | 
|  | 72 | +	PageNum      *int | 
|  | 73 | +	Env          *string | 
|  | 74 | +} | 
|  | 75 | + | 
|  | 76 | +func (a *OpenAPIApiService) GetApiVersionsWithParams(ctx context.Context, args *GetApiVersionsApiParams) GetApiVersionsApiRequest { | 
|  | 77 | +	return GetApiVersionsApiRequest{ | 
|  | 78 | +		ApiService:   a, | 
|  | 79 | +		ctx:          ctx, | 
|  | 80 | +		itemsPerPage: args.ItemsPerPage, | 
|  | 81 | +		pageNum:      args.PageNum, | 
|  | 82 | +		env:          args.Env, | 
|  | 83 | +	} | 
|  | 84 | +} | 
|  | 85 | + | 
|  | 86 | +// Number of items that the response returns per page. | 
|  | 87 | +func (r GetApiVersionsApiRequest) ItemsPerPage(itemsPerPage int) GetApiVersionsApiRequest { | 
|  | 88 | +	r.itemsPerPage = &itemsPerPage | 
|  | 89 | +	return r | 
|  | 90 | +} | 
|  | 91 | + | 
|  | 92 | +// Number of the page that displays the current set of the total objects that the response returns. | 
|  | 93 | +func (r GetApiVersionsApiRequest) PageNum(pageNum int) GetApiVersionsApiRequest { | 
|  | 94 | +	r.pageNum = &pageNum | 
|  | 95 | +	return r | 
|  | 96 | +} | 
|  | 97 | + | 
|  | 98 | +// 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). | 
|  | 99 | +func (r GetApiVersionsApiRequest) Env(env string) GetApiVersionsApiRequest { | 
|  | 100 | +	r.env = &env | 
|  | 101 | +	return r | 
|  | 102 | +} | 
|  | 103 | + | 
|  | 104 | +func (r GetApiVersionsApiRequest) Execute() (*PaginatedApiVersions, *http.Response, error) { | 
|  | 105 | +	return r.ApiService.GetApiVersionsExecute(r) | 
|  | 106 | +} | 
|  | 107 | + | 
|  | 108 | +/* | 
|  | 109 | +GetApiVersions Provides a list of versions for a given environment. | 
|  | 110 | +
 | 
|  | 111 | +API that provides a list of available versionsfor a given environment. | 
|  | 112 | +
 | 
|  | 113 | +	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | 
|  | 114 | +	@return GetApiVersionsApiRequest | 
|  | 115 | +*/ | 
|  | 116 | +func (a *OpenAPIApiService) GetApiVersions(ctx context.Context) GetApiVersionsApiRequest { | 
|  | 117 | +	return GetApiVersionsApiRequest{ | 
|  | 118 | +		ApiService: a, | 
|  | 119 | +		ctx:        ctx, | 
|  | 120 | +	} | 
|  | 121 | +} | 
|  | 122 | + | 
|  | 123 | +// GetApiVersionsExecute executes the request | 
|  | 124 | +// | 
|  | 125 | +//	@return PaginatedApiVersions | 
|  | 126 | +func (a *OpenAPIApiService) GetApiVersionsExecute(r GetApiVersionsApiRequest) (*PaginatedApiVersions, *http.Response, error) { | 
|  | 127 | +	var ( | 
|  | 128 | +		localVarHTTPMethod  = http.MethodGet | 
|  | 129 | +		localVarPostBody    any | 
|  | 130 | +		formFiles           []formFile | 
|  | 131 | +		localVarReturnValue *PaginatedApiVersions | 
|  | 132 | +	) | 
|  | 133 | + | 
|  | 134 | +	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenAPIApiService.GetApiVersions") | 
|  | 135 | +	if err != nil { | 
|  | 136 | +		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} | 
|  | 137 | +	} | 
|  | 138 | + | 
|  | 139 | +	localVarPath := localBasePath + "/api/atlas/v2/unauth/openapi/versions" | 
|  | 140 | + | 
|  | 141 | +	localVarHeaderParams := make(map[string]string) | 
|  | 142 | +	localVarQueryParams := url.Values{} | 
|  | 143 | +	localVarFormParams := url.Values{} | 
|  | 144 | + | 
|  | 145 | +	if r.itemsPerPage != nil { | 
|  | 146 | +		parameterAddToHeaderOrQuery(localVarQueryParams, "itemsPerPage", r.itemsPerPage, "") | 
|  | 147 | +	} else { | 
|  | 148 | +		var defaultValue int = 100 | 
|  | 149 | +		r.itemsPerPage = &defaultValue | 
|  | 150 | +		parameterAddToHeaderOrQuery(localVarQueryParams, "itemsPerPage", r.itemsPerPage, "") | 
|  | 151 | +	} | 
|  | 152 | +	if r.pageNum != nil { | 
|  | 153 | +		parameterAddToHeaderOrQuery(localVarQueryParams, "pageNum", r.pageNum, "") | 
|  | 154 | +	} else { | 
|  | 155 | +		var defaultValue int = 1 | 
|  | 156 | +		r.pageNum = &defaultValue | 
|  | 157 | +		parameterAddToHeaderOrQuery(localVarQueryParams, "pageNum", r.pageNum, "") | 
|  | 158 | +	} | 
|  | 159 | +	if r.env != nil { | 
|  | 160 | +		parameterAddToHeaderOrQuery(localVarQueryParams, "env", r.env, "") | 
|  | 161 | +	} | 
|  | 162 | +	// to determine the Content-Type header | 
|  | 163 | +	localVarHTTPContentTypes := []string{} | 
|  | 164 | + | 
|  | 165 | +	// set Content-Type header | 
|  | 166 | +	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) | 
|  | 167 | +	if localVarHTTPContentType != "" { | 
|  | 168 | +		localVarHeaderParams["Content-Type"] = localVarHTTPContentType | 
|  | 169 | +	} | 
|  | 170 | + | 
|  | 171 | +	// to determine the Accept header (only first one) | 
|  | 172 | +	localVarHTTPHeaderAccepts := []string{"application/vnd.atlas.2024-08-05+json"} | 
|  | 173 | + | 
|  | 174 | +	// set Accept header | 
|  | 175 | +	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) | 
|  | 176 | +	if localVarHTTPHeaderAccept != "" { | 
|  | 177 | +		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept | 
|  | 178 | +	} | 
|  | 179 | +	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) | 
|  | 180 | +	if err != nil { | 
|  | 181 | +		return localVarReturnValue, nil, err | 
|  | 182 | +	} | 
|  | 183 | + | 
|  | 184 | +	localVarHTTPResponse, err := a.client.callAPI(req) | 
|  | 185 | +	if err != nil || localVarHTTPResponse == nil { | 
|  | 186 | +		return localVarReturnValue, localVarHTTPResponse, err | 
|  | 187 | +	} | 
|  | 188 | + | 
|  | 189 | +	if localVarHTTPResponse.StatusCode >= 300 { | 
|  | 190 | +		newErr := a.client.makeApiError(localVarHTTPResponse, localVarHTTPMethod, localVarPath) | 
|  | 191 | +		return localVarReturnValue, localVarHTTPResponse, newErr | 
|  | 192 | +	} | 
|  | 193 | + | 
|  | 194 | +	err = a.client.decode(&localVarReturnValue, localVarHTTPResponse.Body, localVarHTTPResponse.Header.Get("Content-Type")) | 
|  | 195 | +	if err != nil { | 
|  | 196 | +		defer localVarHTTPResponse.Body.Close() | 
|  | 197 | +		buf, readErr := io.ReadAll(localVarHTTPResponse.Body) | 
|  | 198 | +		if readErr != nil { | 
|  | 199 | +			err = readErr | 
|  | 200 | +		} | 
|  | 201 | +		newErr := &GenericOpenAPIError{ | 
|  | 202 | +			body:  buf, | 
|  | 203 | +			error: err.Error(), | 
|  | 204 | +		} | 
|  | 205 | +		return localVarReturnValue, localVarHTTPResponse, newErr | 
|  | 206 | +	} | 
|  | 207 | + | 
|  | 208 | +	return localVarReturnValue, localVarHTTPResponse, nil | 
|  | 209 | +} | 
|  | 210 | + | 
|  | 211 | +type GetOpenApiInfoApiRequest struct { | 
|  | 212 | +	ctx        context.Context | 
|  | 213 | +	ApiService OpenAPIApi | 
|  | 214 | +} | 
|  | 215 | + | 
|  | 216 | +type GetOpenApiInfoApiParams struct { | 
|  | 217 | +} | 
|  | 218 | + | 
|  | 219 | +func (a *OpenAPIApiService) GetOpenApiInfoWithParams(ctx context.Context, args *GetOpenApiInfoApiParams) GetOpenApiInfoApiRequest { | 
|  | 220 | +	return GetOpenApiInfoApiRequest{ | 
|  | 221 | +		ApiService: a, | 
|  | 222 | +		ctx:        ctx, | 
|  | 223 | +	} | 
|  | 224 | +} | 
|  | 225 | + | 
|  | 226 | +func (r GetOpenApiInfoApiRequest) Execute() (*OpenApiInfo, *http.Response, error) { | 
|  | 227 | +	return r.ApiService.GetOpenApiInfoExecute(r) | 
|  | 228 | +} | 
|  | 229 | + | 
|  | 230 | +/* | 
|  | 231 | +GetOpenApiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification. | 
|  | 232 | +
 | 
|  | 233 | +This resource returns general information about the MongoDB Atlas Administration API OpenAPI Specification. Deprecated versions: v2-{2024-05-30} | 
|  | 234 | +
 | 
|  | 235 | +	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). | 
|  | 236 | +	@return GetOpenApiInfoApiRequest | 
|  | 237 | +*/ | 
|  | 238 | +func (a *OpenAPIApiService) GetOpenApiInfo(ctx context.Context) GetOpenApiInfoApiRequest { | 
|  | 239 | +	return GetOpenApiInfoApiRequest{ | 
|  | 240 | +		ApiService: a, | 
|  | 241 | +		ctx:        ctx, | 
|  | 242 | +	} | 
|  | 243 | +} | 
|  | 244 | + | 
|  | 245 | +// GetOpenApiInfoExecute executes the request | 
|  | 246 | +// | 
|  | 247 | +//	@return OpenApiInfo | 
|  | 248 | +func (a *OpenAPIApiService) GetOpenApiInfoExecute(r GetOpenApiInfoApiRequest) (*OpenApiInfo, *http.Response, error) { | 
|  | 249 | +	var ( | 
|  | 250 | +		localVarHTTPMethod  = http.MethodGet | 
|  | 251 | +		localVarPostBody    any | 
|  | 252 | +		formFiles           []formFile | 
|  | 253 | +		localVarReturnValue *OpenApiInfo | 
|  | 254 | +	) | 
|  | 255 | + | 
|  | 256 | +	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenAPIApiService.GetOpenApiInfo") | 
|  | 257 | +	if err != nil { | 
|  | 258 | +		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} | 
|  | 259 | +	} | 
|  | 260 | + | 
|  | 261 | +	localVarPath := localBasePath + "/api/atlas/v2/openapi/info" | 
|  | 262 | + | 
|  | 263 | +	localVarHeaderParams := make(map[string]string) | 
|  | 264 | +	localVarQueryParams := url.Values{} | 
|  | 265 | +	localVarFormParams := url.Values{} | 
|  | 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