params

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: LGPL-3.0 Imports: 10 Imported by: 12

Documentation

Overview

The params package holds types that are a part of the charm store's external contract - they will be marshalled (or unmarshalled) as JSON and delivered through the HTTP API.

Index

Constants

View Source
const (
	// ContentHashHeader specifies the header attribute
	// that will hold the content hash for archive GET responses.
	ContentHashHeader = "Content-Sha384"

	// EntityIdHeader specifies the header attribute that will hold the
	// id of the entity for archive GET responses.
	EntityIdHeader = "Entity-Id"
)
View Source
const (
	Everyone = "everyone"
	Admin    = "admin"
)

Special user/group names.

View Source
const (
	// BzrDigestKey is the extra-info key used to store the Bazaar digest
	BzrDigestKey = "bzr-digest"

	// LegacyDownloadStats is the extra-info key used to store the legacy
	// download counts, and to retrieve them when
	// charmstore.LegacyDownloadCountsEnabled is set to true.
	// TODO (frankban): remove this constant when removing the legacy counts
	// logic.
	LegacyDownloadStats = "legacy-download-stats"
)
View Source
const (
	IngestionType        LogType = "ingestion"
	LegacyStatisticsType LogType = "legacyStatistics"

	IngestionStart    = "ingestion started"
	IngestionComplete = "ingestion completed"

	LegacyStatisticsImportStart    = "legacy statistics import started"
	LegacyStatisticsImportComplete = "legacy statistics import completed"
)
View Source
const (
	StatsArchiveDownload            = "archive-download"
	StatsArchiveDownloadPromulgated = "archive-download-promulgated"
	StatsArchiveDelete              = "archive-delete"
	StatsArchiveFailedUpload        = "archive-failed-upload"
	StatsArchiveUpload              = "archive-upload"
	// The following kinds are in use in the legacy API.
	StatsCharmInfo    = "charm-info"
	StatsCharmMissing = "charm-missing"
	StatsCharmEvent   = "charm-event"
)

Define the kinds to be included in stats keys.

Variables

OrderedChannels holds the list of valid channels in order of publishing status, most stable first.

View Source
var ValidChannels = func() map[Channel]bool {
	channels := make(map[Channel]bool, len(OrderedChannels))
	for _, ch := range OrderedChannels {
		channels[ch] = true
	}
	return channels
}()

ValidChannels holds the set of all allowed channels for an entity.

Functions

func API2Resource

func API2Resource(apiInfo Resource) (resource.Resource, error)

API2Resource converts an API Resource struct into a charm resource.

func MaybeTermsAgreementError

func MaybeTermsAgreementError(err error) error

MaybeTermsAgreementError returns err as a *TermAgreementRequiredError if it has a "terms agreement required" error code, otherwise it returns err unchanged.

func NewError

func NewError(code ErrorCode, f string, a ...interface{}) error

NewError returns a new *Error with the given error code and message.

Types

type AllPermsResponse

type AllPermsResponse struct {
	Perms map[Channel]PermResponse
}

AllPermsResponse holds the resource of an id/allperms GET request.

type ArchiveSizeResponse

type ArchiveSizeResponse struct {
	Size int64
}

ArchiveSizeResponse holds the result of an id/meta/archive-size GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaarchive-size

type ArchiveUploadResponse

type ArchiveUploadResponse struct {
	Id            *charm.URL
	PromulgatedId *charm.URL `json:",omitempty"`
}

ArchiveUploadResponse holds the result of a post or a put to /id/archive. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#post-idarchive

type ArchiveUploadTimeResponse

type ArchiveUploadTimeResponse struct {
	UploadTime time.Time
}

ArchiveUploadTimeResponse holds the result of an id/meta/archive-upload-time GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaarchive-upload-time

type BundleCount

type BundleCount struct {
	Count int
}

BundleCount holds the result of an id/meta/bundle-unit-count or bundle-machine-count GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetabundle-unit-count and https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetabundle-machine-count

type CanIngestResponse

type CanIngestResponse struct {
	CanIngest bool
}

