Documentation ¶
Index ¶
- Constants
- Variables
- type API
- type Client
- func (c *Client) Auth(user, key string) error
- func (c *Client) C(name string) ContainerAPI
- func (c *Client) Container(name string) ContainerAPI
- func (c *Client) ContainerInfo(name string) (info ContainerInfo, err error)
- func (c *Client) Containers() ([]ContainerAPI, error)
- func (c *Client) ContainersInfo() ([]ContainerInfo, error)
- func (c *Client) CreateContainer(name string, private bool) (ContainerAPI, error)
- func (c *Client) Credentials() (cache ClientCredentials)
- func (c *Client) Debug(debug bool)
- func (c *Client) Do(request *http.Request) (res *http.Response, err error)
- func (c *Client) Dump() ([]byte, error)
- func (c *Client) Expired() bool
- func (c *Client) Info() (info StorageInformation)
- func (c *Client) NewRequest(method string, body io.Reader, parms ...string) (*http.Request, error)
- func (c *Client) ObjectInfo(container, filename string) (f ObjectInfo, err error)
- func (c *Client) ObjectsInfo(container string) ([]ObjectInfo, error)
- func (c *Client) RemoveContainer(name string) error
- func (c *Client) RemoveObject(container, filename string) error
- func (c *Client) Token() string
- func (c *Client) URL(container, filename string) string
- func (c *Client) Upload(reader io.Reader, container, filename, contentType string) error
- func (c *Client) UploadBody(reader io.Reader, container, filename, contentType string) error
- func (c *Client) UploadFile(filename, container string) error
- func (c *Client) СopyFile(srcContainer, srcPath, dstContainer, dstPath string) error
- type ClientCredentials
- type Container
- func (c *Container) Create(private bool) error
- func (c *Container) Info() (info ContainerInfo, err error)
- func (c *Container) Name() string
- func (c *Container) Object(name string) ObjectAPI
- func (c *Container) ObjectInfo(name string) (ObjectInfo, error)
- func (c *Container) Objects() ([]ObjectAPI, error)
- func (c *Container) ObjectsInfo() ([]ObjectInfo, error)
- func (c *Container) Remove() error
- func (c *Container) RemoveObject(filename string) error
- func (c *Container) URL(filename string) string
- func (c *Container) Upload(reader io.Reader, filename, contentType string) error
- func (c *Container) UploadFile(filename string) error
- type ContainerAPI
- type ContainerInfo
- type DoClient
- type Object
- type ObjectAPI
- type ObjectInfo
- type StorageInformation
Constants ¶
const ( // EnvUser is environmental variable for selectel api username EnvUser = "SELECTEL_USER" // EnvKey is environmental variable for selectel api key EnvKey = "SELECTEL_KEY" )
Variables ¶
var ( // ErrorAuth occurs when client is unable to authenticate ErrorAuth = errors.New("Authentication error") // ErrorBadCredentials occurs when incorrect user/key provided ErrorBadCredentials = errors.New("Bad auth credentials provided") )
var ( // ErrorObjectNotFound occurs when server returns 404 ErrorObjectNotFound = errors.New("Object not found") // ErrorBadResponce occurs when server returns unexpected code ErrorBadResponce = errors.New("Unable to process api responce") // ErrorBadName ErrorBadName = errors.New("Bad container/object name provided") // ErrorBadJSON occurs on unmarhalling error ErrorBadJSON = errors.New("Unable to parse api responce") )
var ( // ErrorConianerNotEmpty occurs when requested container is not empty ErrorConianerNotEmpty = errors.New("Unable to remove container with objects") )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { DoClient Info() StorageInformation Upload(reader io.Reader, container, filename, t string) error UploadBody(reader io.Reader, container, filename, t string) error UploadFile(filename, container string) error Auth(user, key string) error Debug(debug bool) Token() string C(string) ContainerAPI Container(string) ContainerAPI СopyFile(srcContainer, srcPath, dstContainer, dstPath string) error RemoveObject(container, filename string) error URL(container, filename string) string CreateContainer(name string, private bool) (ContainerAPI, error) RemoveContainer(name string) error // ObjectInfo returns information about object in container ObjectInfo(container, filename string) (f ObjectInfo, err error) ObjectsInfo(container string) ([]ObjectInfo, error) ContainerInfo(name string) (info ContainerInfo, err error) ContainersInfo() ([]ContainerInfo, error) Containers() ([]ContainerAPI, error) Credentials() (cache ClientCredentials) Dump() ([]byte, error) }
API for selectel storage
func NewFromCache ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is selectel storage api client
func (*Client) Container ¶
func (c *Client) Container(name string) ContainerAPI
Container returns new ContainerAPI client binted to container name Does no checks for container existance
func (*Client) ContainerInfo ¶
func (c *Client) ContainerInfo(name string) (info ContainerInfo, err error)
func (*Client) Containers ¶
func (c *Client) Containers() ([]ContainerAPI, error)
Containers return all containers from storage
func (*Client) ContainersInfo ¶
func (c *Client) ContainersInfo() ([]ContainerInfo, error)
ContainersInfo return all container-specific information from storage
func (*Client) CreateContainer ¶
func (c *Client) CreateContainer(name string, private bool) (ContainerAPI, error)
CreateContainer creates new container and retuns it. If container already exists, function will return existing container
func (*Client) Credentials ¶
func (c *Client) Credentials() (cache ClientCredentials)
func (*Client) Info ¶
func (c *Client) Info() (info StorageInformation)
Info returns StorageInformation for current user
func (*Client) NewRequest ¶
func (*Client) ObjectInfo ¶
func (c *Client) ObjectInfo(container, filename string) (f ObjectInfo, err error)
func (*Client) ObjectsInfo ¶
func (c *Client) ObjectsInfo(container string) ([]ObjectInfo, error)
ObjectsInfo returns information about all objects in container
func (*Client) RemoveContainer ¶
RemoveContainer removes container with provided name Container should be empty before removing and must exist
func (*Client) RemoveObject ¶
DeleteObject removes object from specified container
func (*Client) Upload ¶
Upload reads all data from reader and uploads to contaier with filename and content type
func (*Client) UploadBody ¶
func (*Client) UploadFile ¶
UploadFile to container
type ClientCredentials ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is realization of ContainerAPI
func (*Container) Info ¶
func (c *Container) Info() (info ContainerInfo, err error)
func (*Container) ObjectInfo ¶
func (c *Container) ObjectInfo(name string) (ObjectInfo, error)
func (*Container) ObjectsInfo ¶
func (c *Container) ObjectsInfo() ([]ObjectInfo, error)
ObjectsInfo returns information about all objects in container
func (*Container) RemoveObject ¶
DeleteObject is shortcut to API.DeleteObject
func (*Container) Upload ¶
Upload reads all data from reader and uploads to contaier with filename and content type shortcut to API.Upload
func (*Container) UploadFile ¶
UploadFile to current container. Shortcut to API.UploadFile
type ContainerAPI ¶
type ContainerAPI interface { Name() string Upload(reader io.Reader, name, contentType string) error UploadFile(filename string) error URL(filename string) string RemoveObject(name string) error // Remove removes current container Remove() error // Create creates current container Create(bool) error // ObjectInfo returns info about object in container ObjectInfo(name string) (ObjectInfo, error) // Object returns object from container Object(name string) ObjectAPI ObjectsInfo() ([]ObjectInfo, error) Objects() ([]ObjectAPI, error) Info() (info ContainerInfo, err error) }
ContainerAPI is interface for selectel storage container
type ContainerInfo ¶
type ContainerInfo struct { BytesUsed uint64 `json:"bytes"` ObjectCount uint64 `json:"count"` Name string `json:"name"` RecievedBytes uint64 `json:"rx_bytes"` TransferedBytes uint64 `json:"tx_bytes"` Type string `json:"type"` }
ContainerInfo is information about container
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func (*Object) Info ¶
func (o *Object) Info() (info ObjectInfo, err error)
func (*Object) UploadFile ¶
type ObjectInfo ¶
type ObjectInfo struct { Size uint64 `json:"bytes"` ContentType string `json:"content_type"` Downloaded uint64 `json:"downloaded"` Hash string `json:"hash"` LastModifiedStr string `json:"last_modified"` LastModified time.Time `json:"-"` Name string `json:"name"` }
ObjectInfo represents object info