realm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// URL specifies the public cloud base url.
	URL = "https://realm.mongodb.com/"
	// APIAdminV3Path specifies the v3 adminapi path.
	APIAdminV3Path = "api/admin/v3.0/"
)

Variables

This section is empty.

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 Application

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

type ApplicationListOptions

type ApplicationListOptions struct {
	Product string `url:"product,omitempty"`
}

type AppsService

type AppsService interface {
	List(context.Context, string, *ApplicationListOptions) ([]Application, *Response, error)
}

AppsService provides access to the applications related functions in the Realm API.

See more: https://docs.mongodb.com/realm/admin/api/v3/#application-level-apis

type AppsServiceOp

type AppsServiceOp service

AppsServiceOp provides an implementation of the AppsService interface.

func (*AppsServiceOp) List

List all Realm apps within an Atlas project/group.

See more: https://docs.mongodb.com/realm/admin/api/v3/#application-level-apis

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	Apps          AppsService
	EventTriggers EventTriggersService
	// contains filtered or unexported fields
}

Client manages communication with Ops Manager API.

func New

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

New returns a new Ops Manager API client instance.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Realm API client.

func (*Client) Do

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

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it. The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.

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, in which case it is resolved relative to the URL 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 as the request body.

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc mongodbatlas.RequestCompletionCallback)

OnRequestCompleted sets the DO API request completion callback.

type ClientOpt

type ClientOpt func(*Client) error

ClientOpt are options for New.

func Options

func Options(opts ...ClientOpt) ClientOpt

Options turns a list of ClientOpt instances into a 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.

func SetWithRaw

func SetWithRaw() ClientOpt

SetWithRaw is a client option for getting raw atlas server response within Response structure.

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// The error code as specified in https://docs.atlas.mongodb.com/reference/api/api-errors/
	ErrorCode string `json:"error_code"`

	// 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:"error,omitempty"`
}

ErrorResponse reports the error caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type EventTrigger

type EventTrigger struct {
	ID              string                 `json:"_id,omitempty"`
	Name            string                 `json:"name,omitempty"`
	Type            string                 `json:"type,omitempty"`
	FunctionID      string                 `json:"function_id,omitempty"`
	FunctionName    string                 `json:"function_name,omitempty"`
	Disabled        *bool                  `json:"disabled,omitempty"`
	Config          EventTriggerConfig     `json:"config,omitempty"`
	EventProcessors map[string]interface{} `json:"event_processors,omitempty"`
	LastModified    *int64                 `json:"last_modified,omitempty"`
}

EventTrigger Represents a response of a trigger

type EventTriggerConfig

type EventTriggerConfig struct {
	OperationTypes           []string    `json:"operation_types,omitempty"`
	OperationType            string      `json:"operation_type,omitempty"`
	Providers                []string    `json:"providers,omitempty"`
	Database                 string      `json:"database,omitempty"`
	Collection               string      `json:"collection,omitempty"`
	ServiceID                string      `json:"service_id,omitempty"`
	Match                    interface{} `json:"match,omitempty"`
	Project                  interface{} `json:"project,omitempty"`
	FullDocument             *bool       `json:"full_document,omitempty"`
	FullDocumentBeforeChange *bool       `json:"full_document_before_change,omitempty"`
	Schedule                 string      `json:"schedule,omitempty"`
	ScheduleType             string      `json:"schedule_type,omitempty"`
	Unordered                *bool       `json:"unordered,omitempty"`
	ClusterName              string      `json:"clusterName,omitempty"`
}

EventTriggerConfig Represents a request of a trigger config

type EventTriggerRequest

type EventTriggerRequest struct {
	Name            string                 `json:"name,omitempty"`
	Type            string                 `json:"type,omitempty"`
	FunctionID      string                 `json:"function_id,omitempty"`
	Disabled        *bool                  `json:"disabled,omitempty"`
	Config          *EventTriggerConfig    `json:"config,omitempty"`
	EventProcessors map[string]interface{} `json:"event_processors,omitempty"`
}

EventTriggerRequest Represents a request of create a trigger

type EventTriggersService

EventTriggersService provides access to the event triggers related functions in the Realm API.

See more: https://docs.mongodb.com/realm/admin/api/v3/#event-trigger-apis

type EventTriggersServiceOp

type EventTriggersServiceOp service

EventTriggersServiceOp provides an implementation of the EventTriggersService interface.

func (*EventTriggersServiceOp) Create

func (s *EventTriggersServiceOp) Create(ctx context.Context, groupID, appID string, createRequest *EventTriggerRequest) (*EventTrigger, *Response, error)

Create one trigger.

See more: https://docs.mongodb.com/realm/admin/api/v3/#post-/groups/%7Bgroupid%7D/apps/%7Bappid%7D/triggers

func (*EventTriggersServiceOp) Delete

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

Delete one trigger.

See more https://docs.mongodb.com/realm/admin/api/v3/#delete-/groups/%7Bgroupid%7D/apps/%7Bappid%7D/triggers/%7Btriggerid%7D

func (*EventTriggersServiceOp) Get

func (s *EventTriggersServiceOp) Get(ctx context.Context, groupID, appID, triggerID string) (*EventTrigger, *Response, error)

Get Retrieve the configuration for a specific trigger.

See more: https://docs.mongodb.com/realm/admin/api/v3/#get-/groups/%7Bgroupid%7D/apps/%7Bappid%7D/triggers/%7Btriggerid%7D

func (EventTriggersServiceOp) List

func (s EventTriggersServiceOp) List(ctx context.Context, groupID, appID string) ([]EventTrigger, *Response, error)

List all triggers.

See more: https://docs.mongodb.com/realm/admin/api/v3/#responses-96

func (*EventTriggersServiceOp) Update

func (s *EventTriggersServiceOp) Update(ctx context.Context, groupID, appID, triggerID string, updateRequest *EventTriggerRequest) (*EventTrigger, *Response, error)

Update updates a trigger.

See more: https://docs.mongodb.com/realm/admin/api/v3/#put-/groups/%7Bgroupid%7D/apps/%7Bappid%7D/triggers/%7Btriggerid%7D

type RequestCompletionCallback

type RequestCompletionCallback = mongodbatlas.RequestCompletionCallback

type Response

type Response = mongodbatlas.Response

Jump to

Keyboard shortcuts

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