You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shared.go 2.2KB

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