core

package
v20241113002.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package core should not be used by end users.

Index

Constants

View Source
const (
	// DefaultCloudURL is default base URL for the services.
	DefaultCloudURL = "https://cloud.mongodb.com"
	// ClientName of the v2 API client.
	ClientName = "go-atlas-sdk-admin"
	// DefaultUserAgent is default user agent header.
	DefaultUserAgent = ClientName + "/" + Version + " (" + runtime.GOOS + ";" + runtime.GOARCH + ")"
)
View Source
const (
	// SDK release tag version.
	Version = "v20241113002.0.0"
	// Resource Version.
	Resource = "20241113"
)

Version of the SDK used for the autorelease process. When version is bumped in the PR it means that the PR is ready to be merged. For more information please see: https://github.com/mongodb/atlas-sdk-go/blob/main/docs/doc_1_concepts.md

Variables

This section is empty.

Functions

func DoRequestWithClient

func DoRequestWithClient(
	ctx context.Context,
	client *http.Client,
	req *http.Request) (*http.Response, error)

DoRequestWithClient submits an HTTP request using the specified client.

Types

type ErrorResponse

type ErrorResponse struct {
	// Response that caused this error
	Response *http.Response
	// ErrorCode is the code as specified in https://docs.atlas.mongodb.com/reference/api/api-errors/
	ErrorCode string `json:"errorCode"`
	// HTTPCode status code.
	HTTPCode int `json:"error"`
	// Reason is short description of the error, which is simply the HTTP status phrase.
	Reason string `json:"reason"`
	// Detail is more detailed description of the error.
	Detail string `json:"detail,omitempty"`
}

ErrorResponse reports the error caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

func (*ErrorResponse) Is

func (r *ErrorResponse) Is(target error) bool
type Link struct {
	Rel  string `json:"rel,omitempty"`
	Href string `json:"href,omitempty"`
}

Link is the link to sub-resources and/or related resources.

type Response

type Response struct {
	*http.Response

	// Links that were returned with the response.
	Links []*Link `json:"links"`

	// Raw data from server response
	Raw []byte `json:"-"`
}

Response is a MongoDBAtlas response. This wraps the standard http.Response returned from MongoDBAtlas API.

func (*Response) CheckResponse

func (resp *Response) CheckResponse(body io.ReadCloser) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL