mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 15:11:07 +02:00
* adds field group support to forms * adds forms for sync destination types * adds type for sync destination form * adds readonlyParams to sync-destinations helper and error handling to findDestination util * updates sync destinations create/edit routes to use forms * updates sync create-and-edit component to use form class and api service * updates sync destinations tests
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
/**
|
|
* Util that resolves the API client method name for a given action and destination type
|
|
* Typically both type and name would be defined as params -> /sys/sync/destinations/{type}/{name}
|
|
* This would result in a method on the API client like systemReadSyncDestinations('aws-sm', 'my-destination')
|
|
* This unfortunately is not the case and type was hardcoded in the path -> /sys/sync/destinations/aws-sm/{name}
|
|
* This results in GET, POST and DELETE methods for each destination type -> systemReadSyncDestinationsAwsSmName('my-destination')
|
|
* Since these are used in numerous places, this util was created to more easily resolve the method name
|
|
*/
|
|
|
|
import { capitalize, classify } from '@ember/string';
|
|
|
|
import type { DestinationType } from 'vault/sync';
|
|
|
|
type TypeKey = 'AwsSm' | 'AzureKv' | 'GcpSm' | 'Gh' | 'VercelProject';
|
|
|
|
export default function apiMethodResolver(
|
|
action: 'read' | 'write' | 'delete' | 'patch',
|
|
type: DestinationType
|
|
) {
|
|
const method = `system${capitalize(action)}SyncDestinations${classify(type)}Name`;
|
|
return method as `system${Capitalize<typeof action>}SyncDestinations${TypeKey}Name`;
|
|
}
|