6
"github.com/containers/podman/v5/pkg/api/handlers/compat"
7
"github.com/containers/podman/v5/pkg/api/handlers/libpod"
8
"github.com/gorilla/mux"
11
func (s *APIServer) registerNetworkHandlers(r *mux.Router) error {
12
// swagger:operation DELETE /networks/{name} compat NetworkDelete
15
// - networks (compat)
16
// summary: Remove a network
17
// description: Remove a network
23
// description: the name of the network
28
// description: no error
30
// $ref: "#/responses/networkNotFound"
32
// $ref: "#/responses/internalError"
33
r.HandleFunc(VersionedPath("/networks/{name}"), s.APIHandler(compat.RemoveNetwork)).Methods(http.MethodDelete)
34
r.HandleFunc("/networks/{name}", s.APIHandler(compat.RemoveNetwork)).Methods(http.MethodDelete)
35
// swagger:operation GET /networks/{name} compat NetworkInspect
38
// - networks (compat)
39
// summary: Inspect a network
40
// description: Display low level configuration network
46
// description: the name of the network
51
// description: Detailed inspect output for troubleshooting
56
// description: Filter the network by scope (swarm, global, or local)
61
// $ref: "#/responses/networkInspectCompat"
63
// $ref: "#/responses/networkNotFound"
65
// $ref: "#/responses/internalError"
66
r.HandleFunc(VersionedPath("/networks/{name}"), s.APIHandler(compat.InspectNetwork)).Methods(http.MethodGet)
67
r.HandleFunc("/networks/{name}", s.APIHandler(compat.InspectNetwork)).Methods(http.MethodGet)
68
// swagger:operation GET /networks compat NetworkList
71
// - networks (compat)
72
// summary: List networks
73
// description: Display summary of network configurations
79
// JSON encoded value of the filters (a `map[string][]string`) to process on the network list. Currently available filters:
80
// - `name=[name]` Matches network name (accepts regex).
81
// - `id=[id]` Matches for full or partial ID.
82
// - `driver=[driver]` Only bridge is supported.
83
// - `label=[key]` or `label=[key=value]` Matches networks based on the presence of a label alone or a label and a value.
88
// $ref: "#/responses/networkListCompat"
90
// $ref: "#/responses/internalError"
91
r.HandleFunc(VersionedPath("/networks"), s.APIHandler(compat.ListNetworks)).Methods(http.MethodGet)
92
r.HandleFunc("/networks", s.APIHandler(compat.ListNetworks)).Methods(http.MethodGet)
93
// swagger:operation POST /networks/create compat NetworkCreate
96
// - networks (compat)
97
// summary: Create network
98
// description: Create a network configuration
100
// - application/json
104
// description: attributes for creating a network
106
// $ref: "#/definitions/networkCreate"
109
// description: network created
118
// $ref: "#/responses/badParamError"
120
// $ref: "#/responses/internalError"
121
r.HandleFunc(VersionedPath("/networks/create"), s.APIHandler(compat.CreateNetwork)).Methods(http.MethodPost)
122
r.HandleFunc("/networks/create", s.APIHandler(compat.CreateNetwork)).Methods(http.MethodPost)
123
// swagger:operation POST /networks/{name}/connect compat NetworkConnect
126
// - networks (compat)
127
// summary: Connect container to network
128
// description: Connect a container to a network
130
// - application/json
136
// description: the name of the network
139
// description: attributes for connecting a container to a network
141
// $ref: "#/definitions/networkConnectRequest"
146
// $ref: "#/responses/badParamError"
148
// $ref: "#/responses/networkConnectedError"
150
// $ref: "#/responses/internalError"
151
r.HandleFunc(VersionedPath("/networks/{name}/connect"), s.APIHandler(compat.Connect)).Methods(http.MethodPost)
152
r.HandleFunc("/networks/{name}/connect", s.APIHandler(compat.Connect)).Methods(http.MethodPost)
153
// swagger:operation POST /networks/{name}/disconnect compat NetworkDisconnect
156
// - networks (compat)
157
// summary: Disconnect container from network
158
// description: Disconnect a container from a network
160
// - application/json
166
// description: the name of the network
169
// description: attributes for disconnecting a container from a network
171
// $ref: "#/definitions/networkDisconnectRequest"
176
// $ref: "#/responses/badParamError"
178
// $ref: "#/responses/internalError"
179
r.HandleFunc(VersionedPath("/networks/{name}/disconnect"), s.APIHandler(compat.Disconnect)).Methods(http.MethodPost)
180
r.HandleFunc("/networks/{name}/disconnect", s.APIHandler(compat.Disconnect)).Methods(http.MethodPost)
181
// swagger:operation POST /networks/prune compat NetworkPrune
184
// - networks (compat)
185
// summary: Delete unused networks
186
// description: Remove networks that do not have containers
188
// - application/json
194
// Filters to process on the prune list, encoded as JSON (a map[string][]string).
195
// Available filters:
196
// - `until=<timestamp>` Prune networks 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.
197
// - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune networks with (or without, in case `label!=...` is used) the specified labels.
209
// $ref: "#/responses/internalError"
210
r.HandleFunc(VersionedPath("/networks/prune"), s.APIHandler(compat.Prune)).Methods(http.MethodPost)
211
r.HandleFunc("/networks/prune", s.APIHandler(compat.Prune)).Methods(http.MethodPost)
213
// swagger:operation DELETE /libpod/networks/{name} libpod NetworkDeleteLibpod
217
// summary: Remove a network
218
// description: Remove a configured network
224
// description: the name of the network
228
// description: remove containers associated with network
230
// - application/json
233
// $ref: "#/responses/networkRmResponse"
235
// $ref: "#/responses/networkNotFound"
237
// $ref: "#/responses/internalError"
238
r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.RemoveNetwork)).Methods(http.MethodDelete)
239
// swagger:operation POST /libpod/networks/{name}/update libpod NetworkUpdateLibpod
243
// summary: Update existing podman network
244
// description: Update existing podman network
246
// - application/json
252
// description: the name or ID of the network
255
// description: attributes for updating a netavark network
257
// $ref: "#/definitions/networkUpdateRequestLibpod"
262
// $ref: "#/responses/badParamError"
264
// $ref: "#/responses/internalError"
265
r.HandleFunc(VersionedPath("/libpod/networks/{name}/update"), s.APIHandler(libpod.UpdateNetwork)).Methods(http.MethodPost)
266
// swagger:operation GET /libpod/networks/{name}/exists libpod NetworkExistsLibpod
270
// summary: Network exists
271
// description: Check if network exists
277
// description: the name or ID of the network
279
// - application/json
282
// description: network exists
284
// $ref: '#/responses/networkNotFound'
286
// $ref: '#/responses/internalError'
287
r.Handle(VersionedPath("/libpod/networks/{name}/exists"), s.APIHandler(libpod.ExistsNetwork)).Methods(http.MethodGet)
288
// swagger:operation GET /libpod/networks/json libpod NetworkListLibpod
292
// summary: List networks
294
// Display summary of network configurations.
295
// - In a 200 response, all of the fields named Bytes are returned as a Base64 encoded string.
301
// JSON encoded value of the filters (a `map[string][]string`) to process on the network list. Available filters:
302
// - `name=[name]` Matches network name (accepts regex).
303
// - `id=[id]` Matches for full or partial ID.
304
// - `driver=[driver]` Only bridge is supported.
305
// - `label=[key]` or `label=[key=value]` Matches networks based on the presence of a label alone or a label and a value.
306
// - `until=[timestamp]` Matches all networks that were created before the given timestamp.
308
// - application/json
311
// $ref: "#/responses/networkListLibpod"
313
// $ref: "#/responses/internalError"
314
r.HandleFunc(VersionedPath("/libpod/networks/json"), s.APIHandler(libpod.ListNetworks)).Methods(http.MethodGet)
315
// swagger:operation GET /libpod/networks/{name}/json libpod NetworkInspectLibpod
319
// summary: Inspect a network
321
// Display configuration for a network.
327
// description: the name of the network
329
// - application/json
332
// $ref: "#/responses/networkInspectResponse"
334
// $ref: "#/responses/networkNotFound"
336
// $ref: "#/responses/internalError"
337
r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet)
338
r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet)
339
// swagger:operation POST /libpod/networks/create libpod NetworkCreateLibpod
343
// summary: Create network
344
// description: Create a new network configuration
346
// - application/json
350
// description: attributes for creating a network
352
// $ref: "#/definitions/networkCreateLibpod"
355
// $ref: "#/responses/networkCreateResponse"
357
// $ref: "#/responses/badParamError"
359
// $ref: "#/responses/conflictError"
361
// $ref: "#/responses/internalError"
362
r.HandleFunc(VersionedPath("/libpod/networks/create"), s.APIHandler(libpod.CreateNetwork)).Methods(http.MethodPost)
363
// swagger:operation POST /libpod/networks/{name}/connect libpod NetworkConnectLibpod
367
// summary: Connect container to network
368
// description: Connect a container to a network.
370
// - application/json
376
// description: the name of the network
379
// description: attributes for connecting a container to a network
381
// $ref: "#/definitions/networkConnectRequestLibpod"
386
// $ref: "#/responses/networkNotFound"
388
// $ref: "#/responses/internalError"
389
r.HandleFunc(VersionedPath("/libpod/networks/{name}/connect"), s.APIHandler(libpod.Connect)).Methods(http.MethodPost)
390
// swagger:operation POST /libpod/networks/{name}/disconnect libpod NetworkDisconnectLibpod
394
// summary: Disconnect container from network
395
// description: Disconnect a container from a network.
397
// - application/json
403
// description: the name of the network
406
// description: attributes for disconnecting a container from a network
408
// $ref: "#/definitions/networkDisconnectRequest"
413
// $ref: "#/responses/networkNotFound"
415
// $ref: "#/responses/internalError"
416
r.HandleFunc(VersionedPath("/libpod/networks/{name}/disconnect"), s.APIHandler(compat.Disconnect)).Methods(http.MethodPost)
417
// swagger:operation POST /libpod/networks/prune libpod NetworkPruneLibpod
421
// summary: Delete unused networks
422
// description: Remove networks that do not have containers
424
// - application/json
430
// Filters to process on the prune list, encoded as JSON (a `map[string][]string`).
431
// Available filters:
432
// - `until=<timestamp>` Prune networks 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.
433
// - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune networks with (or without, in case `label!=...` is used) the specified labels.
436
// $ref: "#/responses/networkPruneResponse"
438
// $ref: "#/responses/internalError"
439
r.HandleFunc(VersionedPath("/libpod/networks/prune"), s.APIHandler(libpod.Prune)).Methods(http.MethodPost)