resources

package
v0.0.0-...-51a0f74 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// HeaderContentType is the header name for the type of a file upload.
	HeaderContentType = "Content-Type"
	// HeaderContentSha384 is the header name for the sha hash of a file upload.
	HeaderContentSha384 = "Content-Sha384"
	// HeaderContentLength is the header name for the length of a file upload.
	HeaderContentLength = "Content-Length"
	// HeaderContentDisposition is the header name for value that holds the filename.
	// The params are formatted according to  RFC 2045 and RFC 2616 (see
	// mime.ParseMediaType and mime.FormatMediaType).
	HeaderContentDisposition = "Content-Disposition"
)
View Source
const (
	// MediaTypeFormData is the media type for file uploads (see
	// mime.FormatMediaType).
	MediaTypeFormData = "form-data"
	// QueryParamPendingID is the query parameter we use to send up the pending id.
	QueryParamPendingID = "pendingid"
)
View Source
const (
	// ContentTypeRaw is the HTTP content-type value used for raw, unformattedcontent.
	ContentTypeRaw = "application/octet-stream"
)
View Source
const FilenameParamForContentDispositionHeader = "filename"

FilenameParamForContentDispositionHeader is the name of the parameter that contains the name of the file being uploaded, see mime.FormatMediaType and RFC 1867 (http://tools.ietf.org/html/rfc1867):

 The original local file name may be supplied as well, either as a
'filename' parameter either of the 'content-disposition: form-data'
 header or in the case of multiple files in a 'content-disposition:
 file' header of the subpart.
View Source
const (
	// HTTPEndpointPath is the URL path, with substitutions, for
	// a resource request.
	HTTPEndpointPath = "/applications/%s/resources/%s"
)

Variables

This section is empty.

Functions

func API2CharmResource

func API2CharmResource(apiInfo params.CharmResource) (charmresource.Resource, error)

API2CharmResource converts an API CharmResource struct into a charm resource.

func API2Resource

func API2Resource(apiRes params.Resource) (resources.Resource, error)

API2Resource converts an API Resource struct into a resource.Resource.

func ApplicationResources2APIResult

func ApplicationResources2APIResult(svcRes resources.ApplicationResources) params.ResourcesResult

func CharmResource2API

func CharmResource2API(res charmresource.Resource) params.CharmResource

CharmResource2API converts a charm resource into a CharmResource struct.

func NewHTTPDownloadRequest

func NewHTTPDownloadRequest(resourceName string) (*http.Request, error)

NewHTTPDownloadRequest creates a new HTTP download request for the given resource.

Intended for use on the client side.

func Resource2API

func Resource2API(res resources.Resource) params.Resource

Resource2API converts a resource.Resource into a Resource struct.

Types

type AddPendingResourcesArgs

type AddPendingResourcesArgs struct {
	// ApplicationID identifies the application being deployed.
	ApplicationID string

	// CharmID identifies the application's charm.
	CharmID CharmID

	// Resources holds the charm store info for each of the resources
	// that should be added/updated on the controller.
	Resources []charmresource.Resource
}

AddPendingResourcesArgs holds the arguments to AddPendingResources().

type CharmID

type CharmID struct {

	// URL of the given charm, includes the reference name and a revision.
	// Old style charm URLs are also supported i.e. charmstore.
	URL string

	// Origin holds the origin of a charm. This includes the source of the
	// charm, along with the revision and channel to identify where the charm
	// originated from.
	Origin apicharm.Origin
}

CharmID represents the underlying charm for a given application. This includes both the URL and the origin.

type Client

type Client struct {
	base.ClientFacade
	// contains filtered or unexported fields
}

Client is the public client for the resources API facade.

func NewClient

func NewClient(apiCaller base.APICallCloser) (*Client, error)

NewClient returns a new Client for the given raw API caller.

func (Client) AddPendingResources

func (c Client) AddPendingResources(args AddPendingResourcesArgs) ([]string, error)

AddPendingResources sends the provided resource info up to Juju without making it available yet.

func (Client) ListResources

func (c Client) ListResources(applications []string) ([]resources.ApplicationResources, error)

ListResources calls the ListResources API server method with the given application names.

func (Client) Upload

func (c Client) Upload(application, name, filename, pendingID string, reader io.ReadSeeker) error

Upload sends the provided resource blob up to Juju.

func (Client) UploadPendingResource

func (c Client) UploadPendingResource(application string, res charmresource.Resource, filename string, reader io.ReadSeeker) (pendingID string, err error)

UploadPendingResource sends the provided resource blob up to Juju and makes it available by calling AddPendingResources to compute the pendingID first, then it uses the client.Upload to actually send it. Pending resources IDs are required for resources uploaded before AddApplication has been called.

type UploadRequest

type UploadRequest struct {
	// Application is the application ID.
	Application string

	// Name is the resource name.
	Name string

	// Filename is the name of the file as it exists on disk.
	Filename string

	// Size is the size of the uploaded data, in bytes.
	Size int64

	// Fingerprint is the fingerprint of the uploaded data.
	Fingerprint charmresource.Fingerprint

	// PendingID is the pending ID to associate with this upload, if any.
	PendingID string

	// Content is the content to upload.
	Content io.ReadSeeker
}

UploadRequest defines a single upload request.

func NewUploadRequest

func NewUploadRequest(application, name, filename string, r io.ReadSeeker) (UploadRequest, error)

NewUploadRequest generates a new upload request for the given resource.

func (UploadRequest) HTTPRequest

func (ur UploadRequest) HTTPRequest() (*http.Request, error)

HTTPRequest generates a new HTTP request.

Jump to

Keyboard shortcuts

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