s3client

package
v0.0.0-...-0a271de Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHTTPClient

func DefaultHTTPClient(logger logger.Logger) *jujuhttp.Client

DefaultHTTPClient returns the default http client used to access the object store.

Types

type AnonymousCredentials

type AnonymousCredentials struct {
	Credentials
}

AnonymousCredentials represents anonymous credentials.

func (AnonymousCredentials) Kind

Kind returns the kind of credentials.

type Blobs

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

Blobs is the client desienged to interact with the s3 compatible object store hosted by the apiserver

func NewBlobsS3Client

func NewBlobsS3Client(session Session) *Blobs

NewBlobsS3Client creates a client to interact with charm blobs stored on the apiserver's s3 compatible object store.

func (*Blobs) GetCharm

func (c *Blobs) GetCharm(ctx context.Context, modelUUID, charmRef string) (io.ReadCloser, error)

GetCharm retrieves a charm from the S3-compatible object store hosted by the apiserver. Returns an archived charm as a stream of bytes

func (*Blobs) GetObject

func (c *Blobs) GetObject(ctx context.Context, modelUUID, sha256 string) (io.ReadCloser, int64, error)

GetObject retrieves an object from the S3-compatible object store hosted by the apiserver. Returns an archived charm as a stream of bytes

type Credentials

type Credentials interface {
	Kind() CredentialsKind
}

Credentials represents the credentials used to access the object store.

type CredentialsKind

type CredentialsKind string

CredentialsKind represents the kind of credentials used to access the object store.

const (
	// AnonymousCredentialsKind represents anonymous credentials.
	AnonymousCredentialsKind CredentialsKind = "anonymous"
	// StaticCredentialsKind represents static credentials.
	StaticCredentialsKind CredentialsKind = "static"
)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient represents the http client used to access the object store.

type S3Client

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

objectsClient is a Juju shim around the AWS S3 client, which Juju uses to drive it's object store requirents

func NewS3Client

func NewS3Client(endpoint string, httpClient HTTPClient, credentials Credentials, logger logger.Logger) (*S3Client, error)

NewS3Client returns a new s3Caller client for accessing the object store.

func (*S3Client) CreateBucket

func (c *S3Client) CreateBucket(ctx context.Context, bucketName string) error

CreateBucket creates a bucket in the object store based on the bucket name.

func (*S3Client) DeleteObject

func (c *S3Client) DeleteObject(ctx context.Context, bucketName, objectName string) error

DeleteObject deletes an object from the object store based on the bucket name and object name.

func (*S3Client) GetObject

func (c *S3Client) GetObject(ctx context.Context, bucketName, objectName string) (io.ReadCloser, int64, string, error)

GetObject gets an object from the object store based on the bucket name and object name.

func (*S3Client) ListObjects

func (c *S3Client) ListObjects(ctx context.Context, bucketName string) ([]string, error)

ListObjects returns a list of objects in the specified bucket.

func (*S3Client) ObjectExists

func (c *S3Client) ObjectExists(ctx context.Context, bucketName, objectName string) error

ObjectExists checks if an object exists in the object store based on the bucket name and object name. Returns nil if the object exists, or an error if it does not.

func (*S3Client) PutObject

func (c *S3Client) PutObject(ctx context.Context, bucketName, objectName string, body io.Reader, hash string) error

PutObject puts an object into the object store based on the bucket name and object name.

type Session

type Session interface {
	// GetObject returns a reader for the specified object.
	GetObject(ctx context.Context, bucketName, objectName string) (io.ReadCloser, int64, string, error)
}

Session is the interface that wraps the GetObject method.

type StaticCredentials

type StaticCredentials struct {
	Key     string
	Secret  string
	Session string
}

S3Client is a Juju shim around the AWS S3 client, which Juju uses to drive its object store requirements. StaticCredentials represents static credentials.

func (StaticCredentials) Kind

Kind returns the kind of credentials.

Jump to

Keyboard shortcuts

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