CanIngestResponse holds the result of an id/meta/can-ingest GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetacan-ingest

type CanWriteResponse

type CanWriteResponse struct {
	CanWrite bool
}

CanWriteResponse holds the result of an id/meta/can-write GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetacan-write

type Channel

type Channel string

Channel is the name of a channel in which an entity may be published.

const (
	// EdgeChannel is the channel used for charms or bundles under development.
	EdgeChannel Channel = "edge"

	// BetaChannel is the channel used for beta charms or bundles.
	BetaChannel Channel = "beta"

	// CandidateChannel is the channel used for charms or bundles release
	// candidates.
	CandidateChannel Channel = "candidate"

	// StableChannel is the channel used for stable charms or bundles.
	StableChannel Channel = "stable"

	// UnpublishedChannel is the default channel to which charms are uploaded.
	UnpublishedChannel Channel = "unpublished"

	// NoChannel represents where no channel has been specifically requested.
	NoChannel Channel = ""

	// DevelopmentChannel is only defined for backward compatibility.
	DevelopmentChannel Channel = "development"
)

type CharmRevision

type CharmRevision struct {
	Revision int
	Sha256   string
	Err      error
}

CharmRevision holds the revision number of a charm and any error encountered in retrieving it.

type DebugStatus

type DebugStatus debugstatus.CheckResult

DebugStatus holds the result of the status checks. This is defined for backward compatibility: new clients should use debugstatus.CheckResult directly.

type DockerInfoResponse

type DockerInfoResponse struct {
	// ImageName holds the image name (including host) of the resource in the docker registry.
	ImageName string

	// Username holds the username to use in the docker auth information.
	// (see https://docs.docker.com/registry/spec/auth/token/#requesting-a-token).
	Username string

	// Password holds the password to use in the docker auth information.
	Password string
}

DockerInfoResponse holds the result of a get of /:id/resources/:name/docker-info

type DockerResourceUploadRequest

type DockerResourceUploadRequest struct {
	// ImageName holds the image name when it's an external image not
	// contained within the charm store's registry. If this is empty, the
	// image should have been uploaded to the charm store's registry.
	ImageName string
	// Digest holds the digest of the image, in the form "sha256:hexbytes".
	Digest string
}

DockerResourceUploadRequest holds the body of a POST to /:id/resources/:name when the resource is a docker image.

type EntityResult

type EntityResult struct {
	Id *charm.URL
	// Meta holds at most one entry for each meta value
	// specified in the include flags, holding the
	// data that would be returned by reading /meta/meta?id=id.
	// Metadata not relevant to a particular result will not
	// be included.
	Meta map[string]interface{} `json:",omitempty"`
}

EntityResult holds a the resolved entity ID along with any requested metadata.

type Error

type Error struct {
	Message string
	Code    ErrorCode
	Info    map[string]*Error `json:",omitempty"`
}

Error represents an error - it is returned for any response that fails. See https://github.com/juju/charmstore/blob/v4/docs/API.md#errors

func (*Error) Cause

func (e *Error) Cause() error

Cause implements errgo.Causer.Cause.

func (*Error) Error

func (e *Error) Error() string

Error implements error.Error.

func (*Error) ErrorCode

func (e *Error) ErrorCode() string

ErrorCode holds the class of the error in machine readable format.

func (*Error) ErrorInfo

func (e *Error) ErrorInfo() map[string]*Error

ErrorInfo returns additional info on the error. TODO(rog) rename this so that it more accurately reflects its role.

type ErrorCode

type ErrorCode string

ErrorCode holds the class of an error in machine-readable format. It is also an error in its own right.

