Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import type { Swagger } from "atlassian-openapi";

export const openapi: Swagger.SwaggerV3 = {
openapi: "3.0.0",
info: {
title: "Ctrlplane API",
version: "1.0.0",
},
paths: {
"/v1/deployments/{deploymentId}/release-channels/name/{name}": {
delete: {
summary: "Delete a release channel",
operationId: "deleteReleaseChannel",
parameters: [
{
name: "deploymentId",
in: "path",
required: true,
schema: { type: "string" },
},
{
name: "name",
in: "path",
required: true,
schema: { type: "string" },
},
],
responses: {
"200": {
description: "Release channel deleted",
content: {
"application/json": {
schema: {
type: "object",
properties: { message: { type: "string" } },
required: ["message"],
},
},
},
},
"403": {
description: "Permission denied",
content: {
"application/json": {
schema: {
type: "object",
properties: { error: { type: "string" } },
required: ["error"],
},
},
},
},
"404": {
description: "Release channel not found",
content: {
"application/json": {
schema: {
type: "object",
properties: { error: { type: "string" } },
required: ["error"],
},
},
},
},
"500": {
description: "Failed to delete release channel",
content: {
"application/json": {
schema: {
type: "object",
properties: { error: { type: "string" } },
required: ["error"],
},
},
},
},
},
},
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { NextResponse } from "next/server";

import { and, eq } from "@ctrlplane/db";
import * as schema from "@ctrlplane/db/schema";
import { Permission } from "@ctrlplane/validators/auth";

import { authn, authz } from "~/app/api/v1/auth";
import { request } from "~/app/api/v1/middleware";

export const DELETE = request()
.use(authn)
.use(
authz(async ({ can, extra: { deploymentId } }) =>
can
.perform(Permission.ReleaseChannelDelete)
.on({ type: "deployment", id: deploymentId }),
),
)
.handle<unknown, { params: { deploymentId: string; name: string } }>(
async (ctx, { params }) => {
try {
await ctx.db
.delete(schema.releaseChannel)
.where(
and(
eq(schema.releaseChannel.deploymentId, params.deploymentId),
eq(schema.releaseChannel.name, params.name),
),
);

return NextResponse.json(
{ message: "Release channel deleted" },
{ status: 200 },
);
} catch {
return NextResponse.json(
{ error: "Failed to delete release channel" },
{ status: 500 },
);
}
},
);
98 changes: 98 additions & 0 deletions openapi.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,104 @@
"version": "1.0.0"
},
"paths": {
"/v1/deployments/{deploymentId}/release-channels/name/{name}": {
"delete": {
"summary": "Delete a release channel",
"operationId": "deleteReleaseChannel",
"parameters": [
{
"name": "deploymentId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Release channel deleted",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
},
"required": [
"message"
]
}
}
}
},
"403": {
"description": "Permission denied",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
}
}
}
},
"404": {
"description": "Release channel not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
}
}
}
},
"500": {
"description": "Failed to delete release channel",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
}
}
}
}
}
}
},
"/v1/environments/{environmentId}": {
"get": {
"summary": "Get an environment",
Expand Down
Loading