Skip to content

Commit 7a3c840

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add last_used_at to application keys and date_last_used to api keys responses (#900)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 2804e33 commit 7a3c840

26 files changed

+291
-60
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18761,6 +18761,13 @@ components:
1876118761
format: date-time
1876218762
readOnly: true
1876318763
type: string
18764+
date_last_used:
18765+
description: Date the API Key was last used
18766+
example: '2020-11-27T10:00:00.000Z'
18767+
format: date-time
18768+
nullable: true
18769+
readOnly: true
18770+
type: string
1876418771
key:
1876518772
description: The API key.
1876618773
readOnly: true
@@ -18819,6 +18826,13 @@ components:
1881918826
minLength: 4
1882018827
readOnly: true
1882118828
type: string
18829+
last_used_at:
18830+
description: Last usage timestamp of the application key.
18831+
example: '2020-12-20T10:00:00.000Z'
18832+
format: date-time
18833+
nullable: true
18834+
readOnly: true
18835+
type: string
1882218836
name:
1882318837
description: Name of the application key.
1882418838
example: Application Key for managing dashboards
@@ -34754,6 +34768,13 @@ components:
3475434768
example: '2020-11-23T10:00:00.000Z'
3475534769
readOnly: true
3475634770
type: string
34771+
date_last_used:
34772+
description: Date the API Key was last used.
34773+
example: '2020-11-27T10:00:00.000Z'
34774+
format: date-time
34775+
nullable: true
34776+
readOnly: true
34777+
type: string
3475734778
last4:
3475834779
description: The last four characters of the API key.
3475934780
example: abcd
@@ -34802,6 +34823,12 @@ components:
3480234823
minLength: 4
3480334824
readOnly: true
3480434825
type: string
34826+
last_used_at:
34827+
description: Last usage timestamp of the application key.
34828+
example: '2020-12-20T10:00:00.000Z'
34829+
nullable: true
34830+
readOnly: true
34831+
type: string
3480534832
name:
3480634833
description: Name of the application key.
3480734834
example: Application Key for managing dashboards
@@ -37778,6 +37805,7 @@ components:
3777837805
- type
3777937806
type: object
3778037807
RoleAttributes:
37808+
additionalProperties: {}
3778137809
description: Attributes of the role.
3778237810
properties:
3778337811
created_at:

examples/v2_key-management_GetCurrentUserApplicationKey.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ use datadog_api_client::datadogV2::api_key_management::KeyManagementAPI;
44

55
#[tokio::main]
66
async fn main() {
7+
// there is a valid "application_key" in the system
8+
let application_key_data_id = std::env::var("APPLICATION_KEY_DATA_ID").unwrap();
79
let configuration = datadog::Configuration::new();
810
let api = KeyManagementAPI::with_config(configuration);
911
let resp = api
10-
.get_current_user_application_key("app_key_id".to_string())
12+
.get_current_user_application_key(application_key_data_id.clone())
1113
.await;
1214
if let Ok(value) = resp {
1315
println!("{:#?}", value);

src/datadogV2/model/model_full_api_key_attributes.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ pub struct FullAPIKeyAttributes {
1717
/// Creation date of the API key.
1818
#[serde(rename = "created_at")]
1919
pub created_at: Option<chrono::DateTime<chrono::Utc>>,
20+
/// Date the API Key was last used
21+
#[serde(
22+
rename = "date_last_used",
23+
default,
24+
with = "::serde_with::rust::double_option"
25+
)]
26+
pub date_last_used: Option<Option<chrono::DateTime<chrono::Utc>>>,
2027
/// The API key.
2128
#[serde(rename = "key")]
2229
pub key: Option<String>,
@@ -44,6 +51,7 @@ impl FullAPIKeyAttributes {
4451
FullAPIKeyAttributes {
4552
category: None,
4653
created_at: None,
54+
date_last_used: None,
4755
key: None,
4856
last4: None,
4957
modified_at: None,
@@ -64,6 +72,11 @@ impl FullAPIKeyAttributes {
6472
self
6573
}
6674

75+
pub fn date_last_used(mut self, value: Option<chrono::DateTime<chrono::Utc>>) -> Self {
76+
self.date_last_used = Some(value);
77+
self
78+
}
79+
6780
pub fn key(mut self, value: String) -> Self {
6881
self.key = Some(value);
6982
self
@@ -123,6 +136,7 @@ impl<'de> Deserialize<'de> for FullAPIKeyAttributes {
123136
{
124137
let mut category: Option<String> = None;
125138
let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
139+
let mut date_last_used: Option<Option<chrono::DateTime<chrono::Utc>>> = None;
126140
let mut key: Option<String> = None;
127141
let mut last4: Option<String> = None;
128142
let mut modified_at: Option<chrono::DateTime<chrono::Utc>> = None;
@@ -148,6 +162,10 @@ impl<'de> Deserialize<'de> for FullAPIKeyAttributes {
148162
}
149163
created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
150164
}
165+
"date_last_used" => {
166+
date_last_used =
167+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
168+
}
151169
"key" => {
152170
if v.is_null() {
153171
continue;
@@ -191,6 +209,7 @@ impl<'de> Deserialize<'de> for FullAPIKeyAttributes {
191209
let content = FullAPIKeyAttributes {
192210
category,
193211
created_at,
212+
date_last_used,
194213
key,
195214
last4,
196215
modified_at,

src/datadogV2/model/model_full_application_key_attributes.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ pub struct FullApplicationKeyAttributes {
2020
/// The last four characters of the application key.
2121
#[serde(rename = "last4")]
2222
pub last4: Option<String>,
23+
/// Last usage timestamp of the application key.
24+
#[serde(
25+
rename = "last_used_at",
26+
default,
27+
with = "::serde_with::rust::double_option"
28+
)]
29+
pub last_used_at: Option<Option<chrono::DateTime<chrono::Utc>>>,
2330
/// Name of the application key.
2431
#[serde(rename = "name")]
2532
pub name: Option<String>,
@@ -39,6 +46,7 @@ impl FullApplicationKeyAttributes {
3946
created_at: None,
4047
key: None,
4148
last4: None,
49+
last_used_at: None,
4250
name: None,
4351
scopes: None,
4452
additional_properties: std::collections::BTreeMap::new(),
@@ -61,6 +69,11 @@ impl FullApplicationKeyAttributes {
6169
self
6270
}
6371

72+
pub fn last_used_at(mut self, value: Option<chrono::DateTime<chrono::Utc>>) -> Self {
73+
self.last_used_at = Some(value);
74+
self
75+
}
76+
6477
pub fn name(mut self, value: String) -> Self {
6578
self.name = Some(value);
6679
self
@@ -106,6 +119,7 @@ impl<'de> Deserialize<'de> for FullApplicationKeyAttributes {
106119
let mut created_at: Option<chrono::DateTime<chrono::Utc>> = None;
107120
let mut key: Option<String> = None;
108121
let mut last4: Option<String> = None;
122+
let mut last_used_at: Option<Option<chrono::DateTime<chrono::Utc>>> = None;
109123
let mut name: Option<String> = None;
110124
let mut scopes: Option<Option<Vec<String>>> = None;
111125
let mut additional_properties: std::collections::BTreeMap<
@@ -134,6 +148,10 @@ impl<'de> Deserialize<'de> for FullApplicationKeyAttributes {
134148
}
135149
last4 = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
136150
}
151+
"last_used_at" => {
152+
last_used_at =
153+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
154+
}
137155
"name" => {
138156
if v.is_null() {
139157
continue;
@@ -155,6 +173,7 @@ impl<'de> Deserialize<'de> for FullApplicationKeyAttributes {
155173
created_at,
156174
key,
157175
last4,
176+
last_used_at,
158177
name,
159178
scopes,
160179
additional_properties,

src/datadogV2/model/model_partial_api_key_attributes.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ pub struct PartialAPIKeyAttributes {
1717
/// Creation date of the API key.
1818
#[serde(rename = "created_at")]
1919
pub created_at: Option<String>,
20+
/// Date the API Key was last used.
21+
#[serde(
22+
rename = "date_last_used",
23+
default,
24+
with = "::serde_with::rust::double_option"
25+
)]
26+
pub date_last_used: Option<Option<chrono::DateTime<chrono::Utc>>>,
2027
/// The last four characters of the API key.
2128
#[serde(rename = "last4")]
2229
pub last4: Option<String>,
@@ -41,6 +48,7 @@ impl PartialAPIKeyAttributes {
4148
PartialAPIKeyAttributes {
4249
category: None,
4350
created_at: None,
51+
date_last_used: None,
4452
last4: None,
4553
modified_at: None,
4654
name: None,
@@ -60,6 +68,11 @@ impl PartialAPIKeyAttributes {
6068
self
6169
}
6270

71+
pub fn date_last_used(mut self, value: Option<chrono::DateTime<chrono::Utc>>) -> Self {
72+
self.date_last_used = Some(value);
73+
self
74+
}
75+
6376
pub fn last4(mut self, value: String) -> Self {
6477
self.last4 = Some(value);
6578
self
@@ -114,6 +127,7 @@ impl<'de> Deserialize<'de> for PartialAPIKeyAttributes {
114127
{
115128
let mut category: Option<String> = None;
116129
let mut created_at: Option<String> = None;
130+
let mut date_last_used: Option<Option<chrono::DateTime<chrono::Utc>>> = None;
117131
let mut last4: Option<String> = None;
118132
let mut modified_at: Option<String> = None;
119133
let mut name: Option<String> = None;
@@ -138,6 +152,10 @@ impl<'de> Deserialize<'de> for PartialAPIKeyAttributes {
138152
}
139153
created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
140154
}
155+
"date_last_used" => {
156+
date_last_used =
157+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
158+
}
141159
"last4" => {
142160
if v.is_null() {
143161
continue;
@@ -175,6 +193,7 @@ impl<'de> Deserialize<'de> for PartialAPIKeyAttributes {
175193
let content = PartialAPIKeyAttributes {
176194
category,
177195
created_at,
196+
date_last_used,
178197
last4,
179198
modified_at,
180199
name,

src/datadogV2/model/model_partial_application_key_attributes.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ pub struct PartialApplicationKeyAttributes {
1717
/// The last four characters of the application key.
1818
#[serde(rename = "last4")]
1919
pub last4: Option<String>,
20+
/// Last usage timestamp of the application key.
21+
#[serde(
22+
rename = "last_used_at",
23+
default,
24+
with = "::serde_with::rust::double_option"
25+
)]
26+
pub last_used_at: Option<Option<String>>,
2027
/// Name of the application key.
2128
#[serde(rename = "name")]
2229
pub name: Option<String>,
@@ -35,6 +42,7 @@ impl PartialApplicationKeyAttributes {
3542
PartialApplicationKeyAttributes {
3643
created_at: None,
3744
last4: None,
45+
last_used_at: None,
3846
name: None,
3947
scopes: None,
4048
additional_properties: std::collections::BTreeMap::new(),
@@ -52,6 +60,11 @@ impl PartialApplicationKeyAttributes {
5260
self
5361
}
5462

63+
pub fn last_used_at(mut self, value: Option<String>) -> Self {
64+
self.last_used_at = Some(value);
65+
self
66+
}
67+
5568
pub fn name(mut self, value: String) -> Self {
5669
self.name = Some(value);
5770
self
@@ -96,6 +109,7 @@ impl<'de> Deserialize<'de> for PartialApplicationKeyAttributes {
96109
{
97110
let mut created_at: Option<String> = None;
98111
let mut last4: Option<String> = None;
112+
let mut last_used_at: Option<Option<String>> = None;
99113
let mut name: Option<String> = None;
100114
let mut scopes: Option<Option<Vec<String>>> = None;
101115
let mut additional_properties: std::collections::BTreeMap<
@@ -118,6 +132,10 @@ impl<'de> Deserialize<'de> for PartialApplicationKeyAttributes {
118132
}
119133
last4 = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
120134
}
135+
"last_used_at" => {
136+
last_used_at =
137+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
138+
}
121139
"name" => {
122140
if v.is_null() {
123141
continue;
@@ -138,6 +156,7 @@ impl<'de> Deserialize<'de> for PartialApplicationKeyAttributes {
138156
let content = PartialApplicationKeyAttributes {
139157
created_at,
140158
last4,
159+
last_used_at,
141160
name,
142161
scopes,
143162
additional_properties,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-09-08T09:24:42.052Z
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": "",
6+
"headers": {
7+
"Accept": [
8+
"application/json"
9+
]
10+
},
11+
"method": "get",
12+
"uri": "https://api.datadoghq.com/api/v2/api_keys/invalidId"
13+
},
14+
"response": {
15+
"body": {
16+
"string": "{\"errors\":[\"API key not found\"]}",
17+
"encoding": null
18+
},
19+
"headers": {
20+
"Content-Type": [
21+
"application/json"
22+
]
23+
},
24+
"status": {
25+
"code": 404,
26+
"message": "Not Found"
27+
}
28+
},
29+
"recorded_at": "Mon, 08 Sep 2025 09:24:42 GMT"
30+
}
31+
],
32+
"recorded_with": "VCR 6.0.0"
33+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-05-12T09:52:13.069Z
1+
2025-09-08T09:24:42.741Z

0 commit comments

Comments
 (0)