Skip to content

Support DD_SITE env var and document server variable usage #306

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

Merged
merged 4 commits into from
Sep 25, 2024
Merged
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
5 changes: 4 additions & 1 deletion .generator/src/generator/templates/configuration.j2
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ impl Default for Configuration {
unstable_operations,
auth_keys,
server_index: 0,
server_variables: HashMap::new(),
server_variables: HashMap::from([(
"site".into(),
env::var("DD_SITE").unwrap_or("datadoghq.com".into()),
)]),
server_operation_index: HashMap::new(),
server_operation_variables: HashMap::new(),
proxy_url: None,
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ configuration.set_auth_key(
);
```

### Datacenter Selection

By default the library will use the US1 Datadog datacenter, at `datadoghq.com`. To change this, we expose OpenAPI-style server index and server variable fields. For example, to switch the target datacenter to the EU datacenter, you can set the following values on the configuration object:

```rust
configuration.server_index = 0;
configuration.server_variables.insert("site".into(), "datadoghq.eu".into());
```

Alternatively, you can set the environment variable `DD_SITE=datadoghq.eu` to achieve the same result.

For a list of sites and alternative server URL schemes, you can refer to the code [here](https://github.com/DataDog/datadog-api-client-rust/blob/1e121063af9e4983a34d1c6185936dda621cad8b/src/datadog/configuration.rs#L223).

### 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 use these endpoints:
Expand Down
5 changes: 4 additions & 1 deletion src/datadog/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ impl Default for Configuration {
unstable_operations,
auth_keys,
server_index: 0,
server_variables: HashMap::new(),
server_variables: HashMap::from([(
"site".into(),
env::var("DD_SITE").unwrap_or("datadoghq.com".into()),
)]),
server_operation_index: HashMap::new(),
server_operation_variables: HashMap::new(),
proxy_url: None,
Expand Down
Loading