github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/api/server/register_secrets.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/hanks177/podman/v4/pkg/api/handlers/libpod" 8 "github.com/gorilla/mux" 9 ) 10 11 func (s *APIServer) registerSecretHandlers(r *mux.Router) error { 12 // swagger:operation POST /libpod/secrets/create libpod SecretCreateLibpod 13 // --- 14 // tags: 15 // - secrets 16 // summary: Create a secret 17 // parameters: 18 // - in: query 19 // name: name 20 // type: string 21 // description: User-defined name of the secret. 22 // required: true 23 // - in: query 24 // name: driver 25 // type: string 26 // description: Secret driver 27 // default: "file" 28 // - in: body 29 // name: request 30 // description: Secret 31 // schema: 32 // type: string 33 // produces: 34 // - application/json 35 // responses: 36 // '201': 37 // $ref: "#/responses/SecretCreateResponse" 38 // '500': 39 // "$ref": "#/responses/internalError" 40 r.Handle(VersionedPath("/libpod/secrets/create"), s.APIHandler(libpod.CreateSecret)).Methods(http.MethodPost) 41 // swagger:operation GET /libpod/secrets/json libpod SecretListLibpod 42 // --- 43 // tags: 44 // - secrets 45 // summary: List secrets 46 // description: Returns a list of secrets 47 // parameters: 48 // - in: query 49 // name: filters 50 // type: string 51 // description: | 52 // JSON encoded value of the filters (a `map[string][]string`) to process on the secrets list. Currently available filters: 53 // - `name=[name]` Matches secrets name (accepts regex). 54 // - `id=[id]` Matches for full or partial ID. 55 // produces: 56 // - application/json 57 // parameters: 58 // responses: 59 // '200': 60 // "$ref": "#/responses/SecretListResponse" 61 // '500': 62 // "$ref": "#/responses/internalError" 63 r.Handle(VersionedPath("/libpod/secrets/json"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) 64 // swagger:operation GET /libpod/secrets/{name}/json libpod SecretInspectLibpod 65 // --- 66 // tags: 67 // - secrets 68 // summary: Inspect secret 69 // parameters: 70 // - in: path 71 // name: name 72 // type: string 73 // required: true 74 // description: the name or ID of the secret 75 // produces: 76 // - application/json 77 // responses: 78 // '200': 79 // "$ref": "#/responses/SecretInspectResponse" 80 // '404': 81 // "$ref": "#/responses/NoSuchSecret" 82 // '500': 83 // "$ref": "#/responses/internalError" 84 r.Handle(VersionedPath("/libpod/secrets/{name}/json"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) 85 // swagger:operation DELETE /libpod/secrets/{name} libpod SecretDeleteLibpod 86 // --- 87 // tags: 88 // - secrets 89 // summary: Remove secret 90 // parameters: 91 // - in: path 92 // name: name 93 // type: string 94 // required: true 95 // description: the name or ID of the secret 96 // - in: query 97 // name: all 98 // type: boolean 99 // description: Remove all secrets 100 // default: false 101 // produces: 102 // - application/json 103 // responses: 104 // '204': 105 // description: no error 106 // '404': 107 // "$ref": "#/responses/NoSuchSecret" 108 // '500': 109 // "$ref": "#/responses/internalError" 110 r.Handle(VersionedPath("/libpod/secrets/{name}"), s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete) 111 112 /* 113 * Docker compatibility endpoints 114 */ 115 // swagger:operation GET /secrets compat SecretList 116 // --- 117 // tags: 118 // - secrets (compat) 119 // summary: List secrets 120 // description: Returns a list of secrets 121 // parameters: 122 // - in: query 123 // name: filters 124 // type: string 125 // description: | 126 // JSON encoded value of the filters (a `map[string][]string`) to process on the secrets list. Currently available filters: 127 // - `name=[name]` Matches secrets name (accepts regex). 128 // - `id=[id]` Matches for full or partial ID. 129 // produces: 130 // - application/json 131 // parameters: 132 // responses: 133 // '200': 134 // "$ref": "#/responses/SecretListCompatResponse" 135 // '500': 136 // "$ref": "#/responses/internalError" 137 r.Handle(VersionedPath("/secrets"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) 138 r.Handle("/secrets", s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) 139 // swagger:operation POST /secrets/create compat SecretCreate 140 // --- 141 // tags: 142 // - secrets (compat) 143 // summary: Create a secret 144 // parameters: 145 // - in: body 146 // name: create 147 // description: | 148 // attributes for creating a secret 149 // schema: 150 // $ref: "#/definitions/SecretCreate" 151 // produces: 152 // - application/json 153 // responses: 154 // '201': 155 // $ref: "#/responses/SecretCreateResponse" 156 // '409': 157 // "$ref": "#/responses/SecretInUse" 158 // '500': 159 // "$ref": "#/responses/internalError" 160 r.Handle(VersionedPath("/secrets/create"), s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost) 161 r.Handle("/secrets/create", s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost) 162 // swagger:operation GET /secrets/{name} compat SecretInspect 163 // --- 164 // tags: 165 // - secrets (compat) 166 // summary: Inspect secret 167 // parameters: 168 // - in: path 169 // name: name 170 // type: string 171 // required: true 172 // description: the name or ID of the secret 173 // produces: 174 // - application/json 175 // responses: 176 // '200': 177 // "$ref": "#/responses/SecretInspectCompatResponse" 178 // '404': 179 // "$ref": "#/responses/NoSuchSecret" 180 // '500': 181 // "$ref": "#/responses/internalError" 182 r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) 183 r.Handle("/secrets/{name}", s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) 184 // swagger:operation DELETE /secrets/{name} compat SecretDelete 185 // --- 186 // tags: 187 // - secrets (compat) 188 // summary: Remove secret 189 // parameters: 190 // - in: path 191 // name: name 192 // type: string 193 // required: true 194 // description: the name or ID of the secret 195 // produces: 196 // - application/json 197 // responses: 198 // '204': 199 // description: no error 200 // '404': 201 // "$ref": "#/responses/NoSuchSecret" 202 // '500': 203 // "$ref": "#/responses/internalError" 204 r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete) 205 r.Handle("/secret/{name}", s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete) 206 207 r.Handle(VersionedPath("/secrets/{name}/update"), s.APIHandler(compat.UpdateSecret)).Methods(http.MethodPost) 208 r.Handle("/secrets/{name}/update", s.APIHandler(compat.UpdateSecret)).Methods(http.MethodPost) 209 return nil 210 }