Skip to content

add deleteCustomFramework endpoint #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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": "2025-01-13 18:28:01.987122",
"spec_repo_commit": "3517c947"
"regenerated": "2025-01-13 22:02:26.277331",
"spec_repo_commit": "5aa96e08"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-13 18:28:02.002232",
"spec_repo_commit": "3517c947"
"regenerated": "2025-01-13 22:02:26.292325",
"spec_repo_commit": "5aa96e08"
}
}
}
108 changes: 108 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,27 @@ components:
required: true
schema:
type: string
CustomFrameworkHandle:
description: The framework handle.
in: path
name: handle
required: true
schema:
type: string
CustomFrameworkOrgID:
description: The ID of the organization.
in: path
name: org_id
required: true
schema:
type: string
CustomFrameworkVersion:
description: The framework version.
in: path
name: version
required: true
schema:
type: string
EntityID:
description: UUID or Entity Ref.
in: path
Expand Down Expand Up @@ -8375,6 +8396,54 @@ components:
$ref: '#/components/schemas/CustomDestinationResponseDefinition'
type: array
type: object
CustomFrameworkMetadata:
description: Response object for an organization's custom frameworks.
properties:
created_at:
description: Framework Creation Date
format: int64
type: integer
created_by:
description: Framework Creator
type: string
description:
description: Framework Description
type: string
handle:
description: Framework Handle
example: ''
type: string
icon_url:
description: Framework Icon URL
type: string
id:
description: Custom Framework ID
example: ''
type: string
name:
description: Framework Name
example: ''
type: string
org_id:
description: Org ID
example: 0
format: int64
type: integer
updated_at:
description: Framework Update Date
format: int64
type: integer
version:
description: Framework Version
example: ''
type: string
required:
- id
- org_id
- handle
- version
- name
type: object
DORADeploymentRequest:
description: Request to create a DORA deployment event.
properties:
Expand Down Expand Up @@ -9015,6 +9084,12 @@ components:
type: string
x-enum-varnames:
- APPDEFINITIONS
DeleteCustomFrameworkResponse:
description: Delete a custom framework.
properties:
data:
$ref: '#/components/schemas/CustomFrameworkMetadata'
type: object
DependencyLocation:
description: Static library vulnerability location.
properties:
Expand Down Expand Up @@ -40135,6 +40210,39 @@ paths:
operator: OR
permissions:
- org_management
/api/v2/orgs/{org_id}/cloud_security_management/custom_frameworks/{handle}/{version}:
delete:
description: Delete a custom framework.
operationId: DeleteCustomFramework
parameters:
- $ref: '#/components/parameters/CustomFrameworkOrgID'
- $ref: '#/components/parameters/CustomFrameworkHandle'
- $ref: '#/components/parameters/CustomFrameworkVersion'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteCustomFrameworkResponse'
description: OK
'400':
$ref: '#/components/responses/BadRequestResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
'500':
$ref: '#/components/responses/BadRequestResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- security_monitoring_rules_read
summary: Delete a custom framework
tags:
- Security Monitoring
x-permission:
operator: OR
permissions:
- security_monitoring_rules_read
/api/v2/permissions:
get:
description: Returns a list of all permissions, including name, description,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ log,https://github.com/rust-lang/log,MIT OR Apache-2.0,The Rust Project Develope
memchr,https://github.com/BurntSushi/memchr,Unlicense OR MIT,"Andrew Gallant <[email protected]>, bluss"
mime,https://github.com/hyperium/mime,MIT OR Apache-2.0,Sean McArthur <[email protected]>
mime_guess,https://github.com/abonander/mime_guess,MIT,Austin Bonander <[email protected]>
miniz_oxide,https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide,MIT OR Zlib OR Apache-2.0,"Frommi <[email protected]>, oyvindln <[email protected]>"
miniz_oxide,https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide,MIT OR Zlib OR Apache-2.0,"Frommi <[email protected]>, oyvindln <[email protected]>, Rich Geldreich [email protected]"
mio,https://github.com/tokio-rs/mio,MIT,"Carl Lerche <[email protected]>, Thomas de Zeeuw <[email protected]>, Tokio Contributors <[email protected]>"
native-tls,https://github.com/sfackler/rust-native-tls,MIT OR Apache-2.0,Steven Fackler <[email protected]>
num-conv,https://github.com/jhpratt/num-conv,MIT OR Apache-2.0,Jacob Pratt <[email protected]>
Expand Down
21 changes: 21 additions & 0 deletions examples/v2_security-monitoring_DeleteCustomFramework.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Delete a custom framework returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = SecurityMonitoringAPI::with_config(configuration);
let resp = api
.delete_custom_framework(
"org_id".to_string(),
"handle".to_string(),
"version".to_string(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
128 changes: 128 additions & 0 deletions src/datadogV2/api/api_security_monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,14 @@ pub enum CreateSecurityMonitoringSuppressionError {
UnknownValue(serde_json::Value),
}

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

/// DeleteHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_historical_job`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -2032,6 +2040,126 @@ impl SecurityMonitoringAPI {
}
}

/// Delete a custom framework.
pub async fn delete_custom_framework(
&self,
org_id: String,
handle: String,
version: String,
) -> Result<
crate::datadogV2::model::DeleteCustomFrameworkResponse,
datadog::Error<DeleteCustomFrameworkError>,
> {
match self
.delete_custom_framework_with_http_info(org_id, handle, version)
.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),
}
}

/// Delete a custom framework.
pub async fn delete_custom_framework_with_http_info(
&self,
org_id: String,
handle: String,
version: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::DeleteCustomFrameworkResponse>,
datadog::Error<DeleteCustomFrameworkError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.delete_custom_framework";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/orgs/{org_id}/cloud_security_management/custom_frameworks/{handle}/{version}",
local_configuration.get_operation_host(operation_id), org_id=
datadog::urlencode(org_id)
, handle=
datadog::urlencode(handle)
, version=
datadog::urlencode(version)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, 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::DeleteCustomFrameworkResponse>(
&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<DeleteCustomFrameworkError> =
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))
}
}

/// Delete an existing job.
pub async fn delete_historical_job(
&self,
Expand Down
4 changes: 4 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,10 @@ pub mod model_org_config_write;
pub use self::model_org_config_write::OrgConfigWrite;
pub mod model_org_config_write_attributes;
pub use self::model_org_config_write_attributes::OrgConfigWriteAttributes;
pub mod model_delete_custom_framework_response;
pub use self::model_delete_custom_framework_response::DeleteCustomFrameworkResponse;
pub mod model_custom_framework_metadata;
pub use self::model_custom_framework_metadata::CustomFrameworkMetadata;
pub mod model_permissions_response;
pub use self::model_permissions_response::PermissionsResponse;
pub mod model_permission;
Expand Down
Loading
Loading