Skip to content

Commit 0f793f2

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add cloud-agnostic account filters endpoints to Cloud Cost Management (#1836)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 64db983 commit 0f793f2

16 files changed

Lines changed: 1519 additions & 2 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,6 +4062,86 @@ components:
40624062
type: string
40634063
type: array
40644064
type: object
4065+
AccountFilters:
4066+
description: The account filters for a cloud account.
4067+
properties:
4068+
attributes:
4069+
$ref: "#/components/schemas/AccountFiltersAttributes"
4070+
id:
4071+
description: The ID of the cloud account.
4072+
example: "123456789123"
4073+
type: string
4074+
type:
4075+
$ref: "#/components/schemas/AccountFiltersType"
4076+
required:
4077+
- attributes
4078+
- type
4079+
type: object
4080+
AccountFiltersAttributes:
4081+
description: Attributes for the account filters of a cloud account.
4082+
properties:
4083+
account_filters:
4084+
$ref: "#/components/schemas/AccountFilteringConfig"
4085+
account_id:
4086+
description: The cloud account ID.
4087+
example: "123456789123"
4088+
type: string
4089+
cloud:
4090+
description: The cloud provider of the account, for example `aws`, `aws_cur2`, or `oci`.
4091+
example: "aws_cur2"
4092+
type: string
4093+
type: object
4094+
AccountFiltersPatchData:
4095+
description: Account filters patch data.
4096+
properties:
4097+
attributes:
4098+
$ref: "#/components/schemas/AccountFiltersPatchRequestAttributes"
4099+
type:
4100+
$ref: "#/components/schemas/AccountFiltersPatchRequestType"
4101+
required:
4102+
- attributes
4103+
- type
4104+
type: object
4105+
AccountFiltersPatchRequest:
4106+
description: Account filters patch request.
4107+
properties:
4108+
data:
4109+
$ref: "#/components/schemas/AccountFiltersPatchData"
4110+
required:
4111+
- data
4112+
type: object
4113+
AccountFiltersPatchRequestAttributes:
4114+
description: Attributes for an account filters patch request.
4115+
properties:
4116+
account_filters:
4117+
$ref: "#/components/schemas/AccountFilteringConfig"
4118+
required:
4119+
- account_filters
4120+
type: object
4121+
AccountFiltersPatchRequestType:
4122+
default: account_filters_patch_request
4123+
description: Type of account filters patch request.
4124+
enum:
4125+
- account_filters_patch_request
4126+
example: account_filters_patch_request
4127+
type: string
4128+
x-enum-varnames:
4129+
- ACCOUNT_FILTERS_PATCH_REQUEST
4130+
AccountFiltersResponse:
4131+
description: Response containing the account filters for a cloud account.
4132+
properties:
4133+
data:
4134+
$ref: "#/components/schemas/AccountFilters"
4135+
type: object
4136+
AccountFiltersType:
4137+
default: account_filters
4138+
description: Type of account filters.
4139+
enum:
4140+
- account_filters
4141+
example: account_filters
4142+
type: string
4143+
x-enum-varnames:
4144+
- ACCOUNT_FILTERS
40654145
ActionConnectionAttributes:
40664146
description: The definition of `ActionConnectionAttributes` object.
40674147
properties:
@@ -126466,6 +126546,182 @@ paths:
126466126546
"x-permission":
126467126547
operator: OPEN
126468126548
permissions: []
126549+
/api/v2/cost/account_filters/{cloud_account_id}:
126550+
get:
126551+
description: Get the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds).
126552+
operationId: GetCostAccountFilters
126553+
parameters:
126554+
- $ref: "#/components/parameters/CloudAccountID"
126555+
responses:
126556+
"200":
126557+
content:
126558+
application/json:
126559+
examples:
126560+
default:
126561+
summary: Include new accounts and exclude specific accounts
126562+
value:
126563+
data:
126564+
attributes:
126565+
account_filters:
126566+
excluded_accounts:
126567+
- "123456789123"
126568+
- "123456789143"
126569+
include_new_accounts: true
126570+
account_id: "123456789123"
126571+
cloud: aws_cur2
126572+
id: "123"
126573+
type: account_filters
126574+
include_accounts:
126575+
summary: Exclude new accounts and include specific accounts
126576+
value:
126577+
data:
126578+
attributes:
126579+
account_filters:
126580+
include_new_accounts: false
126581+
included_accounts:
126582+
- "123456789123"
126583+
- "123456789143"
126584+
account_id: "123456789123"
126585+
cloud: aws_cur2
126586+
id: "123"
126587+
type: account_filters
126588+
schema:
126589+
$ref: "#/components/schemas/AccountFiltersResponse"
126590+
description: OK
126591+
"400":
126592+
content:
126593+
application/json:
126594+
schema:
126595+
$ref: "#/components/schemas/APIErrorResponse"
126596+
description: Bad Request
126597+
"403":
126598+
content:
126599+
application/json:
126600+
schema:
126601+
$ref: "#/components/schemas/APIErrorResponse"
126602+
description: Forbidden
126603+
"404":
126604+
content:
126605+
application/json:
126606+
schema:
126607+
$ref: "#/components/schemas/APIErrorResponse"
126608+
description: Not Found
126609+
"429":
126610+
$ref: "#/components/responses/TooManyRequestsResponse"
126611+
security:
126612+
- apiKeyAuth: []
126613+
appKeyAuth: []
126614+
- AuthZ:
126615+
- cloud_cost_management_read
126616+
summary: Get account filters
126617+
tags:
126618+
- Cloud Cost Management
126619+
"x-permission":
126620+
operator: OR
126621+
permissions:
126622+
- cloud_cost_management_read
126623+
patch:
126624+
description: Update the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds).
126625+
operationId: UpdateCostAccountFilters
126626+
parameters:
126627+
- $ref: "#/components/parameters/CloudAccountID"
126628+
requestBody:
126629+
content:
126630+
application/json:
126631+
examples:
126632+
default:
126633+
summary: Exclude new accounts and include specific accounts
126634+
value:
126635+
data:
126636+
attributes:
126637+
account_filters:
126638+
include_new_accounts: false
126639+
included_accounts:
126640+
- "123456789123"
126641+
- "123456789143"
126642+
type: account_filters_patch_request
126643+
exclude_accounts:
126644+
summary: Include new accounts and exclude specific accounts
126645+
value:
126646+
data:
126647+
attributes:
126648+
account_filters:
126649+
excluded_accounts:
126650+
- "123456789123"
126651+
- "123456789143"
126652+
include_new_accounts: true
126653+
type: account_filters_patch_request
126654+
schema:
126655+
$ref: "#/components/schemas/AccountFiltersPatchRequest"
126656+
required: true
126657+
responses:
126658+
"200":
126659+
content:
126660+
application/json:
126661+
examples:
126662+
default:
126663+
summary: Exclude new accounts and include specific accounts
126664+
value:
126665+
data:
126666+
attributes:
126667+
account_filters:
126668+
include_new_accounts: false
126669+
included_accounts:
126670+
- "123456789123"
126671+
- "123456789143"
126672+
account_id: "123456789123"
126673+
cloud: aws_cur2
126674+
id: "123"
126675+
type: account_filters
126676+
exclude_accounts:
126677+
summary: Include new accounts and exclude specific accounts
126678+
value:
126679+
data:
126680+
attributes:
126681+
account_filters:
126682+
excluded_accounts:
126683+
- "123456789123"
126684+
- "123456789143"
126685+
include_new_accounts: true
126686+
account_id: "123456789123"
126687+
cloud: aws_cur2
126688+
id: "123"
126689+
type: account_filters
126690+
schema:
126691+
$ref: "#/components/schemas/AccountFiltersResponse"
126692+
description: OK
126693+
"400":
126694+
content:
126695+
application/json:
126696+
schema:
126697+
$ref: "#/components/schemas/APIErrorResponse"
126698+
description: Bad Request
126699+
"403":
126700+
content:
126701+
application/json:
126702+
schema:
126703+
$ref: "#/components/schemas/APIErrorResponse"
126704+
description: Forbidden
126705+
"404":
126706+
content:
126707+
application/json:
126708+
schema:
126709+
$ref: "#/components/schemas/APIErrorResponse"
126710+
description: Not Found
126711+
"429":
126712+
$ref: "#/components/responses/TooManyRequestsResponse"
126713+
security:
126714+
- apiKeyAuth: []
126715+
appKeyAuth: []
126716+
- AuthZ:
126717+
- cloud_cost_management_write
126718+
summary: Update account filters
126719+
tags:
126720+
- Cloud Cost Management
126721+
"x-permission":
126722+
operator: OR
126723+
permissions:
126724+
- cloud_cost_management_write
126469126725
/api/v2/cost/anomalies:
126470126726
get:
126471126727
description: List detected Cloud Cost Management anomalies for the organization.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Get account filters returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = CloudCostManagementAPI::with_config(configuration);
9+
let resp = api.get_cost_account_filters(9223372036854775807).await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Update account filters returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
use datadog_api_client::datadogV2::model::AccountFilteringConfig;
5+
use datadog_api_client::datadogV2::model::AccountFiltersPatchData;
6+
use datadog_api_client::datadogV2::model::AccountFiltersPatchRequest;
7+
use datadog_api_client::datadogV2::model::AccountFiltersPatchRequestAttributes;
8+
use datadog_api_client::datadogV2::model::AccountFiltersPatchRequestType;
9+
10+
#[tokio::main]
11+
async fn main() {
12+
let body = AccountFiltersPatchRequest::new(AccountFiltersPatchData::new(
13+
AccountFiltersPatchRequestAttributes::new(
14+
AccountFilteringConfig::new()
15+
.excluded_accounts(vec!["123456789123".to_string(), "123456789143".to_string()])
16+
.include_new_accounts(Some(true))
17+
.included_accounts(vec!["123456789123".to_string(), "123456789143".to_string()]),
18+
),
19+
AccountFiltersPatchRequestType::ACCOUNT_FILTERS_PATCH_REQUEST,
20+
));
21+
let configuration = datadog::Configuration::new();
22+
let api = CloudCostManagementAPI::with_config(configuration);
23+
let resp = api
24+
.update_cost_account_filters(9223372036854775807, body)
25+
.await;
26+
if let Ok(value) = resp {
27+
println!("{:#?}", value);
28+
} else {
29+
println!("{:#?}", resp.unwrap_err());
30+
}
31+
}

0 commit comments

Comments
 (0)