api

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RealmRequestOriginHeader is the name of the header for where the api request
	// is coming from (UI, CLI, ADMIN API)
	RealmRequestOriginHeader = "X-BAAS-Request-Origin"

	// RealmCLIHeaderValue is the value of the RealmRequestOriginHeader if the request
	// is from the CLI
	RealmCLIHeaderValue = "mongodb-baas-cli"
)
View Source
const DefaultAtlasBaseURL = "https://cloud.mongodb.com"

DefaultAtlasBaseURL is the default atlas prod base url

View Source
const DefaultBaseURL = "https://realm.mongodb.com"

DefaultBaseURL is the default prod base url for Realm apps

Variables

This section is empty.

Functions

func UnmarshalRealmError

func UnmarshalRealmError(res *http.Response) error

UnmarshalRealmError unmarshals an *http.Response into an ErrRealmResponse. If the Body does not contain content it uses the provided Status

Types

type AuthClient

type AuthClient struct {
	Client
	// contains filtered or unexported fields
}

AuthClient is a Client that is aware of a User's auth credentials

func NewAuthClient

func NewAuthClient(client Client, user *user.User) *AuthClient

NewAuthClient returns a new *AuthClient

func (*AuthClient) ExecuteRequest

func (ac *AuthClient) ExecuteRequest(method, path string, options RequestOptions) (*http.Response, error)

ExecuteRequest makes a call to the provided path, supplying the user's access token

func (*AuthClient) RefreshAuth

func (ac *AuthClient) RefreshAuth() (auth.Response, error)

RefreshAuth makes a call to the session endpoint using the user's refresh token in order to obtain a new access token

type Client

type Client interface {
	ExecuteRequest(method, path string, options RequestOptions) (*http.Response, error)
}

Client represents something that is capable of making HTTP requests

func NewClient

func NewClient(baseURL string) Client

NewClient returns a new Client

type ErrAppNotFound

type ErrAppNotFound struct {
	ClientAppID string
}

ErrAppNotFound is used when an app cannot be found by client app ID

func (ErrAppNotFound) Error

func (eanf ErrAppNotFound) Error() string

type ErrRealmResponse

type ErrRealmResponse struct {
	// contains filtered or unexported fields
}

ErrRealmResponse represents a response from a Realm API call

func (ErrRealmResponse) Error

func (esr ErrRealmResponse) Error() string

Error returns a stringified error message

func (ErrRealmResponse) ErrorCode

func (esr ErrRealmResponse) ErrorCode() string

ErrorCode returns this ErrorCode on the error

func (*ErrRealmResponse) UnmarshalJSON

func (esr *ErrRealmResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into an ErrRealmResponse

type ExportStrategy

type ExportStrategy string

ExportStrategy is the enumeration of possible strategies which can be used when exporting a realm application

const (

	// ExportStrategyNone will result in no extra configuration into the call to Export
	ExportStrategyNone ExportStrategy = "none"
	// ExportStrategyTemplate will result in the `template` querystring parameter getting added to the call to Export
	ExportStrategyTemplate ExportStrategy = "template"
	// ExportStrategySourceControl will result in the `source_control` querystring parameter getting added to the call to Export
	ExportStrategySourceControl ExportStrategy = "source_control"
)

type RealmClient

type RealmClient interface {
	AddSecret(groupID, appID string, secret secrets.Secret) error
	Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
	CopyAsset(groupID, appID, fromPath, toPath string) error
	CreateDraft(groupID, appID string) (*models.AppDraft, error)
	CreateEmptyApp(groupID, appName, location, deploymentModel string) (*models.App, error)
	DeleteAsset(groupID, appID, path string) error
	DeployDraft(groupID, appID, draftID string) (*models.Deployment, error)
	Diff(groupID, appID string, appData []byte, strategy string) ([]string, error)
	DiscardDraft(groupID, appID, draftID string) error
	DraftDiff(groupID, appID, draftID string) (*models.DraftDiff, error)
	Export(groupID, appID string, strategy ExportStrategy) (string, io.ReadCloser, error)
	ExportDependencies(groupID, appID string) (string, io.ReadCloser, error)
	FetchAppByClientAppID(clientAppID string) (*models.App, error)
	FetchAppByGroupIDAndClientAppID(groupID, clientAppID string) (*models.App, error)
	FetchAppsByGroupID(groupID string) ([]*models.App, error)
	GetDeployment(groupID, appID, deploymentID string) (*models.Deployment, error)
	GetDrafts(groupID, appID string) ([]models.AppDraft, error)
	Import(groupID, appID string, appData []byte, strategy string) error
	InvalidateCache(groupID, appID, path string) error
	ListAssetsForAppID(groupID, appID string) ([]hosting.AssetMetadata, error)
	ListSecrets(groupID, appID string) ([]secrets.Secret, error)
	MoveAsset(groupID, appID, fromPath, toPath string) error
	RemoveSecretByID(groupID, appID, secretID string) error
	RemoveSecretByName(groupID, appID, secretName string) error
	SetAssetAttributes(groupID, appID, path string, attributes ...hosting.AssetAttribute) error
	UpdateSecretByID(groupID, appID, secretID, secretValue string) error
	UpdateSecretByName(groupID, appID, secretName, secretValue string) error
	UploadAsset(groupID, appID, path, hash string, size int64, body io.Reader, attributes ...hosting.AssetAttribute) error
	UploadDependencies(groupID, appID, fullPath string) error
}

RealmClient represents a Client that can be used to call the Realm Admin API

func NewRealmClient

func NewRealmClient(client Client) RealmClient

NewRealmClient returns a new RealmClient to be used for making calls to the Realm Admin API

type RequestOptions

type RequestOptions struct {
	Body   io.Reader
	Header http.Header
}

RequestOptions represents a simple set of options to use with HTTP requests

Directories

Path Synopsis
Package mock_api is a generated GoMock package.
Package mock_api is a generated GoMock package.

Jump to

Keyboard shortcuts

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