Documentation
¶
Overview ¶
Package tea is a client for the Transparency Exchange API (TEA) v1.0.0.
import tea "github.com/oolong-project/tea-client-go"
The client is built in two layers. Package teaapi is generated from the pinned OpenAPI document (spec/openapi.yaml) and holds every spec type and a low-level client. This package is the API people use: it returns teaapi types and owns what the specification leaves to the client.
- URL policy: every URL is https, or http under a base the caller configured with WithInsecureHTTPBase. Userinfo and dot segments are refused. Nothing a server sends widens the policy.
- Credentials are bound to one API root (WithBearerToken, WithAPIKey) and decided by the client's transport on every hop, redirects included; they never leave their root.
- Every response is bounded in bytes and in time (Limits), whatever http.Client the caller passes, and Generated() calls are bounded too.
- Errors are typed (*APIError, *UnexpectedResponseError, *URLPolicyError) and match sentinels with errors.Is. No error carries a credential or a response body beyond a sanitised server message.
- Discovery (Client.Discover) follows the specification, fails over within a bound and never prompts.
- Downloads (API.DownloadArtifact, API.DownloadArtifactToFile) verify the published checksums while streaming and fail closed.
- Client.FullFlow reads a TEI's product release, lifecycle and components, as the ReARM CLI's full_tea_flow does.
Every server is treated as untrusted. Every call that does I/O takes a context.Context, and the library's own time bounds apply inside it.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/google/uuid"
tea "github.com/oolong-project/tea-client-go"
)
func main() {
ctx := context.Background()
c, err := tea.New()
if err != nil {
log.Fatal(err)
}
base, err := tea.ParseAPIBase("https://demo.rearmhq.com/tea", "1.0.0")
if err != nil {
log.Fatal(err)
}
api, err := c.API(base)
if err != nil {
log.Fatal(err)
}
release, err := api.GetProductRelease(ctx, uuid.MustParse("b9f115fb-6688-4a3f-a262-3acc04e1fc9e"))
if err != nil {
log.Fatal(err)
}
fmt.Println(release.Version, release.LatestCollection.Version)
}
Output:
Index ¶
- Variables
- func VerifyChecksums(r io.Reader, sums []teaapi.Checksum, o DownloadOptions) ([]teaapi.ChecksumType, error)
- type API
- func (a *API) AllComponentReleaseCollectionsOf(ctx context.Context, id uuid.UUID, p CollectionPage) iter.Seq2[teaapi.Collection, error]
- func (a *API) AllComponentReleases(ctx context.Context, q ReleaseQuery) iter.Seq2[teaapi.ComponentRelease, error]
- func (a *API) AllComponentReleasesOf(ctx context.Context, id uuid.UUID, p ReleasePage) iter.Seq2[teaapi.ComponentRelease, error]
- func (a *API) AllComponents(ctx context.Context, q ComponentQuery) iter.Seq2[teaapi.Component, error]
- func (a *API) AllProductReleaseCollectionsOf(ctx context.Context, id uuid.UUID, p CollectionPage) iter.Seq2[teaapi.Collection, error]
- func (a *API) AllProductReleases(ctx context.Context, q ReleaseQuery) iter.Seq2[teaapi.ProductRelease, error]
- func (a *API) AllProductReleasesOf(ctx context.Context, id uuid.UUID, p ReleasePage) iter.Seq2[teaapi.ProductRelease, error]
- func (a *API) AllProducts(ctx context.Context, q ProductQuery) iter.Seq2[teaapi.Product, error]
- func (a *API) Base() APIBase
- func (a *API) DownloadArtifact(ctx context.Context, ref ArtifactRef, f teaapi.ArtifactFormat, w io.Writer, ...) (DownloadResult, error)
- func (a *API) DownloadArtifactToFile(ctx context.Context, ref ArtifactRef, f teaapi.ArtifactFormat, path string, ...) (res DownloadResult, err error)
- func (a *API) DownloadLatestArtifact(ctx context.Context, id uuid.UUID, mediaType string, w io.Writer, ...) (DownloadResult, error)
- func (a *API) DownloadSignature(ctx context.Context, ref ArtifactRef, f teaapi.ArtifactFormat, w io.Writer, ...) (int64, error)
- func (a *API) Generated() *teaapi.ClientWithResponses
- func (a *API) GetArtifact(ctx context.Context, id uuid.UUID, version int) (*teaapi.Artifact, error)
- func (a *API) GetComponent(ctx context.Context, id uuid.UUID) (*teaapi.Component, error)
- func (a *API) GetComponentCLE(ctx context.Context, id uuid.UUID) (*teaapi.Cle, error)
- func (a *API) GetComponentRelease(ctx context.Context, id uuid.UUID) (*teaapi.ComponentReleaseWithCollection, error)
- func (a *API) GetComponentReleaseCLE(ctx context.Context, id uuid.UUID) (*teaapi.Cle, error)
- func (a *API) GetComponentReleaseCollection(ctx context.Context, id uuid.UUID, version int) (*teaapi.Collection, error)
- func (a *API) GetLatestArtifact(ctx context.Context, id uuid.UUID) (*teaapi.Artifact, error)
- func (a *API) GetLatestComponentReleaseCollection(ctx context.Context, id uuid.UUID) (*teaapi.Collection, error)
- func (a *API) GetLatestProductReleaseCollection(ctx context.Context, id uuid.UUID) (*teaapi.Collection, error)
- func (a *API) GetProduct(ctx context.Context, id uuid.UUID) (*teaapi.Product, error)
- func (a *API) GetProductCLE(ctx context.Context, id uuid.UUID) (*teaapi.Cle, error)
- func (a *API) GetProductRelease(ctx context.Context, id uuid.UUID) (*teaapi.ProductReleaseWithCollection, error)
- func (a *API) GetProductReleaseCLE(ctx context.Context, id uuid.UUID) (*teaapi.Cle, error)
- func (a *API) GetProductReleaseCollection(ctx context.Context, id uuid.UUID, version int) (*teaapi.Collection, error)
- func (a *API) ListComponentReleaseCollections(ctx context.Context, id uuid.UUID, pg CollectionPage) (*teaapi.PaginatedCollectionResponse, error)
- func (a *API) ListComponentReleases(ctx context.Context, id uuid.UUID, pg ReleasePage) (*teaapi.PaginatedComponentReleaseResponse, error)
- func (a *API) ListProductReleaseCollections(ctx context.Context, id uuid.UUID, pg CollectionPage) (*teaapi.PaginatedCollectionResponse, error)
- func (a *API) ListProductReleases(ctx context.Context, id uuid.UUID, pg ReleasePage) (*teaapi.PaginatedProductReleaseResponse, error)
- func (a *API) QueryComponentReleases(ctx context.Context, q ReleaseQuery) (*teaapi.PaginatedComponentReleaseResponse, error)
- func (a *API) QueryComponents(ctx context.Context, q ComponentQuery) (*teaapi.PaginatedComponentResponse, error)
- func (a *API) QueryProductReleases(ctx context.Context, q ReleaseQuery) (*teaapi.PaginatedProductReleaseResponse, error)
- func (a *API) QueryProducts(ctx context.Context, q ProductQuery) (*teaapi.PaginatedProductResponse, error)
- func (a *API) RequestToken(ctx context.Context, keyID, secret string) (*teaapi.TokenResponse, error)
- type APIBase
- type APIError
- type AmbiguousError
- type ArtifactRef
- type Attempt
- type Candidate
- type Challenge
- type ChecksumError
- type Client
- func (c *Client) API(base APIBase) (*API, error)
- func (c *Client) Candidates(ctx context.Context, results []DiscoveryResult) ([]Candidate, error)
- func (c *Client) Discover(ctx context.Context, t tei.TEI) ([]DiscoveryResult, error)
- func (c *Client) DiscoverPURL(ctx context.Context, base APIBase, purl string) ([]DiscoveryResult, error)
- func (c *Client) FlowFromRelease(ctx context.Context, a *API, release uuid.UUID, o FlowOptions) (*FlowResult, error)
- func (c *Client) FullFlow(ctx context.Context, t tei.TEI, o FlowOptions) (*FlowResult, error)
- func (c *Client) SelectServer(r DiscoveryResult) (APIBase, error)
- type CollectionPage
- type CollectionSortField
- type ComponentQuery
- type ComponentSortField
- type DiscoveryError
- type DiscoveryResult
- type DownloadOptions
- type DownloadResult
- type DownloadSource
- type ErrorCode
- type FlowComponent
- type FlowOptions
- type FlowResult
- type Limits
- type NotResolvedError
- type Option
- func WithAPIKey(rootURL, keyID, secret string) Option
- func WithBearerToken(rootURL, token string) Option
- func WithDiscoveryAttempts(n int, firstBackoff time.Duration) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithInsecureHTTPBase(rawURL string) Option
- func WithLimits(l Limits) Option
- func WithPreemptiveAPIKey(rootURL, keyID, secret string) Option
- func WithTrace(f func(TraceEvent)) Option
- func WithUserAgent(ua string) Option
- func WithWellKnownLocation(domain, location string) Option
- type Page
- type ProductQuery
- type ProductSortField
- type ReleasePage
- type ReleaseQuery
- type ReleaseSortField
- type SortOrder
- type Stage
- type TokenError
- type TraceEvent
- type TraceKind
- type URLPolicyError
- type UnexpectedResponseError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChecksumMismatch: a listed checksum did not match the bytes // (*ChecksumError wraps it). ErrChecksumMismatch = errors.New("tea: checksum mismatch") // ErrNoUsableChecksum: the format lists no checksum this client can // verify with a strong algorithm (SHA-1 only counts with // DownloadOptions.AllowSHA1Only; BLAKE3 and unknown algorithms are not // supported), or no checksum at all. ErrNoUsableChecksum = errors.New("tea: no usable checksum") // ErrUnsupportedContentEncoding: a response kept a Content-Encoding other // than identity, so its bytes are not the bytes the checksums cover. ErrUnsupportedContentEncoding = errors.New("tea: unsupported content encoding") )
Checksum verification errors.
var ( ErrObjectUnknown = errors.New("tea: object unknown") ErrNotImplemented = errors.New("tea: not implemented") ErrSignatureNotFound = errors.New("tea: signature not found") ErrNoAcceptableFormat = errors.New("tea: no acceptable format") ErrInvalidRequest = errors.New("tea: invalid request") ErrInvalidPageToken = errors.New("tea: invalid page token") ErrForbidden = errors.New("tea: forbidden (HTTP 403)") ErrServer = errors.New("tea: server error (HTTP 5xx)") )
Sentinels an *APIError matches with errors.Is.
var ( // ErrResponseTooLarge: a response body was larger than the limit for its // kind of call (Limits), by Content-Length or while reading. ErrResponseTooLarge = errors.New("tea: response body exceeds the limit") // ErrInvalidArgument: a caller-supplied argument was refused before any request. ErrInvalidArgument = errors.New("tea: invalid argument") // ErrInvalidOption: New was given an option value it cannot use. ErrInvalidOption = errors.New("tea: invalid option") // ErrPageLimit: an iterator stopped after Limits.Pages pages. ErrPageLimit = errors.New("tea: page limit reached") // ErrTooManyComponents: a release has more component refs than Limits.FlowComponents. ErrTooManyComponents = errors.New("tea: too many components") // ErrTooManyResults: a discovery answer, or the results given to // Candidates, exceeded Limits.DiscoveryResults. ErrTooManyResults = errors.New("tea: too many discovery results") // ErrTimeout: one of the library's own time bounds (Limits.AttemptTimeout, // CallTimeout or IdleTimeout) fired while the caller's context was live. ErrTimeout = errors.New("tea: time bound exceeded") // ErrInsecureURL: a URL was refused by the URL policy (https only, plus // http under a WithInsecureHTTPBase allowance; no userinfo, no dot segments). ErrInsecureURL = errors.New("tea: URL refused by policy") // ErrRedirectLimit: more redirects than Limits.Redirects. ErrRedirectLimit = errors.New("tea: too many redirects") // ErrNoAccessToken: an API-key credential (WithAPIKey, // WithPreemptiveAPIKey) could not obtain the access token a request // needed. The cause is reachable with errors.As and errors.Is: a // *TokenError, ErrNotImplemented (the server has no /token), an // *UnexpectedResponseError (a redirect from /token, among others), an // *APIError, ErrTimeout, ErrInvalidArgument (an API outside the key's // root) or a context error. ErrNoAccessToken = errors.New("tea: no access token") )
Sentinels for failures the client itself detects.
var SupportedVersions = []string{"1.0.0"}
SupportedVersions are the TEA API versions this client implements.
Functions ¶
func VerifyChecksums ¶
func VerifyChecksums(r io.Reader, sums []teaapi.Checksum, o DownloadOptions) ([]teaapi.ChecksumType, error)
VerifyChecksums reads r to the end and verifies it against sums with the rules of DownloadArtifact: every listed checksum of a supported algorithm must match (*ChecksumError otherwise), at least one of them other than SHA-1 (or SHA-1 with o.AllowSHA1Only), else ErrNoUsableChecksum; an algValue that is not lowercase hex of its algorithm's length is refused (*UnexpectedResponseError). With o.MaxBytes > 0, reading stops with ErrResponseTooLarge past that many bytes. It returns the algorithms verified, in the order first listed.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the typed TEA API at one APIBase. It is safe for concurrent use. Every method returns teaapi types; errors are *APIError (non-2xx), *UnexpectedResponseError (a 2xx the client cannot use), *URLPolicyError, or wrap ErrResponseTooLarge, ErrTimeout, ErrInvalidArgument or the caller's context error.
func (*API) AllComponentReleaseCollectionsOf ¶
func (a *API) AllComponentReleaseCollectionsOf(ctx context.Context, id uuid.UUID, p CollectionPage) iter.Seq2[teaapi.Collection, error]
AllComponentReleaseCollectionsOf iterates over every collection of one component release.
func (*API) AllComponentReleases ¶
func (a *API) AllComponentReleases(ctx context.Context, q ReleaseQuery) iter.Seq2[teaapi.ComponentRelease, error]
AllComponentReleases iterates over every component release the query selects.
func (*API) AllComponentReleasesOf ¶
func (a *API) AllComponentReleasesOf(ctx context.Context, id uuid.UUID, p ReleasePage) iter.Seq2[teaapi.ComponentRelease, error]
AllComponentReleasesOf iterates over every release of one component.
func (*API) AllComponents ¶
func (a *API) AllComponents(ctx context.Context, q ComponentQuery) iter.Seq2[teaapi.Component, error]
AllComponents iterates over every component the query selects.
func (*API) AllProductReleaseCollectionsOf ¶
func (a *API) AllProductReleaseCollectionsOf(ctx context.Context, id uuid.UUID, p CollectionPage) iter.Seq2[teaapi.Collection, error]
AllProductReleaseCollectionsOf iterates over every collection of one product release.
func (*API) AllProductReleases ¶
func (a *API) AllProductReleases(ctx context.Context, q ReleaseQuery) iter.Seq2[teaapi.ProductRelease, error]
AllProductReleases iterates over every product release the query selects.
func (*API) AllProductReleasesOf ¶
func (a *API) AllProductReleasesOf(ctx context.Context, id uuid.UUID, p ReleasePage) iter.Seq2[teaapi.ProductRelease, error]
AllProductReleasesOf iterates over every release of one product.
func (*API) AllProducts ¶
AllProducts iterates over every product the query selects.
Example ¶
package main
import (
"context"
"fmt"
"log"
tea "github.com/oolong-project/tea-client-go"
)
func main() {
ctx := context.Background()
c, err := tea.New()
if err != nil {
log.Fatal(err)
}
base, err := tea.ParseAPIBase("https://demo.rearmhq.com/tea", "1.0.0")
if err != nil {
log.Fatal(err)
}
api, err := c.API(base)
if err != nil {
log.Fatal(err)
}
for p, err := range api.AllProducts(ctx, tea.ProductQuery{Page: tea.Page{PageSize: 50}}) {
if err != nil {
log.Fatal(err)
}
fmt.Println(p.Uuid, p.Name)
}
}
Output:
func (*API) DownloadArtifact ¶
func (a *API) DownloadArtifact(ctx context.Context, ref ArtifactRef, f teaapi.ArtifactFormat, w io.Writer, o DownloadOptions) (DownloadResult, error)
DownloadArtifact streams the content of format f of artifact revision ref to w and verifies it against f's checksums while streaming.
The bytes come from f.Url when it is set (an external location: it must pass the URL policy, and no credential is sent to it on any hop), else from <base>/artifact/<uuid>/<version>/download?mediaType=<f.MediaType>, the versioned endpoint, so the bytes are those of the revision whose checksums f carries. Redirects follow the client's rules; the Authorization header is decided on every hop. Content-Disposition is ignored. Only 200 is accepted: a 406 wraps ErrNoAcceptableFormat, other statuses are *APIError or *UnexpectedResponseError. A Content-Encoding the transport did not remove (it decodes only the gzip it asked for) is ErrUnsupportedContentEncoding.
The checksums are checked before the request: an algValue that is not lowercase hex of its algorithm's length is *UnexpectedResponseError, and without a supported checksum other than SHA-1 (SHA-1 counts only with o.AllowSHA1Only) the call fails with ErrNoUsableChecksum and makes no request; BLAKE3 and unknown algorithms are not supported and are ignored. After the body, every supported checksum listed must match, else *ChecksumError. More than o.MaxBytes (default Limits.DownloadBytes) is ErrResponseTooLarge. No response headers, or no next body byte, for Limits.IdleTimeout fails the call with an error wrapping ErrTimeout; a download that keeps sending is never cut off. There is no other time limit than ctx.
When it returns an error, DownloadArtifact may already have written bytes to w: the caller must discard them. DownloadArtifactToFile does that.
func (*API) DownloadArtifactToFile ¶
func (a *API) DownloadArtifactToFile(ctx context.Context, ref ArtifactRef, f teaapi.ArtifactFormat, path string, o DownloadOptions) (res DownloadResult, err error)
DownloadArtifactToFile downloads like DownloadArtifact into a temporary file (mode 0600) created in path's directory, verifies it, syncs it and renames it over path. On any error the temporary file is removed and path is not touched. The library never derives a file name from the server (Content-Disposition is ignored).
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/google/uuid"
tea "github.com/oolong-project/tea-client-go"
)
func main() {
ctx := context.Background()
c, err := tea.New()
if err != nil {
log.Fatal(err)
}
base, err := tea.ParseAPIBase("https://demo.rearmhq.com/tea", "1.0.0")
if err != nil {
log.Fatal(err)
}
api, err := c.API(base)
if err != nil {
log.Fatal(err)
}
release, err := api.GetProductRelease(ctx, uuid.MustParse("b9f115fb-6688-4a3f-a262-3acc04e1fc9e"))
if err != nil {
log.Fatal(err)
}
for _, art := range release.LatestCollection.Artifacts {
for _, f := range art.Formats {
// Written to a temporary file, verified against the format's
// checksums, then renamed into place; nothing is left on failure.
res, err := api.DownloadArtifactToFile(ctx, tea.ArtifactRef{UUID: art.Uuid, Version: art.Version}, f, "sbom.json", tea.DownloadOptions{})
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Bytes, res.Verified)
return
}
}
}
Output:
func (*API) DownloadLatestArtifact ¶
func (a *API) DownloadLatestArtifact(ctx context.Context, id uuid.UUID, mediaType string, w io.Writer, o DownloadOptions) (DownloadResult, error)
DownloadLatestArtifact reads the latest revision of artifact id (GetLatestArtifact), picks its format whose media type is mediaType (type and subtype compared case-insensitively, parameters exactly; none is an error wrapping ErrNoAcceptableFormat, with no download), and downloads that revision with DownloadArtifact. It does not use the latest download endpoint: the latest revision can change between reading the checksums and fetching the bytes.
func (*API) DownloadSignature ¶
func (a *API) DownloadSignature(ctx context.Context, ref ArtifactRef, f teaapi.ArtifactFormat, w io.Writer, o DownloadOptions) (int64, error)
DownloadSignature streams the detached signature of format f of artifact revision ref to w and returns the number of bytes written. It uses f.SignatureUrl when set (external: no credential on any hop), else <base>/artifact/<uuid>/<version>/signature/download?mediaType=<f.MediaType>. The URL, redirect, status and content-coding rules of DownloadArtifact apply; more than o.MaxBytes (default Limits.SignatureBytes) is ErrResponseTooLarge, and Limits.IdleTimeout applies. A 404 SIGNATURE_NOT_FOUND wraps ErrSignatureNotFound. The bytes are not verified: the specification defines no signature technology. On error, bytes already written to w must be discarded.
func (*API) Generated ¶
func (a *API) Generated() *teaapi.ClientWithResponses
Generated returns the generated client for operations this package does not wrap. It sends through the same bounded, auth-aware doer as the typed methods: the URL policy, the credential rules and the byte and time limits apply. Its requests carry no call kind, so each is classified by its path relative to the API base: /artifact/{uuid}/{latest|version}/download as a download (Limits.DownloadBytes, IdleTimeout), .../signature as a signature (SignatureBytes, IdleTimeout), /discovery as discovery (DiscoveryBytes, AttemptTimeout), and everything else as JSON (JSONBytes, CallTimeout).
The generated download operations read the whole body into memory, so a download through Generated can hold up to Limits.DownloadBytes (512 MiB by default); DownloadArtifact streams and verifies checksums instead.
The auth transport decides every Authorization header, so a header set by a request editor is removed off a credential root and replaced on one. In particular a token request made through Generated cannot carry HTTP Basic credentials; use RequestToken.
func (*API) GetArtifact ¶
GetArtifact reads one revision of an artifact's metadata.
func (*API) GetComponent ¶
GetComponent reads one component.
func (*API) GetComponentCLE ¶
GetComponentCLE reads a component's lifecycle events.
func (*API) GetComponentRelease ¶
func (a *API) GetComponentRelease(ctx context.Context, id uuid.UUID) (*teaapi.ComponentReleaseWithCollection, error)
GetComponentRelease reads one component release with its latest collection.
func (*API) GetComponentReleaseCLE ¶
GetComponentReleaseCLE reads a component release's lifecycle events.
func (*API) GetComponentReleaseCollection ¶
func (a *API) GetComponentReleaseCollection(ctx context.Context, id uuid.UUID, version int) (*teaapi.Collection, error)
GetComponentReleaseCollection reads one version of a component release's collection.
func (*API) GetLatestArtifact ¶
GetLatestArtifact reads the latest revision of an artifact's metadata.
func (*API) GetLatestComponentReleaseCollection ¶
func (a *API) GetLatestComponentReleaseCollection(ctx context.Context, id uuid.UUID) (*teaapi.Collection, error)
GetLatestComponentReleaseCollection reads a component release's latest collection.
func (*API) GetLatestProductReleaseCollection ¶
func (a *API) GetLatestProductReleaseCollection(ctx context.Context, id uuid.UUID) (*teaapi.Collection, error)
GetLatestProductReleaseCollection reads a product release's latest collection.
func (*API) GetProduct ¶
GetProduct reads one product.
func (*API) GetProductCLE ¶
GetProductCLE reads a product's lifecycle events.
func (*API) GetProductRelease ¶
func (a *API) GetProductRelease(ctx context.Context, id uuid.UUID) (*teaapi.ProductReleaseWithCollection, error)
GetProductRelease reads one product release with its latest collection.
func (*API) GetProductReleaseCLE ¶
GetProductReleaseCLE reads a product release's lifecycle events.
func (*API) GetProductReleaseCollection ¶
func (a *API) GetProductReleaseCollection(ctx context.Context, id uuid.UUID, version int) (*teaapi.Collection, error)
GetProductReleaseCollection reads one version of a product release's collection.
func (*API) ListComponentReleaseCollections ¶
func (a *API) ListComponentReleaseCollections(ctx context.Context, id uuid.UUID, pg CollectionPage) (*teaapi.PaginatedCollectionResponse, error)
ListComponentReleaseCollections reads one page of a component release's collections.
func (*API) ListComponentReleases ¶
func (a *API) ListComponentReleases(ctx context.Context, id uuid.UUID, pg ReleasePage) (*teaapi.PaginatedComponentReleaseResponse, error)
ListComponentReleases reads one page of a component's releases.
func (*API) ListProductReleaseCollections ¶
func (a *API) ListProductReleaseCollections(ctx context.Context, id uuid.UUID, pg CollectionPage) (*teaapi.PaginatedCollectionResponse, error)
ListProductReleaseCollections reads one page of a product release's collections.
func (*API) ListProductReleases ¶
func (a *API) ListProductReleases(ctx context.Context, id uuid.UUID, pg ReleasePage) (*teaapi.PaginatedProductReleaseResponse, error)
ListProductReleases reads one page of a product's releases.
func (*API) QueryComponentReleases ¶
func (a *API) QueryComponentReleases(ctx context.Context, q ReleaseQuery) (*teaapi.PaginatedComponentReleaseResponse, error)
QueryComponentReleases reads one page of component releases.
func (*API) QueryComponents ¶
func (a *API) QueryComponents(ctx context.Context, q ComponentQuery) (*teaapi.PaginatedComponentResponse, error)
QueryComponents reads one page of components.
func (*API) QueryProductReleases ¶
func (a *API) QueryProductReleases(ctx context.Context, q ReleaseQuery) (*teaapi.PaginatedProductReleaseResponse, error)
QueryProductReleases reads one page of product releases.
func (*API) QueryProducts ¶
func (a *API) QueryProducts(ctx context.Context, q ProductQuery) (*teaapi.PaginatedProductResponse, error)
QueryProducts reads one page of products.
func (*API) RequestToken ¶
func (a *API) RequestToken(ctx context.Context, keyID, secret string) (*teaapi.TokenResponse, error)
RequestToken exchanges an API key for an access token with the client_credentials grant: one POST to <API base>/token, with the key id and secret each form-urlencoded before joining them for HTTP Basic (RFC 6749 section 2.3.1). The request follows no redirect: a 3xx answer is an *UnexpectedResponseError and no request reaches its Location, so the credentials reach exactly the URL built from this API's base. A configured bearer token is not sent on it. A 404 wraps ErrNotImplemented (the server has no authentication); a token-error-response is a *TokenError. The response is bounded by Limits.ErrorBodyBytes and the call by CallTimeout. Neither the key id nor the secret appears in any error or trace event.
type APIBase ¶
type APIBase struct {
// contains filtered or unexported fields
}
APIBase is one TEA API: a root URL and the version used in paths. Build it with ParseAPIBase (or, in discovery, from a server the client selected).
func ParseAPIBase ¶
ParseAPIBase validates rootURL against the specification's rootUrl pattern (absolute http or https, no userinfo, query, fragment or trailing "/"; a refusal never repeats userinfo, a query or a fragment) and refuses dot segments with a *URLPolicyError; version must be a SemVer 2.0.0 version that is one of SupportedVersions once build metadata is ignored. The version is kept verbatim for paths. Whether an http root may be used is decided by Client.API, against the client's allowances.
type APIError ¶
type APIError struct {
Operation string
Status int
// TEA is true when the body was a TEA error-response: Content-Type
// application/json and a JSON object with a string "error" property.
TEA bool
// Code is the error code when TEA, ErrorCodeUnknown for an unknown code.
Code ErrorCode
// RawCode is the code as received when it is unknown, sanitised and
// truncated to 64 bytes.
RawCode string
// Message is the server's message, control characters removed and
// truncated to 200 bytes. No other part of a body reaches an error.
Message string
// Challenge is the parsed WWW-Authenticate header of a 401, if any.
Challenge *Challenge
}
APIError is a non-2xx answer from a TEA server.
type AmbiguousError ¶
type AmbiguousError struct {
Results []DiscoveryResult
}
AmbiguousError is a discovery with several results and no FlowOptions.Select. Results are in the server's order; Candidates loads them for a choice.
func (*AmbiguousError) Error ¶
func (e *AmbiguousError) Error() string
type ArtifactRef ¶
ArtifactRef names one revision of an artifact: the checksums a download verifies are those of this revision.
type Attempt ¶
type Attempt struct {
Stage Stage // StageWellKnown or StageAPIDiscovery
URL string // scheme, host, port and path: never the query (the TEI or PURL)
Reason string // sanitised, at most 200 bytes; never response-body content
Err error // the cause, e.g. wrapping ErrTimeout, ErrResponseTooLarge, ErrInsecureURL
}
Attempt is one failed discovery attempt.
type Candidate ¶
type Candidate struct {
Result DiscoveryResult
API *API
Release *teaapi.ProductReleaseWithCollection
}
Candidate is one discovery result with the API of its selected server and its product release, as Candidates loads it.
type Challenge ¶
type Challenge struct {
Scheme string // as received, e.g. "Bearer"
Error string // the error parameter, e.g. "invalid_token"; "" when absent
}
Challenge is a parsed WWW-Authenticate challenge of a 401 response.
type ChecksumError ¶
type ChecksumError struct {
Alg teaapi.ChecksumType
Expected string
Actual string
}
ChecksumError is a listed checksum that did not match. Expected and Actual are lowercase hex digests of Alg's length.
func (*ChecksumError) Error ¶
func (e *ChecksumError) Error() string
func (*ChecksumError) Unwrap ¶
func (e *ChecksumError) Unwrap() error
Unwrap returns ErrChecksumMismatch.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a TEA client. It is safe for concurrent use.
func New ¶
New builds a Client. It refuses an option value it cannot parse (ErrInvalidOption), including an http credential root or well-known location that no WithInsecureHTTPBase allowance covers.
func (*Client) API ¶
API returns the typed API bound to base. An http base must be under a WithInsecureHTTPBase allowance (*URLPolicyError otherwise).
func (*Client) Candidates ¶
Candidates loads, for each discovery result, the server SelectServer picks, its API and the product release there: one product-release request per result, in order. More than Limits.DiscoveryResults results (a caller may pass results it did not get from Discover) is ErrTooManyResults before any request. The first failure (a refused server, a failed request) is returned, naming the result's index.
func (*Client) Discover ¶
Discover resolves a TEI as discovery/readme.md defines it: fetch https://<domain>/.well-known/tea (or the WithWellKnownLocation base for the domain), validate it, order its endpoints by the greatest mutually supported version and then priority, and ask each in turn for /v<version>/discovery?tei=<TEI>. It returns the results of the first valid answer, in the server's order; it never prompts.
A TEA 404 ends discovery with *NotResolvedError (no failover); 400, 401 and 403 end it with *APIError. A 401 with a Bearer challenge under a WithAPIKey or WithPreemptiveAPIKey root is first recovered as for an API call (one token request, one retry), and a failure to obtain the token ends discovery with an error matching ErrNoAccessToken. Connection, TLS and DNS failures, an attempt exceeding Limits.AttemptTimeout, 5xx, a non-TEA 404, an invalid or oversized body, or more than Limits.DiscoveryResults results are failed attempts: the client backs off (250 ms doubling, capped at 4 s, by default) and tries the next candidate, cycling through the candidates, until WithDiscoveryAttempts' bound (default 4, counted across both stages, the well-known fetch included) is used up, which gives a *DiscoveryError. The caller's context ending ends Discover with its error. No credential is sent except to a configured credential root.
Example ¶
package main
import (
"context"
"fmt"
"log"
tea "github.com/oolong-project/tea-client-go"
"github.com/oolong-project/tea-client-go/tei"
)
func main() {
ctx := context.Background()
c, err := tea.New()
if err != nil {
log.Fatal(err)
}
t, err := tei.Parse("tei://demo.rearmhq.com/uuid/b9f115fb-6688-4a3f-a262-3acc04e1fc9e")
if err != nil {
log.Fatal(err)
}
results, err := c.Discover(ctx, t) // every result, in the server's order
if err != nil {
log.Fatal(err)
}
base, err := c.SelectServer(results[0]) // a servers[] root, not the /discovery base
if err != nil {
log.Fatal(err)
}
api, err := c.API(base)
if err != nil {
log.Fatal(err)
}
release, err := api.GetProductRelease(ctx, results[0].ProductReleaseUUID)
if err != nil {
log.Fatal(err)
}
fmt.Println(release.Version)
}
Output:
func (*Client) DiscoverPURL ¶
func (c *Client) DiscoverPURL(ctx context.Context, base APIBase, purl string) ([]DiscoveryResult, error)
DiscoverPURL resolves a PURL within the inventory of one known API base: /v<version>/discovery?purl=<PURL> at base. Classification, the attempt bound and backoff are those of Discover, with base as the only candidate. purl must start with "pkg:", be at most 2048 bytes of valid UTF-8 and have no control characters; it is sent as given, query-encoded once.
func (*Client) FlowFromRelease ¶
func (c *Client) FlowFromRelease(ctx context.Context, a *API, release uuid.UUID, o FlowOptions) (*FlowResult, error)
FlowFromRelease reads product release release at a with its lifecycle and components. The release's CLE is nil when the server answers NOT_IMPLEMENTED or OBJECT_UNKNOWN; another CLE error (a failure to obtain an access token, ErrNoAccessToken, included), or any error on the release itself, is returned. More component refs than Limits.FlowComponents is ErrTooManyComponents before any component request (never a silent truncation). For each ref, in order: a pinned ref reads that component release; an unpinned one reads the component and its newest release (ListComponentReleases sorted by createdDate descending, page size 1; a component with no release fails with an error wrapping ErrObjectUnknown), then that release. Then the component release's CLE, as for the product release. A component's failure is recorded in its Err and the walk continues; the caller's context ending ends the walk with ctx.Err().
func (*Client) FullFlow ¶
func (c *Client) FullFlow(ctx context.Context, t tei.TEI, o FlowOptions) (*FlowResult, error)
FullFlow resolves t and reads its product release with its lifecycle and components (the CLI's full_tea_flow): Discover; with one result the server SelectServer picks and FlowFromRelease. With several results and no o.Select it returns *AmbiguousError (and reads no product release); with o.Select it loads Candidates (at most Limits.DiscoveryResults product-release requests), lets Select choose (an index out of range wraps ErrInvalidArgument) and continues with the chosen candidate's API and release. Discovery errors are returned as Discover gives them.
Example ¶
package main
import (
"context"
"fmt"
"log"
tea "github.com/oolong-project/tea-client-go"
"github.com/oolong-project/tea-client-go/tei"
)
func main() {
ctx := context.Background()
c, err := tea.New()
if err != nil {
log.Fatal(err)
}
t, err := tei.Parse("tei://demo.rearmhq.com/uuid/b9f115fb-6688-4a3f-a262-3acc04e1fc9e")
if err != nil {
log.Fatal(err)
}
res, err := c.FullFlow(ctx, t, tea.FlowOptions{})
if err != nil {
log.Fatal(err) // *tea.AmbiguousError when discovery returned several results
}
fmt.Println(*res.Release.ProductName, res.Release.Version)
for _, comp := range res.Components {
if comp.Err != nil {
fmt.Println("component", comp.Ref.Uuid, "failed:", comp.Err)
continue
}
fmt.Println("component release", comp.Release.Uuid, comp.Release.Version)
}
}
Output:
func (*Client) SelectServer ¶
func (c *Client) SelectServer(r DiscoveryResult) (APIBase, error)
SelectServer chooses the API base for a discovery result with the rules of the well-known selection: servers with a version in SupportedVersions (build metadata ignored), ordered by the greatest such version, then priority (absent = 1) descending, then the order received. The chosen rootUrl must pass the URL policy: an http root is usable only under a WithInsecureHTTPBase allowance (*URLPolicyError otherwise). The base that answered /discovery is not used unless it is listed in Servers.
type CollectionPage ¶
type CollectionPage struct {
Page
SortField CollectionSortField
}
CollectionPage pages through one release's collections (listProductReleaseCollections, listComponentReleaseCollections).
type CollectionSortField ¶
type CollectionSortField string
CollectionSortField is the spec's sort-field-collection.
const CollectionSortVersion CollectionSortField = "version"
Collection sort fields.
func (CollectionSortField) Valid ¶
func (f CollectionSortField) Valid() bool
Valid reports whether f is empty or one of the constants.
type ComponentQuery ¶
type ComponentQuery struct {
Page
SortField ComponentSortField
IDType teaapi.IdentifierType
IDValue string
}
ComponentQuery selects components (queryComponents).
type ComponentSortField ¶
type ComponentSortField string
ComponentSortField is the spec's sort-field-component.
const ComponentSortName ComponentSortField = "name"
Component sort fields.
func (ComponentSortField) Valid ¶
func (f ComponentSortField) Valid() bool
Valid reports whether f is empty or one of the constants.
type DiscoveryError ¶
DiscoveryError is a discovery that did not reach a result: the attempt bound was exhausted, or the well-known document offered no endpoint with a supported version. Stage is the stage it ended in.
func (*DiscoveryError) Error ¶
func (e *DiscoveryError) Error() string
func (*DiscoveryError) Unwrap ¶
func (e *DiscoveryError) Unwrap() []error
Unwrap returns each attempt's Err, so errors.Is(err, ErrTimeout), errors.Is(err, ErrTooManyResults) and the like see through a DiscoveryError.
type DiscoveryResult ¶
type DiscoveryResult struct {
// ProductReleaseUUID is the resolved product release. A server may send
// any form google/uuid decodes; the value is canonical (String() is
// lowercase).
ProductReleaseUUID uuid.UUID
// Servers are the API roots that serve the release, as received and
// validated: non-empty, each rootUrl matching the specification's
// pattern and allowed by the URL policy, each version SemVer, each
// priority in [0, 1]. Use SelectServer to choose one.
Servers []teaapi.ServerInfo
// DiscoveredAt is the API base whose /discovery gave this result
// (informational: later calls go to a server from Servers).
DiscoveredAt APIBase
}
DiscoveryResult is one entry of a /discovery answer: a product release and the TEA servers that serve it.
type DownloadOptions ¶
type DownloadOptions struct {
// MaxBytes overrides the byte limit for this call: Limits.DownloadBytes
// for artifact content, Limits.SignatureBytes for a signature. Zero
// keeps the limit; negative is refused.
MaxBytes int64
// AllowSHA1Only accepts a format whose only supported checksum is
// SHA-1. Off by default: such a format fails with ErrNoUsableChecksum.
AllowSHA1Only bool
}
DownloadOptions adjusts one download.
type DownloadResult ¶
type DownloadResult struct {
// Bytes is the number of bytes written.
Bytes int64
// MediaType is the media type (type/subtype, lowercase, no parameters)
// of the response's Content-Type, "" when absent or unparsable.
MediaType string
// Source is where the bytes came from.
Source DownloadSource
// Verified are the checksum algorithms verified, in the order first
// listed in the format.
Verified []teaapi.ChecksumType
}
DownloadResult describes a verified download.
type DownloadSource ¶
type DownloadSource string
DownloadSource says where the bytes of a download came from.
const ( // DownloadSourceServer: the TEA server's versioned download endpoint // (redirects it answered with included). DownloadSourceServer DownloadSource = "server" // DownloadSourceExternal: the format's external url. DownloadSourceExternal DownloadSource = "external" )
Download sources.
type ErrorCode ¶
type ErrorCode string
ErrorCode is the error code of a TEA error-response body. The six codes of the specification's unknown-error-type are known; any other code received maps to ErrorCodeUnknown and is kept, truncated, in APIError.RawCode.
const ( ErrorCodeUnknown ErrorCode = "" ErrorCodeObjectUnknown ErrorCode = "OBJECT_UNKNOWN" ErrorCodeNotImplemented ErrorCode = "NOT_IMPLEMENTED" ErrorCodeNoAcceptableFormat ErrorCode = "NO_ACCEPTABLE_FORMAT" ErrorCodeSignatureNotFound ErrorCode = "SIGNATURE_NOT_FOUND" ErrorCodeInvalidRequest ErrorCode = "INVALID_REQUEST" ErrorCodeInvalidPageToken ErrorCode = "INVALID_PAGE_TOKEN" )
Error codes of the TEA specification (unknown-error-type).
type FlowComponent ¶
type FlowComponent struct {
Ref teaapi.ComponentRef
// Pinned is true when Ref.Release names the component release.
Pinned bool
// Component is fetched for an unpinned ref only.
Component *teaapi.Component
// Release is the pinned component release, or for an unpinned ref the
// newest by createdDate.
Release *teaapi.ComponentReleaseWithCollection
// CLE is the component release's lifecycle; nil when NOT_IMPLEMENTED or
// OBJECT_UNKNOWN, or with SkipCLE.
CLE *teaapi.Cle
// Err is this component's failure; the walk continues with the others.
Err error
}
FlowComponent is one component ref of a product release, resolved.
type FlowOptions ¶
type FlowOptions struct {
// Select chooses among several discovery results. It is given every
// candidate (each with its selected server and product release) and
// returns the index of the one to continue with. nil: several results
// are an *AmbiguousError. The library never prompts; a caller that
// asks a person does it here or after an *AmbiguousError.
Select func(ctx context.Context, cands []Candidate) (int, error)
// SkipCLE skips every lifecycle (CLE) request.
SkipCLE bool
}
FlowOptions adjusts FullFlow and FlowFromRelease.
type FlowResult ¶
type FlowResult struct {
// API is the API the release was read from.
API *API
// Release is the product release; its LatestCollection carries the
// artifacts and their formats (the flow downloads nothing).
Release *teaapi.ProductReleaseWithCollection
// ReleaseCLE is nil when the server answers NOT_IMPLEMENTED or
// OBJECT_UNKNOWN for it, or with SkipCLE.
ReleaseCLE *teaapi.Cle
// Components follow the release's component refs, in order.
Components []FlowComponent
}
FlowResult is a product release with its lifecycle and components.
type Limits ¶
type Limits struct {
WellKnownBytes int64 // .well-known/tea; default 64 KiB
DiscoveryBytes int64 // /discovery; default 1 MiB
DiscoveryResults int // results in one /discovery answer and given to Candidates; default 32
JSONBytes int64 // every other JSON response; default 16 MiB
ErrorBodyBytes int64 // non-2xx bodies (read to classify, then discarded) and /token; default 64 KiB
DownloadBytes int64 // artifact content; default 512 MiB
SignatureBytes int64 // signature content; default 16 MiB
Redirects int // per request; default 5
Pages int // per iterator; default 1000
FlowComponents int // component refs walked by the flow helper; default 1000
// AttemptTimeout bounds each discovery attempt (one well-known GET or one
// /discovery GET, headers and body); default 15 s.
AttemptTimeout time.Duration
// CallTimeout bounds each non-download request (typed JSON calls,
// /token, Generated() calls classified as JSON), headers and body;
// default 30 s.
CallTimeout time.Duration
// IdleTimeout bounds downloads and signatures: the longest wait for the
// response headers or for the next body byte. A download that keeps
// sending is never cut off. Default 30 s.
IdleTimeout time.Duration
}
Limits bounds what the client reads and how long it waits. The zero value of a field means its default. For the three durations, a negative value disables that bound and leaves only the caller's context; a byte or count limit must not be negative.
type NotResolvedError ¶
type NotResolvedError struct {
Base APIBase
Code ErrorCode // the TEA error code, ErrorCodeUnknown for an unknown one
RawCode string // the code as received when unknown, sanitised, at most 64 bytes
}
NotResolvedError is a TEA error answer with status 404 from /discovery: the server at Base does not resolve the identifier. Discovery stops there and does not fail over (discovery/readme.md "Unresolved identifiers").
func (*NotResolvedError) Error ¶
func (e *NotResolvedError) Error() string
func (*NotResolvedError) Is ¶
func (e *NotResolvedError) Is(target error) bool
Is matches ErrObjectUnknown when Code is OBJECT_UNKNOWN.
type Option ¶
type Option func(*options)
Option configures a Client.
func WithAPIKey ¶
WithAPIKey configures an API key (key id and secret) for rootURL (an API root, as in servers[].rootUrl). No token is requested up front: clients do not probe /token. When a GET under rootURL (an API call, or a /discovery request of Discover or DiscoverPURL) is answered 401 with a Bearer challenge from a URL under rootURL, the client requests a token from <rootURL>/v<version>/token, where version is that of the API that made the request (whose base must be under rootURL), with the client_credentials grant and HTTP Basic credentials, following no redirect; it caches the token (until expires_in minus 30 s, when given) and retries the request once with it. A 401 on a request that carried the cached token drops it, and the client obtains a fresh one and retries once. There is never more than one recovery per request, and none on a 403. Concurrent requests share one token request. A failure to obtain the token matches ErrNoAccessToken. The token is sent on requests under rootURL and nowhere else, like a WithBearerToken token. An http rootURL must be under a WithInsecureHTTPBase allowance. The key id, the secret and the token never appear in an error or a trace event.
When several credentials cover a URL, the one with the longest root applies (the first configured among equal roots).
For a server that answers an anonymous caller with less instead of a 401, use WithPreemptiveAPIKey.
Example ¶
package main
import (
"log"
tea "github.com/oolong-project/tea-client-go"
)
func main() {
// The key is exchanged for a token only when the server asks for one
// (a 401 with a Bearer challenge under the root), and the token is sent
// under that root only.
c, err := tea.New(tea.WithAPIKey("https://tea.example.com/tea", "key-id", "key-secret"))
if err != nil {
log.Fatal(err)
}
_ = c
}
Output:
func WithBearerToken ¶
WithBearerToken sends "Authorization: Bearer <token>" on requests under rootURL (an API root, as in servers[].rootUrl), and on no other request. An http rootURL must be under a WithInsecureHTTPBase allowance.
func WithDiscoveryAttempts ¶
WithDiscoveryAttempts sets the total number of discovery attempts across the well-known and /discovery stages (default 4) and the first backoff (default 250 ms, doubling, capped at 4 s). Every request counts, the successful well-known fetch included, so Discover needs at least 2; DiscoverPURL makes no well-known request. A zero firstBackoff keeps the default.
func WithHTTPClient ¶
WithHTTPClient makes the client send through hc. The library copies hc and sets its own CheckRedirect (redirect limit and URL policy) and wraps its Transport (nil means http.DefaultTransport) in the auth transport. A transport passed here therefore sits below the auth transport and sees Authorization headers: use WithTrace for debug output, not a transport that dumps headers. hc.Timeout, if set, applies on top of the library's own time bounds.
func WithInsecureHTTPBase ¶
WithInsecureHTTPBase allows plain http for URLs under rawURL: same host and port, and a path equal to rawURL's path or below it by whole segments. rawURL is an absolute http URL without userinfo, query, fragment, trailing "/" or dot segment. Repeatable. There is no global switch, and nothing a server sends adds or widens an allowance.
Example ¶
package main
import (
"log"
tea "github.com/oolong-project/tea-client-go"
)
func main() {
// A local server over plain http: the allowance covers the origin and
// every path under it, and nothing else.
c, err := tea.New(
tea.WithInsecureHTTPBase("http://localhost:8086"),
tea.WithWellKnownLocation("localhost", "http://localhost:8086"),
tea.WithBearerToken("http://localhost:8086/tea", "a-token"),
)
if err != nil {
log.Fatal(err)
}
_ = c
}
Output:
func WithLimits ¶
WithLimits sets the limits; zero fields keep their defaults.
func WithPreemptiveAPIKey ¶ added in v0.1.0
WithPreemptiveAPIKey is WithAPIKey for a server that answers an anonymous caller with less instead of a 401 (a filtered listing, only the public results of a discovery): the client does not wait for a challenge. Before an API sends a request to a URL under rootURL (a typed call, a Generated() call, a download from the server, a /discovery request of Discover or DiscoverPURL), the client makes sure it holds an access token, requesting one from <rootURL>/v<version>/token when it holds none (none obtained yet, expired, or dropped after a 401), and sends it on that request. Concurrent requests share one token request. When the token cannot be obtained the request is not sent and the error matches ErrNoAccessToken.
A .well-known/tea request and a redirect hop never cause a token request and carry the token only when one is already held; an external artifact or signature URL never carries it.
This departs from the specification's description of /token ("Clients do not probe this endpoint to discover whether authentication is required"): use it for a root you know to require your key. Against a server without /token every request under rootURL fails (ErrNoAccessToken, wrapping ErrNotImplemented), where WithAPIKey would go on without a credential.
Everything else is as WithAPIKey: where the key and the token are sent, the cache, one fresh token and one retry after a 401 on a cached token, nothing on a 403. A 401 on a request whose token was obtained for it is returned as it is. New refuses a rootURL that is also the root of another credential.
func WithTrace ¶
func WithTrace(f func(TraceEvent)) Option
WithTrace registers an observer called synchronously, in request order, for every request the client makes (redirects included), every response, and each failed discovery attempt and backoff. Events never carry headers, bodies, query strings or credentials. A panic in f is not recovered.
func WithUserAgent ¶
WithUserAgent replaces the default User-Agent "tea-client-go/<version>".
func WithWellKnownLocation ¶
WithWellKnownLocation makes discovery fetch <location>/.well-known/tea for TEIs of domain, instead of https://<domain>/.well-known/tea. An http location also needs a WithInsecureHTTPBase allowance covering it.
type Page ¶
Page carries the paging parameters every list operation takes. A zero field is omitted from the request (PageSize 0 is the server's default). PageToken is passed back verbatim; it is opaque.
type ProductQuery ¶
type ProductQuery struct {
Page
SortField ProductSortField
IDType teaapi.IdentifierType
IDValue string
}
ProductQuery selects products (queryProducts).
type ProductSortField ¶
type ProductSortField string
ProductSortField is the spec's sort-field-product.
const ProductSortName ProductSortField = "name"
Product sort fields.
func (ProductSortField) Valid ¶
func (f ProductSortField) Valid() bool
Valid reports whether f is empty or one of the constants.
type ReleasePage ¶
type ReleasePage struct {
Page
SortField ReleaseSortField
}
ReleasePage pages through one parent's releases (listProductReleases, listComponentReleases).
type ReleaseQuery ¶
type ReleaseQuery struct {
Page
SortField ReleaseSortField
IDType teaapi.IdentifierType
IDValue string
}
ReleaseQuery selects product releases or component releases (queryProductReleases, queryComponentReleases).
type ReleaseSortField ¶
type ReleaseSortField string
ReleaseSortField is the spec's sort-field-product-release and sort-field-component-release (the same set).
const ( ReleaseSortCreatedDate ReleaseSortField = "createdDate" ReleaseSortReleaseDate ReleaseSortField = "releaseDate" ReleaseSortVersion ReleaseSortField = "version" )
Release sort fields.
func (ReleaseSortField) Valid ¶
func (f ReleaseSortField) Valid() bool
Valid reports whether f is empty or one of the constants.
type SortOrder ¶
type SortOrder string
SortOrder is the spec's sort-order.
Sort orders. The zero value omits the parameter (server default: asc).
type Stage ¶
type Stage string
Stage names the part of the protocol a request or an attempt belongs to.
type TokenError ¶
type TokenError struct {
Status int
Code teaapi.TokenErrorResponseError
Description string
}
TokenError is an OAuth 2.0 token-error-response (RFC 6749 section 5.2) from /token. Code is as received, sanitised and truncated to 64 bytes; Description is sanitised and truncated to 200 bytes.
func (*TokenError) Error ¶
func (e *TokenError) Error() string
type TraceEvent ¶
type TraceEvent struct {
Kind TraceKind
Stage Stage
Method string
URL string // scheme, host, port and path only: never query, fragment or userinfo
Status int // TraceResponse
Reason string // TraceAttemptFailed: same text as the Attempt in a discovery error
Wait time.Duration // TraceBackoff
}
TraceEvent is what a WithTrace observer receives. It never carries a header, a body, a query string or a credential.
type URLPolicyError ¶
URLPolicyError is a URL the client refused to request or follow. URL is redacted: scheme, host, port and path only, never userinfo or query.
func (*URLPolicyError) Error ¶
func (e *URLPolicyError) Error() string
func (*URLPolicyError) Unwrap ¶
func (e *URLPolicyError) Unwrap() error
Unwrap returns ErrInsecureURL or ErrRedirectLimit.
type UnexpectedResponseError ¶
UnexpectedResponseError is a response the client cannot use: a 2xx body that is missing or does not decode to the declared type, a response that breaks a rule callers rely on (hasNext without nextPageToken), or a status the operation does not expect.
func (*UnexpectedResponseError) Error ¶
func (e *UnexpectedResponseError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
oolongtest
Package oolongtest starts an oolong TEA server (github.com/oolong-project/oolong, oolong/oolong-server) for integration tests.
|
Package oolongtest starts an oolong TEA server (github.com/oolong-project/oolong, oolong/oolong-server) for integration tests. |
|
Package teaapi holds the models and the low-level client of the Transparency Exchange API (TEA) v1.0.0, generated by oapi-codegen (pinned in ../tools.mod) from ../spec/openapi.yaml, which is a byte copy of spec/openapi.yaml of CycloneDX/transparency-exchange-api at commit 962a0228af1bfcc1232ac3f79239317ff33fdb04 (see ../spec/SPEC_PIN.md).
|
Package teaapi holds the models and the low-level client of the Transparency Exchange API (TEA) v1.0.0, generated by oapi-codegen (pinned in ../tools.mod) from ../spec/openapi.yaml, which is a byte copy of spec/openapi.yaml of CycloneDX/transparency-exchange-api at commit 962a0228af1bfcc1232ac3f79239317ff33fdb04 (see ../spec/SPEC_PIN.md). |
|
Package tei parses Transparency Exchange Identifiers (TEIs) as defined by the TEA discovery specification ("TEI syntax", discovery/readme.md of CycloneDX/transparency-exchange-api at the commit spec/SPEC_PIN.md names).
|
Package tei parses Transparency Exchange Identifiers (TEIs) as defined by the TEA discovery specification ("TEI syntax", discovery/readme.md of CycloneDX/transparency-exchange-api at the commit spec/SPEC_PIN.md names). |