VAULT-12144: add openapi responses for /sys/seal endpoints (#18625)

* added responses to seal/unseal endpoints

Signed-off-by: Daniel Huckins <dhuckins@users.noreply.github.com>

* add response for /seal-status

Signed-off-by: Daniel Huckins <dhuckins@users.noreply.github.com>

* added change log

---------

Signed-off-by: Daniel Huckins <dhuckins@users.noreply.github.com>
This commit is contained in:
Daniel Huckins 2023-03-28 15:39:08 -04:00 committed by GitHub
parent e33b87a2c3
commit 4b52cea28c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 150 additions and 0 deletions

3
changelog/18625.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
openapi: add openapi response definitions to /sys/seal endpoints
```

View File

@ -958,6 +958,11 @@ func (b *SystemBackend) rekeyPaths() []*framework.Path {
Operations: map[logical.Operation]framework.OperationHandler{
logical.UpdateOperation: &framework.PathOperation{
Summary: "Seal the Vault.",
Responses: map[int][]framework.Response{
http.StatusNoContent: {{
Description: "OK",
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["seal"][0]),
@ -980,6 +985,77 @@ func (b *SystemBackend) rekeyPaths() []*framework.Path {
Operations: map[logical.Operation]framework.OperationHandler{
logical.UpdateOperation: &framework.PathOperation{
Summary: "Unseal the Vault.",
Responses: map[int][]framework.Response{
http.StatusOK: {{
// unseal returns `vault.SealStatusResponse` struct
Fields: map[string]*framework.FieldSchema{
"type": {
Type: framework.TypeString,
Required: true,
},
"initialized": {
Type: framework.TypeBool,
Required: true,
},
"sealed": {
Type: framework.TypeBool,
Required: true,
},
"t": {
Type: framework.TypeInt,
Required: true,
},
"n": {
Type: framework.TypeInt,
Required: true,
},
"progress": {
Type: framework.TypeInt,
Required: true,
},
"nonce": {
Type: framework.TypeString,
Required: true,
},
"version": {
Type: framework.TypeString,
Required: true,
},
"build_date": {
Type: framework.TypeString,
Required: true,
},
"migration": {
Type: framework.TypeBool,
Required: true,
},
"cluster_name": {
Type: framework.TypeString,
Required: false,
},
"cluster_id": {
Type: framework.TypeString,
Required: false,
},
"recovery_seal": {
Type: framework.TypeBool,
Required: true,
},
"storage_type": {
Type: framework.TypeString,
Required: false,
},
"hcp_link_status": {
Type: framework.TypeString,
Required: false,
},
"hcp_link_resource_ID": {
Type: framework.TypeString,
Required: false,
},
},
}},
},
},
},
@ -1058,6 +1134,77 @@ func (b *SystemBackend) statusPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.handleSealStatus,
Summary: "Check the seal status of a Vault.",
Responses: map[int][]framework.Response{
http.StatusOK: {{
// unseal returns `vault.SealStatusResponse` struct
Fields: map[string]*framework.FieldSchema{
"type": {
Type: framework.TypeString,
Required: true,
},
"initialized": {
Type: framework.TypeBool,
Required: true,
},
"sealed": {
Type: framework.TypeBool,
Required: true,
},
"t": {
Type: framework.TypeInt,
Required: true,
},
"n": {
Type: framework.TypeInt,
Required: true,
},
"progress": {
Type: framework.TypeInt,
Required: true,
},
"nonce": {
Type: framework.TypeString,
Required: true,
},
"version": {
Type: framework.TypeString,
Required: true,
},
"build_date": {
Type: framework.TypeString,
Required: true,
},
"migration": {
Type: framework.TypeBool,
Required: true,
},
"cluster_name": {
Type: framework.TypeString,
Required: false,
},
"cluster_id": {
Type: framework.TypeString,
Required: false,
},
"recovery_seal": {
Type: framework.TypeBool,
Required: true,
},
"storage_type": {
Type: framework.TypeString,
Required: false,
},
"hcp_link_status": {
Type: framework.TypeString,
Required: false,
},
"hcp_link_resource_ID": {
Type: framework.TypeString,
Required: false,
},
},
}},
},
},
},