client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const PostQuorumTimeoutMs = 100

Variables

View Source
var NilContainerInfo = &ContainerInfo{}

NilContainerInfo is useful for testing.

Functions

func ResponseStub

func ResponseStub(statusCode int, body string) *http.Response

ResponseStub returns a fake response with the given info.

Note: The Request field of the returned response will be nil; you may want to set the Request field if you have a specific request to reference.

func StubResponse

func StubResponse(resp *http.Response) *http.Response

StubResponse returns a standalone response with the detail from the original response; the full body will be read into memory and the original response's Body closed. This is used to allow the response to complete and close so the transport can be used for another request/response.

Note: Any error reading the original response's body will be ignored.

Note: The Request field of the returned response will be nil; you may want to set the Request field if you have a specific request to reference.

Types

type Client

type Client interface {
	PutAccount(headers map[string]string) *http.Response
	PostAccount(headers map[string]string) *http.Response
	// GetAccount reads the body of the response and converts it into a
	// []ContainerRecord while also returning the response instance itself.
	GetAccount(marker string, endMarker string, limit int, prefix string, delimiter string, reverse string, headers map[string]string) ([]ContainerRecord, *http.Response)
	HeadAccount(headers map[string]string) *http.Response
	DeleteAccount(headers map[string]string) *http.Response
	PutContainer(container string, headers map[string]string) *http.Response
	PostContainer(container string, headers map[string]string) *http.Response
	// GetContainer reads the body of the response and converts it into an
	// []ObjectRecord while also returning the response instance itself.
	GetContainer(container string, marker string, endMarker string, limit int, prefix string, delimiter string, reverse string, headers map[string]string) ([]ObjectRecord, *http.Response)
	HeadContainer(container string, headers map[string]string) *http.Response
	DeleteContainer(container string, headers map[string]string) *http.Response
	PutObject(container string, obj string, headers map[string]string, src io.Reader) *http.Response
	PostObject(container string, obj string, headers map[string]string) *http.Response
	GetObject(container string, obj string, headers map[string]string) *http.Response
	HeadObject(container string, obj string, headers map[string]string) *http.Response
	DeleteObject(container string, obj string, headers map[string]string) *http.Response
}

Client is an API interface to CloudFiles.

func NewClient

func NewClient(tenant string, username string, password string, apikey string, region string, authurl string, private bool) (Client, *http.Response)

NewClient creates a new end-user client. It authenticates immediately, and returns the error response if unable to.

func NewDirectClient

func NewDirectClient(account string) (Client, error)

NewDirectClient creates a new direct client with the given account name.

func NewInsecureClient

func NewInsecureClient(tenant string, username string, password string, apikey string, region string, authurl string, private bool) (Client, *http.Response)

NewInsecureClient creates a new end-user client with SSL verification turned off. It authenticates immediately, and returns the error response if unable to.

type ContainerInfo

type ContainerInfo struct {
	ReadACL            string
	WriteACL           string
	SyncKey            string
	ObjectCount        int64
	ObjectBytes        int64
	Metadata           map[string]string
	SysMetadata        map[string]string
	StoragePolicyIndex int
}

ContainerInfo is persisted in memcache via JSON; so this needs to continue to have public fields.

type ContainerRecord

type ContainerRecord struct {
	Count int64  `json:"count"`
	Bytes int64  `json:"bytes"`
	Name  string `json:"name"`
}

ContainerRecord is an entry in an account listing.

type KeystonePasswordAuthV2

type KeystonePasswordAuthV2 struct {
	TenantName          string `json:"tenantName"`
	PasswordCredentials struct {
		Username string `json:"username"`
		Password string `json:"password"`
	} `json:"passwordCredentials"`
}

type KeystoneRequestV2

type KeystoneRequestV2 struct {
	Auth interface{} `json:"auth"`
}

type KeystoneResponseV2

type KeystoneResponseV2 struct {
	Access struct {
		Token struct {
			ID     string `json:"id"`
			Tenant struct {
				Name string `json:"name"`
				ID   string `json:"id"`
			} `json:"tenant"`
		} `json:"token"`
		ServiceCatalog []struct {
			Endpoints []struct {
				PublicURL   string `json:"publicURL"`
				InternalURL string `json:"internalURL"`
				Region      string `json:"region"`
			} `json:"endpoints"`
			Type string `json:"type"`
		} `json:"serviceCatalog"`
		User struct {
			RaxDefaultRegion string `json:"RAX-AUTH:defaultRegion"`
		} `json:"user"`
	} `json:"access"`
}

type ObjectRecord

type ObjectRecord struct {
	Hash         string `json:"hash"`
	LastModified string `json:"last_modified"`
	Bytes        int    `json:"bytes"`
	Name         string `json:"name"`
	ContentType  string `json:"content_type"`
}

ObjectRecord is an entry in a container listing.

type ProxyClient