const (
	// ErrOther is used as an error code when the
	// charmstore returns an empty error code.
	ErrOther            ErrorCode = "other charmstore error"
	ErrNotFound         ErrorCode = "not found"
	ErrMetadataNotFound ErrorCode = "metadata not found"
	ErrForbidden        ErrorCode = "forbidden"
	ErrBadRequest       ErrorCode = "bad request"
	// TODO change to ErrAlreadyExists
	ErrDuplicateUpload    ErrorCode = "duplicate upload"
	ErrMultipleErrors     ErrorCode = "multiple errors"
	ErrUnauthorized       ErrorCode = "unauthorized"
	ErrMethodNotAllowed   ErrorCode = "method not allowed"
	ErrServiceUnavailable ErrorCode = "service unavailable"
	ErrEntityIdNotAllowed ErrorCode = "charm or bundle id not allowed"
	ErrInvalidEntity      ErrorCode = "invalid charm or bundle"
	ErrReadOnly           ErrorCode = "charmstore is in read-only mode"
)

func (ErrorCode) Error

func (code ErrorCode) Error() string

func (ErrorCode) ErrorCode

func (code ErrorCode) ErrorCode() ErrorCode

type ExpandedId

type ExpandedId struct {
	Id string
}

ExpandedId holds a charm or bundle fully qualified id. A slice of ExpandedId is used as response for id/expand-id GET requests.

type FinishUploadResponse

type FinishUploadResponse struct {
	// Hash holds the SHA384 hash of the complete blob. (hex-encoded)
	Hash string
}

FinishUploadResponse holds the response to a put /upload/upload-id/part-number request.

type HashResponse

type HashResponse struct {
	Sum string
}

HashResponse holds the result of id/meta/hash and id/meta/hash256 GET requests. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetahash and https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetahash256

type IdNameResponse

type IdNameResponse struct {
	Name string
}

IdNameResponse holds the result of an id/meta/id-name GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaid-name

type IdResponse

type IdResponse struct {
	Id       *charm.URL
	User     string `json:",omitempty"`
	Series   string `json:",omitempty"`
	Name     string
	Revision int
}

IdResponse holds the result of an id/meta/id GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaid

type IdRevisionResponse

type IdRevisionResponse struct {
	Revision int
}

IdRevisionResponse holds the result of an id/meta/id-revision GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaid-revision

type IdSeriesResponse

type IdSeriesResponse struct {
	Series string
}

IdSeriesResponse holds the result of an id/meta/id-series GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaid-series

type IdUserResponse

type IdUserResponse struct {
	User string
}

IdUserResponse holds the result of an id/meta/id-user GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaid-user

type ListResponse

type ListResponse struct {
	Results []EntityResult
}

ListResponse holds the response from a list operation.

type Log

type Log struct {
	// Data holds the log message as a JSON-encoded value.
	Data *json.RawMessage

	// Level holds the log level as a string.
	Level LogLevel

	// Type holds the log type as a string.
	Type LogType

	// URLs holds a slice of entity URLs associated with the log message.
	URLs []*charm.URL `json:",omitempty"`
}

Log holds the representation of a log message. This is used by clients to store log events in the charm store.

type LogLevel

type LogLevel string

LogLevel defines log levels (e.g. "info" or "error") to be used in log requests and responses.

const (
	InfoLevel    LogLevel = "info"
	WarningLevel LogLevel = "warning"
	ErrorLevel   LogLevel = "error"
)

type LogResponse

type LogResponse struct {
	// Data holds the log message as a JSON-encoded value.
	Data json.RawMessage

	// Level holds the log level as a string.
	Level LogLevel

	// Type holds the log type as a string.
	Type LogType

	// URLs holds a slice of entity URLs associated with the log message.
	URLs []*charm.URL `json:",omitempty"`

	// Time holds the time of the log.
	Time time.Time
}

LogResponse represents a single log message and is used in the responses to /log GET requests. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-log

type LogType

type LogType string

LogType defines log types (e.g. "ingestion") to be used in log requests and responses.

type ManifestFile

type ManifestFile struct {
	Name string
	Size int64
}

ManifestFile holds information about a charm or bundle file. A slice of ManifestFile is used as response for id/meta/manifest GET requests. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetamanifest

type MetaAnyResponse

type MetaAnyResponse EntityResult

MetaAnyResponse holds the result of a meta/any request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaany

type NewUploadResponse

type NewUploadResponse UploadInfoResponse

