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
138 changes: 138 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73349,6 +73349,86 @@ components:
- MINUS_ID
- NAME
- MINUS_NAME
OrgGroupPolicySuggestionAttributes:
description: Attributes of an org group policy suggestion.
properties:
consensus_ratio:
description: The ratio of member orgs whose configuration agrees on the recommended value.
example: 0.75
format: double
maximum: 1
minimum: 0
type: number
policy_name:
description: The name of the suggested policy.
example: "monitor_timezone"
type: string
recommended_value:
description: The recommended value for the policy, based on member org consensus.
example: "UTC"
status:
$ref: "#/components/schemas/OrgGroupPolicySuggestionStatus"
required:
- policy_name
- status
- consensus_ratio
- recommended_value
type: object
OrgGroupPolicySuggestionData:
description: An org group policy suggestion resource.
properties:
attributes:
$ref: "#/components/schemas/OrgGroupPolicySuggestionAttributes"
id:
description: The ID of the org group policy suggestion.
example: "1a2b3c4d-5e6f-7890-abcd-ef0123456789"
type: string
relationships:
$ref: "#/components/schemas/OrgGroupPolicySuggestionRelationships"
type:
$ref: "#/components/schemas/OrgGroupPolicySuggestionType"
required:
- id
- type
- attributes
type: object
OrgGroupPolicySuggestionListResponse:
description: Response containing a list of org group policy suggestions.
properties:
data:
description: An array of org group policy suggestions.
items:
$ref: "#/components/schemas/OrgGroupPolicySuggestionData"
type: array
required:
- data
type: object
OrgGroupPolicySuggestionRelationships:
description: Relationships of an org group policy suggestion.
properties:
org_group:
$ref: "#/components/schemas/OrgGroupRelationshipToOne"
type: object
OrgGroupPolicySuggestionStatus:
description: The status of the policy suggestion.
enum:
- pending
- accepted
- dismissed
example: pending
type: string
x-enum-varnames:
- PENDING
- ACCEPTED
- DISMISSED
OrgGroupPolicySuggestionType:
description: Org group policy suggestions resource type.
enum:
- org_group_policy_suggestions
example: org_group_policy_suggestions
type: string
x-enum-varnames:
- ORG_GROUP_POLICY_SUGGESTIONS
OrgGroupPolicyType:
description: Org group policies resource type.
enum:
Expand Down Expand Up @@ -164682,6 +164762,64 @@ paths:
x-unstable: |-
**Note**: This endpoint is in preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
/api/v2/org_group_policy_suggestions:
get:
description: List suggested organization group policies. Requires a filter on org group ID.
operationId: ListOrgGroupPolicySuggestions
parameters:
- $ref: "#/components/parameters/OrgGroupPolicyFilterOrgGroupId"
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
- attributes:
consensus_ratio: 0.75
policy_name: "monitor_timezone"
recommended_value: "UTC"
status: "pending"
id: "1a2b3c4d-5e6f-7890-abcd-ef0123456789"
relationships:
org_group:
data:
id: "a1b2c3d4-e5f6-7890-abcd-ef0123456789"
type: org_groups
type: org_group_policy_suggestions
schema:
$ref: "#/components/schemas/OrgGroupPolicySuggestionListResponse"
description: OK
"400":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Bad Request
"401":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Unauthorized
"403":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Forbidden
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
summary: List org group policy suggestions
tags: [Org Groups]
"x-permission":
operator: OR
permissions:
- org_group_read
x-unstable: |-
**Note**: This endpoint is in preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
/api/v2/org_groups:
get:
description: List all organization groups that the requesting organization has access to.
Expand Down
21 changes: 21 additions & 0 deletions examples/v2_org-groups_ListOrgGroupPolicySuggestions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// List org group policy suggestions returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_org_groups::OrgGroupsAPI;
use uuid::Uuid;

