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

     1  package server
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/hanks177/podman/v4/pkg/api/handlers/compat"
     7  	"github.com/gorilla/mux"
     8  )
     9  
    10  func (s *APIServer) registerArchiveHandlers(r *mux.Router) error {
    11  	// swagger:operation PUT /containers/{name}/archive compat PutContainerArchive
    12  	// ---
    13  	//  summary: Put files into a container
    14  	//  description: Put a tar archive of files into a container
    15  	//  tags:
    16  	//   - containers (compat)
    17  	//  produces:
    18  	//  - application/json
    19  	//  parameters:
    20  	//   - in: path
    21  	//     name: name
    22  	//     type: string
    23  	//     description: container name or id
    24  	//     required: true
    25  	//   - in: query
    26  	//     name: path
    27  	//     type: string
    28  	//     description: Path to a directory in the container to extract
    29  	//     required: true
    30  	//   - in: query
    31  	//     name: noOverwriteDirNonDir
    32  	//     type: string
    33  	//     description: if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa (1 or true)
    34  	//   - in: query
    35  	//     name: copyUIDGID
    36  	//     type: string
    37  	//     description: copy UID/GID maps to the dest file or di (1 or true)
    38  	//   - in: body
    39  	//     name: request
    40  	//     description: tarfile of files to copy into the container
    41  	//     schema:
    42  	//       type: string
    43  	//  responses:
    44  	//    200:
    45  	//      description: no error
    46  	//    400:
    47  	//      $ref: "#/responses/badParamError"
    48  	//    403:
    49  	//      description: the container rootfs is read-only
    50  	//    404:
    51  	//      $ref: "#/responses/containerNotFound"
    52  	//    500:
    53  	//      $ref: "#/responses/internalError"
    54  
    55  	// swagger:operation GET /containers/{name}/archive compat ContainerArchive
    56  	// ---
    57  	//  summary: Get files from a container
    58  	//  description: Get a tar archive of files from a container
    59  	//  tags:
    60  	//   - containers (compat)
    61  	//  produces:
    62  	//  - application/json
    63  	//  parameters:
    64  	//   - in: path
    65  	//     name: name
    66  	//     type: string
    67  	//     description: container name or id
    68  	//     required: true
    69  	//   - in: query
    70  	//     name: path
    71  	//     type: string
    72  	//     description: Path to a directory in the container to extract
    73  	//     required: true
    74  	//  responses:
    75  	//    200:
    76  	//      description: no error
    77  	//      schema:
    78  	//       type: string
    79  	//       format: binary
    80  	//    400:
    81  	//      $ref: "#/responses/badParamError"
    82  	//    404:
    83  	//      $ref: "#/responses/containerNotFound"
    84  	//    500:
    85  	//      $ref: "#/responses/internalError"
    86  	r.HandleFunc(VersionedPath("/containers/{name}/archive"), s.APIHandler(compat.Archive)).Methods(http.MethodGet, http.MethodPut, http.MethodHead)
    87  	// Added non version path to URI to support docker non versioned paths
    88  	r.HandleFunc("/containers/{name}/archive", s.APIHandler(compat.Archive)).Methods(http.MethodGet, http.MethodPut, http.MethodHead)
    89  
    90  	/*
    91  		Libpod
    92  	*/
    93  
    94  	// swagger:operation PUT /libpod/containers/{name}/archive libpod PutContainerArchiveLibpod
    95  	// ---
    96  	//  summary: Copy files into a container
    97  	//  description: Copy a tar archive of files into a container
    98  	//  tags:
    99  	//   - containers
   100  	//  produces:
   101  	//  - application/json
   102  	//  parameters:
   103  	//   - in: path
   104  	//     name: name
   105  	//     type: string
   106  	//     description: container name or id
   107  	//     required: true
   108  	//   - in: query
   109  	//     name: path
   110  	//     type: string
   111  	//     description: Path to a directory in the container to extract
   112  	//     required: true
   113  	//   - in: query
   114  	//     name: pause
   115  	//     type: boolean
   116  	//     description: pause the container while copying (defaults to true)
   117  	//     default: true
   118  	//   - in: body
   119  	//     name: request
   120  	//     description: tarfile of files to copy into the container
   121  	//     schema:
   122  	//       type: string
   123  	//  responses:
   124  	//    200:
   125  	//      description: no error
   126  	//    400:
   127  	//      $ref: "#/responses/badParamError"
   128  	//    403:
   129  	//      description: the container rootfs is read-only
   130  	//    404:
   131  	//      $ref: "#/responses/containerNotFound"
   132  	//    500:
   133  	//      $ref: "#/responses/internalError"
   134  
   135  	// swagger:operation GET /libpod/containers/{name}/archive libpod ContainerArchiveLibpod
   136  	// ---
   137  	//  summary: Copy files from a container
   138  	//  description: Copy a tar archive of files from a container
   139  	//  tags:
   140  	//   - containers (compat)
   141  	//  produces:
   142  	//  - application/json
   143  	//  parameters:
   144  	//   - in: path
   145  	//     name: name
   146  	//     type: string
   147  	//     description: container name or id
   148  	//     required: true
   149  	//   - in: query
   150  	//     name: path
   151  	//     type: string
   152  	//     description: Path to a directory in the container to extract
   153  	//     required: true
   154  	//   - in: query
   155  	//     name: rename
   156  	//     type: string
   157  	//     description: JSON encoded map[string]string to translate paths
   158  	//  responses:
   159  	//    200:
   160  	//      description: no error
   161  	//      schema:
   162  	//       type: string
   163  	//       format: binary
   164  	//    400:
   165  	//      $ref: "#/responses/badParamError"
   166  	//    404:
   167  	//      $ref: "#/responses/containerNotFound"
   168  	//    500:
   169  	//      $ref: "#/responses/internalError"
   170  	r.HandleFunc(VersionedPath("/libpod/containers/{name}/archive"), s.APIHandler(compat.Archive)).Methods(http.MethodGet, http.MethodPut, http.MethodHead)
   171  
   172  	return nil
   173  }