summaryrefslogtreecommitdiff
path: root/pkg/api/server/register_secrets.go
blob: 95abf83e83d020d40202e43932a99a83eb41d64e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package server

import (
	"net/http"

	"github.com/containers/podman/v2/pkg/api/handlers/compat"
	"github.com/containers/podman/v2/pkg/api/handlers/libpod"
	"github.com/gorilla/mux"
)

func (s *APIServer) registerSecretHandlers(r *mux.Router) error {
	// swagger:operation POST /libpod/secrets/create libpod libpodCreateSecret
	// ---
	// tags:
	//  - secrets
	// summary: Create a secret
	// parameters:
	//   - in: query
	//     name: name
	//     type: string
	//     description: User-defined name of the secret.
	//     required: true
	//   - in: query
	//     name: driver
	//     type: string
	//     description: Secret driver
	//     default: "file"
	//   - in: body
	//     name: request
	//     description: Secret
	//     schema:
	//       type: string
	// produces:
	// - application/json
	// responses:
	//   '201':
	//     $ref: "#/responses/SecretCreateResponse"
	//   '500':
	//      "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/libpod/secrets/create"), s.APIHandler(libpod.CreateSecret)).Methods(http.MethodPost)
	// swagger:operation GET /libpod/secrets/json libpod libpodListSecret
	// ---
	// tags:
	//  - secrets
	// summary: List secrets
	// description: Returns a list of secrets
	// produces:
	// - application/json
	// parameters:
	// responses:
	//   '200':
	//     "$ref": "#/responses/SecretListResponse"
	//   '500':
	//      "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/libpod/secrets/json"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet)
	// swagger:operation GET /libpod/secrets/{name}/json libpod libpodInspectSecret
	// ---
	// tags:
	//  - secrets
	// summary: Inspect secret
	// parameters:
	//  - in: path
	//    name: name
	//    type: string
	//    required: true
	//    description: the name or ID of the secret
	// produces:
	// - application/json
	// responses:
	//   '200':
	//     "$ref": "#/responses/SecretInspectResponse"
	//   '404':
	//     "$ref": "#/responses/NoSuchSecret"
	//   '500':
	//     "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/libpod/secrets/{name}/json"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet)
	// swagger:operation DELETE /libpod/secrets/{name} libpod libpodRemoveSecret
	// ---
	// tags:
	//  - secrets
	// summary: Remove secret
	// parameters:
	//  - in: path
	//    name: name
	//    type: string
	//    required: true
	//    description: the name or ID of the secret
	//  - in: query
	//    name: all
	//    type: boolean
	//    description: Remove all secrets
	//    default: false
	// produces:
	// - application/json
	// responses:
	//   '204':
	//     description: no error
	//   '404':
	//     "$ref": "#/responses/NoSuchSecret"
	//   '500':
	//     "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/libpod/secrets/{name}"), s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete)

	/*
	 * Docker compatibility endpoints
	 */
	// swagger:operation GET /secrets compat ListSecret
	// ---
	// tags:
	//  - secrets (compat)
	// summary: List secrets
	// description: Returns a list of secrets
	// produces:
	// - application/json
	// parameters:
	// responses:
	//   '200':
	//     "$ref": "#/responses/SecretListResponse"
	//   '500':
	//      "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/secrets"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet)
	r.Handle("/secrets", s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet)
	// swagger:operation POST /secrets/create compat CreateSecret
	// ---
	// tags:
	//  - secrets (compat)
	// summary: Create a secret
	// parameters:
	//  - in: body
	//    name: create
	//    description: |
	//      attributes for creating a secret
	//    schema:
	//      $ref: "#/definitions/SecretCreate"
	// produces:
	// - application/json
	// responses:
	//   '201':
	//     $ref: "#/responses/SecretCreateResponse"
	//   '409':
	//     "$ref": "#/responses/SecretInUse"
	//   '500':
	//      "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/secrets/create"), s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost)
	r.Handle("/secrets/create", s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost)
	// swagger:operation GET /secrets/{name} compat InspectSecret
	// ---
	// tags:
	//  - secrets (compat)
	// summary: Inspect secret
	// parameters:
	//  - in: path
	//    name: name
	//    type: string
	//    required: true
	//    description: the name or ID of the secret
	// produces:
	// - application/json
	// responses:
	//   '200':
	//     "$ref": "#/responses/SecretInspectResponse"
	//   '404':
	//     "$ref": "#/responses/NoSuchSecret"
	//   '500':
	//     "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet)
	r.Handle("/secrets/{name}", s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet)
	// swagger:operation DELETE /secrets/{name} compat RemoveSecret
	// ---
	// tags:
	//  - secrets (compat)
	// summary: Remove secret
	// parameters:
	//  - in: path
	//    name: name
	//    type: string
	//    required: true
	//    description: the name or ID of the secret
	// produces:
	// - application/json
	// responses:
	//   '204':
	//     description: no error
	//   '404':
	//     "$ref": "#/responses/NoSuchSecret"
	//   '500':
	//     "$ref": "#/responses/InternalError"
	r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete)
	r.Handle("/secret/{name}", s.APIHandler(compat.RemoveSecret)).Methods(http.MethodDelete)

	r.Handle(VersionedPath("/secrets/{name}/update"), s.APIHandler(compat.UpdateSecret)).Methods(http.MethodPost)
	r.Handle("/secrets/{name}/update", s.APIHandler(compat.UpdateSecret)).Methods(http.MethodPost)
	return nil
}