common.go

 1package lfs
 2
 3import "time"
 4
 5const (
 6	// MediaType contains the media type for LFS server requests
 7	MediaType = "application/vnd.git-lfs+json"
 8)
 9
10// Pointer contains LFS pointer data
11type Pointer struct {
12	Oid  string `json:"oid"`
13	Size int64  `json:"size"`
14}
15
16// PointerBlob associates a Git blob with a Pointer.
17type PointerBlob struct {
18	Hash string
19	Pointer
20}
21
22// ErrorResponse describes the error to the client.
23type ErrorResponse struct {
24	Message          string
25	DocumentationURL string `json:"documentation_url,omitempty"`
26	RequestID        string `json:"request_id,omitempty"`
27}
28
29// BatchResponse contains multiple object metadata Representation structures
30// for use with the batch API.
31// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses
32type BatchResponse struct {
33	Transfer string            `json:"transfer,omitempty"`
34	Objects  []*ObjectResponse `json:"objects"`
35}
36
37// ObjectResponse is object metadata as seen by clients of the LFS server.
38type ObjectResponse struct {
39	Pointer
40	Actions map[string]*Link `json:"actions,omitempty"`
41	Error   *ObjectError     `json:"error,omitempty"`
42}
43
44// Link provides a structure with information about how to access a object.
45type Link struct {
46	Href      string            `json:"href"`
47	Header    map[string]string `json:"header,omitempty"`
48	ExpiresAt *time.Time        `json:"expires_at,omitempty"`
49	ExpiresIn *time.Duration    `json:"expires_in,omitempty"`
50}
51
52// ObjectError defines the JSON structure returned to the client in case of an error.
53type ObjectError struct {
54	Code    int    `json:"code"`
55	Message string `json:"message"`
56}
57
58// BatchRequest contains multiple requests processed in one batch operation.
59// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#requests
60type BatchRequest struct {
61	Operation string     `json:"operation"`
62	Transfers []string   `json:"transfers,omitempty"`
63	Ref       *Reference `json:"ref,omitempty"`
64	Objects   []Pointer  `json:"objects"`
65	HashAlgo  string     `json:"hash_algo,omitempty"`
66}
67
68// Reference contains a git reference.
69// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#ref-property
70type Reference struct {
71	Name string `json:"name"`
72}