aliyunoss_restapi

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 17 Imported by: 0

README

aliyunoss-restapi

This a restful api in a kube-like way which implements the original AliyunOss SDK for easily interacting with AliyunOss

Documentation

Index

Constants

View Source
const (
	AccessEndpoint  = "ALIYUNOSS_ACCESS_ENDPOINT"
	AccessKeyID     = "ALIYUNOSS_ACCESS_KEY_ID"
	AccessKeySecret = "ALIYUNOSS_ACCESS_SECRET"
	CustomProxy     = "ALIYUNOSS_CUSTOM_PROXY"
)
View Source
const (
	ModelNative = false
	ModelProxy  = true
)

Variables

View Source
var (
	ErrNoAccessEndpoint  = errors.New("unable to load configuration, ALIYUNOSS_ACCESS_ENDPOINT must be defined")
	ErrNoAccessKeyID     = errors.New("unable to load configuration, ALIYUNOSS_ACCESS_KEY_ID must be defined")
	ErrNoAccessKeySecret = errors.New("unable to load configuration, ALIYUNOSS_ACCESS_SECRET must be defined")
)

Functions

func GetAccessEndpoint

func GetAccessEndpoint() (string, error)

func GetAccessKeyID

func GetAccessKeyID() (string, error)

func GetAccessKeySecret

func GetAccessKeySecret() (string, error)

func GetCustomProxy added in v1.0.3

func GetCustomProxy() string

func ReadBody

func ReadBody(body io.ReadCloser) ([]byte, error)

Types

type Interface

type Interface interface {
	Verb(verb string) *Request
	Post() *Request
	Put() *Request
	Get() *Request
	Delete() *Request
}

type Option

type Option struct {
	EndPoint        string
	AccessKeyID     string
	AccessKeySecret string

	Bucket     string
	BucketName string
	BaseUrl    string

	Context context.Context
}

type Proxy added in v1.0.3

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

func Run added in v1.0.3

func Run(listenPort int32) *Proxy

func (*Proxy) Shutdown added in v1.0.3

func (p *Proxy) Shutdown()

type ProxyRequestParams added in v1.0.3

type ProxyRequestParams struct {
	AccessEndpoint  string `form:"access_endpoint"`
	AccessKeyID     string `form:"access_key_id"`
	AccessKeySecret string `form:"access_key_secret"`
	BucketName      string `form:"bucket_name"`
	Namespace       string `form:"namespace"`
	Channel         string `form:"channel"`
	Filename        string `form:"filename"`
}

func (ProxyRequestParams) ToUrlParams added in v1.0.3

func (prp ProxyRequestParams) ToUrlParams() string

type Request

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

func NewRequest

func NewRequest(c *RestOssClient) *Request

func (*Request) Body

func (r *Request) Body(obj interface{}) *Request

Body makes the request use obj as the body. Optional. If obj is a string, try to read a file of that name. If obj is a []byte, send it directly. If obj is an io.Reader, use it directly. If obj is a runtime.Object, marshal it correctly, and set Content-Type header. If obj is a runtime.Object and nil, do nothing. Otherwise, set an error.

func (*Request) Bucket

func (r *Request) Bucket(bucketName string) *Request

Bucket will specify the ossOption Bucket

func (*Request) Channel

func (r *Request) Channel(channel string) *Request

Channel applies the channel scope to a request (<resource>/[ns/<namespace>/]/[ch/<channel>/]<name>)

func (*Request) Delete

func (r *Request) Delete() error

func (*Request) Download

func (r *Request) Download() (io.ReadCloser, error)

func (*Request) ForceDelete added in v1.0.1

func (r *Request) ForceDelete(key string) error

func (*Request) FullRootPath

func (r *Request) FullRootPath() string

func (*Request) List

func (r *Request) List(opts ...oss.Option) (oss.ListObjectsResult, error)

func (*Request) MaxRetries

func (r *Request) MaxRetries(maxRetries int) *Request

MaxRetries makes the request use the given integer as a ceiling of retrying upon receiving "Retry-After" headers and 429 status-code in the response. The default is 10 unless this function is specifically called with a different value. A zero maxRetries prevent it from doing retires and return an error immediately.

func (*Request) Name

func (r *Request) Name(resourceName string) *Request

Name sets the name of a resource to access (<resource>/[ns/<namespace>/]/[ch/<channel>/]<name>)

func (*Request) Namespace

func (r *Request) Namespace(namespace string) *Request

Namespace applies the namespace scope to a request (<resource>/[ns/<namespace>/]/[ch/<channel>/]<name>)

func (*Request) Resource

func (r *Request) Resource(resource string) *Request

Resource sets the resource to access (<resource>/[ns/<namespace>/]/[ch/<channel>/]<name>)

func (*Request) SetModel added in v1.0.3

func (r *Request) SetModel(bo bool)

func (*Request) SetOption added in v1.0.3

func (r *Request) SetOption(opt *Option)

func (*Request) Timeout

func (r *Request) Timeout(d time.Duration) *Request

Timeout makes the request use the given duration as an overall timeout for the request. Additionally, if set passes the value as "timeout" parameter in URL.

func (*Request) Upload

func (r *Request) Upload() error

func (*Request) Verb

func (r *Request) Verb(verb string) *Request

Verb sets the verb this request will use.

type RestOssClient

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

func NewRestClient

func NewRestClient(opt *Option) (*RestOssClient, error)

func (*RestOssClient) Delete

func (a *RestOssClient) Delete() *Request

Delete begins a DELETE request. Short for a.Verb("DELETE").

func (*RestOssClient) DeleteObject

func (a *RestOssClient) DeleteObject(bucketName, objectKey string) error

func (*RestOssClient) Get

func (a *RestOssClient) Get() *Request

Get begins a GET request. Short for a.Verb("GET").

func (*RestOssClient) GetObject

func (a *RestOssClient) GetObject(bucketName, objectKey string) (io.ReadCloser, error)

func (*RestOssClient) ListBucket

func (a *RestOssClient) ListBucket() error

func (*RestOssClient) ListObjects

func (a *RestOssClient) ListObjects(bucketName string, opts ...oss.Option) (oss.ListObjectsResult, error)

func (*RestOssClient) Post

func (a *RestOssClient) Post() *Request

Post begins a POST request. Short for a.Verb("POST").

func (*RestOssClient) Put

func (a *RestOssClient) Put() *Request

Put begins a PUT request. Short for a.Verb("PUT").

func (*RestOssClient) PutObject

func (a *RestOssClient) PutObject(bucketName, objectKey string, reader io.Reader) error

func (*RestOssClient) Verb

func (a *RestOssClient) Verb(verb string) *Request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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