Skip to content
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
223 changes: 223 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17294,11 +17294,201 @@ components:
schema:
$ref: '#/components/schemas/EntityToSchema'
type: object
EntityResponseArray:
properties:
data:
items:
$ref: '#/components/schemas/PreviewEntityResponseData'
type: array
required:
- data
type: object
EntityResponseData:
description: List of entity data.
items:
$ref: '#/components/schemas/EntityData'
type: array
EntityResponseDataAttributes:
properties:
apiVersion:
type: string
description:
type: string
displayName:
type: string
kind:
type: string
name:
type: string
namespace:
type: string
owner:
type: string
properties:
additionalProperties: {}
type: object
tags:
items:
type: string
type: array
type: object
EntityResponseDataRelationships:
properties:
incidents:
$ref: '#/components/schemas/EntityResponseDataRelationshipsIncidents'
oncalls:
$ref: '#/components/schemas/EntityResponseDataRelationshipsOncalls'
rawSchema:
$ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchema'
relatedEntities:
$ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntities'
schema:
$ref: '#/components/schemas/EntityResponseDataRelationshipsSchema'
type: object
EntityResponseDataRelationshipsIncidents:
properties:
data:
items:
$ref: '#/components/schemas/EntityResponseDataRelationshipsIncidentsDataItems'
type: array
type: object
EntityResponseDataRelationshipsIncidentsDataItems:
properties:
id:
example: ''
type: string
type:
$ref: '#/components/schemas/EntityResponseDataRelationshipsIncidentsDataItemsType'
required:
- type
- id
type: object
EntityResponseDataRelationshipsIncidentsDataItemsType:
default: incident
description: Incident resource type.
enum:
- incident
example: incident
type: string
x-enum-varnames:
- INCIDENT
EntityResponseDataRelationshipsOncalls:
properties:
data:
items:
$ref: '#/components/schemas/EntityResponseDataRelationshipsOncallsDataItems'
type: array
type: object
EntityResponseDataRelationshipsOncallsDataItems:
properties:
id:
example: ''
type: string
type:
$ref: '#/components/schemas/EntityResponseDataRelationshipsOncallsDataItemsType'
required:
- type
- id
type: object
EntityResponseDataRelationshipsOncallsDataItemsType:
default: oncall
description: Oncall resource type.
enum:
- oncall
example: oncall
type: string
x-enum-varnames:
- ONCALL
EntityResponseDataRelationshipsRawSchema:
properties:
data:
$ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchemaData'
required:
- data
type: object
EntityResponseDataRelationshipsRawSchemaData:
properties:
id:
example: ''
type: string
type:
$ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchemaDataType'
required:
- type
- id
type: object
EntityResponseDataRelationshipsRawSchemaDataType:
default: rawSchema
description: Raw schema resource type.
enum:
- rawSchema
example: rawSchema
type: string
x-enum-varnames:
- RAWSCHEMA
EntityResponseDataRelationshipsRelatedEntities:
properties:
data:
items:
$ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntitiesDataItems'
type: array
type: object
EntityResponseDataRelationshipsRelatedEntitiesDataItems:
properties:
id:
example: ''
type: string
type:
$ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntitiesDataItemsType'
required:
- type
- id
type: object
EntityResponseDataRelationshipsRelatedEntitiesDataItemsType:
default: relatedEntity
description: Related entity resource type.
enum:
- relatedEntity
example: relatedEntity
type: string
x-enum-varnames:
- RELATEDENTITY
EntityResponseDataRelationshipsSchema:
properties:
data:
$ref: '#/components/schemas/EntityResponseDataRelationshipsSchemaData'
required:
- data
type: object
EntityResponseDataRelationshipsSchemaData:
properties:
id:
example: ''
type: string
type:
$ref: '#/components/schemas/EntityResponseDataRelationshipsSchemaDataType'
required:
- type
- id
type: object
EntityResponseDataRelationshipsSchemaDataType:
default: schema
description: Schema resource type.
enum:
- schema
example: schema
type: string
x-enum-varnames:
- SCHEMA
EntityResponseDataType:
default: entity
description: Entity resource type.
enum:
- entity
example: entity
type: string
x-enum-varnames:
- ENTITY
EntityResponseIncludedIncident:
description: Included incident.
properties:
Expand Down Expand Up @@ -37681,6 +37871,19 @@ components:
description: Offset type.
type: string
type: object
PreviewEntityResponseData:
properties:
attributes:
$ref: '#/components/schemas/EntityResponseDataAttributes'
id:
type: string
relationships:
$ref: '#/components/schemas/EntityResponseDataRelationships'
type:
$ref: '#/components/schemas/EntityResponseDataType'
required:
- type
type: object
ProcessSummariesMeta:
description: Response metadata object.
properties:
Expand Down Expand Up @@ -58421,6 +58624,26 @@ paths:
tags:
- Software Catalog
x-codegen-request-body-name: body
/api/v2/catalog/entity/preview:
post:
operationId: PreviewCatalogEntities
responses:
'202':
content:
application/json:
schema:
$ref: '#/components/schemas/EntityResponseArray'
description: Accepted
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- apm_service_catalog_read
summary: Preview catalog entities
tags:
- Software Catalog
/api/v2/catalog/entity/{entity_id}:
delete:
description: Delete a single entity in Software Catalog.
Expand Down
15 changes: 15 additions & 0 deletions examples/v2_software-catalog_PreviewCatalogEntities.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Preview catalog entities returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_software_catalog::SoftwareCatalogAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = SoftwareCatalogAPI::with_config(configuration);
let resp = api.preview_catalog_entities().await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
112 changes: 112 additions & 0 deletions src/datadogV2/api/api_software_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ pub enum ListCatalogRelationError {
UnknownValue(serde_json::Value),
}

/// PreviewCatalogEntitiesError is a struct for typed errors of method [`SoftwareCatalogAPI::preview_catalog_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PreviewCatalogEntitiesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}

/// UpsertCatalogEntityError is a struct for typed errors of method [`SoftwareCatalogAPI::upsert_catalog_entity`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -1017,6 +1025,110 @@ impl SoftwareCatalogAPI {
}
}

pub async fn preview_catalog_entities(
&self,
) -> Result<
crate::datadogV2::model::EntityResponseArray,
datadog::Error<PreviewCatalogEntitiesError>,
> {
match self.preview_catalog_entities_with_http_info().await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}

pub async fn preview_catalog_entities_with_http_info(
&self,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::EntityResponseArray>,
datadog::Error<PreviewCatalogEntitiesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.preview_catalog_entities";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/catalog/entity/preview",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());

// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));

// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};

// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};

local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;

let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);

if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::EntityResponseArray>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<PreviewCatalogEntitiesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}

/// Create or update entities in Software Catalog.
pub async fn upsert_catalog_entity(
&self,
Expand Down
Loading