Skip to content

Commit fc4bf86

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit bd35a75a of spec repo
1 parent 5a2f363 commit fc4bf86

13 files changed

+869
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-09-16 14:02:52.161932",
8-
"spec_repo_commit": "966987f5"
7+
"regenerated": "2024-09-17 11:55:35.606223",
8+
"spec_repo_commit": "bd35a75a"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-16 14:02:52.179359",
13-
"spec_repo_commit": "966987f5"
12+
"regenerated": "2024-09-17 11:55:35.624474",
13+
"spec_repo_commit": "bd35a75a"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15182,6 +15182,32 @@ components:
1518215182
- EDGE_LAPTOP_LARGE
1518315183
- EDGE_TABLET
1518415184
- EDGE_MOBILE_SMALL
15185+
SyntheticsFetchUptimesPayload:
15186+
description: Object containing IDs of Synthetic tests and a timeframe.
15187+
properties:
15188+
from_ts:
15189+
description: Timestamp in seconds (Unix epoch) for the start of uptime.
15190+
example: 0
15191+
format: int64
15192+
type: integer
15193+
public_ids:
15194+
description: An array of Synthetic test IDs you want to delete.
15195+
example: []
15196+
items:
15197+
description: A Synthetic test ID.
15198+
example: abc-def-123
15199+
type: string
15200+
type: array
15201+
to_ts:
15202+
description: Timestamp in seconds (Unix epoch) for the end of uptime.
15203+
example: 0
15204+
format: int64
15205+
type: integer
15206+
required:
15207+
- from_ts
15208+
- to_ts
15209+
- public_ids
15210+
type: object
1518515211
SyntheticsGetAPITestLatestResultsResponse:
1518615212
description: Object with the latest Synthetic API test run.
1518715213
properties:
@@ -16481,6 +16507,24 @@ components:
1648116507
description: String Port number to use when performing the test. Supports templated
1648216508
variables.
1648316509
type: string
16510+
SyntheticsTestUptime:
16511+
description: Object containing the uptime for a Synthetic test ID.
16512+
properties:
16513+
from_ts:
16514+
description: Timestamp in seconds for the start of uptime.
16515+
format: int64
16516+
type: integer
16517+
overall:
16518+
$ref: '#/components/schemas/SyntheticsUptime'
16519+
public_id:
16520+
description: A Synthetic test ID.
16521+
example: abc-def-123
16522+
type: string
16523+
to_ts:
16524+
description: Timestamp in seconds for the end of uptime.
16525+
format: int64
16526+
type: integer
16527+
type: object
1648416528
SyntheticsTiming:
1648516529
description: 'Object containing all metrics and their values collected for a
1648616530
Synthetic API test.
@@ -16604,6 +16648,62 @@ components:
1660416648
new_status:
1660516649
$ref: '#/components/schemas/SyntheticsTestPauseStatus'
1660616650
type: object
16651+
SyntheticsUptime:
16652+
description: Object containing the uptime information.
16653+
properties:
16654+
errors:
16655+
description: An array of error objects returned while querying the history
16656+
data for the service level objective.
16657+
items:
16658+
$ref: '#/components/schemas/SLOHistoryResponseErrorWithType'
16659+
nullable: true
16660+
type: array
16661+
group:
16662+
description: The location name
16663+
example: name
16664+
type: string
16665+
history:
16666+
description: 'The state transition history for the monitor, represented
16667+
as an array of
16668+
16669+
pairs. Each pair is an array where the first element is the transition
16670+
timestamp
16671+
16672+
in Unix epoch format (integer) and the second element is the state (integer).
16673+
16674+
For the state, an integer value of `0` indicates uptime, `1` indicates
16675+
downtime,
16676+
16677+
and `2` indicates no data.'
16678+
example:
16679+
- - 1579212382
16680+
- 0
16681+
items:
16682+
description: An array of transitions
16683+
example:
16684+
- 1579212382
16685+
- 0
16686+
items:
16687+
description: A timeseries data point which is a tuple of (timestamp,
16688+
value).
16689+
format: double
16690+
type: number
16691+
maxItems: 2
16692+
minItems: 2
16693+
type: array
16694+
type: array
16695+
span_precision:
16696+
description: The number of decimal places to which the SLI value is accurate
16697+
for the given from-to timestamps.
16698+
example: 2.0
16699+
format: double
16700+
type: number
16701+
uptime:
16702+
description: The overall uptime.
16703+
example: 99.99
16704+
format: double
16705+
type: number
16706+
type: object
1660716707
SyntheticsVariableParser:
1660816708
description: Details of the parser to use for the global variable.
1660916709
example:
@@ -31307,6 +31407,49 @@ paths:
3130731407
tags:
3130831408
- Synthetics
3130931409
x-codegen-request-body-name: body
31410+
/api/v1/synthetics/tests/uptimes:
31411+
post:
31412+
description: Fetch uptime for multiple Synthetic tests by ID.
31413+
operationId: FetchUptimes
31414+
requestBody:
31415+
content:
31416+
application/json:
31417+
schema:
31418+
$ref: '#/components/schemas/SyntheticsFetchUptimesPayload'
31419+
description: Public ID list of the Synthetic tests and timeframe.
31420+
required: true
31421+
responses:
31422+
'200':
31423+
content:
31424+
application/json:
31425+
schema:
31426+
items:
31427+
$ref: '#/components/schemas/SyntheticsTestUptime'
31428+
type: array
31429+
description: OK.
31430+
'400':
31431+
content:
31432+
application/json:
31433+
schema:
31434+
$ref: '#/components/schemas/APIErrorResponse'
31435+
description: '- JSON format is wrong'
31436+
'403':
31437+
content:
31438+
application/json:
31439+
schema:
31440+
$ref: '#/components/schemas/APIErrorResponse'
31441+
description: Forbidden
31442+
'429':
31443+
$ref: '#/components/responses/TooManyRequestsResponse'
31444+
security:
31445+
- apiKeyAuth: []
31446+
appKeyAuth: []
31447+
- AuthZ:
31448+
- synthetics_read
31449+
summary: Fetch uptime for multiple tests
31450+
tags:
31451+
- Synthetics
31452+
x-codegen-request-body-name: body
3131031453
/api/v1/synthetics/tests/{public_id}:
3131131454
get:
3131231455
description: Get the detailed configuration associated with a Synthetic test.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Fetch uptime for multiple tests returns "OK." response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_synthetics::SyntheticsAPI;
4+
use datadog_api_client::datadogV1::model::SyntheticsFetchUptimesPayload;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
let body =
9+
SyntheticsFetchUptimesPayload::new(1726041488, vec!["p8m-9gw-nte".to_string()], 1726055954);
10+
let configuration = datadog::Configuration::new();
11+
let api = SyntheticsAPI::with_config(configuration);
12+
let resp = api.fetch_uptimes(body).await;
13+
if let Ok(value) = resp {
14+
println!("{:#?}", value);
15+
} else {
16+
println!("{:#?}", resp.unwrap_err());
17+
}
18+
}

