Skip to content

docs: update sdk api docs #46

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/dreadnode/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ groups: ["strikes"]

**Source file:** `__init__.py`

This module initializes the `dreadnode.api` package.

The `dreadnode.api` package provides the API layer for interacting with the
Dreadnode SDK. It includes modules and functions for handling requests,
responses, and other API-related functionality.

Modules in this package should be imported and used to facilitate communication
with external services or internal components of the Dreadnode system.

141 changes: 139 additions & 2 deletions docs/dreadnode/api/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ groups: ["strikes"]

**Source file:** `client.py`

This module provides the `ApiClient` class, which serves as a client for interacting

with the Dreadnode API. It includes methods for managing projects, runs, tasks, and
exporting data in various formats.

Dependencies:
- httpx
- pandas
- pydantic
- ulid
- dreadnode.util.logger
- dreadnode.version.VERSION

## Classes


Expand All @@ -19,87 +32,211 @@ groups: ["strikes"]

Client for the Dreadnode API.

This class provides methods to interact with the Dreadnode API, including
managing projects, runs, tasks, and exporting data.

**Parameters:**

- **`_base_url`** (`str`): The base URL of the API.
- **`_client`** (`httpx.Client`): The HTTP client used for making requests.

#### Methods

##### `__init__`

`__init__(...)`

Initialize self. See help(type(self)) for accurate signature.
Initializes the ApiClient.

**Parameters:**

- **`base_url`** (`str`): The base URL of the API.
- **`api_key`** (`str`): The API key for authentication.
- **`debug`** (`bool`) *(optional)*: Whether to enable debug logging. Defaults to False. Default: `False`

---

##### `export_metrics`

`export_metrics(...)`

Exports metric data for a specific project.

**Parameters:**

- **`project`** (`str`): The project identifier.
- **`filter`** (`str`) *(optional)*: A filter string. Defaults to None. Default: `None`
- **`status`** (`StatusFilter`) *(optional)*: The status filter. Defaults to "completed". Default: `"completed"`
- **`metrics`** (`list[str]`) *(optional)*: A list of metrics to include. Defaults to None. Default: `None`
- **`aggregations`** (`list[MetricAggregationType]`) *(optional)*: Aggregations to apply. Defaults to None. Default: `None`

**Returns:** `pd.DataFrame` — A DataFrame containing the exported data.

---

##### `export_parameters`

`export_parameters(...)`

Exports parameter data for a specific project.

**Parameters:**

- **`project`** (`str`): The project identifier.
- **`filter`** (`str`) *(optional)*: A filter string. Defaults to None. Default: `None`
- **`status`** (`StatusFilter`) *(optional)*: The status filter. Defaults to "completed". Default: `"completed"`
- **`parameters`** (`list[str]`) *(optional)*: A list of parameters to include. Defaults to None. Default: `None`
- **`metrics`** (`list[str]`) *(optional)*: A list of metrics to include. Defaults to None. Default: `None`
- **`aggregations`** (`list[MetricAggregationType]`) *(optional)*: Aggregations to apply. Defaults to None. Default: `None`

**Returns:** `pd.DataFrame` — A DataFrame containing the exported data.

---

##### `export_runs`

`export_runs(...)`

Exports run data for a specific project.

**Parameters:**

- **`project`** (`str`): The project identifier.
- **`filter`** (`str`) *(optional)*: A filter string. Defaults to None. Default: `None`
- **`status`** (`StatusFilter`) *(optional)*: The status filter. Defaults to "completed". Default: `"completed"`
- **`aggregations`** (`list[MetricAggregationType]`) *(optional)*: Aggregations to apply. Defaults to None. Default: `None`

**Returns:** `pd.DataFrame` — A DataFrame containing the exported data.

---

##### `export_timeseries`

`export_timeseries(...)`

Exports timeseries data for a specific project.

**Parameters:**

- **`project`** (`str`): The project identifier.
- **`filter`** (`str`) *(optional)*: A filter string. Defaults to None. Default: `None`
- **`status`** (`StatusFilter`) *(optional)*: The status filter. Defaults to "completed". Default: `"completed"`
- **`metrics`** (`list[str]`) *(optional)*: A list of metrics to include. Defaults to None. Default: `None`
- **`time_axis`** (`TimeAxisType`) *(optional)*: The time axis type. Defaults to "relative". Default: `"relative"`
- **`aggregations`** (`list[TimeAggregationType]`) *(optional)*: Aggregations to apply. Defaults to None. Default: `None`

**Returns:** `pd.DataFrame` — A DataFrame containing the exported data.

---

##### `get_project`

`get_project(...)`

Retrieves details of a specific project.

**Parameters:**

- **`project`** (`str`): The project identifier.

**Returns:** `Project` — The Project object.

---

##### `get_run`

`get_run(...)`

Retrieves details of a specific run.

**Parameters:**

- **`run`** (`Union[str, ULID]`): The run identifier.

**Returns:** `Run` — The Run object.

---

##### `get_run_tasks`

`get_run_tasks(...)`

Lists all tasks for a specific run.

**Parameters:**

- **`run`** (`Union[str, ULID]`): The run identifier.

**Returns:** `list[Task]` — A list of Task objects.

---

##### `get_run_trace`

`get_run_trace(...)`

Retrieves the trace spans for a specific run.

**Parameters:**

- **`run`** (`Union[str, ULID]`): The run identifier.

**Returns:** `Union[list[Task, TraceSpan]]` — A list of Task or TraceSpan objects.

---

##### `get_user_data_credentials`

`get_user_data_credentials(...)`

Retrieves user data credentials.

**Returns:** `UserDataCredentials` — The user data credentials.

---

##### `list_projects`

`list_projects(...)`

Lists all projects.

**Returns:** `list[Project]` — A list of Project objects.

---

##### `list_runs`

`list_runs(...)`

Lists all runs for a specific project.

**Parameters:**

- **`project`** (`str`): The project identifier.

**Returns:** `list[Run]` — A list of Run objects.

---

##### `request`

`request(...)`

Make a request to the API. Raise an exception for non-200 status codes.
Makes an HTTP request to the API and raises exceptions for errors.

**Parameters:**

- **`method`** (`str`): The HTTP method (e.g., "GET", "POST").
- **`path`** (`str`): The API endpoint path.
- **`params`** (`dict[str, t.Any]`) *(optional)*: Query parameters. Defaults to None. Default: `None`
- **`json_data`** (`dict[str, t.Any]`) *(optional)*: JSON payload. Defaults to None. Default: `None`

**Returns:** `httpx.Response` — The HTTP response object.

**Raises:**

- `RuntimeError` — If the response status code indicates an error.

---

Expand Down
Loading