Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add V2 endpoints for datasets, monitors, notifiers, users #59

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
63 changes: 49 additions & 14 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,33 @@
]
},
{
"group": "User endpoints",
"group": "Manage resources",
"pages": [
"restapi/manage-resources/overview",
"restapi/manage-resources/manage-datasets",
"restapi/manage-resources/manage-monitors",
"restapi/manage-resources/manage-notifiers",
"restapi/manage-resources/manage-users"
]
},
{
"group": "Annotation endpoints",
"pages": [
"restapi/endpoints/getCurrentUser"
"restapi/endpoints/getAnnotations",
"restapi/endpoints/getAnnotation",
"restapi/endpoints/createAnnotation",
"restapi/endpoints/updateAnnotation",
"restapi/endpoints/deleteAnnotation"
]
},
{
"group": "API token endpoints",
"pages": [
"restapi/endpoints/getTokens",
"restapi/endpoints/getToken",
"restapi/endpoints/createToken",
"restapi/endpoints/regenerateToken",
"restapi/endpoints/deleteToken"
]
},
{
Expand All @@ -498,23 +522,34 @@
]
},
{
"group": "Annotation endpoints",
"group": "Monitor endpoints",
"pages": [
"restapi/endpoints/getAnnotations",
"restapi/endpoints/getAnnotation",
"restapi/endpoints/createAnnotation",
"restapi/endpoints/updateAnnotation",
"restapi/endpoints/deleteAnnotation"
"restapi/endpoints/getMonitors",
"restapi/endpoints/getMonitor",
"restapi/endpoints/createMonitor",
"restapi/endpoints/updateMonitor",
"restapi/endpoints/deleteMonitor"
]
},
{
"group": "API token endpoints",
"group": "Notifier endpoints",
"pages": [
"restapi/endpoints/getTokens",
"restapi/endpoints/getToken",
"restapi/endpoints/createToken",
"restapi/endpoints/regenerateToken",
"restapi/endpoints/deleteToken"
"restapi/endpoints/getNotifiers",
"restapi/endpoints/getNotifier",
"restapi/endpoints/createNotifier",
"restapi/endpoints/updateNotifier",
"restapi/endpoints/deleteNotifier"
]
},
{
"group": "User endpoints",
"pages": [
"restapi/endpoints/getCurrentUser",
"restapi/endpoints/getUsers",
"restapi/endpoints/getUser",
"restapi/endpoints/createUser",
"restapi/endpoints/updateUser",
"restapi/endpoints/deleteUser"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion restapi/endpoints/createDataset.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Create dataset
openapi: "v1 post /datasets"
openapi: "v2 post /datasets"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/createMonitor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Create monitor
openapi: "v2 post /monitors"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/createNotifier.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Create notifier
openapi: "v2 post /notifiers"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/createUser.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Create user
openapi: "v2 post /users"
---
2 changes: 1 addition & 1 deletion restapi/endpoints/deleteDataset.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Delete dataset
openapi: "v1 delete /datasets/{id}"
openapi: "v2 delete /datasets/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/deleteMonitor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Delete monitor
openapi: "v2 delete /monitors/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/deleteNotifier.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Delete notifier
openapi: "v2 delete /notifiers/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/deleteUser.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Delete user
openapi: "v2 delete /users/{id}"
---
2 changes: 1 addition & 1 deletion restapi/endpoints/getCurrentUser.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Retrieve current user
openapi: "v1 get /user"
openapi: "v2 get /user"
---
2 changes: 1 addition & 1 deletion restapi/endpoints/getDataset.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Retrieve dataset
openapi: "v1 get /datasets/{id}"
openapi: "v2 get /datasets/{id}"
---
2 changes: 1 addition & 1 deletion restapi/endpoints/getDatasets.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: List all datasets
openapi: "v1 get /datasets"
openapi: "v2 get /datasets"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/getMonitor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Retrieve monitor
openapi: "v2 get /monitors/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/getMonitors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: List all monitors
openapi: "v2 get /monitors"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/getNotifier.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Retrieve notifier
openapi: "v2 get /notifiers/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/getNotifiers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: List all notifiers
openapi: "v2 get /notifiers"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/getUser.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Retrieve user
openapi: "v2 get /users/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/getUsers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: List all users
openapi: "v2 get /users"
---
2 changes: 1 addition & 1 deletion restapi/endpoints/trimDataset.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Trim dataset
openapi: "v1 post /datasets/{id}/trim"
openapi: "v2 post /datasets/{id}/trim"
---
2 changes: 1 addition & 1 deletion restapi/endpoints/updateDataset.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Update dataset
openapi: "v1 put /datasets/{id}"
openapi: "v2 put /datasets/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/updateMonitor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Update monitor
openapi: "v2 put /monitors/{id}"
---
4 changes: 4 additions & 0 deletions restapi/endpoints/updateNotifier.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Update notifier
openapi: "v2 put /notifiers/{id}"
---
10 changes: 10 additions & 0 deletions restapi/endpoints/updateUser.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Update user
openapi: "v2 put /users/{id}"
---

<Warning>
Using this endpoint, you can change the name of your own user. Authorize the request with a [personal access token (PAT)](/reference/tokens).

You cannot change the names of other users, you cannot change properties other than your name, and you cannot use an API token to authorize the request.
</Warning>
143 changes: 143 additions & 0 deletions restapi/manage-resources/manage-datasets.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
title: Manage datasets via API
sidebarTitle: "Datasets"
description: "Learn how to manage Axiom datasets via API."
tags: ['axiom documentation', 'documentation', 'axiom', 'axiom api', 'rest api', 'rest', 'authorization', 'headers', 'datasets', 'users', 'monitors', 'notifiers', 'response']
---

import Prerequisites from "/snippets/minimal-prerequisites.mdx"

This page explains how to manage datasets programmatically via the API.

<Prerequisites />
{/* list separator */}
- [Create an API token in Axiom](/reference/tokens) with permissions to create, read, update, and delete datasets.
- In the code samples below, replace `API_TOKEN` with the Axiom API token you have generated. For added security, store the API token in an environment variable.

## Create datasets

To create a dataset, send a POST request to the `datasets` endpoint. In the body of the request, specify the name and the description of the dataset. For example:

```bash
curl -X 'POST' 'https://api.axiom.co/v2/datasets' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer API_TOKEN' \
-d '{
"description": "This is a test dataset.",
"name": "test_dataset"
}'
```

The example response contains the dataset ID that you can later use to access the dataset programmatically.

```json
{
"created": "2024-04-20T02:35:14.137Z",
"description": "This is a test dataset.",
"id": "test_dataset",
"name": "test_dataset",
"who": ""
}
```

For more information, see the [API reference](/restapi/endpoints/createDataset).

## Get information about datasets

### Get information about all datasets

To get information about all the datasets in your Axiom organization, send a GET request to the `datasets` endpoint. For example:

```bash
curl -X 'GET' 'https://api.axiom.co/v2/datasets' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer API_TOKEN'
```

The example response is a list of dataset objects. Each object contains a unique dataset ID that you can later use to access the dataset programmatically.

```json
[
{
"created": "2024-04-20T02:35:14.137Z",
"description": "This is a test dataset.",
"id": "test_dataset1",
"name": "test_dataset1",
"who": ""
},
{
"created": "2024-04-20T02:35:24.137Z",
"description": "This is another test dataset.",
"id": "test_dataset2",
"name": "test_dataset2",
"who": ""
}
]
```

For more information, see the [API reference](/restapi/endpoints/getDatasets).

### Get information about specific dataset

To get information about a specific dataset, send a GET request to the `datasets/ID` endpoint where `ID` is the unique ID of the dataset. For example:

```bash
curl -X 'GET' 'https://api.axiom.co/v2/datasets/test_dataset' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer API_TOKEN'
```

Example response:

```json
[
{
"created": "2024-04-20T02:35:14.137Z",
"description": "This is a test dataset.",
"id": "test_dataset",
"name": "test_dataset",
"who": ""
},
]
```

For more information, see the [API reference](/restapi/endpoints/getDataset).

## Update datasets

To update a dataset, send a PUT request to the `datasets/ID` endpoint where `ID` is the unique ID of the dataset. In the body of the request, specify the properties you want to update. For example:

```bash
curl -X 'PUT' 'https://api.axiom.co/v2/datasets/test_dataset' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer API_TOKEN' \
-d '{
"description": "This is a production dataset."
}'
```

Example response:

```json
{
"created": "2024-04-20T02:35:14.137Z",
"description": "This is a production dataset.",
"id": "test_dataset",
"name": "test_dataset",
"who": ""
}
```

For more information, see the [API reference](/restapi/endpoints/updateDataset).

## Delete datasets

To delete a dataset, send a DELETE request to the `datasets/ID` endpoint where `ID` is the unique ID of the dataset. For example:

```bash
curl -X 'DELETE' 'https://api.axiom.co/v2/datasets/test_dataset' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer API_TOKEN'
```

For more information, see the [API reference](/restapi/endpoints/deleteDataset).
Loading