tos

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TOSACLPrivate                = "private"
	TOSACLPublicRead             = "public-read"
	TOSACLPublicReadWrite        = "public-read-write"
	TOSACLAuthenticatedRead      = "authenticated-read"
	TOSACLBucketOwnerRead        = "bucket-owner-read"
	TOSACLBucketOwnerFullControl = "bucket-owner-full-control"
)

TOS canned ACL values. PUT bucket ACL accepts these via the `x-tos-acl` header; GET bucket ACL replies with a Grants list that we collapse back to one of these canonical values for the bucket-acl-check `audit` view.

Variables

This section is empty.

Functions

func NormalizeTOSACL added in v0.3.1

func NormalizeTOSACL(level string) string

NormalizeTOSACL maps user-friendly aliases to canned TOS ACL values.

Types

type Bucket

type Bucket struct {
	Name             string `json:"Name"`
	CreationDate     string `json:"CreationDate"`
	Location         string `json:"Location"`
	ExtranetEndpoint string `json:"ExtranetEndpoint"`
	IntranetEndpoint string `json:"IntranetEndpoint"`
	ProjectName      string `json:"ProjectName"`
	BucketType       string `json:"BucketType"`
}

type BucketItem

type BucketItem struct {
	Key           string `json:"Key"`
	LastModified  string `json:"LastModified"`
	ETag          string `json:"ETag"`
	Size          int64  `json:"Size"`
	StorageClass  string `json:"StorageClass"`
	Type          string `json:"Type"`
	HashCrc64ECMA string `json:"HashCrc64ecma"`
}

type Client

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

func NewClient

func NewClient(cred auth.Credential, opts ...Option) *Client

func (*Client) GetBucketACL added in v0.3.1

func (c *Client) GetBucketACL(ctx context.Context, bucket, region string) (string, error)

GetBucketACL returns the canned ACL value for bucket. The TOS data plane returns a permission grant list rather than a direct canned value, so the helper collapses Grants back into one of the TOSACL* constants.

func (*Client) ListBuckets

func (c *Client) ListBuckets(ctx context.Context, region string) (ListBucketsOutput, error)

func (*Client) ListObjectsV2

func (c *Client) ListObjectsV2(ctx context.Context, bucket, region, token string, maxKeys int) (ListObjectsV2Output, error)

func (*Client) PutBucketACL added in v0.3.1

func (c *Client) PutBucketACL(ctx context.Context, bucket, region, acl string) error

PutBucketACL sets the canned ACL on bucket via the `x-tos-acl` header.

type Driver

type Driver struct {
	Cred   auth.Credential
	Region string
	Client *Client
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(cred auth.Credential, region string, opts ...Option) *Driver

func (*Driver) AuditBucketACL added in v0.3.1

func (d *Driver) AuditBucketACL(ctx context.Context, bucket string) ([]schema.BucketACLEntry, error)

AuditBucketACL enumerates buckets in scope and returns their canned ACL.

func (*Driver) ExposeBucket added in v0.3.1

func (d *Driver) ExposeBucket(ctx context.Context, bucket, level string) (string, error)

ExposeBucket sets the bucket public-readable (defaults to public-read).

func (*Driver) GetBuckets

func (d *Driver) GetBuckets(ctx context.Context) ([]schema.Storage, error)

func (*Driver) ListObjects

func (d *Driver) ListObjects(ctx context.Context, buckets map[string]string) ([]schema.BucketResult, error)

func (*Driver) NewClient

func (d *Driver) NewClient() (*Client, error)

func (*Driver) TotalObjects

func (d *Driver) TotalObjects(ctx context.Context, buckets map[string]string) ([]schema.BucketResult, error)

func (*Driver) UnexposeBucket added in v0.3.1

func (d *Driver) UnexposeBucket(ctx context.Context, bucket string) error

UnexposeBucket reverts the bucket to private.

type GetBucketACLOutput added in v0.3.1

type GetBucketACLOutput struct {
	Owner struct {
		ID string `json:"ID"`
	} `json:"Owner"`
	Grants []struct {
		Grantee struct {
			Type string `json:"Type"`
			URI  string `json:"Canned"`
			ID   string `json:"ID"`
		} `json:"Grantee"`
		Permission string `json:"Permission"`
	} `json:"Grants"`
}

GetBucketACLOutput captures the JSON returned by `GET /?acl`. Only the fields needed to derive a canonical ACL string are kept.

type ListBucketsOutput

type ListBucketsOutput struct {
	Buckets []Bucket `json:"Buckets"`
	Owner   struct {
		ID string `json:"ID"`
	} `json:"Owner"`
}

type ListObjectsV2Output

type ListObjectsV2Output struct {
	Name                  string       `json:"Name"`
	Prefix                string       `json:"Prefix"`
	MaxKeys               int          `json:"MaxKeys"`
	Delimiter             string       `json:"Delimiter"`
	EncodingType          string       `json:"EncodingType"`
	IsTruncated           bool         `json:"IsTruncated"`
	ContinuationToken     string       `json:"ContinuationToken"`
	NextContinuationToken string       `json:"NextContinuationToken"`
	Contents              []BucketItem `json:"Contents"`
}

type Option

type Option func(*Client)

func WithBaseURL

func WithBaseURL(rawURL string) Option

func WithClock

func WithClock(now func() time.Time) Option

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

func WithRetryPolicy

func WithRetryPolicy(p volcapi.RetryPolicy) Option

Jump to

Keyboard shortcuts

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