delete_deployment
Delete a deployment record using the New Relic REST v2 API. Requires admin role permissions.
Instructions
Delete a deployment record (REST v2). Requires admin role permissions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application_id | Yes | ||
| id | Yes | ||
| confirm | Yes | ||
| region | No |
Implementation Reference
- src/tools/rest/deployments.ts:129-137 (handler)The delete handler function that executes the delete_deployment tool logic. It checks the confirm flag, constructs the REST API path, and calls client.delete().
async delete(args: DeleteDeploymentArgs): Promise<unknown> { if (args.confirm !== true) { throw new Error('delete_deployment: confirm must be true'); } const client = this.restFor(args.region); const path = `/applications/${args.application_id}/deployments/${args.id}`; const res = await client.delete<unknown>(path); return { ...res }; } - src/tools/rest/deployments.ts:20-25 (schema)Type definition (DeleteDeploymentArgs) for the delete_deployment tool's input parameters: application_id, id, confirm, and optional region.
type DeleteDeploymentArgs = { application_id: number; id: number; confirm: true; region?: Region; }; - getDeleteTool() returns the Tool definition including name 'delete_deployment', description, and JSON Schema input validation (application_id, id, confirm, region).
getDeleteTool(): Tool { return { name: 'delete_deployment', description: 'Delete a deployment record (REST v2). Requires admin role permissions.', inputSchema: { type: 'object', properties: { application_id: { type: 'number' }, id: { type: 'number' }, confirm: { type: 'boolean' }, region: { type: 'string', enum: ['US', 'EU'] }, }, required: ['application_id', 'id', 'confirm'], }, }; - src/server.ts:83-83 (registration)Tool registration: getDeleteTool() is called and added to the tools array in registerTools().
restDeployments.getDeleteTool(), - src/server.ts:183-186 (registration)Case handler in server.ts that routes the 'delete_deployment' tool call to RestDeploymentsTool.delete().
case 'delete_deployment': return await new RestDeploymentsTool().delete( args as Parameters<RestDeploymentsTool['delete']>[0] ); - src/client/rest-client.ts:109-124 (helper)The delete method on NewRelicRestClient that performs the HTTP DELETE request to the New Relic REST API v2.
async delete<T>(path: string): Promise<RestResponse<T>> { const url = this.buildUrl(path); const response = await fetch(url, { method: 'DELETE', headers: { 'Content-Type': 'application/json', 'Api-Key': this.apiKey, }, }); const links = parseLinkHeader(response.headers.get('link')); const data = (await response.json()) as T; if (!response.ok) { throw new Error(`REST API error: ${response.status} ${response.statusText}`); } return { status: response.status, data, links, url }; }