mongodbrealm

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RealmAccessToken = ""

Functions

func CheckResponse

func CheckResponse(r *http.Response) 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.

Types

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	// Services used for communicating with the API
	RealmApps   RealmAppsService
	RealmValues RealmValuesService
	// contains filtered or unexported fields
}

Client manages communication with mongodbrealm v1.0 API

func New

func New(ctx context.Context, httpClient *http.Client, opts ...ClientOpt) (*Client, error)

New returns a new mongodbrealm API client instance.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new mongodbrealm API Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

func (*Client) NewGZipRequest

func (c *Client) NewGZipRequest(ctx context.Context, method, urlStr string) (*http.Request, error)

NewGZipRequest creates an API request that accepts gzip. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the DO API request completion callback

func (*Client) RealmAppInputFromString

func (c *Client) RealmAppInputFromString(value string) (*RealmAppInput, error)

func (*Client) RealmValueFromString

func (c *Client) RealmValueFromString(key string, value string) (*RealmValue, error)

type ClientOpt

type ClientOpt func(*Client) error

ClientOpt are options for New.

func SetAPIAuth

func SetAPIAuth(ctx context.Context, pub string, priv string) ClientOpt

func SetBaseURL

func SetBaseURL(bu string) ClientOpt

SetBaseURL is a client option for setting the base URL.

func SetUserAgent

func SetUserAgent(ua string) ClientOpt

SetUserAgent is a client option for setting the user agent.

type Completer

type Completer interface {
	OnRequestCompleted(RequestCompletionCallback)
}

type Doer

type Doer interface {
	Do(context.Context, *http.Request, interface{}) (*Response, error)
}

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response
	// The error code, which is simply the HTTP status code.
	ErrorCode int `json:"Error"`

	// A short description of the error, which is simply the HTTP status phrase.
	Reason string `json:"reason"`

	// A 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

type GZipRequestDoer

type GZipRequestDoer interface {
	Doer
	Completer
	NewGZipRequest(context.Context, string, string) (*http.Request, error)
}

type ListOptions

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	PageNum int `url:"pageNum,omitempty"`

	// For paginated result sets, the number of results to include per page.
	ItemsPerPage int `url:"itemsPerPage,omitempty"`
}

ListOptions specifies the optional parameters to List methods that support pagination.

type RealmApp

type RealmApp struct {
	Name            string `json:"name,omitempty"`
	ID              string `json:"_id,omitempty"`
	ClientAppID     string `json:"client_app_id,omitempty"`
	Location        string `json:"location,omitempty"`
	DeploymentModel string `json:"deployment_model,omitempty"`
	GroupID         string `json:"group_id,omitempty"`
	Product         string `json:"product,omitempty"`
	DomainID        string `json:"domain_id,omitempty"`
}

RealmApp represents MongoDB API Key. {"_id":"5f12de8c15049be9464eb269","client_app_id":"mad-elion-arays","name":"mad-elion","location":"US-VA","deployment_model":"GLOBAL","domain_id":"5f12de8c15049be9464eb26a","group_id":"5f12d8cc6c2bfd1e0c670f4a","last_used":1595072140,"last_modified":1595072140,"product":"standard"}

type RealmAppInput

type RealmAppInput struct {
	Name            string `json:"name,omitempty"`
	ClientAppID     string `json:"client_app_id,omitempty"`
	Location        string `json:"location,omitempty"`
	DeploymentModel string `json:"deployment_model,omitempty"`
	Product         string `json:"product,omitempty"`
}

RealmAppInput represents MongoDB API key input request for Create.

type RealmAppsService

RealmService is an interface for interfacing with the Realm endpoints of the MongoDB Atlas API. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys/

type RealmAppsServiceOp

type RealmAppsServiceOp service

RealmAppsServiceOp handles communication with the RealmApp related methods of the MongoDB Atlas API

func (*RealmAppsServiceOp) Create

func (s *RealmAppsServiceOp) Create(ctx context.Context, groupID string, createRequest *RealmAppInput) (*RealmApp, *Response, error)

Create an API Key by the {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-create-one/

func (*RealmAppsServiceOp) Delete

func (s *RealmAppsServiceOp) Delete(ctx context.Context, groupID, appID string) (*Response, error)

Delete the API Key specified to {API-KEY-ID} from the organization associated to {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKey-delete-one-apiKey/

func (*RealmAppsServiceOp) Get

func (s *RealmAppsServiceOp) Get(ctx context.Context, groupID string, appID string) (*RealmApp, *Response, error)

Get gets the RealmApp specified to {API-KEY-ID} from the organization associated to {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-get-one/

func (*RealmAppsServiceOp) List

func (s *RealmAppsServiceOp) List(ctx context.Context, groupID string, listOptions *ListOptions) ([]RealmApp, *Response, error)

List all API-KEY in the organization associated to {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-get-all/

func (*RealmAppsServiceOp) Update

func (s *RealmAppsServiceOp) Update(ctx context.Context, groupID, appID string, updateRequest *RealmAppInput) (*RealmApp, *Response, error)

Update a API Key in the organization associated to {ORG-ID} See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-update-one/

type RealmAuth

type RealmAuth struct {
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	UserID       string `json:"user_id,omitempty"`
	DeviceID     string `json:"device_id,omitempty"`
}

type RealmValue

type RealmValue struct {
	ID      string          `json:"_id,omitempty"`
	Name    string          `json:"name,omitempty"`
	Value   json.RawMessage `json:"value,omitempty"`
	Private bool            `json:"private,omitempty"`
}

type RealmValuesServiceOp

type RealmValuesServiceOp service

RealmValuesServiceOp handles communication with the RealmValue related methods of the MongoDB Atlas API

func (*RealmValuesServiceOp) Create

func (s *RealmValuesServiceOp) Create(ctx context.Context, groupID string, appID string, createRequest *RealmValue) (*RealmValue, *Response, error)

Create an API Key by the {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-create-one/

func (*RealmValuesServiceOp) Delete

func (s *RealmValuesServiceOp) Delete(ctx context.Context, groupID, appID string, keyID string) (*Response, error)

Delete the API Key specified to {API-KEY-ID} from the organization associated to {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKey-delete-one-apiKey/

func (*RealmValuesServiceOp) Get

func (s *RealmValuesServiceOp) Get(ctx context.Context, groupID string, appID string, valueID string) (*RealmValue, *Response, error)

Get gets the RealmValue specified to {API-KEY-ID} from the organization associated to {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-get-one/

func (*RealmValuesServiceOp) List

func (s *RealmValuesServiceOp) List(ctx context.Context, groupID string, appID string, listOptions *ListOptions) ([]RealmValue, *Response, error)

List all API-KEY in the organization associated to {ORG-ID}. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-get-all/

func (*RealmValuesServiceOp) Update

func (s *RealmValuesServiceOp) Update(ctx context.Context, groupID string, appID string, keyID string, updateRequest *RealmValue) (*RealmValue, *Response, error)

Update a API Key in the organization associated to {ORG-ID} See more: https://docs.atlas.mongodb.com/reference/api/apiKeys-orgs-update-one/

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

type RequestDoer

type RequestDoer interface {
	Doer
	Completer
	NewRequest(context.Context, string, string, interface{}) (*http.Request, error)
}

type Response

type Response struct {
	*http.Response

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

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

func (*Response) CurrentPage

func (resp *Response) CurrentPage() (int, error)

CurrentPage gets the current page for list pagination request.

func (*Response) IsLastPage

func (resp *Response) IsLastPage() bool

IsLastPage returns true if the current page is the last page

Jump to

Keyboard shortcuts

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