From cbbe8771318768d67849d773eb40ed6c25b96c33 Mon Sep 17 00:00:00 2001 From: Jeremy PLANCKEEL Date: Mon, 18 Mar 2024 15:09:22 +0100 Subject: [PATCH] docs: add docs forr events and lock Signed-off-by: Jeremy PLANCKEEL --- README.md | 95 ++--------------------------------------- docs/events.md | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/locks.md | 68 +++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 91 deletions(-) create mode 100644 docs/events.md create mode 100644 docs/locks.md diff --git a/README.md b/README.md index 0f4e298..bf98290 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Each time an event is created, we create a log in json format, which enables tra - [x] Link a pull_request to an event - [x] Calculates the time between two linked events - [ ] Cli to create and search event -- [ ] Lock deployment endpoint +- [x] Lock deployment endpoint - [ ] Add to cli lock and unlock function - [ ] Config file for cli - [ ] function search event of the day on cli @@ -64,98 +64,11 @@ To run test: make test ``` +## Documentations -## Grpc Call +### Events -You can use Grpcurl to call grpc api - -### Create an Event - -```bash -grpcurl --plaintext -d '{ - "attributes": { - "message": "deployment service serverless version v0.0.1", - "priority": "1", - "service": "service-event", - "source": "github_action", - "status": "1", - "type": "1" - }, - "links": { - "pull_request_link": "https://github.com/bananaops/tracker/pull/240" - }, - "title": "Deployment service lambda" -}' localhost:8765 tracker.event.v1alpha1.EventService/CreateEvent - -``` - -### List Events - -```bash -grpcurl --plaintext localhost:8765 tracker.event.v1alpha1.EventService/ListEvents - -``` - -### Get Event Id - -```bash -grpcurl --plaintext -d '{ - "id": "3ac2d880-ad52-4d50-b60d-9b44f54ae58f" -}' localhost:8765 tracker.event.v1alpha1.EventService/GetEvent - -``` - -### Get Search Event - -```bash -// With Priority P1 -grpcurl --plaintext -d '{ - "priority": "1" -}' localhost:8765 tracker.event.v1alpha1.EventService/SearchEvents - -// With Priority P1 and Start Date -grpcurl --plaintext -d '{ - "priority": "1", - "start_date": "2024-02-27" -}' localhost:8765 tracker.event.v1alpha1.EventService/SearchEvents - -// With Priority P1 and End Date -grpcurl --plaintext -d '{ - "priority": "1", - "end_date": "2024-02-28T15:04:05-07:00" -}' localhost:8765 tracker.event.v1alpha1.EventService/SearchEvents - -``` - -### Create Lock - -```bash -grpcurl --plaintext -d '{ - "service": "tracker-service", - "who": "jplanckeel" -}' localhost:8765 tracker.lock.v1alpha1.LockService/CreateLock -``` -### Get Lock - -```bash -grpcurl --plaintext -d '{ - "id": "2db91b8b-84ab-4e20-86e0-2104366bec5e" -}' localhost:8765 tracker.lock.v1alpha1.LockService/GetLock -``` - -### Delete Lock - -```bash -grpcurl --plaintext -d '{ - "id": "2db91b8b-84ab-4e20-86e0-2104366bec5e" -}' localhost:8765 tracker.lock.v1alpha1.LockService/UnLock -``` - -### List Locks - -```bash -grpcurl --plaintext localhost:8765 tracker.lock.v1alpha1.LockService/ListLocks -``` +### Locks ## Contributing diff --git a/docs/events.md b/docs/events.md new file mode 100644 index 0000000..1b90814 --- /dev/null +++ b/docs/events.md @@ -0,0 +1,113 @@ +# Events Documentation + +## Grpc Call + +You can use Grpcurl to call grpc api + +### Create an Event + +```bash +grpcurl --plaintext -d '{ + "attributes": { + "message": "deployment service serverless version v0.0.1", + "priority": "1", + "service": "service-event", + "source": "github_action", + "status": "1", + "type": "1" + }, + "links": { + "pull_request_link": "https://github.com/bananaops/tracker/pull/240" + }, + "title": "Deployment service lambda" +}' localhost:8765 tracker.event.v1alpha1.EventService/CreateEvent + +``` + +### List Events + +```bash +grpcurl --plaintext localhost:8765 tracker.event.v1alpha1.EventService/ListEvents + +``` + +### Get Event Id + +```bash +grpcurl --plaintext -d '{ + "id": "3ac2d880-ad52-4d50-b60d-9b44f54ae58f" +}' localhost:8765 tracker.event.v1alpha1.EventService/GetEvent + +``` + +### Get Search Event + +```bash +// With Priority P1 +grpcurl --plaintext -d '{ + "priority": "1" +}' localhost:8765 tracker.event.v1alpha1.EventService/SearchEvents + +// With Priority P1 and Start Date +grpcurl --plaintext -d '{ + "priority": "1", + "start_date": "2024-02-27" +}' localhost:8765 tracker.event.v1alpha1.EventService/SearchEvents + +// With Priority P1 and End Date +grpcurl --plaintext -d '{ + "priority": "1", + "end_date": "2024-02-28T15:04:05-07:00" +}' localhost:8765 tracker.event.v1alpha1.EventService/SearchEvents + +``` + +## Rest Call + +### Create an Event + +```bash +curl -X POST localhost:8080/api/v1alpha1/event -d ' +{ + "title": "Deployment service lambda", + "attributes": { + "message": "deployment service version v0.0.1", + "source": "github_action", + "type": 1, + "priority": 1, + "relatedId": "", + "service": "service-event", + "status": 1 + }, + "links": { + "pullRequestLink": "https://github.com/bananaops/events-tracker/pull/240" + } +}' +``` + + +### List Events + +```bash +curl "http://localhost:8080/api/v1alpha1/events/list" +``` + +### Get Event Id + +```bash +curl "localhost:8080/api/v1alpha1/event/a5fa1d90-44c9-4d4a-a436-930a9ee37e79" +``` + +### Get Search Event + +```bash +// With Priority P3 +curl "localhost:8080/api/v1alpha1/events/search?priority=3" + +// With Priority P1 and Start Date +curl "localhost:8080/api/v1alpha1/events/search?start_date=2024-03-01" + +// With Priority P1 and End Date +curl "localhost:8080/api/v1alpha1/events/search?end_date=2024-03-01" + +``` diff --git a/docs/locks.md b/docs/locks.md new file mode 100644 index 0000000..acf6c50 --- /dev/null +++ b/docs/locks.md @@ -0,0 +1,68 @@ +# Lock Documentation + +## Grpc Call + +You can use Grpcurl to call grpc api + + +### Create Lock + +```bash +grpcurl --plaintext -d '{ + "service": "tracker-service", + "who": "jplanckeel" +}' localhost:8765 tracker.lock.v1alpha1.LockService/CreateLock +``` + +### List Locks + +```bash +grpcurl --plaintext localhost:8765 tracker.lock.v1alpha1.LockService/ListLocks +``` + +### Get Lock + +```bash +grpcurl --plaintext -d '{ + "id": "2db91b8b-84ab-4e20-86e0-2104366bec5e" +}' localhost:8765 tracker.lock.v1alpha1.LockService/GetLock +``` + +### Delete Lock + +```bash +grpcurl --plaintext -d '{ + "id": "2db91b8b-84ab-4e20-86e0-2104366bec5e" +}' localhost:8765 tracker.lock.v1alpha1.LockService/UnLock +``` + +## Rest Call + + +### Create Lock + +```bash +curl -X POST localhost:8080/api/v1alpha1/lock -d ' +{ + "service": "tracker-service", + "who": "jplanckeel" +}' +``` + +### List Locks + +```bash +curl "localhost:8080/api/v1alpha1/locks/list" +``` + +### Get Lock + +```bash +curl "localhost:8080/api/v1alpha1/lock/57fcab51-c8ab-4f92-8d10-b41e456e8354" +``` + +### Delete Lock + +```bash +curl -X DELETE "localhost:8080/api/v1alpha1/unlock/e8ac122e-13cb-4abe-a127-98ec87acfb77" +```