Skip to content

APIBot: GO SDK Dev Preview #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ filename: "{{ .InterfaceName | snakecase }}.go"
mockname: "{{.InterfaceName}}"

packages:
go.mongodb.org/atlas-sdk/v20250312006/admin:
github.com/mongodb/atlas-sdk-go/admin:
config:
include-regex: ".*Api"
4 changes: 2 additions & 2 deletions admin/api_cloud_provider_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type CloudProviderAccessApi interface {
/*
CreateCloudProviderAccessRole Create One Cloud Provider Access Role
Creates one access role for the specified cloud provider. Some MongoDB Cloud features use these cloud provider access roles for authentication. To use this resource, the requesting Service Account or API Key must have the Project Owner role.
Creates one access role for the specified cloud provider. Some MongoDB Cloud features use these cloud provider access roles for authentication. To use this resource, the requesting Service Account or API Key must have the Project Owner role. For the GCP provider, if the project folder is not yet provisioned, Atlas will now create the role asynchronously. An intermediate role with status `IN_PROGRESS` will be returned, and the final service account will be provisioned. Once the GCP project is set up, subsequent requests will create the service account synchronously.
@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. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. **NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.
Expand Down Expand Up @@ -297,7 +297,7 @@ func (r CreateCloudProviderAccessRoleApiRequest) Execute() (*CloudProviderAccess
/*
CreateCloudProviderAccessRole Create One Cloud Provider Access Role
Creates one access role for the specified cloud provider. Some MongoDB Cloud features use these cloud provider access roles for authentication. To use this resource, the requesting Service Account or API Key must have the Project Owner role.
Creates one access role for the specified cloud provider. Some MongoDB Cloud features use these cloud provider access roles for authentication. To use this resource, the requesting Service Account or API Key must have the Project Owner role. For the GCP provider, if the project folder is not yet provisioned, Atlas will now create the role asynchronously. An intermediate role with status `IN_PROGRESS` will be returned, and the final service account will be provisioned. Once the GCP project is set up, subsequent requests will create the service account synchronously.
@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. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access. **NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.
Expand Down
314 changes: 314 additions & 0 deletions admin/api_open_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
// Code based on the AtlasAPI V2 OpenAPI file

package admin

import (
"context"
"io"
"net/http"
"net/url"
)

type OpenAPIApi interface {

/*
GetApiVersions Provides a list of versions for a given environment.
API that provides a list of available versionsfor a given environment.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return GetApiVersionsApiRequest
*/
GetApiVersions(ctx context.Context) GetApiVersionsApiRequest
/*
GetApiVersions Provides a list of versions for a given environment.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param GetApiVersionsApiParams - Parameters for the request
@return GetApiVersionsApiRequest
*/
GetApiVersionsWithParams(ctx context.Context, args *GetApiVersionsApiParams) GetApiVersionsApiRequest

// Method available only for mocking purposes
GetApiVersionsExecute(r GetApiVersionsApiRequest) (*PaginatedApiVersions, *http.Response, error)

/*
GetOpenApiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification.
This resource returns general information about the MongoDB Atlas Administration API OpenAPI Specification. Deprecated versions: v2-{2024-05-30}
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return GetOpenApiInfoApiRequest
*/
GetOpenApiInfo(ctx context.Context) GetOpenApiInfoApiRequest
/*
GetOpenApiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param GetOpenApiInfoApiParams - Parameters for the request
@return GetOpenApiInfoApiRequest
*/
GetOpenApiInfoWithParams(ctx context.Context, args *GetOpenApiInfoApiParams) GetOpenApiInfoApiRequest

// Method available only for mocking purposes
GetOpenApiInfoExecute(r GetOpenApiInfoApiRequest) (*OpenApiInfo, *http.Response, error)
}

// OpenAPIApiService OpenAPIApi service
type OpenAPIApiService service

type GetApiVersionsApiRequest struct {
ctx context.Context
ApiService OpenAPIApi
itemsPerPage *int
pageNum *int
env *string
}

type GetApiVersionsApiParams struct {
ItemsPerPage *int
PageNum *int
Env *string
}

func (a *OpenAPIApiService) GetApiVersionsWithParams(ctx context.Context, args *GetApiVersionsApiParams) GetApiVersionsApiRequest {
return GetApiVersionsApiRequest{
ApiService: a,
ctx: ctx,
itemsPerPage: args.ItemsPerPage,
pageNum: args.PageNum,
env: args.Env,
}
}

// Number of items that the response returns per page.
func (r GetApiVersionsApiRequest) ItemsPerPage(itemsPerPage int) GetApiVersionsApiRequest {
r.itemsPerPage = &itemsPerPage
return r
}