NewUploadResponse holds the response from a POST request to /upload. TODO remove this when the charmstore code no longer requires it.

type Part

type Part struct {
	// Hash holds the SHA384 hash of the part.
	Hash string
	// Size holds the size of the part.
	Size int64
	// Offset holds the offset of the part from the start
	// of the file.
	Offset int64
	// Complete holds whether the part has been
	// successfully uploaded.
	Complete bool
}

Part represents one part of a multipart blob.

type Parts

type Parts struct {
	Parts []Part
}

Parts holds a list of all the parts that are required by a multipart upload, as required by a PUT request to /upload/$upload-id.

type PermRequest

type PermRequest struct {
	Read  []string
	Write []string
}

PermRequest holds the request of an id/meta/perm PUT request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#put-idmetaperm

type PermResponse

type PermResponse struct {
	Read  []string
	Write []string
}

PermResponse holds the result of an id/meta/perm GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetaperm

type PromulgateRequest

type PromulgateRequest struct {
	Promulgated bool
}

PromulgateRequest holds the request of an id/promulgate PUT request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#put-idpromulgate

type PromulgatedResponse

type PromulgatedResponse struct {
	Promulgated bool
}

PromulgatedResponse holds the result of an id/meta/promulgated GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetapromulgated

type PublishRequest

type PublishRequest struct {
	Channels []Channel
	// Resources defines the resource revisions to use for the charm.
	// Each resource in the charm's metadata.yaml (if any) must have its
	// name mapped to a revision. That revision must be one of the
	// existing revisions for that resource.
	Resources map[string]int `json:",omitempty"`
}

PublishRequest holds the request of an id/publish PUT request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#put-idpublish

type PublishResponse

type PublishResponse struct {
	Id            *charm.URL
	PromulgatedId *charm.URL `json:",omitempty"`
}

PublishResponse holds the result of an id/publish PUT request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#put-idpublish

type Published

type Published struct {
	Id          *charm.URL
	PublishTime time.Time
}

Published holds the result of a changes/published GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-changespublished

type PublishedInfo

type PublishedInfo struct {
	// Channel holds the value of the channel that
	// the entity has been published to.
	// This will never be "unpublished" as entities
	// cannot be published to that channel.
	Channel Channel

	// Current holds whether the entity is the most
	// recently published member of the channel.
	Current bool
}

PublishedInfo holds information on a channel that an entity has been published to.

type PublishedResponse

type PublishedResponse struct {
	// Channels holds an entry for each channel that the
	// entity has been published to.
	Info []PublishedInfo
}

PublishedResponse holds the result of an id/meta/published GET request.

type RelatedResponse

type RelatedResponse struct {
	// Requires holds an entry for each interface provided by
	// the charm, containing all charms that require that interface.
	Requires map[string][]EntityResult `json:",omitempty"`

	// Provides holds an entry for each interface required by the
	// the charm, containing all charms that provide that interface.
	Provides map[string][]EntityResult `json:",omitempty"`
}

RelatedResponse holds the result of an id/meta/charm-related GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetacharm-related

type Resource

type Resource struct {
	// Name identifies the resource.
	Name string

	// Type is the name of the resource type.
	Type string

	// Path is where the resource will be stored.
	Path string

	// Description contains user-facing info about the resource.
	Description string `json:",omitempty"`

	// Revision is the revision, if applicable.
	Revision int

	// Fingerprint is the SHA-384 checksum for the resource blob.
	Fingerprint []byte

	// Size is the size of the resource, in bytes.
	Size int64
}

Resource describes a resource in the charm store.

func Resource2API

func Resource2API(res resource.Resource) Resource

Resource2API converts a charm resource into an API Resource struct.

type ResourceUploadResponse

type ResourceUploadResponse struct {
	Revision int
}

ResourceUploadResponse holds the result of a post or a put to /id/resources/name.

type RevisionInfoResponse

type RevisionInfoResponse struct {
	Revisions []*charm.URL
}

RevisionInfoResponse holds the result of an id/meta/revision-info GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetarevision-info

type SearchResponse

