Skip to content

Commit 2c0dd01

Browse files
committed
Add endpoint to delete PIPE status
1 parent 35f9c0d commit 2c0dd01

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ The PIPE Queue service provides FIFO (First-In-First-Out) queues and status trac
346346
| POST | `/pipe/status` | Set status for a PIPE machine | `{"pipe_id": "string", "status": "string", "details": {}}` | Status details |
347347
| GET | `/pipe/status/{pipe_id}` | Get status of a specific PIPE machine | N/A | Status details |
348348
| GET | `/pipe/statuses` | Get status of all PIPE machines | N/A | Array of statuses |
349+
| DELETE | `/pipe/status/{pipe_id}` | Delete status of a specific PIPE machine | N/A | `{"message": "Status deleted for PIPE: pipe_id"}` |
350+
349351

350352
### Example Usage
351353

api/pipe_queue.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,37 @@ def set_pipe_status(event, context):
427427

428428
return http_response(HTTPStatus.OK, status_info)
429429

430+
def delete_pipe_status(event, context):
431+
"""Deletes the status of a PIPE machine.
432+
433+
Args:
434+
event.pathParameters.pipe_id (str): Identifier for the PIPE machine
435+
436+
Returns:
437+
200 status code if successful or if the PIPE status doesn't exist
438+
400 status code if the pipe_id is missing
439+
"""
440+
pipe_id = event['pathParameters']['pipe_id']
441+
442+
if not pipe_id:
443+
log.error("Missing required field: pipe_id")
444+
return http_response(
445+
HTTPStatus.BAD_REQUEST,
446+
"Missing required field: pipe_id"
447+
)
448+
449+
# Delete the status item
450+
PIPE_QUEUE_TABLE.delete_item(
451+
Key={
452+
'pk': f"STATUS#{pipe_id}",
453+
'sk': 'INFO'
454+
}
455+
)
456+
457+
return http_response(
458+
HTTPStatus.OK,
459+
{"message": f"Status deleted for PIPE: {pipe_id}"}
460+
)
430461

431462
def get_pipe_status_handler(event, context):
432463
"""Gets the status of a PIPE machine.
@@ -456,4 +487,4 @@ def get_all_pipe_statuses_handler(event, context):
456487
200 status code with status information for all PIPE machines
457488
"""
458489
statuses = get_all_pipe_statuses()
459-
return http_response(HTTPStatus.OK, statuses)
490+
return http_response(HTTPStatus.OK, statuses)

serverless.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,14 @@ functions:
452452
method: post
453453
cors: true
454454

455+
deletePipeStatus:
456+
handler: api/pipe_queue.delete_pipe_status
457+
events:
458+
- http:
459+
path: /pipe/status/{pipe_id}
460+
method: delete
461+
cors: true
462+
455463
getPipeStatus:
456464
handler: api/pipe_queue.get_pipe_status_handler
457465
events:

0 commit comments

Comments
 (0)