1package lfs23import (4 "time"5)67const (8 // MediaType contains the media type for LFS server requests.9 MediaType = "application/vnd.git-lfs+json"1011 // OperationDownload is the operation name for a download request.12 OperationDownload = "download"1314 // OperationUpload is the operation name for an upload request.15 OperationUpload = "upload"1617 // ActionDownload is the action name for a download request.18 ActionDownload = OperationDownload1920 // ActionUpload is the action name for an upload request.21 ActionUpload = OperationUpload2223 // ActionVerify is the action name for a verify request.24 ActionVerify = "verify"2526 // DefaultLocksLimit is the default number of locks to return in a single27 // request.28 DefaultLocksLimit = 2029)3031// Pointer contains LFS pointer data32type Pointer struct {33 Oid string `json:"oid"`34 Size int64 `json:"size"`35}3637// PointerBlob associates a Git blob with a Pointer.38type PointerBlob struct {39 Hash string40 Pointer41}4243// ErrorResponse describes the error to the client.44type ErrorResponse struct {45 Message string `json:"message,omitempty"`46 DocumentationURL string `json:"documentation_url,omitempty"`47 RequestID string `json:"request_id,omitempty"`48}4950// BatchResponse contains multiple object metadata Representation structures51// for use with the batch API.52// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses53type BatchResponse struct {54 Transfer string `json:"transfer,omitempty"`55 Objects []*ObjectResponse `json:"objects"`56 HashAlgo string `json:"hash_algo,omitempty"`57}5859// ObjectResponse is object metadata as seen by clients of the LFS server.60type ObjectResponse struct {61 Pointer62 Actions map[string]*Link `json:"actions,omitempty"`63 Error *ObjectError `json:"error,omitempty"`64}6566// Link provides a structure with information about how to access a object.67type Link struct {68 Href string `json:"href"`69 Header map[string]string `json:"header,omitempty"`70 ExpiresAt *time.Time `json:"expires_at,omitempty"`71 ExpiresIn *time.Duration `json:"expires_in,omitempty"`72}7374// ObjectError defines the JSON structure returned to the client in case of an error.75type ObjectError struct {76 Code int `json:"code"`77 Message string `json:"message"`78}7980// BatchRequest contains multiple requests processed in one batch operation.81// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#requests82type BatchRequest struct {83 Operation string `json:"operation"`84 Transfers []string `json:"transfers,omitempty"`85 Ref *Reference `json:"ref,omitempty"`86 Objects []Pointer `json:"objects"`87 HashAlgo string `json:"hash_algo,omitempty"`88}8990// Reference contains a git reference.91// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#ref-property92type Reference struct {93 Name string `json:"name"`94}9596// AuthenticateResponse is the git-lfs-authenticate JSON response object.97type AuthenticateResponse struct {98 Header map[string]string `json:"header"`99 Href string `json:"href"`100 ExpiresIn time.Duration `json:"expires_in"`101 ExpiresAt time.Time `json:"expires_at"`102}103104// LockCreateRequest contains the request data for creating a lock.105// https://github.com/git-lfs/git-lfs/blob/main/docs/api/locking.md106// https://github.com/git-lfs/git-lfs/blob/main/locking/schemas/http-lock-create-request-schema.json107type LockCreateRequest struct {108 Path string `json:"path"`109 Ref Reference `json:"ref,omitempty"`110}111112// Owner contains the owner data for a lock.113type Owner struct {114 Name string `json:"name"`115}116117// Lock contains the response data for creating a lock.118// https://github.com/git-lfs/git-lfs/blob/main/docs/api/locking.md119// https://github.com/git-lfs/git-lfs/blob/main/locking/schemas/http-lock-create-response-schema.json120type Lock struct {121 ID string `json:"id"`122 Path string `json:"path"`123 LockedAt time.Time `json:"locked_at"`124 Owner Owner `json:"owner,omitempty"`125}126127// LockDeleteRequest contains the request data for deleting a lock.128// https://github.com/git-lfs/git-lfs/blob/main/docs/api/locking.md129// https://github.com/git-lfs/git-lfs/blob/main/locking/schemas/http-lock-delete-request-schema.json130type LockDeleteRequest struct {131 Force bool `json:"force,omitempty"`132 Ref Reference `json:"ref,omitempty"`133}134135// LockListResponse contains the response data for listing locks.136// https://github.com/git-lfs/git-lfs/blob/main/docs/api/locking.md137// https://github.com/git-lfs/git-lfs/blob/main/locking/schemas/http-lock-list-response-schema.json138type LockListResponse struct {139 Locks []Lock `json:"locks"`140 NextCursor string `json:"next_cursor,omitempty"`141}142143// LockVerifyRequest contains the request data for verifying a lock.144type LockVerifyRequest struct {145 Ref Reference `json:"ref,omitempty"`146 Cursor string `json:"cursor,omitempty"`147 Limit int `json:"limit,omitempty"`148}149150// LockVerifyResponse contains the response data for verifying a lock.151// https://github.com/git-lfs/git-lfs/blob/main/docs/api/locking.md152// https://github.com/git-lfs/git-lfs/blob/main/locking/schemas/http-lock-verify-response-schema.json153type LockVerifyResponse struct {154 Ours []Lock `json:"ours"`155 Theirs []Lock `json:"theirs"`156 NextCursor string `json:"next_cursor,omitempty"`157}158159// LockResponse contains the response data for a lock.160type LockResponse struct {161 Lock Lock `json:"lock"`162 ErrorResponse163}