src/datadogV1/api/api_synthetics.rs

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ pub enum EditGlobalVariableError {
159159
UnknownValue(serde_json::Value),
160160
}
161161

162+
/// FetchUptimesError is a struct for typed errors of method [`SyntheticsAPI::fetch_uptimes`]
163+
#[derive(Debug, Clone, Serialize, Deserialize)]
164+
#[serde(untagged)]
165+
pub enum FetchUptimesError {
166+
APIErrorResponse(crate::datadogV1::model::APIErrorResponse),
167+
UnknownValue(serde_json::Value),
168+
}
169+
162170
/// GetAPITestError is a struct for typed errors of method [`SyntheticsAPI::get_api_test`]
163171
#[derive(Debug, Clone, Serialize, Deserialize)]
164172
#[serde(untagged)]
@@ -1514,6 +1522,157 @@ impl SyntheticsAPI {
15141522
}
15151523
}
15161524

1525+
/// Fetch uptime for multiple Synthetic tests by ID.
1526+
pub async fn fetch_uptimes(
1527+
&self,
1528+
body: crate::datadogV1::model::SyntheticsFetchUptimesPayload,
1529+
) -> Result<Vec<crate::datadogV1::model::SyntheticsTestUptime>, datadog::Error<FetchUptimesError>>
1530+
{
1531+
match self.fetch_uptimes_with_http_info(body).await {
1532+
Ok(response_content) => {
1533+
if let Some(e) = response_content.entity {
1534+
Ok(e)
1535+
} else {
1536+
Err(datadog::Error::Serde(serde::de::Error::custom(
1537+
"response content was None",
1538+
)))
1539+
}
1540+
}
1541+
Err(err) => Err(err),
1542+
}
1543+
}
1544+
1545+
/// Fetch uptime for multiple Synthetic tests by ID.
1546+
pub async fn fetch_uptimes_with_http_info(
1547+
&self,
1548+
body: crate::datadogV1::model::SyntheticsFetchUptimesPayload,
1549+
) -> Result<
1550+
datadog::ResponseContent<Vec<crate::datadogV1::model::SyntheticsTestUptime>>,
1551+
datadog::Error<FetchUptimesError>,
1552+
> {
1553+
let local_configuration = &self.config;
1554+
let operation_id = "v1.fetch_uptimes";
1555+
1556+
let local_client = &self.client;
1557+
1558+
let local_uri_str = format!(
1559+
"{}/api/v1/synthetics/tests/uptimes",
1560+
local_configuration.get_operation_host(operation_id)
1561+
);
1562+
let mut local_req_builder =
1563+
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1564+
1565+
// build headers
1566+
let mut headers = HeaderMap::new();
1567+
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
1568+
headers.insert("Accept", HeaderValue::from_static("application/json"));
1569+
1570+
// build user agent
1571+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1572+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1573+
Err(e) => {
1574+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
1575+
headers.insert(
1576+
reqwest::header::USER_AGENT,
1577+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1578+
)
1579+
}
1580+
};
1581+
1582+
// build auth
1583+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1584+
headers.insert(
1585+
"DD-API-KEY",
1586+
HeaderValue::from_str(local_key.key.as_str())
1587+
.expect("failed to parse DD-API-KEY header"),
1588+
);
1589+
};
1590+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1591+
headers.insert(
1592+
"DD-APPLICATION-KEY",
1593+
HeaderValue::from_str(local_key.key.as_str())
1594+
.expect("failed to parse DD-APPLICATION-KEY header"),
1595+
);
1596+
};
1597+
1598+
// build body parameters
1599+
let output = Vec::new();
1600+
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
1601+
if body.serialize(&mut ser).is_ok() {
1602+
if let Some(content_encoding) = headers.get("Content-Encoding") {
1603+
match content_encoding.to_str().unwrap_or_default() {
1604+
"gzip" => {
1605+
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
1606+
let _ = enc.write_all(ser.into_inner().as_slice());
1607+
match enc.finish() {
1608+
Ok(buf) => {
1609+
local_req_builder = local_req_builder.body(buf);
1610+
}
1611+
Err(e) => return Err(datadog::Error::Io(e)),
1612+
}
1613+
}
1614+
"deflate" => {
1615+
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
1616+
let _ = enc.write_all(ser.into_inner().as_slice());
1617+
match enc.finish() {
1618+
Ok(buf) => {
1619+
local_req_builder = local_req_builder.body(buf);
1620+
}
1621+
Err(e) => return Err(datadog::Error::Io(e)),
1622+
}
1623+
}
1624+
"zstd1" => {
1625+
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
1626+
let _ = enc.write_all(ser.into_inner().as_slice());
1627+
match enc.finish() {
1628+
Ok(buf) => {
1629+
local_req_builder = local_req_builder.body(buf);
1630+
}
1631+
Err(e) => return Err(datadog::Error::Io(e)),
1632+
}
1633+
}
1634+
_ => {
1635+
local_req_builder = local_req_builder.body(ser.into_inner());
1636+
}
1637+
}
1638+
} else {
1639+
local_req_builder = local_req_builder.body(ser.into_inner());
1640+
}
1641+
}
1642+
1643+
local_req_builder = local_req_builder.headers(headers);
1644+
let local_req = local_req_builder.build()?;
1645+
log::debug!("request content: {:?}", local_req.body());
1646+
let local_resp = local_client.execute(local_req).await?;
1647+
1648+
let local_status = local_resp.status();
1649+
let local_content = local_resp.text().await?;
1650+
log::debug!("response content: {}", local_content);
1651+
1652+
if !local_status.is_client_error() && !local_status.is_server_error() {
1653+
match serde_json::from_str::<Vec<crate::datadogV1::model::SyntheticsTestUptime>>(
1654+
&local_content,
1655+
) {
1656+
Ok(e) => {
1657+
return Ok(datadog::ResponseContent {
1658+
status: local_status,
1659+
content: local_content,
1660+
entity: Some(e),
1661+
})
1662+
}
1663+
Err(e) => return Err(datadog::Error::Serde(e)),
1664+
};
1665+
} else {
1666+
let local_entity: Option<FetchUptimesError> = serde_json::from_str(&local_content).ok();
1667+
let local_error = datadog::ResponseContent {
1668+
status: local_status,
1669+
content: local_content,
1670+
entity: local_entity,
1671+
};
1672+
Err(datadog::Error::ResponseError(local_error))
1673+
}
1674+
}
1675+
15171676
/// Get the detailed configuration associated with
15181677
/// a Synthetic API test.
15191678
pub async fn get_api_test(

src/datadogV1/model/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,12 @@ pub mod model_synthetics_ci_test_body;
15041504
pub use self::model_synthetics_ci_test_body::SyntheticsCITestBody;
15051505
pub mod model_synthetics_ci_test;
15061506
pub use self::model_synthetics_ci_test::SyntheticsCITest;
1507+
pub mod model_synthetics_fetch_uptimes_payload;
1508+
pub use self::model_synthetics_fetch_uptimes_payload::SyntheticsFetchUptimesPayload;
1509+
pub mod model_synthetics_test_uptime;
1510+
pub use self::model_synthetics_test_uptime::SyntheticsTestUptime;
1511+
pub mod model_synthetics_uptime;
1512+
pub use self::model_synthetics_uptime::SyntheticsUptime;
15071513
pub mod model_synthetics_patch_test_body;
15081514
pub use self::model_synthetics_patch_test_body::SyntheticsPatchTestBody;
15091515
pub mod model_synthetics_patch_test_operation;

0 commit comments

Comments
 (0)