From d0cc7bc71a27e5b0a74e282dd45dac9c5c5cffdd Mon Sep 17 00:00:00 2001 From: Anton Averchenkov <84287187+averche@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:46:01 -0400 Subject: [PATCH] openapi: Add display attributes for identity/ (remaining) (#19763) --- vault/identity_lookup.go | 12 +++++ vault/identity_store_upgrade.go | 84 +++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 8 deletions(-) diff --git a/vault/identity_lookup.go b/vault/identity_lookup.go index fd4d8484f..ad4903ad9 100644 --- a/vault/identity_lookup.go +++ b/vault/identity_lookup.go @@ -17,6 +17,12 @@ func lookupPaths(i *IdentityStore) []*framework.Path { return []*framework.Path{ { Pattern: "lookup/entity$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "entity", + OperationVerb: "look-up", + }, + Fields: map[string]*framework.FieldSchema{ "name": { Type: framework.TypeString, @@ -48,6 +54,12 @@ func lookupPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "lookup/group$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationVerb: "look-up", + }, + Fields: map[string]*framework.FieldSchema{ "name": { Type: framework.TypeString, diff --git a/vault/identity_store_upgrade.go b/vault/identity_store_upgrade.go index a3c507b47..56b82e1a6 100644 --- a/vault/identity_store_upgrade.go +++ b/vault/identity_store_upgrade.go @@ -14,6 +14,12 @@ func upgradePaths(i *IdentityStore) []*framework.Path { return []*framework.Path{ { Pattern: "persona$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "persona", + OperationVerb: "create", + }, + Fields: map[string]*framework.FieldSchema{ "id": { Type: framework.TypeString, @@ -49,6 +55,12 @@ vault metadata=key1=value1 metadata=key2=value2 }, { Pattern: "persona/id/" + framework.GenericNameRegex("id"), + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "persona", + OperationSuffix: "by-id", + }, + Fields: map[string]*framework.FieldSchema{ "id": { Type: framework.TypeString, @@ -75,10 +87,26 @@ vault metadata=key1=value1 metadata=key2=value2 `, }, }, - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.handleEntityUpdateCommon(), - logical.ReadOperation: i.pathAliasIDRead(), - logical.DeleteOperation: i.pathAliasIDDelete(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.handleEntityUpdateCommon(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "update", + }, + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathAliasIDRead(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "read", + }, + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathAliasIDDelete(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "delete", + }, + }, }, HelpSynopsis: strings.TrimSpace(aliasHelp["alias-id"][0]), @@ -86,6 +114,12 @@ vault metadata=key1=value1 metadata=key2=value2 }, { Pattern: "persona/id/?$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "persona", + OperationSuffix: "by-id", + }, + Callbacks: map[logical.Operation]framework.OperationFunc{ logical.ListOperation: i.pathAliasIDList(), }, @@ -95,6 +129,12 @@ vault metadata=key1=value1 metadata=key2=value2 }, { Pattern: "alias$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "alias", + OperationVerb: "create", + }, + Fields: map[string]*framework.FieldSchema{ "id": { Type: framework.TypeString, @@ -127,6 +167,12 @@ vault metadata=key1=value1 metadata=key2=value2 { Pattern: "alias/id/" + framework.GenericNameRegex("id"), + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "alias", + OperationSuffix: "by-id", + }, + Fields: map[string]*framework.FieldSchema{ "id": { Type: framework.TypeString, @@ -149,10 +195,26 @@ vault metadata=key1=value1 metadata=key2=value2 Description: "Name of the alias", }, }, - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.handleAliasCreateUpdate(), - logical.ReadOperation: i.pathAliasIDRead(), - logical.DeleteOperation: i.pathAliasIDDelete(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.handleAliasCreateUpdate(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "update", + }, + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathAliasIDRead(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "read", + }, + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathAliasIDDelete(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "delete", + }, + }, }, HelpSynopsis: strings.TrimSpace(aliasHelp["alias-id"][0]), @@ -160,6 +222,12 @@ vault metadata=key1=value1 metadata=key2=value2 }, { Pattern: "alias/id/?$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "alias", + OperationSuffix: "by-id", + }, + Callbacks: map[logical.Operation]framework.OperationFunc{ logical.ListOperation: i.pathAliasIDList(), },