client

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package client provides a client for the versions API.

The client needs to be authenticated with AWS. It should be used in internal development and CI tools for administrative tasks. For just fetching information from the API, use the fetcher package instead.

Needed IAM permissions for read mode: - "s3:GetObject" - "s3:ListBucket"

Additional needed IAM permissions for write mode: - "s3:PutObject" - "s3:DeleteObject" - "cloudfront:CreateInvalidation"

Thread-safety of the bucket is not guaranteed. The client is not thread-safe.

Each sub-API included in the Constellation Resource API should define it's resources by implementing types that implement apiObject. The new package can then call this package's Fetch and Update functions to get/modify resources from the API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v2.9.0

func Delete(ctx context.Context, c *Client, obj APIObject) error

Delete deletes the given apiObject from the public Constellation API.

func DeleteWithSignature added in v2.10.0

func DeleteWithSignature(ctx context.Context, c *Client, obj APIObject) error

DeleteWithSignature deletes the given apiObject and it's signature from the public Constellation API.

func Fetch

func Fetch[T APIObject](ctx context.Context, c *Client, obj T) (T, error)

Fetch fetches the given apiObject from the public Constellation API.

func NewClient

func NewClient(ctx context.Context, region, bucket, distributionID string, dryRun bool,
	log *slog.Logger,
) (*Client, CloseFunc, error)

NewClient creates a new client for the versions API.

func NewReadOnlyClient

func NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string,
	log *slog.Logger,
) (*Client, CloseFunc, error)

NewReadOnlyClient creates a new read-only client. This client can be used to fetch objects but cannot write updates.

func SignAndUpdate added in v2.10.0

func SignAndUpdate(ctx context.Context, c *Client, obj APIObject, signer sigstore.Signer) error

SignAndUpdate signs the given apiObject and updates the object and it's signature in the API. This function should be used in favor of manually managing signatures. The signing is specified as part of the signer argument.

func Update

func Update(ctx context.Context, c *Client, obj APIObject) error

Update creates/updates the given apiObject in the public Constellation API.

Types

type APIObject added in v2.9.0

type APIObject interface {
	ValidateRequest() error
	Validate() error
	JSONPath() string
}

APIObject is an object that is used to perform CRUD operations on the API.

type Client

type Client struct {
	DryRun bool // no write operations are performed

	Logger *slog.Logger
	// contains filtered or unexported fields
}

Client is the a general client for all APIs.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes the client. It invalidates the CDN cache for all uploaded files.

func (*Client) DeletePath

func (c *Client) DeletePath(ctx context.Context, path string) error

DeletePath deletes all objects at a given path from a s3 bucket.

type CloseFunc

type CloseFunc func(ctx context.Context) error

CloseFunc is a function that closes the client.

type NotFoundError

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

NotFoundError is an error that is returned when a resource is not found.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

Jump to

Keyboard shortcuts

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