github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/api/server/register_pods.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) registerPodsHandlers(r *mux.Router) error { 11 // swagger:operation GET /libpod/pods/json pods PodListLibpod 12 // --- 13 // summary: List pods 14 // produces: 15 // - application/json 16 // parameters: 17 // - in: query 18 // name: filters 19 // type: string 20 // description: | 21 // JSON encoded value of the filters (a map[string][]string) to process on the pods list. Available filters: 22 // - `id=<pod-id>` Matches all of pod id. 23 // - `label=<key>` or `label=<key>:<value>` Matches pods based on the presence of a label alone or a label and a value. 24 // - `name=<pod-name>` Matches all of pod name. 25 // - `until=<timestamp>` List pods created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time. 26 // - `status=<pod-status>` Pod's status: `stopped`, `running`, `paused`, `exited`, `dead`, `created`, `degraded`. 27 // - `network=<pod-network>` Name or full ID of network. 28 // - `ctr-names=<pod-ctr-names>` Container name within the pod. 29 // - `ctr-ids=<pod-ctr-ids>` Container ID within the pod. 30 // - `ctr-status=<pod-ctr-status>` Container status within the pod. 31 // - `ctr-number=<pod-ctr-number>` Number of containers in the pod. 32 // responses: 33 // 200: 34 // $ref: "#/responses/podsListResponse" 35 // 400: 36 // $ref: "#/responses/badParamError" 37 // 500: 38 // $ref: "#/responses/internalError" 39 r.Handle(VersionedPath("/libpod/pods/json"), s.APIHandler(libpod.Pods)).Methods(http.MethodGet) 40 // swagger:operation POST /libpod/pods/create pods PodCreateLibpod 41 // --- 42 // summary: Create a pod 43 // produces: 44 // - application/json 45 // parameters: 46 // - in: body 47 // name: create 48 // description: attributes for creating a pod 49 // schema: 50 // $ref: "#/definitions/PodSpecGenerator" 51 // responses: 52 // 201: 53 // schema: 54 // $ref: "#/definitions/IDResponse" 55 // 400: 56 // $ref: "#/responses/badParamError" 57 // 409: 58 // description: status conflict 59 // schema: 60 // type: string 61 // description: message describing error 62 // 500: 63 // $ref: "#/responses/internalError" 64 r.Handle(VersionedPath("/libpod/pods/create"), s.APIHandler(libpod.PodCreate)).Methods(http.MethodPost) 65 // swagger:operation POST /libpod/pods/prune pods PodPruneLibpod 66 // --- 67 // summary: Prune unused pods 68 // produces: 69 // - application/json 70 // responses: 71 // 200: 72 // $ref: '#/responses/podPruneResponse' 73 // 400: 74 // $ref: "#/responses/badParamError" 75 // 409: 76 // description: pod already exists 77 // 500: 78 // $ref: "#/responses/internalError" 79 r.Handle(VersionedPath("/libpod/pods/prune"), s.APIHandler(libpod.PodPrune)).Methods(http.MethodPost) 80 // swagger:operation DELETE /libpod/pods/{name} pods PodDeleteLibpod 81 // --- 82 // summary: Remove pod 83 // produces: 84 // - application/json 85 // parameters: 86 // - in: path 87 // name: name 88 // type: string 89 // required: true 90 // description: the name or ID of the pod 91 // - in: query 92 // name: force 93 // type: boolean 94 // description : force removal of a running pod by first stopping all containers, then removing all containers in the pod 95 // responses: 96 // 200: 97 // $ref: '#/responses/podRmResponse' 98 // 400: 99 // $ref: "#/responses/badParamError" 100 // 404: 101 // $ref: "#/responses/podNotFound" 102 // 500: 103 // $ref: "#/responses/internalError" 104 r.Handle(VersionedPath("/libpod/pods/{name}"), s.APIHandler(libpod.PodDelete)).Methods(http.MethodDelete) 105 // swagger:operation GET /libpod/pods/{name}/json pods PodInspectLibpod 106 // --- 107 // summary: Inspect pod 108 // produces: 109 // - application/json 110 // parameters: 111 // - in: path 112 // name: name 113 // type: string 114 // required: true 115 // description: the name or ID of the pod 116 // responses: 117 // 200: 118 // $ref: "#/responses/podInspectResponse" 119 // 404: 120 // $ref: "#/responses/podNotFound" 121 // 500: 122 // $ref: "#/responses/internalError" 123 r.Handle(VersionedPath("/libpod/pods/{name}/json"), s.APIHandler(libpod.PodInspect)).Methods(http.MethodGet) 124 // swagger:operation GET /libpod/pods/{name}/exists pods PodExistsLibpod 125 // --- 126 // summary: Pod exists 127 // description: Check if a pod exists by name or ID 128 // produces: 129 // - application/json 130 // parameters: 131 // - in: path 132 // name: name 133 // type: string 134 // required: true 135 // description: the name or ID of the pod 136 // responses: 137 // 204: 138 // description: pod exists 139 // 404: 140 // $ref: "#/responses/podNotFound" 141 // 500: 142 // $ref: "#/responses/internalError" 143 r.Handle(VersionedPath("/libpod/pods/{name}/exists"), s.APIHandler(libpod.PodExists)).Methods(http.MethodGet) 144 // swagger:operation POST /libpod/pods/{name}/kill pods PodKillLibpod 145 // --- 146 // summary: Kill a pod 147 // produces: 148 // - application/json 149 // parameters: 150 // - in: path 151 // name: name 152 // type: string 153 // required: true 154 // description: the name or ID of the pod 155 // - in: query 156 // name: signal 157 // type: string 158 // description: signal to be sent to pod 159 // default: SIGKILL 160 // responses: 161 // 200: 162 // $ref: "#/responses/podKillResponse" 163 // 400: 164 // $ref: "#/responses/badParamError" 165 // 404: 166 // $ref: "#/responses/podNotFound" 167 // 409: 168 // $ref: "#/responses/podKillResponse" 169 // 500: 170 // $ref: "#/responses/internalError" 171 r.Handle(VersionedPath("/libpod/pods/{name}/kill"), s.APIHandler(libpod.PodKill)).Methods(http.MethodPost) 172 // swagger:operation POST /libpod/pods/{name}/pause pods PodPauseLibpod 173 // --- 174 // summary: Pause a pod 175 // description: Pause a pod 176 // produces: 177 // - application/json 178 // parameters: 179 // - in: path 180 // name: name 181 // type: string 182 // required: true 183 // description: the name or ID of the pod 184 // responses: 185 // 200: 186 // $ref: '#/responses/podPauseResponse' 187 // 404: 188 // $ref: "#/responses/podNotFound" 189 // 409: 190 // $ref: '#/responses/podPauseResponse' 191 // 500: 192 // $ref: "#/responses/internalError" 193 r.Handle(VersionedPath("/libpod/pods/{name}/pause"), s.APIHandler(libpod.PodPause)).Methods(http.MethodPost) 194 // swagger:operation POST /libpod/pods/{name}/restart pods PodRestartLibpod 195 // --- 196 // summary: Restart a pod 197 // produces: 198 // - application/json 199 // parameters: 200 // - in: path 201 // name: name 202 // type: string 203 // required: true 204 // description: the name or ID of the pod 205 // responses: 206 // 200: 207 // $ref: '#/responses/podRestartResponse' 208 // 404: 209 // $ref: "#/responses/podNotFound" 210 // 409: 211 // $ref: "#/responses/podRestartResponse" 212 // 500: 213 // $ref: "#/responses/internalError" 214 r.Handle(VersionedPath("/libpod/pods/{name}/restart"), s.APIHandler(libpod.PodRestart)).Methods(http.MethodPost) 215 // swagger:operation POST /libpod/pods/{name}/start pods PodStartLibpod 216 // --- 217 // summary: Start a pod 218 // produces: 219 // - application/json 220 // parameters: 221 // - in: path 222 // name: name 223 // type: string 224 // required: true 225 // description: the name or ID of the pod 226 // responses: 227 // 200: 228 // $ref: '#/responses/podStartResponse' 229 // 304: 230 // $ref: "#/responses/podAlreadyStartedError" 231 // 404: 232 // $ref: "#/responses/podNotFound" 233 // 409: 234 // $ref: '#/responses/podStartResponse' 235 // 500: 236 // $ref: "#/responses/internalError" 237 r.Handle(VersionedPath("/libpod/pods/{name}/start"), s.APIHandler(libpod.PodStart)).Methods(http.MethodPost) 238 // swagger:operation POST /libpod/pods/{name}/stop pods PodStopLibpod 239 // --- 240 // summary: Stop a pod 241 // produces: 242 // - application/json 243 // parameters: 244 // - in: path 245 // name: name 246 // type: string 247 // required: true 248 // description: the name or ID of the pod 249 // - in: query 250 // name: t 251 // type: integer 252 // description: timeout 253 // responses: 254 // 200: 255 // $ref: '#/responses/podStopResponse' 256 // 304: 257 // $ref: "#/responses/podAlreadyStoppedError" 258 // 400: 259 // $ref: "#/responses/badParamError" 260 // 404: 261 // $ref: "#/responses/podNotFound" 262 // 409: 263 // $ref: "#/responses/podStopResponse" 264 // 500: 265 // $ref: "#/responses/internalError" 266 r.Handle(VersionedPath("/libpod/pods/{name}/stop"), s.APIHandler(libpod.PodStop)).Methods(http.MethodPost) 267 // swagger:operation POST /libpod/pods/{name}/unpause pods PodUnpauseLibpod 268 // --- 269 // summary: Unpause a pod 270 // produces: 271 // - application/json 272 // parameters: 273 // - in: path 274 // name: name 275 // type: string 276 // required: true 277 // description: the name or ID of the pod 278 // responses: 279 // 200: 280 // $ref: '#/responses/podUnpauseResponse' 281 // 404: 282 // $ref: "#/responses/podNotFound" 283 // 409: 284 // $ref: '#/responses/podUnpauseResponse' 285 // 500: 286 // $ref: "#/responses/internalError" 287 r.Handle(VersionedPath("/libpod/pods/{name}/unpause"), s.APIHandler(libpod.PodUnpause)).Methods(http.MethodPost) 288 // swagger:operation GET /libpod/pods/{name}/top pods PodTopLibpod 289 // --- 290 // summary: List processes 291 // description: List processes running inside a pod 292 // produces: 293 // - application/json 294 // parameters: 295 // - in: path 296 // name: name 297 // type: string 298 // required: true 299 // description: Name of pod to query for processes 300 // - in: query 301 // name: stream 302 // type: boolean 303 // description: when true, repeatedly stream the latest output (As of version 4.0) 304 // - in: query 305 // name: delay 306 // type: integer 307 // description: if streaming, delay in seconds between updates. Must be >1. (As of version 4.0) 308 // default: 5 309 // - in: query 310 // name: ps_args 311 // type: string 312 // default: -ef 313 // description: | 314 // arguments to pass to ps such as aux. 315 // Requires ps(1) to be installed in the container if no ps(1) compatible AIX descriptors are used. 316 // responses: 317 // 200: 318 // $ref: "#/responses/podTopResponse" 319 // 404: 320 // $ref: "#/responses/podNotFound" 321 // 500: 322 // $ref: "#/responses/internalError" 323 r.Handle(VersionedPath("/libpod/pods/{name}/top"), s.APIHandler(libpod.PodTop)).Methods(http.MethodGet) 324 // swagger:operation GET /libpod/pods/stats pods PodStatsAllLibpod 325 // --- 326 // tags: 327 // - pods 328 // summary: Statistics for one or more pods 329 // description: Display a live stream of resource usage statistics for the containers in one or more pods 330 // parameters: 331 // - in: query 332 // name: all 333 // description: Provide statistics for all running pods. 334 // type: boolean 335 // - in: query 336 // name: namesOrIDs 337 // description: Names or IDs of pods. 338 // type: array 339 // items: 340 // type: string 341 // produces: 342 // - application/json 343 // responses: 344 // 200: 345 // $ref: "#/responses/podStatsResponse" 346 // 404: 347 // $ref: "#/responses/podNotFound" 348 // 500: 349 // $ref: "#/responses/internalError" 350 r.Handle(VersionedPath("/libpod/pods/stats"), s.APIHandler(libpod.PodStats)).Methods(http.MethodGet) 351 return nil 352 }