github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/api/server/register_manifest.go (about)

     1  package server
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/hanks177/podman/v4/pkg/api/handlers/libpod"
     7  	"github.com/gorilla/mux"
     8  )
     9  
    10  func (s *APIServer) registerManifestHandlers(r *mux.Router) error {
    11  	v3 := r.PathPrefix("/v{version:[0-3][0-9A-Za-z.-]*}/libpod/manifests").Subrouter()
    12  	v4 := r.PathPrefix("/v{version:[4-9][0-9A-Za-z.-]*}/libpod/manifests").Subrouter()
    13  	// swagger:operation POST /libpod/manifests/{name}/push manifests ManifestPushV3Libpod
    14  	// ---
    15  	// summary: Push manifest to registry
    16  	// description: |
    17  	//   Push a manifest list or image index to a registry
    18  	//
    19  	//   Deprecated: As of 4.0.0 use ManifestPushLibpod instead
    20  	// produces:
    21  	// - application/json
    22  	// parameters:
    23  	//  - in: path
    24  	//    name: name
    25  	//    type: string
    26  	//    required: true
    27  	//    description: the name or ID of the manifest
    28  	//  - in: query
    29  	//    name: destination
    30  	//    type: string
    31  	//    required: true
    32  	//    description: the destination for the manifest
    33  	//  - in: query
    34  	//    name: all
    35  	//    description: push all images
    36  	//    type: boolean
    37  	// responses:
    38  	//   200:
    39  	//     schema:
    40  	//       $ref: "#/definitions/IDResponse"
    41  	//   400:
    42  	//     $ref: "#/responses/badParamError"
    43  	//   404:
    44  	//     $ref: "#/responses/manifestNotFound"
    45  	//   500:
    46  	//     $ref: "#/responses/internalError"
    47  	v3.Handle("/{name}/push", s.APIHandler(libpod.ManifestPushV3)).Methods(http.MethodPost)
    48  	// swagger:operation POST /libpod/manifests/{name}/registry/{destination} manifests ManifestPushLibpod
    49  	// ---
    50  	// summary: Push manifest list to registry
    51  	// description: |
    52  	//   Push a manifest list or image index to the named registry
    53  	//
    54  	//   As of v4.0.0
    55  	// produces:
    56  	// - application/json
    57  	// parameters:
    58  	//  - in: path
    59  	//    name: name
    60  	//    type: string
    61  	//    required: true
    62  	//    description: the name or ID of the manifest list
    63  	//  - in: path
    64  	//    name: destination
    65  	//    type: string
    66  	//    required: true
    67  	//    description: the registry for the manifest list
    68  	//  - in: query
    69  	//    name: all
    70  	//    description: push all images
    71  	//    type: boolean
    72  	//    default: false
    73  	//  - in: query
    74  	//    name: tlsVerify
    75  	//    type: boolean
    76  	//    default: false
    77  	//    description: skip TLS verification for registries
    78  	// responses:
    79  	//   200:
    80  	//     schema:
    81  	//       $ref: "#/definitions/IDResponse"
    82  	//   400:
    83  	//     $ref: "#/responses/badParamError"
    84  	//   404:
    85  	//     $ref: "#/responses/manifestNotFound"
    86  	//   500:
    87  	//     $ref: "#/responses/internalError"
    88  	v4.Handle("/{name:.*}/registry/{destination:.*}", s.APIHandler(libpod.ManifestPush)).Methods(http.MethodPost)
    89  	// swagger:operation POST /libpod/manifests manifests ManifestCreateLibpod
    90  	// ---
    91  	// summary: Create
    92  	// description: Create a manifest list
    93  	// produces:
    94  	// - application/json
    95  	// parameters:
    96  	// - in: query
    97  	//   name: name
    98  	//   type: string
    99  	//   description: manifest list or index name to create
   100  	//   required: true
   101  	// - in: query
   102  	//   name: images
   103  	//   type: string
   104  	//   required: true
   105  	//   description: |
   106  	//     One or more names of an image or a manifest list. Repeat parameter as needed.
   107  	//
   108  	//     Support for multiple images, as of version 4.0.0
   109  	//     Alias of `image` is support for compatibility with < 4.0.0
   110  	//     Response status code is 200 with < 4.0.0 for compatibility
   111  	// - in: query
   112  	//   name: all
   113  	//   type: boolean
   114  	//   description: add all contents if given list
   115  	// - in: body
   116  	//   name: options
   117  	//   description: options for new manifest
   118  	//   required: false
   119  	//   schema:
   120  	//     $ref: "#/definitions/ManifestModifyOptions"
   121  	// responses:
   122  	//   201:
   123  	//     schema:
   124  	//       $ref: "#/definitions/IDResponse"
   125  	//   400:
   126  	//     $ref: "#/responses/badParamError"
   127  	//   404:
   128  	//     $ref: "#/responses/imageNotFound"
   129  	//   500:
   130  	//     $ref: "#/responses/internalError"
   131  	v3.Handle("/create", s.APIHandler(libpod.ManifestCreate)).Methods(http.MethodPost)
   132  	v4.Handle("/{name:.*}", s.APIHandler(libpod.ManifestCreate)).Methods(http.MethodPost)
   133  	// swagger:operation GET /libpod/manifests/{name}/exists manifests ManifestExistsLibpod
   134  	// ---
   135  	// summary: Exists
   136  	// description: |
   137  	//   Check if manifest list exists
   138  	//
   139  	//   Note: There is no contract that the manifest list will exist for a follow-on operation
   140  	// parameters:
   141  	//  - in: path
   142  	//    name: name
   143  	//    type: string
   144  	//    required: true
   145  	//    description: the name or ID of the manifest list
   146  	// produces:
   147  	// - application/json
   148  	// responses:
   149  	//   204:
   150  	//     description: manifest list exists
   151  	//   404:
   152  	//     $ref: '#/responses/manifestNotFound'
   153  	//   500:
   154  	//     $ref: '#/responses/internalError'
   155  	v3.Handle("/{name:.*}/exists", s.APIHandler(libpod.ManifestExists)).Methods(http.MethodGet)
   156  	v4.Handle("/{name:.*}/exists", s.APIHandler(libpod.ManifestExists)).Methods(http.MethodGet)
   157  	// swagger:operation GET /libpod/manifests/{name}/json manifests ManifestInspectLibpod
   158  	// ---
   159  	// summary: Inspect
   160  	// description: Display attributes of given manifest list
   161  	// produces:
   162  	// - application/json
   163  	// parameters:
   164  	//  - in: path
   165  	//    name: name
   166  	//    type: string
   167  	//    required: true
   168  	//    description: the name or ID of the manifest list
   169  	// responses:
   170  	//   200:
   171  	//     $ref: "#/responses/manifestInspect"
   172  	//   404:
   173  	//     $ref: "#/responses/manifestNotFound"
   174  	//   500:
   175  	//     $ref: "#/responses/internalError"
   176  	v3.Handle("/{name:.*}/json", s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet)
   177  	v4.Handle("/{name:.*}/json", s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet)
   178  	// swagger:operation PUT /libpod/manifests/{name} manifests ManifestModifyLibpod
   179  	// ---
   180  	// summary: Modify manifest list
   181  	// description: |
   182  	//   Add/Remove an image(s) to a manifest list
   183  	//
   184  	//   Note: operations are not atomic when multiple Images are provided.
   185  	//
   186  	//   As of v4.0.0
   187  	// produces:
   188  	// - application/json
   189  	// parameters:
   190  	//  - in: path
   191  	//    name: name
   192  	//    type: string
   193  	//    required: true
   194  	//    description: the name or ID of the manifest
   195  	//  - in: query
   196  	//    name: tlsVerify
   197  	//    type: boolean
   198  	//    default: false
   199  	//    description: skip TLS verification for registries
   200  	//  - in: body
   201  	//    name: options
   202  	//    description: options for mutating a manifest
   203  	//    required: true
   204  	//    schema:
   205  	//        $ref: "#/definitions/ManifestModifyOptions"
   206  	// responses:
   207  	//   200:
   208  	//     schema:
   209  	//       $ref: "#/definitions/ManifestModifyReport"
   210  	//   404:
   211  	//     $ref: "#/responses/manifestNotFound"
   212  	//   400:
   213  	//     $ref: "#/responses/badParamError"
   214  	//   409:
   215  	//     description: Operation had partial success, both Images and Errors may have members
   216  	//     schema:
   217  	//       $ref: "#/definitions/ManifestModifyReport"
   218  	//   500:
   219  	//     $ref: "#/responses/internalError"
   220  	v4.Handle("/{name:.*}", s.APIHandler(libpod.ManifestModify)).Methods(http.MethodPut)
   221  	// swagger:operation POST /libpod/manifests/{name}/add manifests ManifestAddLibpod
   222  	// ---
   223  	// summary: Add image
   224  	// description: |
   225  	//   Add an image to a manifest list
   226  	//
   227  	//   Deprecated: As of 4.0.0 use ManifestModifyLibpod instead
   228  	// produces:
   229  	// - application/json
   230  	// parameters:
   231  	//  - in: path
   232  	//    name: name
   233  	//    type: string
   234  	//    required: true
   235  	//    description: the name or ID of the manifest
   236  	//  - in: body
   237  	//    name: options
   238  	//    description: options for creating a manifest
   239  	//    schema:
   240  	//      $ref: "#/definitions/ManifestAddOptions"
   241  	// responses:
   242  	//   200:
   243  	//     schema:
   244  	//       $ref: "#/definitions/IDResponse"
   245  	//   404:
   246  	//     $ref: "#/responses/manifestNotFound"
   247  	//   409:
   248  	//     $ref: "#/responses/badParamError"
   249  	//   500:
   250  	//     $ref: "#/responses/internalError"
   251  	v3.Handle("/{name:.*}/add", s.APIHandler(libpod.ManifestAddV3)).Methods(http.MethodPost)
   252  	// swagger:operation DELETE /libpod/manifests/{name} manifests ManifestDeleteV3Libpod
   253  	// ---
   254  	// summary: Remove image from a manifest list
   255  	// description: |
   256  	//   Remove an image from a manifest list
   257  	//
   258  	//   Deprecated: As of 4.0.0 use ManifestModifyLibpod instead
   259  	// produces:
   260  	// - application/json
   261  	// parameters:
   262  	//  - in: path
   263  	//    name: name
   264  	//    type: string
   265  	//    required: true
   266  	//    description: the image associated with the manifest
   267  	//  - in: query
   268  	//    name: digest
   269  	//    type: string
   270  	//    description: image digest to be removed
   271  	// responses:
   272  	//   200:
   273  	//     schema:
   274  	//       $ref: "#/definitions/IDResponse"
   275  	//   400:
   276  	//     $ref: "#/responses/badParamError"
   277  	//   404:
   278  	//     $ref: "#/responses/manifestNotFound"
   279  	//   500:
   280  	//     $ref: "#/responses/internalError"
   281  	v3.Handle("/{name:.*}", s.APIHandler(libpod.ManifestRemoveDigestV3)).Methods(http.MethodDelete)
   282  	// swagger:operation DELETE /libpod/manifests/{name} manifests ManifestDeleteLibpod
   283  	// ---
   284  	// summary: Delete manifest list
   285  	// description: |
   286  	//   Delete named manifest list
   287  	//
   288  	//   As of v4.0.0
   289  	// produces:
   290  	// - application/json
   291  	// parameters:
   292  	//  - in: path
   293  	//    name: name
   294  	//    type: string
   295  	//    required: true
   296  	//    description: The name or ID of the  list to be deleted
   297  	// responses:
   298  	//   200:
   299  	//     $ref: "#/responses/imagesRemoveResponseLibpod"
   300  	//   404:
   301  	//     $ref: "#/responses/manifestNotFound"
   302  	//   500:
   303  	//     $ref: "#/responses/internalError"
   304  	v4.Handle("/{name:.*}", s.APIHandler(libpod.ManifestDelete)).Methods(http.MethodDelete)
   305  	return nil
   306  }