Skip to content

Commit 688e03c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add PreviewCatalogEntities (#1004)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 22d4e4f commit 688e03c

27 files changed

+2483
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17294,11 +17294,201 @@ components:
1729417294
schema:
1729517295
$ref: '#/components/schemas/EntityToSchema'
1729617296
type: object
17297+
EntityResponseArray:
17298+
properties:
17299+
data:
17300+
items:
17301+
$ref: '#/components/schemas/PreviewEntityResponseData'
17302+
type: array
17303+
required:
17304+
- data
17305+
type: object
1729717306
EntityResponseData:
1729817307
description: List of entity data.
1729917308
items:
1730017309
$ref: '#/components/schemas/EntityData'
1730117310
type: array
17311+
EntityResponseDataAttributes:
17312+
properties:
17313+
apiVersion:
17314+
type: string
17315+
description:
17316+
type: string
17317+
displayName:
17318+
type: string
17319+
kind:
17320+
type: string
17321+
name:
17322+
type: string
17323+
namespace:
17324+
type: string
17325+
owner:
17326+
type: string
17327+
properties:
17328+
additionalProperties: {}
17329+
type: object
17330+
tags:
17331+
items:
17332+
type: string
17333+
type: array
17334+
type: object
17335+
EntityResponseDataRelationships:
17336+
properties:
17337+
incidents:
17338+
$ref: '#/components/schemas/EntityResponseDataRelationshipsIncidents'
17339+
oncalls:
17340+
$ref: '#/components/schemas/EntityResponseDataRelationshipsOncalls'
17341+
rawSchema:
17342+
$ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchema'
17343+
relatedEntities:
17344+
$ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntities'
17345+
schema:
17346+
$ref: '#/components/schemas/EntityResponseDataRelationshipsSchema'
17347+
type: object
17348+
EntityResponseDataRelationshipsIncidents:
17349+
properties:
17350+
data:
17351+
items:
17352+
$ref: '#/components/schemas/EntityResponseDataRelationshipsIncidentsDataItems'
17353+
type: array
17354+
type: object
17355+
EntityResponseDataRelationshipsIncidentsDataItems:
17356+
properties:
17357+
id:
17358+
example: ''
17359+
type: string
17360+
type:
17361+
$ref: '#/components/schemas/EntityResponseDataRelationshipsIncidentsDataItemsType'
17362+
required:
17363+
- type
17364+
- id
17365+
type: object
17366+
EntityResponseDataRelationshipsIncidentsDataItemsType:
17367+
default: incident
17368+
description: Incident resource type.
17369+
enum:
17370+
- incident
17371+
example: incident
17372+
type: string
17373+
x-enum-varnames:
17374+
- INCIDENT
17375+
EntityResponseDataRelationshipsOncalls:
17376+
properties:
17377+
data:
17378+
items:
17379+
$ref: '#/components/schemas/EntityResponseDataRelationshipsOncallsDataItems'
17380+
type: array
17381+
type: object
17382+
EntityResponseDataRelationshipsOncallsDataItems:
17383+
properties:
17384+
id:
17385+
example: ''
17386+
type: string
17387+
type:
17388+
$ref: '#/components/schemas/EntityResponseDataRelationshipsOncallsDataItemsType'
17389+
required:
17390+
- type
17391+
- id
17392+
type: object
17393+
EntityResponseDataRelationshipsOncallsDataItemsType:
17394+
default: oncall
17395+
description: Oncall resource type.
17396+
enum:
17397+
- oncall
17398+
example: oncall
17399+
type: string
17400+
x-enum-varnames:
17401+
- ONCALL
17402+
EntityResponseDataRelationshipsRawSchema:
17403+
properties:
17404+
data:
17405+
$ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchemaData'
17406+
required:
17407+
- data
17408+
type: object
17409+
EntityResponseDataRelationshipsRawSchemaData:
17410+
properties:
17411+
id:
17412+
example: ''
17413+
type: string
17414+
type:
17415+
$ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchemaDataType'
17416+
required:
17417+
- type
17418+
- id
17419+
type: object
17420+
EntityResponseDataRelationshipsRawSchemaDataType:
17421+
default: rawSchema
17422+
description: Raw schema resource type.
17423+
enum:
17424+
- rawSchema
17425+
example: rawSchema
17426+
type: string
17427+
x-enum-varnames:
17428+
- RAWSCHEMA
17429+
EntityResponseDataRelationshipsRelatedEntities:
17430+
properties:
17431+
data:
17432+
items:
17433+
$ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntitiesDataItems'
17434+
type: array
17435+
type: object
17436+
EntityResponseDataRelationshipsRelatedEntitiesDataItems:
17437+
properties:
17438+
id:
17439+
example: ''
17440+
type: string
17441+
type:
17442+
$ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntitiesDataItemsType'
17443+
required:
17444+
- type
17445+
- id
17446+
type: object
17447+
EntityResponseDataRelationshipsRelatedEntitiesDataItemsType:
17448+
default: relatedEntity
17449+
description: Related entity resource type.
17450+
enum:
17451+
- relatedEntity
17452+
example: relatedEntity
17453+
type: string
17454+
x-enum-varnames:
17455+
- RELATEDENTITY
17456+
EntityResponseDataRelationshipsSchema:
17457+
properties:
17458+
data:
17459+
$ref: '#/components/schemas/EntityResponseDataRelationshipsSchemaData'
17460+
required:
17461+
- data
17462+
type: object
17463+
EntityResponseDataRelationshipsSchemaData:
17464+
properties:
17465+
id:
17466+
example: ''
17467+
type: string
17468+
type:
17469+
$ref: '#/components/schemas/EntityResponseDataRelationshipsSchemaDataType'
17470+
required:
17471+
- type
17472+
- id
17473+
type: object
17474+
EntityResponseDataRelationshipsSchemaDataType:
17475+
default: schema
17476+
description: Schema resource type.
17477+
enum:
17478+
- schema
17479+
example: schema
17480+
type: string
17481+
x-enum-varnames:
17482+
- SCHEMA
17483+
EntityResponseDataType:
17484+
default: entity
17485+
description: Entity resource type.
17486+
enum:
17487+
- entity
17488+
example: entity
17489+
type: string
17490+
x-enum-varnames:
17491+
- ENTITY
1730217492
EntityResponseIncludedIncident:
1730317493
description: Included incident.
1730417494
properties:
@@ -37681,6 +37871,19 @@ components:
3768137871
description: Offset type.
3768237872
type: string
3768337873
type: object
37874+
PreviewEntityResponseData:
37875+
properties:
37876+
attributes:
37877+
$ref: '#/components/schemas/EntityResponseDataAttributes'
37878+
id:
37879+
type: string
37880+
relationships:
37881+
$ref: '#/components/schemas/EntityResponseDataRelationships'
37882+
type:
37883+
$ref: '#/components/schemas/EntityResponseDataType'
37884+
required:
37885+
- type
37886+
type: object
3768437887
ProcessSummariesMeta:
3768537888
description: Response metadata object.
3768637889
properties:
@@ -58421,6 +58624,26 @@ paths:
5842158624
tags:
5842258625
- Software Catalog
5842358626
x-codegen-request-body-name: body
58627+
/api/v2/catalog/entity/preview:
58628+
post:
58629+
operationId: PreviewCatalogEntities
58630+
responses:
58631+
'202':
58632+
content:
58633+
application/json:
58634+
schema:
58635+
$ref: '#/components/schemas/EntityResponseArray'
58636+
description: Accepted
58637+
'429':
58638+
$ref: '#/components/responses/TooManyRequestsResponse'
58639+
security:
58640+
- apiKeyAuth: []
58641+
appKeyAuth: []
58642+
- AuthZ:
58643+
- apm_service_catalog_read
58644+
summary: Preview catalog entities
58645+
tags:
58646+
- Software Catalog
5842458647
/api/v2/catalog/entity/{entity_id}:
5842558648
delete:
5842658649
description: Delete a single entity in Software Catalog.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Preview catalog entities returns "Accepted" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_software_catalog::SoftwareCatalogAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = SoftwareCatalogAPI::with_config(configuration);
9+
let resp = api.preview_catalog_entities().await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}

