Skip to content

Commit

Permalink
feat: add delete endpoint (#345)
Browse files Browse the repository at this point in the history
Signed-off-by: Pratiksha Sankhe <sankhepratiksha3@gmail.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
psankhe28 and sourcery-ai[bot] authored Aug 13, 2024
1 parent eee53e9 commit b38957d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/ecc-client-elixir-drs-filer/src/API/Object/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ Posts/Create a new object.
| | | This should be an object containing the necessary fields for the object. |
| | | Modify the structure according to your object requirements. |

## deleteObject

Deletes a specific DRS object.

**API Request Body**

| Parameter | Type | Description |
| --------- | ------ | ------------------------------ |
| `baseURL` | string | Base URL for deleting object |
| `id` | string | ID of the object to be deleted |


![Logo]('./../../../../images/logo-elixir.svg)
![Logo]('./../../../../images/logo-elixir-cloud-aai.svg)
Expand Down
39 changes: 38 additions & 1 deletion packages/ecc-client-elixir-drs-filer/src/API/Object/drsAPI.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Posts a new drs object.
* @param {string} baseURL - The base URL for posting the drs object.
* @param {object} objectData - The data of the drs object to be posted.
* This should be an object containing the necessary fields for the drs object.
* Modify the structure according to your object requirements.
* @returns {string} - A string that denotes the object id
*/
const postObject = async (baseURL: string, objectData: object) => {
const url = `${baseURL}/objects`;

Expand Down Expand Up @@ -28,4 +36,33 @@ const postObject = async (baseURL: string, objectData: object) => {
}
};

export { postObject };
/**
*This method deletes a specific object
* @param id ID of the drs obeject to be deleted
*/
const deleteObject = async (baseURL: string, id: string) => {
const url = `${baseURL}/objects/${id}`;
try {
const response = await fetch(url, {
method: "DELETE",
});

if (!response) {
return {
isError: true,
breakpoint: "deleteObject",
error: "No response from server",
};
}

return await response.json();
} catch (error) {
return {
isError: true,
breakpoint: "deleteObject",
error,
};
}
};

export { postObject, deleteObject };
2 changes: 1 addition & 1 deletion packages/ecc-client-elixir-drs-filer/src/API/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import "./Object/drsAPI.js";
import "./Object/drsAPI.js";

Check failure on line 1 in packages/ecc-client-elixir-drs-filer/src/API/index.ts

View workflow job for this annotation

GitHub Actions / Linting checks

Insert `⏎`

0 comments on commit b38957d

Please sign in to comment.