server

package
v0.0.0-...-4bd6544 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version is the version number of the current Facade.
	Version = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CharmStore

type CharmStore interface {
	// ListResources composes, for each of the identified charms, the
	// list of details for each of the charm's resources. Those details
	// are those associated with the specific charm revision. They
	// include the resource's metadata and revision.
	ListResources([]charmstore.CharmID) ([][]charmresource.Resource, error)

	// ResourceInfo returns the metadata for the given resource.
	ResourceInfo(charmstore.ResourceRequest) (charmresource.Resource, error)
}

CharmStore exposes the functionality of the charm store as needed here.

type DataStore

type DataStore interface {
	UploadDataStore
	// contains filtered or unexported methods
}

DataStore is the functionality of Juju's state needed for the resources API.

type Facade

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

Facade is the public API facade for resources.

func NewFacade

func NewFacade(store DataStore, newClient func() (CharmStore, error)) (*Facade, error)

NewFacade returns a new resoures facade for the given Juju state.

func (Facade) AddPendingResources

func (f Facade) AddPendingResources(args api.AddPendingResourcesArgs) (api.AddPendingResourcesResult, error)

AddPendingResources adds the provided resources (info) to the Juju model in a pending state, meaning they are not available until resolved.

func (Facade) ListResources

func (f Facade) ListResources(args api.ListResourcesArgs) (api.ResourcesResults, error)

ListResources returns the list of resources for the given application.

type LegacyHTTPHandler

type LegacyHTTPHandler struct {
	// Connect opens a connection to state resources.
	Connect func(*http.Request) (DataStore, names.Tag, error)

	// HandleUpload provides the upload functionality.
	HandleUpload func(username string, st DataStore, req *http.Request) (*api.UploadResult, error)
}

LegacyHTTPHandler is the HTTP handler for the resources endpoint. We use it rather having a separate handler for each HTTP method since registered API handlers must handle *all* HTTP methods currently.

func NewLegacyHTTPHandler

func NewLegacyHTTPHandler(connect func(*http.Request) (DataStore, names.Tag, error)) *LegacyHTTPHandler

NewLegacyHTTPHandler creates a new http.Handler for the resources endpoint.

func (*LegacyHTTPHandler) ServeHTTP

func (h *LegacyHTTPHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type UploadDataStore

type UploadDataStore interface {
	// GetResource returns the identified resource.
	GetResource(applicationID, name string) (resource.Resource, error)

	// GetPendingResource returns the identified resource.
	GetPendingResource(applicationID, name, pendingID string) (resource.Resource, error)

	// SetResource adds the resource to blob storage and updates the metadata.
	SetResource(applicationID, userID string, res charmresource.Resource, r io.Reader) (resource.Resource, error)

	// UpdatePendingResource adds the resource to blob storage and updates the metadata.
	UpdatePendingResource(applicationID, pendingID, userID string, res charmresource.Resource, r io.Reader) (resource.Resource, error)
}

UploadDataStore describes the the portion of Juju's "state" needed for handling upload requests.

type UploadHandler

type UploadHandler struct {
	// Username is the ID of the user making the upload request.
	Username string

	// Store is the data store into which the resource will be stored.
	Store UploadDataStore
}

UploadHandler provides the functionality to handle upload requests.

func (UploadHandler) HandleRequest

func (uh UploadHandler) HandleRequest(req *http.Request) (*api.UploadResult, error)

HandleRequest handles a resource upload request.

func (UploadHandler) ReadResource

func (uh UploadHandler) ReadResource(req *http.Request) (*UploadedResource, error)

ReadResource extracts the relevant info from the request.

type UploadedResource

type UploadedResource struct {
	// Service is the name of the application associated with the resource.
	Service string

	// PendingID is the resource-specific sub-ID for a pending resource.
	PendingID string

	// Resource is the information about the resource.
	Resource charmresource.Resource

	// Data holds the resource blob.
	Data io.ReadCloser
}

UploadedResource holds both the information about an uploaded resource and the reader containing its data.

Jump to

Keyboard shortcuts

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