From 31e123f7a05aa358d766d21aca7c975ae2eec0f7 Mon Sep 17 00:00:00 2001 From: Anton Averchenkov <84287187+averche@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:45:12 -0400 Subject: [PATCH] openapi: Add display attributes for identity/group (#19762) --- vault/identity_store_group_aliases.go | 44 ++++++++++++-- vault/identity_store_groups.go | 84 +++++++++++++++++++++++---- 2 files changed, 113 insertions(+), 15 deletions(-) diff --git a/vault/identity_store_group_aliases.go b/vault/identity_store_group_aliases.go index c6e776906..4a003a84d 100644 --- a/vault/identity_store_group_aliases.go +++ b/vault/identity_store_group_aliases.go @@ -19,6 +19,13 @@ func groupAliasPaths(i *IdentityStore) []*framework.Path { return []*framework.Path{ { Pattern: "group-alias$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationVerb: "create", + OperationSuffix: "alias", + }, + Fields: map[string]*framework.FieldSchema{ "id": { Type: framework.TypeString, @@ -37,6 +44,7 @@ func groupAliasPaths(i *IdentityStore) []*framework.Path { Description: "ID of the group to which this is an alias.", }, }, + Callbacks: map[logical.Operation]framework.OperationFunc{ logical.UpdateOperation: i.pathGroupAliasRegister(), }, @@ -46,6 +54,12 @@ func groupAliasPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "group-alias/id/" + framework.GenericNameRegex("id"), + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationSuffix: "alias-by-id", + }, + Fields: map[string]*framework.FieldSchema{ "id": { Type: framework.TypeString, @@ -64,10 +78,26 @@ func groupAliasPaths(i *IdentityStore) []*framework.Path { Description: "ID of the group to which this is an alias.", }, }, - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.pathGroupAliasIDUpdate(), - logical.ReadOperation: i.pathGroupAliasIDRead(), - logical.DeleteOperation: i.pathGroupAliasIDDelete(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.pathGroupAliasIDUpdate(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "update", + }, + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathGroupAliasIDRead(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "read", + }, + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathGroupAliasIDDelete(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "delete", + }, + }, }, HelpSynopsis: strings.TrimSpace(groupAliasHelp["group-alias-by-id"][0]), @@ -75,6 +105,12 @@ func groupAliasPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "group-alias/id/?$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationSuffix: "aliases-by-id", + }, + Callbacks: map[logical.Operation]framework.OperationFunc{ logical.ListOperation: i.pathGroupAliasIDList(), }, diff --git a/vault/identity_store_groups.go b/vault/identity_store_groups.go index bc74e76b5..3ba22abeb 100644 --- a/vault/identity_store_groups.go +++ b/vault/identity_store_groups.go @@ -62,7 +62,13 @@ func groupPaths(i *IdentityStore) []*framework.Path { return []*framework.Path{ { Pattern: "group$", - Fields: groupPathFields(), + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationVerb: "create", + }, + + Fields: groupPathFields(), Callbacks: map[logical.Operation]framework.OperationFunc{ logical.UpdateOperation: i.pathGroupRegister(), }, @@ -72,11 +78,33 @@ func groupPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "group/id/" + framework.GenericNameRegex("id"), - Fields: groupPathFields(), - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.pathGroupIDUpdate(), - logical.ReadOperation: i.pathGroupIDRead(), - logical.DeleteOperation: i.pathGroupIDDelete(), + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationSuffix: "by-id", + }, + + Fields: groupPathFields(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.pathGroupIDUpdate(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "update", + }, + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathGroupIDRead(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "read", + }, + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathGroupIDDelete(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "delete", + }, + }, }, HelpSynopsis: strings.TrimSpace(groupHelp["group-by-id"][0]), @@ -84,6 +112,12 @@ func groupPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "group/id/?$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationSuffix: "by-id", + }, + Callbacks: map[logical.Operation]framework.OperationFunc{ logical.ListOperation: i.pathGroupIDList(), }, @@ -93,11 +127,33 @@ func groupPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "group/name/(?P.+)", - Fields: groupPathFields(), - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.UpdateOperation: i.pathGroupNameUpdate(), - logical.ReadOperation: i.pathGroupNameRead(), - logical.DeleteOperation: i.pathGroupNameDelete(), + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationSuffix: "by-name", + }, + + Fields: groupPathFields(), + + Operations: map[logical.Operation]framework.OperationHandler{ + logical.UpdateOperation: &framework.PathOperation{ + Callback: i.pathGroupNameUpdate(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "update", + }, + }, + logical.ReadOperation: &framework.PathOperation{ + Callback: i.pathGroupNameRead(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "read", + }, + }, + logical.DeleteOperation: &framework.PathOperation{ + Callback: i.pathGroupNameDelete(), + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "delete", + }, + }, }, HelpSynopsis: strings.TrimSpace(groupHelp["group-by-name"][0]), @@ -105,6 +161,12 @@ func groupPaths(i *IdentityStore) []*framework.Path { }, { Pattern: "group/name/?$", + + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "group", + OperationSuffix: "by-name", + }, + Callbacks: map[logical.Operation]framework.OperationFunc{ logical.ListOperation: i.pathGroupNameList(), },