src/datadogV2/api/api_software_catalog.rs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ pub enum ListCatalogRelationError {
219219
UnknownValue(serde_json::Value),
220220
}
221221

222+
/// PreviewCatalogEntitiesError is a struct for typed errors of method [`SoftwareCatalogAPI::preview_catalog_entities`]
223+
#[derive(Debug, Clone, Serialize, Deserialize)]
224+
#[serde(untagged)]
225+
pub enum PreviewCatalogEntitiesError {
226+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
227+
UnknownValue(serde_json::Value),
228+
}
229+
222230
/// UpsertCatalogEntityError is a struct for typed errors of method [`SoftwareCatalogAPI::upsert_catalog_entity`]
223231
#[derive(Debug, Clone, Serialize, Deserialize)]
224232
#[serde(untagged)]
@@ -1017,6 +1025,110 @@ impl SoftwareCatalogAPI {
10171025
}
10181026
}
10191027

1028+
pub async fn preview_catalog_entities(
1029+
&self,
1030+
) -> Result<
1031+
crate::datadogV2::model::EntityResponseArray,
1032+
datadog::Error<PreviewCatalogEntitiesError>,
1033+
> {
1034+
match self.preview_catalog_entities_with_http_info().await {
1035+
Ok(response_content) => {
1036+
if let Some(e) = response_content.entity {
1037+
Ok(e)
1038+
} else {
1039+
Err(datadog::Error::Serde(serde::de::Error::custom(
1040+
"response content was None",
1041+
)))
1042+
}
1043+
}
1044+
Err(err) => Err(err),
1045+
}
1046+
}
1047+
1048+
pub async fn preview_catalog_entities_with_http_info(
1049+
&self,
1050+
) -> Result<
1051+
datadog::ResponseContent<crate::datadogV2::model::EntityResponseArray>,
1052+
datadog::Error<PreviewCatalogEntitiesError>,
1053+
> {
1054+
let local_configuration = &self.config;
1055+
let operation_id = "v2.preview_catalog_entities";
1056+
1057+
let local_client = &self.client;
1058+
1059+
let local_uri_str = format!(
1060+
"{}/api/v2/catalog/entity/preview",
1061+
local_configuration.get_operation_host(operation_id)
1062+
);
1063+
let mut local_req_builder =
1064+
local_client.request(reqwest::Method::POST, local_uri_str.as_str());
1065+
1066+
// build headers
1067+
let mut headers = HeaderMap::new();
1068+
headers.insert("Accept", HeaderValue::from_static("application/json"));
1069+
1070+
// build user agent
1071+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1072+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1073+
Err(e) => {
1074+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
1075+
headers.insert(
1076+
reqwest::header::USER_AGENT,
1077+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1078+
)
1079+
}
1080+
};
1081+
1082+
// build auth
1083+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1084+
headers.insert(
1085+
"DD-API-KEY",
1086+
HeaderValue::from_str(local_key.key.as_str())
1087+
.expect("failed to parse DD-API-KEY header"),
1088+
);
1089+
};
1090+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1091+
headers.insert(
1092+
"DD-APPLICATION-KEY",
1093+
HeaderValue::from_str(local_key.key.as_str())
1094+
.expect("failed to parse DD-APPLICATION-KEY header"),
1095+
);
1096+
};
1097+
1098+
local_req_builder = local_req_builder.headers(headers);
1099+
let local_req = local_req_builder.build()?;
1100+
log::debug!("request content: {:?}", local_req.body());
1101+
let local_resp = local_client.execute(local_req).await?;
1102+
1103+
let local_status = local_resp.status();
1104+
let local_content = local_resp.text().await?;
1105+
log::debug!("response content: {}", local_content);
1106+
1107+
if !local_status.is_client_error() && !local_status.is_server_error() {
1108+
match serde_json::from_str::<crate::datadogV2::model::EntityResponseArray>(
1109+
&local_content,
1110+
) {
1111+
Ok(e) => {
1112+
return Ok(datadog::ResponseContent {
1113+
status: local_status,
1114+
content: local_content,
1115+
entity: Some(e),
1116+
})
1117+
}
1118+
Err(e) => return Err(datadog::Error::Serde(e)),
1119+
};
1120+
} else {
1121+
let local_entity: Option<PreviewCatalogEntitiesError> =
1122+
serde_json::from_str(&local_content).ok();
1123+
let local_error = datadog::ResponseContent {
1124+
status: local_status,
1125+
content: local_content,
1126+
entity: local_entity,
1127+
};
1128+
Err(datadog::Error::ResponseError(local_error))
1129+
}
1130+
}
1131+
10201132
/// Create or update entities in Software Catalog.
10211133
pub async fn upsert_catalog_entity(
10221134
&self,

0 commit comments

Comments
 (0)