Documentation ¶
Index ¶
- type APIError
- type APIErrorCode
- type APIErrorExtra
- type APIErrors
- type Base
- type Category
- type Channel
- type Charm
- type ContextMetrics
- type Download
- type Entity
- type FindChannelMap
- type FindResponse
- type FindResponses
- type FindRevision
- type InfoChannelMap
- type InfoResponse
- type InfoRevision
- type RefreshEntity
- type RefreshRequest
- type RefreshRequestAction
- type RefreshRequestContext
- type RefreshResourceRevision
- type RefreshResponse
- type RefreshResponses
- type Release
- type RequestMetrics
- type ResourceRevision
- type ResourcesResponse
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Code APIErrorCode `json:"code"` Message string `json:"message"` Extra APIErrorExtra `json:"extra"` }
APIError represents the error from the CharmHub API.
type APIErrorCode ¶
type APIErrorCode string
APIErrorCode classifies the error code we get back from the API. This isn't tautological list of codes.
const ( ErrorCodeAccessByDownstreamStoreNotAllowed APIErrorCode = "access-by-downstream-store-not-allowed" ErrorCodeAccessByRevisionNotAllowed APIErrorCode = "access-by-revision-not-allowed" ErrorCodeAPIError APIErrorCode = "api-error" ErrorCodeBadArgument APIErrorCode = "bad-argument" ErrorCodeCharmResourceNotFound APIErrorCode = "charm-resource-not-found" ErrorCodeChannelNotFound APIErrorCode = "channel-not-found" ErrorCodeDeviceAuthorizationNeedsRefresh APIErrorCode = "device-authorization-needs-refresh" ErrorCodeDeviceServiceDisallowed APIErrorCode = "device-service-disallowed" ErrorCodeDuplicatedKey APIErrorCode = "duplicated-key" ErrorCodeDuplicateFetchAssertionsKey APIErrorCode = "duplicate-fetch-assertions-key" ErrorCodeEndpointDisabled APIErrorCode = "endpoint-disabled" ErrorCodeIDNotFound APIErrorCode = "id-not-found" ErrorCodeInconsistentData APIErrorCode = "inconsistent-data" ErrorCodeInstanceKeyNotUnique APIErrorCode = "instance-key-not-unique" ErrorCodeInvalidChannel APIErrorCode = "invalid-channel" ErrorCodeInvalidCharmBase APIErrorCode = "invalid-charm-base" ErrorCodeInvalidCharmResource APIErrorCode = "invalid-charm-resource" ErrorCodeInvalidCohortKey APIErrorCode = "invalid-cohort-key" ErrorCodeInvalidGrade APIErrorCode = "invalid-grade" ErrorCodeInvalidMetric APIErrorCode = "invalid-metric" ErrorCodeInvalidUnboundEmptySearch APIErrorCode = "invalid-unbound-empty-search" ErrorCodeMacaroonPermissionRequired APIErrorCode = "macaroon-permission-required" ErrorCodeMissingCharmBase APIErrorCode = "missing-charm-base" ErrorCodeMissingContext APIErrorCode = "missing-context" ErrorCodeMissingFetchAssertionsKey APIErrorCode = "missing-fetch-assertions-key" ErrorCodeMissingHeader APIErrorCode = "missing-header" ErrorCodeMissingInstanceKey APIErrorCode = "missing-instance-key" ErrorCodeMissingKey APIErrorCode = "missing-key" ErrorCodeNameNotFound APIErrorCode = "name-not-found" ErrorCodeNotFound APIErrorCode = "not-found" ErrorCodePaymentRequired APIErrorCode = "payment-required" ErrorCodeRateLimitExceeded APIErrorCode = "rate-limit-exceeded" ErrorCodeRefreshBundleNotSupported APIErrorCode = "refresh-bundle-not-supported" ErrorCodeResourceNotFound APIErrorCode = "resource-not-found" ErrorCodeRevisionConflict APIErrorCode = "revision-conflict" ErrorCodeRevisionNotFound APIErrorCode = "revision-not-found" ErrorCodeServiceMisconfigured APIErrorCode = "service-misconfigured" ErrorCodeStoreAuthorizationNeedsRefresh APIErrorCode = "store-authorization-needs-refresh" ErrorCodeStoreDisallowed APIErrorCode = "store-disallowed" ErrorCodeUnexpectedData APIErrorCode = "unexpected-data" ErrorCodeUnknownGrade APIErrorCode = "unknown-grade" ErrorCodeUserAuthenticationError APIErrorCode = "user-authentication-error" ErrorCodeUserAuthorizationNeedsRefresh APIErrorCode = "user-authorization-needs-refresh" // TODO 2021-04-08 hml // Remove once Charmhub API returns ErrorCodeInvalidCharmBase ErrorCodeInvalidCharmPlatform APIErrorCode = "invalid-charm-platform" ErrorCodeMissingCharmPlatform APIErrorCode = "missing-charm-platform" )
type APIErrorExtra ¶
type APIErrorExtra struct { Releases []Release `json:"releases"` DefaultBases []Base `json:"default-bases"` }
APIErrorExtra defines additional extra payloads from a given error. Think of this object as a series of suggestions to perform against the errorred API request, in the chance of the new request being successful.
type Base ¶
type Base struct { Architecture string `json:"architecture"` Name string `json:"name"` Channel string `json:"channel"` }
Base is a typed tuple for identifying charms or bundles with a matching architecture, os and channel.
type Channel ¶
type Channel struct { Name string `json:"name"` Base Base `json:"base"` ReleasedAt string `json:"released-at"` Risk string `json:"risk"` Track string `json:"track"` }
Channel defines a unique permutation that corresponds to the track, risk and base. There can be multiple channels of the same track and risk, but with different bases.
type Charm ¶
type Charm struct { Name string `json:"name"` PackageID string `json:"package-id"` StoreURL string `json:"store-url"` }
Charm is used to identify charms within a bundle.
type ContextMetrics ¶
ContextMetrics are a map of key value pairs of metrics for the specific charm/application in the context.
type Download ¶
type Download struct { HashSHA256 string `json:"hash-sha-256"` HashSHA384 string `json:"hash-sha-384"` Size int `json:"size"` URL string `json:"url"` }
Download represents the download structure from CharmHub. Elements not used by juju but not used are: "hash-sha3-384" and "hash-sha-512"
type Entity ¶
type Entity struct { Categories []Category `json:"categories"` Charms []Charm `json:"contains-charms"` Description string `json:"description"` License string `json:"license"` Publisher map[string]string `json:"publisher"` Summary string `json:"summary"` UsedBy []string `json:"used-by"` StoreURL string `json:"store-url"` }
Entity holds the information about the charm or bundle, either contains the information about the charm or bundle or whom owns it.
type FindChannelMap ¶
type FindChannelMap struct { Channel Channel `json:"channel,omitempty"` Revision FindRevision `json:"revision,omitempty"` }
type FindResponse ¶
type FindResponse struct { Type Type `json:"type"` ID string `json:"id"` Name string `json:"name"` Entity Entity `json:"result,omitempty"` DefaultRelease FindChannelMap `json:"default-release,omitempty"` }
type FindResponses ¶
type FindResponses struct { Results []FindResponse `json:"results,omitempty"` ErrorList APIErrors `json:"error-list,omitempty"` }
type FindRevision ¶
type FindRevision struct { CreatedAt string `json:"created-at"` Download Download `json:"download"` Bases []Base `json:"bases"` Revision int `json:"revision"` Version string `json:"version"` }
FindRevision is different from InfoRevision. It is missing ConfigYAML and MetadataYAML
type InfoChannelMap ¶
type InfoChannelMap struct { Channel Channel `json:"channel,omitempty"` Revision InfoRevision `json:"revision,omitempty"` }
InfoChannelMap returns the information channel map. This defines a unique revision for a given channel from an info response.
type InfoResponse ¶
type InfoResponse struct { Type Type `json:"type"` ID string `json:"id"` Name string `json:"name"` Entity Entity `json:"result"` ChannelMap []InfoChannelMap `json:"channel-map"` DefaultRelease InfoChannelMap `json:"default-release,omitempty"` ErrorList APIErrors `json:"error-list,omitempty"` }
InfoResponse is the result from an information query.
type InfoRevision ¶
type InfoRevision struct { ConfigYAML string `json:"config-yaml"` CreatedAt string `json:"created-at"` // Via filters, only Download.Size will be available. Download Download `json:"download"` MetadataYAML string `json:"metadata-yaml"` BundleYAML string `json:"bundle-yaml"` Bases []Base `json:"bases"` Revision int `json:"revision"` Version string `json:"version"` }
InfoRevision is different from FindRevision. It has additional fields of ConfigYAML and MetadataYAML. NOTE: InfoRevision will be filled in with the CharmHub api response differently within the InfoResponse.ChannelMap and the InfoResponse.DefaultRelease. The DefaultRelease InfoRevision will include ConfigYAML, MetadataYAML and BundleYAML NOTE 2: actions-yaml is a possible response for the DefaultRelease InfoRevision, but not implemented.
type RefreshEntity ¶
type RefreshEntity struct { Type Type `json:"type"` Download Download `json:"download"` ID string `json:"id"` License string `json:"license"` Name string `json:"name"` Publisher map[string]string `json:"publisher,omitempty"` Resources []ResourceRevision `json:"resources"` Bases []Base `json:"bases,omitempty"` Revision int `json:"revision"` Summary string `json:"summary"` Version string `json:"version"` CreatedAt time.Time `json:"created-at"` }
RefreshEntity is a typed refresh entity. This can either be a charm or a bundle, the type of the refresh entity doesn't actually matter in this circumstance.
type RefreshRequest ¶
type RefreshRequest struct { // Context can be empty (for install and download for example), but has to // be always present and hence the no omitempty. Context []RefreshRequestContext `json:"context"` Actions []RefreshRequestAction `json:"actions"` Fields []string `json:"fields,omitempty"` Metrics RequestMetrics `json:"metrics,omitempty"` }
RefreshRequest defines a typed request for making refresh queries, containing both a series of context and actions, this powerful setup should allow for making batch queries where possible.
type RefreshRequestAction ¶
type RefreshRequestAction struct { // Action can be install, download or refresh. Action string `json:"action"` // InstanceKey should be unique for every action, as results may not be // ordered in the same way, so it is expected to use this to ensure // completeness and ordering. InstanceKey string `json:"instance-key"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Channel *string `json:"channel,omitempty"` Revision *int `json:"revision,omitempty"` Base *Base `json:"base"` ResourceRevisions []RefreshResourceRevision `json:"resource-revisions,omitempty"` }
RefreshRequestAction defines a action to perform against the Refresh API.
type RefreshRequestContext ¶
type RefreshRequestContext struct { InstanceKey string `json:"instance-key"` ID string `json:"id"` Revision int `json:"revision"` Base Base `json:"base,omitempty"` TrackingChannel string `json:"tracking-channel,omitempty"` RefreshedDate *time.Time `json:"refresh-date,omitempty"` Metrics ContextMetrics `json:"metrics,omitempty"` }
RefreshRequestContext can request a given context for making multiple requests to one given entity.
type RefreshResourceRevision ¶
RefreshResourceRevision represents a resource name revision pair for install by revision.
type RefreshResponse ¶
type RefreshResponse struct { Entity RefreshEntity `json:"charm"` // TODO: Pick up new naming of this. EffectiveChannel string `json:"effective-channel"` Error *APIError `json:"error,omitempty"` ID string `json:"id"` InstanceKey string `json:"instance-key"` Name string `json:"name"` Result string `json:"result"` // Officially the released-at is ISO8601, but go's version of time.Time is // both RFC3339 and ISO8601 (the latter makes the T optional). ReleasedAt time.Time `json:"released-at"` }
RefreshResponse defines a typed response for the refresh query.
type RefreshResponses ¶
type RefreshResponses struct { Results []RefreshResponse `json:"results,omitempty"` ErrorList APIErrors `json:"error-list,omitempty"` }
RefreshResponses holds a series of typed RefreshResponse or a series of errors if the query performed failed for some reason.
type Release ¶
Release defines a set of suggested releases that might also work for the given request.
type RequestMetrics ¶
RequestMetrics are a map of key value pairs of metrics for the controller and the model in the request.
type ResourceRevision ¶
type ResourceRevision struct { Download Download `json:"download"` Description string `json:"description"` Name string `json:"name"` Filename string `json:"filename"` Revision int `json:"revision"` Type string `json:"type"` }
ResourceRevision defines a typed response for the list resource revisions query.
type ResourcesResponse ¶
type ResourcesResponse struct {
Revisions []ResourceRevision `json:"revisions"`
}
ResourcesResponse defines a series of typed responses for the list resource revisions query.