type ProxyClient interface {
	PutAccount(account string, headers http.Header) *http.Response
	PostAccount(account string, headers http.Header) *http.Response
	GetAccount(account string, options map[string]string, headers http.Header) *http.Response
	HeadAccount(account string, headers http.Header) *http.Response
	DeleteAccount(account string, headers http.Header) *http.Response
	PutContainer(account string, container string, headers http.Header) *http.Response
	PostContainer(account string, container string, headers http.Header) *http.Response
	GetContainer(account string, container string, options map[string]string, headers http.Header) *http.Response
	GetContainerInfo(account string, container string) (*ContainerInfo, error)
	HeadContainer(account string, container string, headers http.Header) *http.Response
	DeleteContainer(account string, container string, headers http.Header) *http.Response
	PutObject(account string, container string, obj string, headers http.Header, src io.Reader) *http.Response
	PostObject(account string, container string, obj string, headers http.Header) *http.Response
	GetObject(account string, container string, obj string, headers http.Header) *http.Response
	HeadObject(account string, container string, obj string, headers http.Header) *http.Response
	DeleteObject(account string, container string, obj string, headers http.Header) *http.Response
	// ObjectRingFor returns the object ring for the given account/container or
	// a response as to why the ring could not be returned.
	ObjectRingFor(account string, container string) (ring.Ring, *http.Response)
}

ProxyClient is similar to Client except it also accepts an account parameter to its operations. This is meant to be used by the proxy server.

func NewProxyClient

func NewProxyClient(pdc *ProxyDirectClient, mc ring.MemcacheRing, lc map[string]*ContainerInfo) ProxyClient

type ProxyDirectClient

type ProxyDirectClient struct {
	AccountRing   ring.Ring
	ContainerRing ring.Ring
	// contains filtered or unexported fields
}

func NewProxyDirectClient

func NewProxyDirectClient(policyList conf.PolicyList) (*ProxyDirectClient, error)

func (*ProxyDirectClient) DeleteAccount

func (c *ProxyDirectClient) DeleteAccount(account string, headers http.Header) *http.Response

func (*ProxyDirectClient) DeleteContainer

func (c *ProxyDirectClient) DeleteContainer(account string, container string, headers http.Header) *http.Response

func (*ProxyDirectClient) DeleteObject

func (c *ProxyDirectClient) DeleteObject(account string, container string, obj string, headers http.Header, mc ring.MemcacheRing, lc map[string]*ContainerInfo) *http.Response

func (*ProxyDirectClient) GetAccount

func (c *ProxyDirectClient) GetAccount(account string, options map[string]string, headers http.Header) *http.Response

func (*ProxyDirectClient) GetContainer

func (c *ProxyDirectClient) GetContainer(account string, container string, options map[string]string, headers http.Header) *http.Response

func (*ProxyDirectClient) GetContainerInfo

func (c *ProxyDirectClient) GetContainerInfo(account string, container string, mc ring.MemcacheRing, lc map[string]*ContainerInfo) (*ContainerInfo, error)

func (*ProxyDirectClient) GetObject

func (c *ProxyDirectClient) GetObject(account string, container string, obj string, headers http.Header, mc ring.MemcacheRing, lc map[string]*ContainerInfo) *http.Response

func (*ProxyDirectClient) GrepObject

func (c *ProxyDirectClient) GrepObject(account string, container string, obj string, search string, mc ring.MemcacheRing, lc map[string]*ContainerInfo) *http.Response

func (*ProxyDirectClient) HeadAccount

func (c *ProxyDirectClient) HeadAccount(account string, headers http.Header) *http.Response

func (*ProxyDirectClient) HeadContainer

func (c *ProxyDirectClient) HeadContainer(account string, container string, headers http.Header) *http.Response

func (*ProxyDirectClient) HeadObject

func (c *ProxyDirectClient) HeadObject(account string, container string, obj string, headers http.Header, mc ring.MemcacheRing, lc map[string]*ContainerInfo) *http.Response

func (*ProxyDirectClient) ObjectRingFor

func (c *ProxyDirectClient) ObjectRingFor(account string, container string, mc ring.MemcacheRing, lc map[string]*ContainerInfo) (ring.Ring, *http.Response)

func (*ProxyDirectClient) PostAccount

func (c *ProxyDirectClient) PostAccount(account string, headers http.Header) *http.Response

func (*ProxyDirectClient) PostContainer

func (c *ProxyDirectClient) PostContainer(account string, container string, headers http.Header) *http.Response

func (*ProxyDirectClient) PostObject

func (c *ProxyDirectClient) PostObject(account string, container string, obj string, headers http.Header, mc ring.MemcacheRing, lc map[string]*ContainerInfo) *http.Response

func (*ProxyDirectClient) PutAccount

func (c *ProxyDirectClient) PutAccount(account string, headers http.Header) *http.Response

func (*ProxyDirectClient) PutContainer

func (c *ProxyDirectClient) PutContainer(account string, container string, headers http.Header) *http.Response

func (*ProxyDirectClient) PutObject

func (c *ProxyDirectClient) PutObject(account string, container string, obj string, headers http.Header, src io.Reader, mc ring.MemcacheRing, lc map[string]*ContainerInfo) *http.Response

type RaxAPIKeyAuthV2

type RaxAPIKeyAuthV2 struct {
	APIKeyCredentials struct {
		Username string `json:"username"`
		APIKey   string `json:"apiKey"`
	} `json:"RAX-KSKEY:apiKeyCredentials"`
}

Jump to

Keyboard shortcuts

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