#[tokio::main]
async fn main() {
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.ListOrgGroupPolicySuggestions", true);
let api = OrgGroupsAPI::with_config(configuration);
let resp = api
.list_org_group_policy_suggestions(
Uuid::parse_str("a1b2c3d4-e5f6-7890-abcd-ef0123456789").expect("invalid UUID"),
)
.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 @@ -728,6 +728,7 @@ impl Default for Configuration {
("v2.list_org_group_policies".to_owned(), false),
("v2.list_org_group_policy_configs".to_owned(), false),
("v2.list_org_group_policy_overrides".to_owned(), false),
("v2.list_org_group_policy_suggestions".to_owned(), false),
("v2.list_org_groups".to_owned(), false),
("v2.update_org_group".to_owned(), false),
("v2.update_org_group_membership".to_owned(), false),
Expand Down
132 changes: 132 additions & 0 deletions src/datadogV2/api/api_org_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ pub enum ListOrgGroupPolicyOverridesError {
UnknownValue(serde_json::Value),
}

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

/// ListOrgGroupsError is a struct for typed errors of method [`OrgGroupsAPI::list_org_groups`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -2390,6 +2399,129 @@ impl OrgGroupsAPI {
}
}

/// List suggested organization group policies. Requires a filter on org group ID.
pub async fn list_org_group_policy_suggestions(
&self,
filter_org_group_id: uuid::Uuid,
) -> Result<
crate::datadogV2::model::OrgGroupPolicySuggestionListResponse,
datadog::Error<ListOrgGroupPolicySuggestionsError>,
> {
match self
.list_org_group_policy_suggestions_with_http_info(filter_org_group_id)
.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 suggested organization group policies. Requires a filter on org group ID.
pub async fn list_org_group_policy_suggestions_with_http_info(
&self,
filter_org_group_id: uuid::Uuid,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::OrgGroupPolicySuggestionListResponse>,
datadog::Error<ListOrgGroupPolicySuggestionsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_org_group_policy_suggestions";
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_org_group_policy_suggestions' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

let local_client = &self.client;

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

local_req_builder =
local_req_builder.query(&[("filter[org_group_id]", &filter_org_group_id.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::OrgGroupPolicySuggestionListResponse,
>(&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<ListOrgGroupPolicySuggestionsError> =
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))
}
}

/// List all organization groups that the requesting organization has access to.
pub async fn list_org_groups(
&self,
Expand Down
12 changes: 12 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8574,6 +8574,18 @@ pub mod model_org_group_policy_override_update_data;
pub use self::model_org_group_policy_override_update_data::OrgGroupPolicyOverrideUpdateData;
pub mod model_org_group_policy_override_update_attributes;
pub use self::model_org_group_policy_override_update_attributes::OrgGroupPolicyOverrideUpdateAttributes;
pub mod model_org_group_policy_suggestion_list_response;
pub use self::model_org_group_policy_suggestion_list_response::OrgGroupPolicySuggestionListResponse;
pub mod model_org_group_policy_suggestion_data;
pub use self::model_org_group_policy_suggestion_data::OrgGroupPolicySuggestionData;
pub mod model_org_group_policy_suggestion_attributes;
pub use self::model_org_group_policy_suggestion_attributes::OrgGroupPolicySuggestionAttributes;
pub mod model_org_group_policy_suggestion_status;
pub use self::model_org_group_policy_suggestion_status::OrgGroupPolicySuggestionStatus;
pub mod model_org_group_policy_suggestion_relationships;
pub use self::model_org_group_policy_suggestion_relationships::OrgGroupPolicySuggestionRelationships;
pub mod model_org_group_policy_suggestion_type;
pub use self::model_org_group_policy_suggestion_type::OrgGroupPolicySuggestionType;
pub mod model_org_group_sort_option;
pub use self::model_org_group_sort_option::OrgGroupSortOption;
pub mod model_org_group_list_response;
Expand Down
Loading
Loading