vault/ui/lib/sync/addon/utils/api-method-resolver.ts
Vault Automation 31fb778a51
[UI] VAULT-42756 - Secret sync WIF implementation (#14001) (#14167)
* VAULT-42427 - initial code updates for aws form

* VAULT-42756 - implemented wif support for secret sync

* VAULT-42756 - added acceptance and integration test cases for WIF support

* refactor: streamline WIF credential handling and enhance destination details management

* added changelog

* fixed review comments

* updated changelog

* fixed failing tests

* fixed review comments

* fixed validation for Edit scenario

* fixed region field to have no default value selected

* Refactor: updated string literals with centralized enums and some other refactors

Co-authored-by: mohit-hashicorp <mohit.ojha@hashicorp.com>
2026-04-22 12:46:13 +05:30

26 lines
1.2 KiB
TypeScript

/**
* Copyright IBM Corp. 2016, 2025
* 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 { DestinationType } from 'sync/utils/constants';
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`;
}