From 9dba2f64804fbab3599ddb2a17cb671b98eec75f Mon Sep 17 00:00:00 2001 From: Cody Miller Date: Fri, 13 Oct 2023 17:43:29 -0400 Subject: [PATCH] refactor: use new delete route --- src/rest/types/ignite.ts | 2 +- src/sdks/ignite.ts | 40 +++++++++++++++++----------------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/rest/types/ignite.ts b/src/rest/types/ignite.ts index 3ceecd34..49e6fa35 100644 --- a/src/rest/types/ignite.ts +++ b/src/rest/types/ignite.ts @@ -1143,4 +1143,4 @@ export type IgniteEndpoints = {group: Group} > | Endpoint<'DELETE', '/v1/ignite/groups/:group_id', Empty> - | Endpoint<"DELETE", "/v1/ignite/groups/:group_id/:deployment_id", Empty> + | Endpoint<'DELETE', '/v1/ignite/deployments/:deployment_id/group', Empty>; diff --git a/src/sdks/ignite.ts b/src/sdks/ignite.ts index d4b89e14..c312af27 100644 --- a/src/sdks/ignite.ts +++ b/src/sdks/ignite.ts @@ -366,9 +366,12 @@ export const ignite = sdk(client => { return group; }, + /** + * Moves a deployment to a group, or removes it if groupId is null + */ async move( deploymentId: Id<'deployment'>, - groupId: Id<'deployment_group'>, + groupId: Id<'deployment_group'> | null, projectId?: Id<'project'>, ) { if (client.authType !== 'ptk' && !projectId) { @@ -377,6 +380,19 @@ export const ignite = sdk(client => { ); } + if (groupId === null) { + await client.delete( + '/v1/ignite/deployments/:deployment_id/group', + undefined, + { + deployment_id: deploymentId, + ...(projectId ? {project: projectId} : {}), + }, + ); + + return; + } + const {group} = await client.put( '/v1/ignite/groups/:group_id/deployments/:deployment_id', undefined, @@ -390,28 +406,6 @@ export const ignite = sdk(client => { return group; }, - async remove( - deploymentId: Id<'deployment'>, - groupId: Id<'deployment_group'>, - projectId: Id<'project'>, - ) { - if (client.authType !== 'ptk' && !projectId) { - throw new Error( - 'Project ID is required for Bearer or PAT authentication', - ); - } - - await client.delete( - '/v1/ignite/groups/:group_id/:deployment_id', - undefined, - { - group_id: groupId, - deployment_id: deploymentId, - ...(projectId ? {project: projectId} : {}), - }, - ); - }, - async delete(groupId: Id<'deployment_group'>, projectId?: Id<'project'>) { if (client.authType !== 'ptk' && !projectId) { throw new Error(