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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-11 09:38:13.636413",
"spec_repo_commit": "cee92551"
"regenerated": "2024-06-11 14:30:56.286984",
"spec_repo_commit": "71f2f0da"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-11 09:38:13.654057",
"spec_repo_commit": "cee92551"
"regenerated": "2024-06-11 14:30:56.304675",
"spec_repo_commit": "71f2f0da"
}
}
}
103 changes: 103 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10554,6 +10554,52 @@ components:
description: Jira project key
type: string
type: object
ListAPIsResponse:
description: Response for `ListAPIs`.
properties:
data:
description: List of API items.
items:
$ref: '#/components/schemas/ListAPIsResponseData'
type: array
meta:
$ref: '#/components/schemas/ListAPIsResponseMeta'
type: object
ListAPIsResponseData:
description: Data envelope for `ListAPIsResponse`.
properties:
id:
$ref: '#/components/schemas/ApiID'
name:
description: API name.
example: Payments API
type: string
type: object
ListAPIsResponseMeta:
description: Metadata for `ListAPIsResponse`.
properties:
pagination:
$ref: '#/components/schemas/ListAPIsResponseMetaPagination'
type: object
ListAPIsResponseMetaPagination:
description: Pagination metadata information for `ListAPIsResponse`.
properties:
limit:
description: Number of items in the current page.
example: 20
format: int64
type: integer
offset:
description: Offset for pagination.
example: 0
format: int64
type: integer
total_count:
description: Total number of items.
example: 35
format: int64
type: integer
type: object
ListApplicationKeysResponse:
description: Response for a list of application keys.
properties:
Expand Down Expand Up @@ -23350,6 +23396,63 @@ paths:
tags:
- Key Management
x-codegen-request-body-name: body
/api/v2/apicatalog/api:
get:
description: List APIs and their IDs.
operationId: ListAPIs
parameters:
- description: Filter APIs by name
in: query
name: query
required: false
schema:
example: payments
type: string
- description: Number of items per page.
in: query
name: page[limit]
required: false
schema:
default: 20
format: int64
minimum: 1
type: integer
- description: Offset for pagination.
in: query
name: page[offset]
required: false
schema:
default: 0
format: int64
minimum: 0
type: integer
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ListAPIsResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad request
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Forbidden
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: List APIs
tags:
- API Management
x-unstable: '**Note**: This endpoint is in public beta.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/apicatalog/api/{id}:
delete:
description: Delete a specific API by ID.
Expand Down
17 changes: 17 additions & 0 deletions examples/v2_api-management_list_ap_is.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// List APIs returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_api_management::APIManagementAPI;
use datadog_api_client::datadogV2::api_api_management::ListAPIsOptionalParams;

#[tokio::main]
async fn main() {
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.ListAPIs", true);
let api = APIManagementAPI::with_config(configuration);
let resp = api.list_ap_is(ListAPIsOptionalParams::default()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
1 change: 1 addition & 0 deletions src/datadog/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl Default for Configuration {
("v2.create_open_api".to_owned(), false),
("v2.delete_open_api".to_owned(), false),
("v2.get_open_api".to_owned(), false),
("v2.list_ap_is".to_owned(), false),
("v2.update_open_api".to_owned(), false),
("v2.get_active_billing_dimensions".to_owned(), false),
("v2.get_monthly_cost_attribution".to_owned(), false),
Expand Down
168 changes: 168 additions & 0 deletions src/datadogV2/api/api_api_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ impl CreateOpenAPIOptionalParams {
}
}

/// ListAPIsOptionalParams is a struct for passing parameters to the method [`APIManagementAPI::list_ap_is`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct ListAPIsOptionalParams {
/// Filter APIs by name
pub query: Option<String>,
/// Number of items per page.
pub page_limit: Option<i64>,
/// Offset for pagination.
pub page_offset: Option<i64>,
}

impl ListAPIsOptionalParams {
/// Filter APIs by name
pub fn query(mut self, value: String) -> Self {
self.query = Some(value);
self
}
/// Number of items per page.
pub fn page_limit(mut self, value: i64) -> Self {
self.page_limit = Some(value);
self
}
/// Offset for pagination.
pub fn page_offset(mut self, value: i64) -> Self {
self.page_offset = Some(value);
self
}
}

/// UpdateOpenAPIOptionalParams is a struct for passing parameters to the method [`APIManagementAPI::update_open_api`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
Expand Down Expand Up @@ -65,6 +95,15 @@ pub enum GetOpenAPIError {
UnknownValue(serde_json::Value),
}

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

/// UpdateOpenAPIError is a struct for typed errors of method [`APIManagementAPI::update_open_api`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -490,6 +529,135 @@ impl APIManagementAPI {
}
}

/// List APIs and their IDs.
pub async fn list_ap_is(
&self,
params: ListAPIsOptionalParams,
) -> Result<crate::datadogV2::model::ListAPIsResponse, datadog::Error<ListAPIsError>> {
match self.list_ap_is_with_http_info(params).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),
}
}

/// List APIs and their IDs.
pub async fn list_ap_is_with_http_info(
&self,
params: ListAPIsOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::ListAPIsResponse>,
datadog::Error<ListAPIsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_ap_is";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_ap_is' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

// unbox and build optional parameters
let query = params.query;
let page_limit = params.page_limit;
let page_offset = params.page_offset;

let local_client = &self.client;

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

if let Some(ref local_query_param) = query {
local_req_builder =
local_req_builder.query(&[("query", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_limit {
local_req_builder =
local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]);
};
if let Some(ref local_query_param) = page_offset {
local_req_builder =
local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]);
};

// 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::ListAPIsResponse>(&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<ListAPIsError> = 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))
}
}

/// Update information about a specific API. The given content will replace all API content of the given ID.
/// The ID is returned by the create API, or can be found in the URL in the API catalog UI.
///
Expand Down
8 changes: 8 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ pub mod model_api_key_update_data;
pub use self::model_api_key_update_data::APIKeyUpdateData;
pub mod model_api_key_update_attributes;
pub use self::model_api_key_update_attributes::APIKeyUpdateAttributes;
pub mod model_list_ap_is_response;
pub use self::model_list_ap_is_response::ListAPIsResponse;
pub mod model_list_ap_is_response_data;
pub use self::model_list_ap_is_response_data::ListAPIsResponseData;
pub mod model_list_ap_is_response_meta;
pub use self::model_list_ap_is_response_meta::ListAPIsResponseMeta;
pub mod model_list_ap_is_response_meta_pagination;
pub use self::model_list_ap_is_response_meta_pagination::ListAPIsResponseMetaPagination;
pub mod model_jsonapi_error_response;
pub use self::model_jsonapi_error_response::JSONAPIErrorResponse;
pub mod model_jsonapi_error_item;
Expand Down
Loading