// Number of the page that displays the current set of the total objects that the response returns.
func (r GetApiVersionsApiRequest) PageNum(pageNum int) GetApiVersionsApiRequest {
r.pageNum = &pageNum
return r
}

// 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).
func (r GetApiVersionsApiRequest) Env(env string) GetApiVersionsApiRequest {
r.env = &env
return r
}

func (r GetApiVersionsApiRequest) Execute() (*PaginatedApiVersions, *http.Response, error) {
return r.ApiService.GetApiVersionsExecute(r)
}

/*
GetApiVersions Provides a list of versions for a given environment.
API that provides a list of available versionsfor a given environment.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return GetApiVersionsApiRequest
*/
func (a *OpenAPIApiService) GetApiVersions(ctx context.Context) GetApiVersionsApiRequest {
return GetApiVersionsApiRequest{
ApiService: a,
ctx: ctx,
}
}

// GetApiVersionsExecute executes the request
//
// @return PaginatedApiVersions
func (a *OpenAPIApiService) GetApiVersionsExecute(r GetApiVersionsApiRequest) (*PaginatedApiVersions, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody any
formFiles []formFile
localVarReturnValue *PaginatedApiVersions
)

localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenAPIApiService.GetApiVersions")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}

localVarPath := localBasePath + "/api/atlas/v2/unauth/openapi/versions"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

if r.itemsPerPage != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "itemsPerPage", r.itemsPerPage, "")
} else {
var defaultValue int = 100
r.itemsPerPage = &defaultValue
parameterAddToHeaderOrQuery(localVarQueryParams, "itemsPerPage", r.itemsPerPage, "")
}
if r.pageNum != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pageNum", r.pageNum, "")
} else {
var defaultValue int = 1
r.pageNum = &defaultValue
parameterAddToHeaderOrQuery(localVarQueryParams, "pageNum", r.pageNum, "")
}
if r.env != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "env", r.env, "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}

// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}

// to determine the Accept header (only first one)
localVarHTTPHeaderAccepts := []string{"application/vnd.atlas.2024-08-05+json"}

// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := a.client.makeApiError(localVarHTTPResponse, localVarHTTPMethod, localVarPath)
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.client.decode(&localVarReturnValue, localVarHTTPResponse.Body, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
defer localVarHTTPResponse.Body.Close()
buf, readErr := io.ReadAll(localVarHTTPResponse.Body)
if readErr != nil {
err = readErr
}
newErr := &GenericOpenAPIError{
body: buf,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

type GetOpenApiInfoApiRequest struct {
ctx context.Context
ApiService OpenAPIApi
}

type GetOpenApiInfoApiParams struct {
}

func (a *OpenAPIApiService) GetOpenApiInfoWithParams(ctx context.Context, args *GetOpenApiInfoApiParams) GetOpenApiInfoApiRequest {
return GetOpenApiInfoApiRequest{
ApiService: a,
ctx: ctx,
}
}

func (r GetOpenApiInfoApiRequest) Execute() (*OpenApiInfo, *http.Response, error) {
return r.ApiService.GetOpenApiInfoExecute(r)
}

/*
GetOpenApiInfo Return general information about the MongoDB Atlas Administration API OpenAPI Specification.
This resource returns general information about the MongoDB Atlas Administration API OpenAPI Specification. Deprecated versions: v2-{2024-05-30}
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return GetOpenApiInfoApiRequest
*/
func (a *OpenAPIApiService) GetOpenApiInfo(ctx context.Context) GetOpenApiInfoApiRequest {
return GetOpenApiInfoApiRequest{
ApiService: a,
ctx: ctx,
}
}

// GetOpenApiInfoExecute executes the request
//
// @return OpenApiInfo
func (a *OpenAPIApiService) GetOpenApiInfoExecute(r GetOpenApiInfoApiRequest) (*OpenApiInfo, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody any
formFiles []formFile
localVarReturnValue *OpenApiInfo
)

localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenAPIApiService.GetOpenApiInfo")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}

localVarPath := localBasePath + "/api/atlas/v2/openapi/info"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHTTPContentTypes := []string{}

// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}

// to determine the Accept header (only first one)
localVarHTTPHeaderAccepts := []string{"application/vnd.atlas.2024-08-05+json"}

// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := a.client.makeApiError(localVarHTTPResponse, localVarHTTPMethod, localVarPath)
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.client.decode(&localVarReturnValue, localVarHTTPResponse.Body, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
defer localVarHTTPResponse.Body.Close()
buf, readErr := io.ReadAll(localVarHTTPResponse.Body)
if readErr != nil {
err = readErr
}
newErr := &GenericOpenAPIError{
body: buf,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}
Loading