Skip to content

Commit

Permalink
misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzou committed Mar 28, 2024
1 parent ed5a18d commit 3e42f43
Showing 1 changed file with 28 additions and 47 deletions.
75 changes: 28 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
# datadog-api-client-rust
# Datadog API Client

This repository contains a Rust API client for the [Datadog API](https://docs.datadoghq.com/api/).
Rust HTTP client for the [Datadog API](https://docs.datadoghq.com/api/).

For more information, please visit [https://www.datadoghq.com/support/](https://www.datadoghq.com/support/)
To submit support or feature requests, please visit [https://www.datadoghq.com/support/](https://www.datadoghq.com/support/)

## Overview

This API client was generated from OpenAPI specs by code and templates in the `.generator/` folder.

## Requirements

Building this API client library requires:
``TODO``
This API client was generated from Datadog's public OpenAPI specs. Generator code and templates can be found in the repository's `.generator/` folder.

## Installation

Add the following to `Cargo.toml` under `[dependencies]`:
Run `cargo add datadog-api-client` or add the following to `Cargo.toml` under `[dependencies]`:

```
datadog-api-client = { git = "ssh://[email protected]/DataDog/datadog-api-client-rust.git", branch = "master" }
datadog-api-client = "0.0.1"
```

## Getting Started

Please follow the [installation](#installation) instruction and execute the following Rust code:
Please follow the [installation](#installation) instructions and try the following snippet to validate your Datadog API key:

```Rust
use datadog_api_client::datadog::configuration::Configuration;
use datadog_api_client::datadogV1::api::api_monitors::{MonitorsAPI, GetMonitorOptionalParams};
use datadog_api_client::datadogV1::api::api_authentication::AuthenticationAPI;

#[tokio::main]
async fn main() {
env_logger::init();
let configuration = Configuration::new();
let monitors_api = MonitorsAPI::with_config(configuration.clone());

let mut monitor_payload = GetMonitorOptionalParams::default();
monitor_payload.group_states("all".into());

let resp = monitors_api.get_monitor(1234567, monitor_payload).await;
if let Ok(Some(value)) = resp {
let api = AuthenticationAPI::with_config(configuration);
let resp = api.validate().await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
Expand All @@ -53,39 +43,30 @@ By default the library will use the `DD_API_KEY` and `DD_APP_KEY` environment va
To provide your own set of credentials, you need to set some keys on the configuration:

```rust
configuration.set_auth_key(
"apiKeyAuth",
APIKey {
key: "<DD-API-KEY>".to_string(),
prefix: "".to_owned(),
},
);
configuration.set_auth_key(
"appKeyAuth",
APIKey {
key: "<DD-APP-KEY>".to_string(),
prefix: "".to_owned(),
},
);

configuration.set_auth_key(
"apiKeyAuth",
APIKey {
key: "<DD-API-KEY>".to_string(),
prefix: "".to_owned(),
},
);
configuration.set_auth_key(
"appKeyAuth",
APIKey {
key: "<DD-APP-KEY>".to_string(),
prefix: "".to_owned(),
},
);
```

### Unstable Endpoints

This client includes access to Datadog API endpoints while they are in an unstable state and may undergo breaking changes. An extra configuration step is required to enable these endpoints:
This client includes access to Datadog API endpoints while they are in an unstable state and may undergo breaking changes. An extra configuration step is required to use these endpoints:

```rust
configuration.set_unstable_operation_enabled(<OPERATION_NAME>, True )
```
where <OPERATION_NAME> is the API version and name of the method used to interact with that endpoint. For example: `v2.list_incidents`, or `v2.query_timeseries_data`

## Documentation for API Endpoints

To get access to the crate's generated documentation, use:

```
cargo doc --open
configuration.set_unstable_operation_enabled("<OPERATION_NAME>", True)
```
where `<OPERATION_NAME>` is the API version and name of the method used to interact with that endpoint. For example: `v2.list_incidents`, or `v2.query_timeseries_data`

## Author

Expand Down

0 comments on commit 3e42f43

Please sign in to comment.