diff --git a/.generator/src/generator/templates/configuration.j2 b/.generator/src/generator/templates/configuration.j2 index fa03d72cb..65c260f74 100644 --- a/.generator/src/generator/templates/configuration.j2 +++ b/.generator/src/generator/templates/configuration.j2 @@ -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, diff --git a/README.md b/README.md index e6027b683..6d40f7422 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 58339f9f4..894ddbff1 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -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,