type SearchResponse struct {
	SearchTime time.Duration
	Total      int
	Results    []EntityResult
}

SearchResponse holds the response from a search operation.

type SetAuthCookie

type SetAuthCookie struct {
	// Macaroons holds a slice of macaroons.
	Macaroons macaroon.Slice
}

SetAuthCookie holds the parameters used to make a set-auth-cookie request to the charm store.

type Statistic

type Statistic struct {
	Key   string `json:",omitempty"`
	Date  string `json:",omitempty"`
	Count int64
}

Statistic holds one element of a stats/counter response. See https://github.com/juju/charmstore/blob/v4/docs/API.md#get-statscounter

type StatsCount

type StatsCount struct {
	Total int64 // Total count over all time.
	Day   int64 // Count over the last day.
	Week  int64 // Count over the last week.
	Month int64 // Count over the last month.
}

StatsCount holds stats counts and is used as part of StatsResponse.

type StatsResponse

type StatsResponse struct {
	// ArchiveDownloadCount is superceded by ArchiveDownload but maintained for
	// backward compatibility.
	ArchiveDownloadCount int64
	// ArchiveDownload holds the downloads count for a specific revision of the
	// entity.
	ArchiveDownload StatsCount
	// ArchiveDownloadAllRevisions holds the downloads count for all revisions
	// of the entity.
	ArchiveDownloadAllRevisions StatsCount
}

StatsResponse holds the result of an id/meta/stats GET request. See https://github.com/juju/charmstore/blob/v4/docs/API.md#get-idmetastats

type StatsUpdateEntry

type StatsUpdateEntry struct {
	Timestamp      time.Time       // Time when the update did happen.
	Type           StatsUpdateType // One of the constant Download, Traffic or Deploy.
	CharmReference *charm.URL      // The charm to be updated.
}

StatsUpdateEntry holds an entry of the StatsUpdateRequest for a put to /stats/update. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#stats-update

type StatsUpdateRequest

type StatsUpdateRequest struct {
	Entries []StatsUpdateEntry
}

StatsUpdateRequest holds the parameters for a put to /stats/update. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#stats-update

type StatsUpdateType

type StatsUpdateType string

Constants for the StatsUpdateRequest

const (
	UpdateDownload StatsUpdateType = "download" // Accesses with non listed clients and web browsers.
	UpdateTraffic  StatsUpdateType = "traffic"  // Bots and unknown clients.
	UpdateDeploy   StatsUpdateType = "deploy"   // known clients like juju client.
)

type SupportedSeriesResponse

type SupportedSeriesResponse struct {
	SupportedSeries []string
}

SupportedSeries holds the result of an id/meta/supported-series GET request. See See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetasupported-series

type TagsResponse

type TagsResponse struct {
	Tags []string
}

TagsResponse holds the result of an id/meta/tags GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#get-idmetatags

type TermAgreementRequiredError

type TermAgreementRequiredError struct {
	Terms []string
}

TermAgreementRequiredError signals that the user needs to agree to a set of terms and agreements in order to complete an operation.

func (*TermAgreementRequiredError) Error

Error implements the error interface.

type UploadInfoResponse

type UploadInfoResponse struct {
	// UploadId holds the id of the upload.
	UploadId string

	// Parts holds all the known parts of the upload.
	// Parts that haven't been uploaded yet will have nil
	// elements.
	Parts Parts

	// Expires holds when the upload will expire.
	Expires time.Time

	// MinPartSize holds the minimum size of a part that may
	// be uploaded (not including the last part).
	MinPartSize int64

	// MaxPartSize holds the maximum size of a part that may
	// be uploaded.
	MaxPartSize int64

	// MaxParts holds the maximum number of parts.
	MaxParts int
}

UploadInfoResponse holds the response to a get /upload/upload-id request.

type WhoAmIResponse

type WhoAmIResponse struct {
	User   string
	Groups []string
}

WhoAmIResponse holds the result of a whoami GET request. See https://github.com/juju/charmstore/blob/v5-unstable/docs/API.md#whoami

Jump to

Keyboard shortcuts

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