# Hype Group API [Revisited] ## Group API Endpoint List * [List group](#List-group) * [Create Group](#Create-Group) * [Delete Group](#Delete-Group) * [List Group IDs](#List-Group-IDs) * [Edit Group By ID](#Edit-Group-By-ID) * [Delete IDs from Group](#Delete-IDs-from-Group) ### List group **API:** GET `/api/v1/internal/groups?is_active=true&page=5&page_size=5` #### Request Params - `page` (int): which page to fetch - `page_size` (int): how many items to fetch at a time - `is_active` (boolean) - `type` (string): group type - `name` (string): group name - `id` (string): group id #### Response - `200 OK` ```json= { "meta": { "total_count": 14, "count": 2, "page_size": 4, "next": null, "previous": 3, "total_pages": 4, "extra": {} }, "data": [ { "id": "6184921d9042ef660fd92ad1", "created_at": "2021-11-05T02:08:29.593Z", "updated_at": "2021-11-05T02:08:29.593Z", "group_type": "user", "name": "TEST USER GROUP BY NEHA", "is_active": true, "is_imported": true, "ids_count": 0 }, { "id": "6184495b78be50ac4d2f6e5a", "created_at": "2021-11-05T01:04:54.548Z", "updated_at": "2021-11-05T01:04:54.548Z", "group_type": "user", "name": "BIGGROUP2-CLONE", "is_active": true, "is_imported": true, "ids_count": 0 } ] } ``` ### Create Group **API:** `POST /api/v1/internal/groups` #### Request Body Data should be provides as `"form-data"` - key: `group_ids_as_file` value: file - key: `group_ids_as_form` value: `{"name": "gr-hype-v7", "type":"user","ids":["10", "12"]}` #### New response - `201 Created` ```json= { "message": "Group is created", "upload_info": { "job_id": "618980964580aa123a3e5787", "file_url": "https://food-m.p-stageenv.xyz/hype-group/618980964580aa123a3e5787.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20211108%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211108T195502Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22618980964580aa123a3e5787.csv%22&X-Amz-Signature=587e890809aa2b0064574ec52888c2a288469f098f8279932ed172f61d777d17", "status": "PENDING" }, "ids_info": { "added": true }, "group": { "id": "618980964580aa123a3e5786", "created_at": "2021-11-08T19:55:02.160666259Z", "updated_at": "2021-11-08T19:55:02.160666259Z", "group_type": "user", "name": "gr-hype-v6", "is_active": false, "is_imported": false } } ``` - `500 Internal Server Error` ```json { "message": "; record already exists [base error: bad request, check param or body]" } ``` - `400 Bad Request` ```json= { "message": "bad data at key \"group_ids_as_form\" of form-data: unexpected end of JSON input [base error: bad request, check param or body]" } ``` ### Delete Group **API:** `DELETE /api/v1/internal/groups/618980964580aa123a3e5786` #### Response - `200 OK` ```json= { "message": "Group deleted successfully" } ``` ### List Group IDs **API:** `GET /api/v1/internal/groups/6184979b2ad5a7a4e4d9da20/ids?page_size=5&page=1` #### Response - `200 OK` ```json= { "meta": { "total_count": 145, "count": 5, "page_size": 5, "next": 2, "previous": null, "total_pages": 29, "extra": { "name": "TEST USER GROUP BY NEHA" } }, "data": [ "10131", "103240", "1055958", "1089362", "1153554" ] } ``` - `404 Not Found` ```json= { "message": "mongo: no documents in result [base error: resource not found]" } ``` - `400 Bad Request` ```json= { "message": "invalid page param [base error: bad request, check param or body]" } ``` ### Edit Group By ID **Old:** `POST /api/v1/internal/groups/6184979b2ad5a7a4e4d9da20/ids` #### Request Body Data should be provides as `"form-data"` - key: `group_ids_as_file` value: file - key: `group_ids_as_form` value: `{"name": "gr-hype-v7", "type":"user","ids":["10", "12"]}` #### Changes in response - `201 Created` ```json= { "upload_info": { "job_id": "618a3d99c4ade924531010f9", "file_url": "https://food-m.p-stageenv.xyz/hype-group/618a3d99c4ade924531010f9.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20211109%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211109T092130Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22618a3d99c4ade924531010f9.csv%22&X-Amz-Signature=145e098fb98ea9a51b8cbe100b8e5fd9deafb33ba75fb6e133c038b5981edb08", "status": "PENDING" }, "ids_info": { "added": true } } ``` - `400 Bad Request` ```json= { "message": "bad file at key \"group_ids_as_file\" of form-data: http: no such file [base error: bad request, check param or body]" } ``` - `500 Internal Server Error` ```json= { "upload_info": { "status": "UPLOAD_FAILED", "details": "failed to upload group file to minio: failed to make bucket: Get \"http://localhost:9000/hype-group/?location=\": dial tcp 127.0.0.1:9000: connect: connection refused" }, "ids_info": { "added": true } } ``` ### Delete IDs from Group **API:** `DELETE /api/v1/internal/groups/618a3c9106e5eb794329b743/ids` #### Response Body ```json= { "ids":[ "10", "12" ] } ``` #### Response - `200 OK` ```json= { "message": "Success" } ``` > NOTE: `ids_count` is removed ## Job API Endpoint List * [List Job](#List-Job) ### List Job **API:** GET `/api/v1/hype-v2/jobs?status=1&page=5&page_size=5` #### Request Params - `page` (int): which page to fetch - `page_size` (int): how many items to fetch at a time - `group_id`: jobs under a group (identified by id of a group) - `group_name`: jobs under a group (identified by tag name of a group) - `status` (int): default is 1 1: PENDING 2: SUCCESS 3: FAILED > Regex is supported for param `group_name`. #### Response - `200 OK` ```json= { "meta": { "total_count": 3, "count": 1, "page_size": 1, "next": null, "previous": 2, "total_pages": 3, "extra": {} }, "data": [ { "id": "61bf106e83b16ecbb60956dc", "group_id": "618483369042ef660fd924e1", "group_name": "mygroup", "file_url": "https://food-m.p-stageenv.xyz/hype-group/61bf106e83b16ecbb60956dc.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20211219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211219T105854Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%2261bf106e83b16ecbb60956dc.csv%22&X-Amz-Signature=f4d9c5c21f988af0d20ce8c6b2a2cb06661a8fa048e10794d939b638510a5f67", "status": 2, "created_at": "2021-12-19T10:58:54.498Z", "updated_at": "2021-12-19T10:59:00.549Z", "retry_cnt": 0, "reason": null } ] } ```