Documentation ¶
Overview ¶
Package gcsops provides an API client implementing a fraction of Cloud Storage's API originally needed by gcslock and packages using it.
Index ¶
- Constants
- Variables
- type APIError
- type Client
- func (c *Client) Delete(ctx context.Context, headers http.Header, bucket, name string) (err error)
- func (c *Client) Download(ctx context.Context, bucket, name string) (_ io.ReadCloser, err error)
- func (c *Client) List(ctx context.Context, bucket, prefix string, recursive bool) (_ []string, err error)
- func (c *Client) Stat(ctx context.Context, bucket, name string) (_ http.Header, err error)
- func (c *Client) TestPermissions(ctx context.Context, bucket string) (err error)
- func (c *Client) Upload(ctx context.Context, headers http.Header, bucket, name string, body io.Reader) (err error)
Constants ¶
const Endpoint = "https://storage.googleapis.com"
Endpoint is the top-level part of request endpoints to access Cloud Storage.
Variables ¶
var ( // Error is the error class for this package. Error = errs.Class("gcsops") // ErrNotFound is returned when the requested resource is not available. ErrNotFound = Error.New("not found") // ErrPreconditionFailed is returned when one or more conditions given in // the request header fields evaluated to false when tested on the server. ErrPreconditionFailed = Error.New("precondition failed") )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { // Status is the HTTP status (e.g. 502 Gateway Timeout) from the response. Status string // Message contains details of the error. Message string `json:"message" xml:"Message"` }
APIError is an API response error from Google Cloud Storage.
See the following docs for more details:
type Client ¶
Client implements a fraction of Cloud Storage's API originally needed by gcslock and packages using it.
func NewClient ¶
NewClient properly initializes new Client. It awkwardly takes context.Context because it uses oauth2 that stores it.
func (*Client) List ¶
func (c *Client) List(ctx context.Context, bucket, prefix string, recursive bool) (_ []string, err error)
List lists the bucket. It uses JSON API.
func (*Client) TestPermissions ¶
TestPermissions does a self-check of the current user's permissions in GCS. It returns nil if all permissions are correct, otherwise an error about the missing permission or error contacting the API.