openapi: Add display attributes for /sys (p2) (#19707)

This commit is contained in:
Anton Averchenkov 2023-04-13 11:32:57 -04:00 committed by GitHub
parent 254c5e2568
commit 14ac4fc045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 159 additions and 3 deletions

View File

@ -319,6 +319,11 @@ func rawPaths(prefix string, r *RawBackend) []*framework.Path {
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: r.handleRawRead, Callback: r.handleRawRead,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "raw",
OperationVerb: "read",
OperationSuffix: "|path",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusOK: {{ http.StatusOK: {{
Description: "OK", Description: "OK",
@ -334,6 +339,11 @@ func rawPaths(prefix string, r *RawBackend) []*framework.Path {
}, },
logical.UpdateOperation: &framework.PathOperation{ logical.UpdateOperation: &framework.PathOperation{
Callback: r.handleRawWrite, Callback: r.handleRawWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "raw",
OperationVerb: "write",
OperationSuffix: "|path",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusOK: {{ http.StatusOK: {{
Description: "OK", Description: "OK",
@ -343,6 +353,11 @@ func rawPaths(prefix string, r *RawBackend) []*framework.Path {
}, },
logical.CreateOperation: &framework.PathOperation{ logical.CreateOperation: &framework.PathOperation{
Callback: r.handleRawWrite, Callback: r.handleRawWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "raw",
OperationVerb: "write",
OperationSuffix: "|path",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusNoContent: {{ http.StatusNoContent: {{
Description: "OK", Description: "OK",
@ -352,6 +367,11 @@ func rawPaths(prefix string, r *RawBackend) []*framework.Path {
}, },
logical.DeleteOperation: &framework.PathOperation{ logical.DeleteOperation: &framework.PathOperation{
Callback: r.handleRawDelete, Callback: r.handleRawDelete,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "raw",
OperationVerb: "delete",
OperationSuffix: "|path",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusNoContent: {{ http.StatusNoContent: {{
Description: "OK", Description: "OK",
@ -361,6 +381,11 @@ func rawPaths(prefix string, r *RawBackend) []*framework.Path {
}, },
logical.ListOperation: &framework.PathOperation{ logical.ListOperation: &framework.PathOperation{
Callback: r.handleRawList, Callback: r.handleRawList,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "raw",
OperationVerb: "list",
OperationSuffix: "|path",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusOK: {{ http.StatusOK: {{
Description: "OK", Description: "OK",

View File

@ -21,6 +21,13 @@ import (
func (b *SystemBackend) activityQueryPath() *framework.Path { func (b *SystemBackend) activityQueryPath() *framework.Path {
return &framework.Path{ return &framework.Path{
Pattern: "internal/counters/activity$", Pattern: "internal/counters/activity$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "internal-client-activity",
OperationVerb: "report",
OperationSuffix: "counts",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"start_time": { "start_time": {
Type: framework.TypeTime, Type: framework.TypeTime,
@ -51,7 +58,14 @@ func (b *SystemBackend) activityQueryPath() *framework.Path {
// monthlyActivityCountPath is available in every namespace // monthlyActivityCountPath is available in every namespace
func (b *SystemBackend) monthlyActivityCountPath() *framework.Path { func (b *SystemBackend) monthlyActivityCountPath() *framework.Path {
return &framework.Path{ return &framework.Path{
Pattern: "internal/counters/activity/monthly$", Pattern: "internal/counters/activity/monthly$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "internal-client-activity",
OperationVerb: "report",
OperationSuffix: "counts-this-month",
},
HelpSynopsis: strings.TrimSpace(sysHelp["activity-monthly"][0]), HelpSynopsis: strings.TrimSpace(sysHelp["activity-monthly"][0]),
HelpDescription: strings.TrimSpace(sysHelp["activity-monthly"][1]), HelpDescription: strings.TrimSpace(sysHelp["activity-monthly"][1]),
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
@ -77,6 +91,11 @@ func (b *SystemBackend) rootActivityPaths() []*framework.Path {
b.monthlyActivityCountPath(), b.monthlyActivityCountPath(),
{ {
Pattern: "internal/counters/config$", Pattern: "internal/counters/config$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "internal-client-activity",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"default_report_months": { "default_report_months": {
Type: framework.TypeInt, Type: framework.TypeInt,
@ -99,16 +118,29 @@ func (b *SystemBackend) rootActivityPaths() []*framework.Path {
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handleActivityConfigRead, Callback: b.handleActivityConfigRead,
Summary: "Read the client count tracking configuration.", DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "read",
OperationSuffix: "configuration",
},
Summary: "Read the client count tracking configuration.",
}, },
logical.UpdateOperation: &framework.PathOperation{ logical.UpdateOperation: &framework.PathOperation{
Callback: b.handleActivityConfigUpdate, Callback: b.handleActivityConfigUpdate,
Summary: "Enable or disable collection of client count, set retention period, or set default reporting period.", DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
Summary: "Enable or disable collection of client count, set retention period, or set default reporting period.",
}, },
}, },
}, },
{ {
Pattern: "internal/counters/activity/export$", Pattern: "internal/counters/activity/export$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "internal-client-activity",
OperationVerb: "export",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"start_time": { "start_time": {
Type: framework.TypeTime, Type: framework.TypeTime,
@ -124,6 +156,7 @@ func (b *SystemBackend) rootActivityPaths() []*framework.Path {
Default: "json", Default: "json",
}, },
}, },
HelpSynopsis: strings.TrimSpace(sysHelp["activity-export"][0]), HelpSynopsis: strings.TrimSpace(sysHelp["activity-export"][0]),
HelpDescription: strings.TrimSpace(sysHelp["activity-export"][1]), HelpDescription: strings.TrimSpace(sysHelp["activity-export"][1]),

View File

@ -64,6 +64,12 @@ var (
return []*framework.Path{ return []*framework.Path{
{ {
Pattern: "replication/status", Pattern: "replication/status",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "replication",
OperationVerb: "status",
},
Callbacks: map[logical.Operation]framework.OperationFunc{ Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { logical.ReadOperation: func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
resp := &logical.Response{ resp := &logical.Response{

View File

@ -20,6 +20,11 @@ func (b *SystemBackend) pprofPaths() []*framework.Path {
{ {
Pattern: "pprof/$", Pattern: "pprof/$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "index",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofIndex, Callback: b.handlePprofIndex,
@ -38,6 +43,11 @@ render pages.`,
{ {
Pattern: "pprof/cmdline", Pattern: "pprof/cmdline",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "command-line",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofCmdline, Callback: b.handlePprofCmdline,
@ -54,6 +64,11 @@ render pages.`,
{ {
Pattern: "pprof/goroutine", Pattern: "pprof/goroutine",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "goroutines",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofGoroutine, Callback: b.handlePprofGoroutine,
@ -70,6 +85,11 @@ render pages.`,
{ {
Pattern: "pprof/heap", Pattern: "pprof/heap",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "memory-allocations-live",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofHeap, Callback: b.handlePprofHeap,
@ -86,6 +106,11 @@ render pages.`,
{ {
Pattern: "pprof/allocs", Pattern: "pprof/allocs",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "memory-allocations",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofAllocs, Callback: b.handlePprofAllocs,
@ -102,6 +127,11 @@ render pages.`,
{ {
Pattern: "pprof/threadcreate", Pattern: "pprof/threadcreate",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "thread-creations",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofThreadcreate, Callback: b.handlePprofThreadcreate,
@ -119,6 +149,11 @@ render pages.`,
{ {
Pattern: "pprof/block", Pattern: "pprof/block",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "blocking",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofBlock, Callback: b.handlePprofBlock,
@ -135,6 +170,11 @@ render pages.`,
{ {
Pattern: "pprof/mutex", Pattern: "pprof/mutex",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "mutexes",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofMutex, Callback: b.handlePprofMutex,
@ -151,6 +191,11 @@ render pages.`,
{ {
Pattern: "pprof/profile", Pattern: "pprof/profile",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "cpu-profile",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"seconds": { "seconds": {
Type: framework.TypeInt, Type: framework.TypeInt,
@ -174,6 +219,11 @@ render pages.`,
{ {
Pattern: "pprof/symbol", Pattern: "pprof/symbol",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "symbols",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handlePprofSymbol, Callback: b.handlePprofSymbol,
@ -191,6 +241,11 @@ render pages.`,
{ {
Pattern: "pprof/trace", Pattern: "pprof/trace",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
OperationVerb: "execution-trace",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"seconds": { "seconds": {
Type: framework.TypeInt, Type: framework.TypeInt,

View File

@ -21,6 +21,11 @@ func (b *SystemBackend) quotasPaths() []*framework.Path {
return []*framework.Path{ return []*framework.Path{
{ {
Pattern: "quotas/config$", Pattern: "quotas/config$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "rate-limit-quotas",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"rate_limit_exempt_paths": { "rate_limit_exempt_paths": {
Type: framework.TypeStringSlice, Type: framework.TypeStringSlice,
@ -38,6 +43,9 @@ func (b *SystemBackend) quotasPaths() []*framework.Path {
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.UpdateOperation: &framework.PathOperation{ logical.UpdateOperation: &framework.PathOperation{
Callback: b.handleQuotasConfigUpdate(), Callback: b.handleQuotasConfigUpdate(),
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusNoContent: {{ http.StatusNoContent: {{
Description: "OK", Description: "OK",
@ -46,6 +54,9 @@ func (b *SystemBackend) quotasPaths() []*framework.Path {
}, },
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handleQuotasConfigRead(), Callback: b.handleQuotasConfigRead(),
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "configuration",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusOK: {{ http.StatusOK: {{
Description: "OK", Description: "OK",
@ -72,6 +83,12 @@ func (b *SystemBackend) quotasPaths() []*framework.Path {
}, },
{ {
Pattern: "quotas/rate-limit/?$", Pattern: "quotas/rate-limit/?$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "rate-limit-quotas",
OperationVerb: "list",
},
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.ListOperation: &framework.PathOperation{ logical.ListOperation: &framework.PathOperation{
Callback: b.handleRateLimitQuotasList(), Callback: b.handleRateLimitQuotasList(),
@ -93,6 +110,11 @@ func (b *SystemBackend) quotasPaths() []*framework.Path {
}, },
{ {
Pattern: "quotas/rate-limit/" + framework.GenericNameRegex("name"), Pattern: "quotas/rate-limit/" + framework.GenericNameRegex("name"),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "rate-limit-quotas",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"type": { "type": {
Type: framework.TypeString, Type: framework.TypeString,
@ -131,6 +153,9 @@ from any further requests until after the 'block_interval' has elapsed.`,
Operations: map[logical.Operation]framework.OperationHandler{ Operations: map[logical.Operation]framework.OperationHandler{
logical.UpdateOperation: &framework.PathOperation{ logical.UpdateOperation: &framework.PathOperation{
Callback: b.handleRateLimitQuotasUpdate(), Callback: b.handleRateLimitQuotasUpdate(),
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "write",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusNoContent: {{ http.StatusNoContent: {{
Description: http.StatusText(http.StatusNoContent), Description: http.StatusText(http.StatusNoContent),
@ -139,6 +164,9 @@ from any further requests until after the 'block_interval' has elapsed.`,
}, },
logical.ReadOperation: &framework.PathOperation{ logical.ReadOperation: &framework.PathOperation{
Callback: b.handleRateLimitQuotasRead(), Callback: b.handleRateLimitQuotasRead(),
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "read",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusOK: {{ http.StatusOK: {{
Description: "OK", Description: "OK",
@ -177,6 +205,9 @@ from any further requests until after the 'block_interval' has elapsed.`,
}, },
logical.DeleteOperation: &framework.PathOperation{ logical.DeleteOperation: &framework.PathOperation{
Callback: b.handleRateLimitQuotasDelete(), Callback: b.handleRateLimitQuotasDelete(),
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "delete",
},
Responses: map[int][]framework.Response{ Responses: map[int][]framework.Response{
http.StatusNoContent: {{ http.StatusNoContent: {{
Description: "OK", Description: "OK",

View File

@ -72,6 +72,12 @@ func (b *SystemBackend) loginMFAPaths() []*framework.Path {
return []*framework.Path{ return []*framework.Path{
{ {
Pattern: "mfa/validate", Pattern: "mfa/validate",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "mfa",
OperationVerb: "validate",
},
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"mfa_request_id": { "mfa_request_id": {
Type: framework.TypeString, Type: framework.TypeString,