api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationCredentials

type ApplicationCredentials struct {
	// The ID of the key
	KeyID string

	// The secret part of the key
	KeySecret string
}

ApplicationCredentials are used to authorize the client

type Bucket

type Bucket struct {
	AccountID      string                `json:"accountId"`
	ID             string                `json:"bucketId"`
	Info           map[string]string     `json:"bucketInfo"`
	Name           string                `json:"bucketName"`
	Type           string                `json:"bucketType"`
	LifecycleRules []BucketLifecycleRule `json:"lifecycleRules"`
	Revision       int                   `json:"revision"`
}

Bucket is used to represent a B2 Bucket

type BucketCorsRule

type BucketCorsRule struct {
	Name              string   `json:"corsRuleName"`
	AllowedOrigins    []string `json:"allowedOrigins"`
	AllowedHeaders    []string `json:"allowedHeaders"`
	AllowedOperations []string `json:"allowedOperations"`
	ExposeHeaders     []string `json:"exposeHeaders"`
	MaxAgeSeconds     int      `json:"maxAgeSeconds"`
}

BucketCorsRule is used to represent a Bucket's CORS rule

See more on https://www.backblaze.com/b2/docs/cors_rules.html

type BucketCreateRequest

type BucketCreateRequest struct {
	AccountID      string                `json:"accountId"`
	Name           string                `json:"bucketName"`
	Type           string                `json:"bucketType"`
	Info           map[string]string     `json:"bucketInfo,omitempty"`
	CorsRules      []BucketCorsRule      `json:"corsRules,omitempty"`
	LifecycleRules []BucketLifecycleRule `json:"lifecycleRules,omitempty"`
}

BucketCreateRequest represents a request to create a Bucket

type BucketLifecycleRule

type BucketLifecycleRule struct {
	DaysFromHidingToDeleting  int    `json:"daysFromHidingToDeleting"`
	DaysFromUploadingToHiding int    `json:"daysFromUploadingToHiding"`
	FileNamePrefix            string `json:"fileNamePrefix"`
}

BucketLifecycleRule tells B2 to automatically hide and/or delete old files

See more on https://www.backblaze.com/b2/docs/lifecycle_rules.html

type BucketService

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

BucketService handles communication with the Bucket related methods of the B2 API

func (*BucketService) Create

func (s *BucketService) Create(createRequest *BucketCreateRequest) (*Bucket, *http.Response, error)

Create a new Bucket

type Client

type Client struct {

	// User agent for client
	UserAgent string

	// Base URL for API requests
	BaseURL *url.URL

	// Authorization token used for API calls
	Token string

	// The identifier for the account
	AccountID string

	// Services used for communicating with the API
	Bucket *BucketService
	// contains filtered or unexported fields
}

Client manages communication with Backblaze API

func NewClient

func NewClient(credentials *ApplicationCredentials) *Client

NewClient returns a new Backblaze API client

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response.

The API response is JSON decoded and stored in the value pointed to by v.

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest creates an API request suitable for use with Client.Do

The path should always be specified without a preceding slash. It will be resolved to the BaseURL of the Client.

If specified, the value pointed to by body is JSON encoded and included in as the request body.

Jump to

Keyboard shortcuts

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