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