Skip to content

Commit

Permalink
refactor: use new delete route
Browse files Browse the repository at this point in the history
  • Loading branch information
Looskie committed Oct 13, 2023
1 parent 21acf56 commit 9dba2f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/rest/types/ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
40 changes: 17 additions & 23 deletions src/sdks/ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 9dba2f6

Please sign in to comment.