feat(core): Allow transferring credentials in Public API (#10259)
This commit is contained in:
@@ -142,6 +142,12 @@ export declare namespace CredentialRequest {
|
||||
>;
|
||||
|
||||
type Delete = AuthenticatedRequest<{ id: string }, {}, {}, Record<string, string>>;
|
||||
|
||||
type Transfer = AuthenticatedRequest<
|
||||
{ workflowId: string },
|
||||
{},
|
||||
{ destinationProjectId: string }
|
||||
>;
|
||||
}
|
||||
|
||||
export type OperationID = 'getUsers' | 'getUser';
|
||||
|
||||
@@ -19,6 +19,8 @@ import {
|
||||
toJsonSchema,
|
||||
} from './credentials.service';
|
||||
import { Container } from 'typedi';
|
||||
import { z } from 'zod';
|
||||
import { EnterpriseCredentialsService } from '@/credentials/credentials.service.ee';
|
||||
|
||||
export = {
|
||||
createCredential: [
|
||||
@@ -44,6 +46,20 @@ export = {
|
||||
}
|
||||
},
|
||||
],
|
||||
transferCredential: [
|
||||
projectScope('credential:move', 'credential'),
|
||||
async (req: CredentialRequest.Transfer, res: express.Response) => {
|
||||
const body = z.object({ destinationProjectId: z.string() }).parse(req.body);
|
||||
|
||||
await Container.get(EnterpriseCredentialsService).transferOne(
|
||||
req.user,
|
||||
req.params.workflowId,
|
||||
body.destinationProjectId,
|
||||
);
|
||||
|
||||
res.status(204).send();
|
||||
},
|
||||
],
|
||||
deleteCredential: [
|
||||
projectScope('credential:delete', 'credential'),
|
||||
async (
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
put:
|
||||
x-eov-operation-id: transferCredential
|
||||
x-eov-operation-handler: v1/handlers/credentials/credentials.handler
|
||||
tags:
|
||||
- Workflow
|
||||
summary: Transfer a credential to another project.
|
||||
description: Transfer a credential to another project.
|
||||
parameters:
|
||||
- $ref: '../schemas/parameters/credentialId.yml'
|
||||
requestBody:
|
||||
description: Destination project for the credential transfer.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
destinationProjectId:
|
||||
type: string
|
||||
description: The ID of the project to transfer the credential to.
|
||||
required:
|
||||
- destinationProjectId
|
||||
required: true
|
||||
responses:
|
||||
'200':
|
||||
description: Operation successful.
|
||||
'400':
|
||||
$ref: '../../../../shared/spec/responses/badRequest.yml'
|
||||
'401':
|
||||
$ref: '../../../../shared/spec/responses/unauthorized.yml'
|
||||
'404':
|
||||
$ref: '../../../../shared/spec/responses/notFound.yml'
|
||||
@@ -0,0 +1,6 @@
|
||||
name: id
|
||||
in: path
|
||||
description: The ID of the credential.
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
@@ -62,6 +62,8 @@ paths:
|
||||
$ref: './handlers/workflows/spec/paths/workflows.id.deactivate.yml'
|
||||
/workflows/{id}/transfer:
|
||||
$ref: './handlers/workflows/spec/paths/workflows.id.transfer.yml'
|
||||
/credentials/{id}/transfer:
|
||||
$ref: './handlers/credentials/spec/paths/credentials.id.transfer.yml'
|
||||
/workflows/{id}/tags:
|
||||
$ref: './handlers/workflows/spec/paths/workflows.id.tags.yml'
|
||||
/users:
|
||||
|
||||
Reference in New Issue
Block a user