Documentation ¶
Index ¶
- Variables
- func CheckResponse(r *http.Response) error
- type Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewGZipRequest(ctx context.Context, method, urlStr string) (*http.Request, error)
- func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)
- func (c *Client) RealmAppInputFromString(value string) (*RealmAppInput, error)
- func (c *Client) RealmValueFromString(key string, value string) (*RealmValue, error)
- type ClientOpt
- type Completer
- type Doer
- type ErrorResponse
- type GZipRequestDoer
- type ListOptions
- type RealmApp
- type RealmAppInput
- type RealmAppsService
- type RealmAppsServiceOp
- func (s *RealmAppsServiceOp) Create(ctx context.Context, groupID string, createRequest *RealmAppInput) (*RealmApp, *Response, error)
- func (s *RealmAppsServiceOp) Delete(ctx context.Context, groupID, appID string) (*Response, error)
- func (s *RealmAppsServiceOp) Get(ctx context.Context, groupID string, appID string) (*RealmApp, *Response, error)
- func (s *RealmAppsServiceOp) List(ctx context.Context, groupID string, listOptions *ListOptions) ([]RealmApp, *Response, error)
- func (s *RealmAppsServiceOp) Update(ctx context.Context, groupID, appID string, updateRequest *RealmAppInput) (*RealmApp, *Response, error)
- type RealmAuth
- type RealmValue
- type RealmValuesService
- type RealmValuesServiceOp
- func (s *RealmValuesServiceOp) Create(ctx context.Context, groupID string, appID string, createRequest *RealmValue) (*RealmValue, *Response, error)
- func (s *RealmValuesServiceOp) Delete(ctx context.Context, groupID, appID string, keyID string) (*Response, error)
- func (s *RealmValuesServiceOp) Get(ctx context.Context, groupID string, appID string, valueID string) (*RealmValue, *Response, error)
- func (s *RealmValuesServiceOp) List(ctx context.Context, groupID string, appID string, listOptions *ListOptions) ([]RealmValue, *Response, error)
- func (s *RealmValuesServiceOp) Update(ctx context.Context, groupID string, appID string, keyID string, ...) (*RealmValue, *Response, error)
- type RequestCompletionCallback
- type RequestDoer
- type Response
Constants ¶
This section is empty.
Variables ¶
var RealmAccessToken = ""
Functions ¶
func CheckResponse ¶
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 (*Client) NewGZipRequest ¶
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 ¶
ClientOpt are options for New.
func SetBaseURL ¶
SetBaseURL is a client option for setting the base URL.
func SetUserAgent ¶
SetUserAgent is a client option for setting the user agent.
type Completer ¶
type Completer interface {
OnRequestCompleted(RequestCompletionCallback)
}
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 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 ¶
type RealmAppsService interface { List(context.Context, string, *ListOptions) ([]RealmApp, *Response, error) Get(context.Context, string, string) (*RealmApp, *Response, error) Create(context.Context, string, *RealmAppInput) (*RealmApp, *Response, error) Update(context.Context, string, string, *RealmAppInput) (*RealmApp, *Response, error) Delete(context.Context, string, string) (*Response, error) }
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 ¶
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 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 RealmValuesService ¶
type RealmValuesService interface { List(context.Context, string, string, *ListOptions) ([]RealmValue, *Response, error) Get(context.Context, string, string, string) (*RealmValue, *Response, error) Create(context.Context, string, string, *RealmValue) (*RealmValue, *Response, error) Update(context.Context, string, string, string, *RealmValue) (*RealmValue, *Response, error) Delete(context.Context, string, string, string) (*Response, error) }
endpoints of the MongoDB Atlas API. See more: https://docs.atlas.mongodb.com/reference/api/apiKeys/
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 ¶
RequestCompletionCallback defines the type of the request callback function
type RequestDoer ¶
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 ¶
CurrentPage gets the current page for list pagination request.
func (*Response) IsLastPage ¶
IsLastPage returns true if the current page is the last page