api

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api holds the wire types and error codes of the /v1 routes.

Index

Constants

View Source
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 Blobs

type Blobs struct {
	Blobs []string `json:"blobs"`
}

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"
	CodeLandInvalid        Code = "vcs_land_invalid"
	CodeLandTimeout        Code = "vcs_land_timeout"
	CodeUnauthorized       Code = "unauthorized"
	CodeInvalidBody        Code = "invalid_body"
	CodeInternal           Code = "internal_error"
	CodeMethodNotAllowed   Code = "method_not_allowed"
)

func (Code) Status

func (c Code) Status() int

Status is the HTTP status of c. An unknown code is 500.

type Commit

type Commit struct {
	Tree string `json:"tree"`
	Time string `json:"time"`
}

Commit is the root tree of a commit and its committer time (RFC 3339).

type CreateRepoRequest

type CreateRepoRequest struct {
	Name  string `json:"name"`
	Owner string `json:"owner"`
}

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 Error struct {
	Code    Code           `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details"`
}

func (*Error) Error

func (e *Error) Error() string

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

type Events struct {
	Events []Event `json:"events"`
	Cursor string  `json:"cursor"`
}

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 Has

type Has struct {
	Present []bool `json:"present"`
}

type HasRequest

type HasRequest struct {
	SHAs []string `json:"shas"`
}

type ImportPackRequest

type ImportPackRequest struct {
	Index string `json:"index"`
	Pack  string `json:"pack"`
}

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"`
}

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.

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

type LandedCommit struct {
	Old string `json:"old"`
	New string `json:"new"`
}

LandedCommit is a commit of the range and the commit that replaced it on the ref.

type Object

type Object struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

Object is one git object. Type is commit, tree, blob or tag. Data is base64.

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 OpObject

type OpObject struct {
	Data string `json:"data"`
}

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 Refs

type Refs struct {
	Refs []Ref `json:"refs"`
}

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 Repos

type Repos struct {
	Repos []Repo `json:"repos"`
}

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

type SwapRefRequest struct {
	Expect int64  `json:"expect"`
	Commit string `json:"commit"`
}

SwapRefRequest is the body of PUT /v1/vcs/refs/{name}. Expect is the stored generation, or 0 to create the ref.

type Tree

type Tree struct {
	SHA     string      `json:"sha"`
	Entries []TreeEntry `json:"entries"`
}

type TreeEntry

type TreeEntry struct {
	Name string `json:"name"`
	Mode string `json:"mode"`
	SHA  string `json:"sha"`
	Size int64  `json:"size,omitempty"`
}

TreeEntry is one entry of a tree. Name is the base64 of the name bytes, which need not be UTF-8. Mode is the octal git mode.

type Trees

type Trees struct {
	Trees []Tree `json:"trees"`
}

Jump to

Keyboard shortcuts

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