Documentation
¶
Overview ¶
Package api holds the wire types and error codes of the /v1 routes.
Index ¶
- Constants
- type Blobs
- type BlobsRequest
- type ClaimRequest
- type ClaimResponse
- type Code
- type Commit
- type CreateRepoRequest
- type CreateRepoResponse
- type CreateSubscriptionRequest
- type Error
- type ErrorBody
- type Event
- type Events
- type FlushRequest
- type Has
- type HasRequest
- type ImportPackRequest
- type LandRequest
- type LandResponse
- type LandedCommit
- type Object
- type OpHeads
- type OpObject
- type ProtectedRefs
- type PutObjectsRequest
- type PutObjectsResponse
- type Ref
- type Refs
- type Repo
- type Repos
- type SetWorkspaceRequest
- type Subscription
- type Subscriptions
- type SwapOpHeadsRequest
- type SwapRefRequest
- type Tree
- type TreeEntry
- type Trees
Constants ¶
const ( HeaderSignature = "X-Motte-Signature" HeaderPartition = "X-Motte-Partition" HeaderSequence = "X-Motte-Sequence" )
Headers of an event delivery. Signature is "sha256=" and the lowercase hex HMAC-SHA256 of the request body under the secret of the subscription.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobsRequest ¶
type BlobsRequest struct {
SHAs []string `json:"shas"`
}
type ClaimRequest ¶
type ClaimRequest struct {
Epoch uint64 `json:"epoch"`
Owner string `json:"owner"`
Repo string `json:"repo"`
}
ClaimRequest is the body of PUT /v1/workspaces/{id}/claim.
type ClaimResponse ¶
type ClaimResponse struct {
Epoch uint64 `json:"epoch"`
Op string `json:"op"`
Snapshot string `json:"snapshot"`
}
ClaimResponse returns the stored epoch, op and snapshot of the workspace.
type Code ¶
type Code string
Code is a wire error code.
const ( CodeNotFound Code = "vcs_not_found" CodeGenerationConflict Code = "vcs_generation_conflict" CodeClaimLost Code = "vcs_claim_lost" CodeObjectInvalid Code = "vcs_object_invalid" CodeObjectTooLarge Code = "vcs_object_too_large" CodeRepoForbidden Code = "vcs_repo_forbidden" CodeWorkspaceConflict Code = "vcs_workspace_conflict" CodeWorkspaceDeleted Code = "vcs_workspace_deleted" CodeRefProtected Code = "vcs_ref_protected" CodeEventsPruned Code = "vcs_events_pruned" CodeLandConflict Code = "vcs_land_conflict" CodeLandStale Code = "vcs_land_stale" CodeLandInvalid Code = "vcs_land_invalid" CodeLandTimeout Code = "vcs_land_timeout" CodeInvalidBody Code = "invalid_body" CodeInternal Code = "internal_error" CodeMethodNotAllowed Code = "method_not_allowed" )
type CreateRepoRequest ¶
CreateRepoRequest is the body of POST /v1/repos.
type CreateRepoResponse ¶
type CreateRepoResponse struct {
Path string `json:"path"`
}
type CreateSubscriptionRequest ¶ added in v0.6.0
type CreateSubscriptionRequest struct {
URL string `json:"url"`
Secret string `json:"secret"`
Repo string `json:"repo,omitempty"`
}
CreateSubscriptionRequest is the body of POST /v1/subscriptions. Repo is empty for the events of every repo.
type Error ¶
type ErrorBody ¶
type ErrorBody struct {
Error Error `json:"error"`
}
ErrorBody is the body of every error response. A conflict on a ref sets Details["ref"] to the stored Ref.
type Event ¶ added in v0.6.0
type Event struct {
Partition int `json:"partition"`
Seq int64 `json:"seq"`
Repo string `json:"repo"`
Ref string `json:"ref"`
Old string `json:"old"`
New string `json:"new"`
Generation int64 `json:"generation"`
Kind string `json:"kind"`
Time string `json:"time"`
}
Event is one change of a ref. Its identity is Partition and Seq. Events of one ref share a partition, and Seq has no gap and follows commit order in a partition. No order holds across partitions. Old is empty for a create and New is empty for a delete. Generation is that of the ref after the change, or of the deleted ref. Kind is the scope of the grant that wrote the ref: node, write, merge or operator. Time is RFC 3339.
type Events ¶ added in v0.6.0
Events is the answer of GET /v1/events. Cursor is opaque. A consumer passes it as the cursor of the next call, and gets the events after the last one here.
type FlushRequest ¶
type FlushRequest struct {
Epoch uint64 `json:"epoch"`
Generation int64 `json:"generation"`
Prev string `json:"prev"`
Op string `json:"op"`
Snapshot string `json:"snapshot"`
}
FlushRequest is the body of POST /v1/workspaces/{id}/flush.
type HasRequest ¶
type HasRequest struct {
SHAs []string `json:"shas"`
}
type ImportPackRequest ¶
ImportPackRequest is the body of PUT /v1/vcs/packs/{pack_id}. The pack ID is the lowercase hex SHA-256 of the pack bytes. Both fields are base64.
type LandRequest ¶ added in v0.6.0
type LandRequest struct {
ID string `json:"id,omitempty"`
Ref string `json:"ref"`
Base string `json:"base"`
Head string `json:"head"`
ExpectTree string `json:"expect_tree,omitempty"`
}
LandRequest is the body of POST /v1/repos/{repo}/lands. Base..Head is a linear range of commits that the repository already stores. ID is optional: a repeat of an accepted ID returns the first result and never lands twice. ExpectTree is optional: when set, the land moves the ref only if the tree of the commit that Head becomes equals it.
type LandResponse ¶ added in v0.6.0
type LandResponse struct {
ID string `json:"id"`
Ref string `json:"ref"`
Generation int64 `json:"generation"`
Tip string `json:"tip"`
FastForward bool `json:"fast_forward"`
Commits []LandedCommit `json:"commits"`
}
LandResponse is the answer of a land that moved the ref, or found the head already at its tip. Tip is the commit of the head after the land, and Generation is the generation of the ref move that holds it. The ref can move on before the answer arrives. FastForward is set when the head already descended from the tip and the ref moved to it as it is, and Commits is then empty. Else Commits maps each commit of the range to its new commit, oldest first.
type LandedCommit ¶ added in v0.6.0
LandedCommit is a commit of the range and the commit that replaced it on the ref.
type OpHeads ¶
type OpHeads struct {
Epoch uint64 `json:"epoch"`
Generation int64 `json:"generation"`
Heads []string `json:"heads"`
}
OpHeads is the head set of the op log of a workspace. Generation starts at 1.
type ProtectedRefs ¶ added in v0.6.0
type ProtectedRefs struct {
Patterns []string `json:"patterns"`
}
ProtectedRefs is the body of PUT and GET /v1/repos/{repo}/protected-refs. A pattern is a ref name, or a prefix that ends in "*".
type PutObjectsRequest ¶
type PutObjectsRequest struct {
Objects []Object `json:"objects"`
}
type PutObjectsResponse ¶
type PutObjectsResponse struct {
SHAs []string `json:"shas"`
}
type Ref ¶
type Ref struct {
Name string `json:"name"`
Commit string `json:"commit"`
Generation int64 `json:"generation"`
}
Ref is one ref of a repository. Commit is 40 lowercase hex digits. Generation is never reused, even when the ref is deleted and created again.
type Repo ¶
type Repo struct {
Path string `json:"path"`
Name string `json:"name"`
Owner string `json:"owner"`
CreatedAt string `json:"created_at"`
}
Repo is one repository of the store.
type SetWorkspaceRequest ¶
type SetWorkspaceRequest struct {
Op string `json:"op"`
Commit string `json:"commit"`
Generation int64 `json:"generation"`
}
SetWorkspaceRequest is the body of PUT /v1/vcs/workspace. Generation is that of the op-heads swap of Op.
type Subscription ¶ added in v0.6.0
type Subscription struct {
ID string `json:"id"`
URL string `json:"url"`
Repo string `json:"repo,omitempty"`
Cursor string `json:"cursor"`
CreatedAt string `json:"created_at"`
}
Subscription is a registered receiver. Cursor is an event cursor that holds the last event that it acknowledged in each partition. The secret is never returned.
type Subscriptions ¶ added in v0.6.0
type Subscriptions struct {
Subscriptions []Subscription `json:"subscriptions"`
}
type SwapOpHeadsRequest ¶
type SwapOpHeadsRequest struct {
ExpectGeneration int64 `json:"expect_generation"`
Heads []string `json:"heads"`
}
SwapOpHeadsRequest is the body of PUT /v1/vcs/op-heads. ExpectGeneration is 0 for the first write.
type SwapRefRequest ¶
SwapRefRequest is the body of PUT /v1/vcs/refs/{name}. Expect is the stored generation, or 0 to create the ref.