kinto

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

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

func NewClient(scheme, host, base string) *Client

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 NewClientFromStr(u string) (*Client, error)

func (*Client) Alive

func (c *Client) Alive() bool

Alive returns back whether any error occurred while doing a GET on /

func (*Client) AllRecords

func (c *Client) AllRecords(collection api.Getter) error

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

func (c *Client) Batch(b *batch.Batch) error

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

func (c *Client) BatchMaxRequests() (int, error)

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

func (c *Client) Delete(collection api.Getter, record api.Recorded) (*api.DeleteResponse, error)

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

func (c *Client) NewAccount(user *auth.User) error

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

func (c *Client) NewAdmin(password string) error

NewAdmin is the same as NewAccount, however with the "admin" user pre-configured.

func (*Client) NewBucket

func (c *Client) NewBucket(bucket *buckets.Bucket) error

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

func (c *Client) NewBucketWithPermissions(bucket *buckets.Bucket, perms *authz.Permissions) error

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

func (c *Client) NewCollection(collection api.Poster) error

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

func (c *Client) NewRecord(collection api.Getter, record interface{}) error

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

func (c *Client) SignerStatusFor(collection api.Patcher) (*kintosigner.Status, error)

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

func (c *Client) ToResign(collection api.Patcher) error

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

func (c *Client) ToReview(collection api.Patcher) error

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

func (c *Client) ToRollBack(collection api.Patcher) error

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

func (c *Client) ToSign(collection api.Patcher) error

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

func (c *Client) ToSigned(collection api.Patcher) error

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

func (c *Client) ToWIP(collection api.Patcher) error

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

func (c *Client) TryAuth() (bool, error)

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

func (c *Client) UpdateRecord(collection api.Getter, record api.Recorded) error

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

func (c *Client) WithToolHeader(tool string) *Client

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.

Directories

Path Synopsis
api
plugins

Jump to

Keyboard shortcuts

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