Documentation
¶
Index ¶
- type Client
- func (c *Client) Alive() bool
- func (c *Client) AllRecords(collection api.Getter) error
- func (c *Client) Batch(b *batch.Batch) error
- func (c *Client) BatchMaxRequests() (int, error)
- func (c *Client) Delete(collection api.Getter, record api.Recorded) (*api.DeleteResponse, error)
- func (c *Client) NewAccount(user *auth.User) error
- func (c *Client) NewAdmin(password string) error
- func (c *Client) NewBucket(bucket *buckets.Bucket) error
- func (c *Client) NewBucketWithPermissions(bucket *buckets.Bucket, perms *authz.Permissions) error
- func (c *Client) NewCollection(collection api.Poster) error
- func (c *Client) NewCollectionWithPermissions(collection api.Poster, perms *authz.Permissions) error
- func (c *Client) NewRecord(collection api.Getter, record interface{}) error
- func (c *Client) NewRecordWithPermissions(collection api.Getter, record interface{}, perms *authz.Permissions) error
- func (c *Client) SignerStatusFor(collection api.Patcher) (*kintosigner.Status, error)
- func (c *Client) ToResign(collection api.Patcher) error
- func (c *Client) ToReview(collection api.Patcher) error
- func (c *Client) ToRollBack(collection api.Patcher) error
- func (c *Client) ToSign(collection api.Patcher) error
- func (c *Client) ToSigned(collection api.Patcher) error
- func (c *Client) ToWIP(collection api.Patcher) error
- func (c *Client) TryAuth() (bool, error)
- func (c *Client) UpdateRecord(collection api.Getter, record api.Recorded) error
- func (c *Client) UpdateRecordWithPermissions(collection api.Getter, record api.Recorded, perms *authz.Permissions) error
- func (c *Client) WithAuthenticator(authenticator auth.Authenticator) *Client
- func (c *Client) WithToolHeader(tool string) *Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thread safe client for the Kinto REST API.
For information on the API that this client targets, please see the Kinto 1.x API documentation:
https://docs.kinto-storage.org/en/stable/api/
func NewClient ¶
NewClient constructs a client with the scheme (E.G "https"), the host (E.G "settings.stage.mozaws.net"), and the API base (E.G "/v1").
func NewClientFromStr ¶
func (*Client) AllRecords ¶
AllRecords retrieves all records for the given collection.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/records.html#retrieving-stored-records
func (*Client) Batch ¶
Batch POSTs a single batch request. Note that the size of a batch request is bounded by the remote server's "batch_max_requests" settings (which can be found under "settings" under the root resource).
The most reliable way to to use this endpoint is to query this limit via `BatchMaxRequests` and use that value in the batch.NewBatches API.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/batch.html
func (*Client) BatchMaxRequests ¶
BatchMaxRequests retrieves the "settings.batch_max_requests" from the utility endpoint.
This API is most useful when used in conjunction withe batch.NewBatches API.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/utilities.html#api-utilities
func (*Client) Delete ¶
Delete deletes the given record from the given collection.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/records.html#delete-stored-records
func (*Client) NewAccount ¶
NewAccount creates a new Kinto local account using the provide principal and password.
See https://docs.kinto-storage.org/en/stable/api/1.x/accounts.html#put--accounts-(user_id) for details.
func (*Client) NewAdmin ¶
NewAdmin is the same as NewAccount, however with the "admin" user pre-configured.
func (*Client) NewBucket ¶
NewBucket creates a new bucket with default permissions.
See https://docs.kinto-storage.org/en/stable/api/1.x/buckets.html#post--buckets for details.
func (*Client) NewBucketWithPermissions ¶
NewBucketWithPermissions creates a new bucket with the provided permissions.
See https://docs.kinto-storage.org/en/stable/api/1.x/buckets.html#post--buckets for details.
func (*Client) NewCollection ¶
NewCollection creates a new collection with the provided permissions.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/collections.html#post--buckets-(bucket_id)-collections
func (*Client) NewCollectionWithPermissions ¶
func (c *Client) NewCollectionWithPermissions(collection api.Poster, perms *authz.Permissions) error
NewCollectionWithPermissions creates a new collection with the provided permissions.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/collections.html#post--buckets-(bucket_id)-collections
func (*Client) NewRecord ¶
NewRecord POSTs a new record under the given collection with default permissions.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/records.html#uploading-a-record
func (*Client) NewRecordWithPermissions ¶
func (c *Client) NewRecordWithPermissions(collection api.Getter, record interface{}, perms *authz.Permissions) error
NewRecordWithPermissions POSTs a new record under the given collection with the given permissions.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/records.html#uploading-a-record
func (*Client) SignerStatusFor ¶
SignerStatusFor retrieves the Kinto Signer signer status for the given collection.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) ToResign ¶
ToResign puts the given collection into the "to-resign" state.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) ToReview ¶
ToReview puts the given collection into the "to-review" state.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) ToRollBack ¶
ToRollBack puts the given collection into the "to-rollback" state.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) ToSign ¶
ToSign puts the given collection into the "to-sign" state.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) ToSigned ¶
ToSigned puts the given collection into the "signed" state.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) ToWIP ¶
ToWIP puts the given collection into the "work-in-progress" state.
For details on the Kinto Signer plugin, please see: https://github.com/Kinto/kinto-signer
func (*Client) TryAuth ¶
TryAuth does a GET on the Kinto's root resource and checks for the presence of user metadata in order to determine the configured authenticator successfully authenticates.
See https://docs.kinto-storage.org/en/stable/api/1.x/authentication.html#try-authentication for details.
func (*Client) UpdateRecord ¶
UpdateRecord PATCHes a given record under the given collection with default permissions.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/records.html#patch--buckets-(bucket_id)-collections-(collection_id)-records-(record_id)
func (*Client) UpdateRecordWithPermissions ¶
func (c *Client) UpdateRecordWithPermissions(collection api.Getter, record api.Recorded, perms *authz.Permissions) error
UpdateRecordWithPermissions PATCHes a given record under the given collection with the given permissions.
For details, please see: https://docs.kinto-storage.org/en/stable/api/1.x/records.html#patch--buckets-(bucket_id)-collections-(collection_id)-records-(record_id)
func (*Client) WithAuthenticator ¶
func (c *Client) WithAuthenticator(authenticator auth.Authenticator) *Client
WithAuthenticator sets the authentication backend for future requests. The use of this configuration lazy and done on a per-request basis, so it is possible to use the same client but swap accounts in-and-out as necessary.
Although this API is thread safe it is not advised to swap out authentication methods for client that is shared between goroutines as other threads may be assuming that a given authenticator is being used, which can lead to surprising results.
func (*Client) WithToolHeader ¶
WithToolHeader sets the header value for X-AUTOMATED-TOOL, which is sent with every request.
By default, this is set to "https://github.com/mozilla/OneCRL-Tools/kinto", however it would be appreciated if consumers of this library set this to pointer to the code that is actually making API calls.