@@ -297,6 +297,15 @@ pub enum ListOrgGroupPolicyOverridesError {
297297 UnknownValue ( serde_json:: Value ) ,
298298}
299299
300+ /// ListOrgGroupPolicySuggestionsError is a struct for typed errors of method [`OrgGroupsAPI::list_org_group_policy_suggestions`]
301+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
302+ #[ serde( untagged) ]
303+ pub enum ListOrgGroupPolicySuggestionsError {
304+ JSONAPIErrorResponse ( crate :: datadogV2:: model:: JSONAPIErrorResponse ) ,
305+ APIErrorResponse ( crate :: datadogV2:: model:: APIErrorResponse ) ,
306+ UnknownValue ( serde_json:: Value ) ,
307+ }
308+
300309/// ListOrgGroupsError is a struct for typed errors of method [`OrgGroupsAPI::list_org_groups`]
301310#[ derive( Debug , Clone , Serialize , Deserialize ) ]
302311#[ serde( untagged) ]
@@ -2390,6 +2399,129 @@ impl OrgGroupsAPI {
23902399 }
23912400 }
23922401
2402+ /// List suggested organization group policies. Requires a filter on org group ID.
2403+ pub async fn list_org_group_policy_suggestions (
2404+ & self ,
2405+ filter_org_group_id : uuid:: Uuid ,
2406+ ) -> Result <
2407+ crate :: datadogV2:: model:: OrgGroupPolicySuggestionListResponse ,
2408+ datadog:: Error < ListOrgGroupPolicySuggestionsError > ,
2409+ > {
2410+ match self
2411+ . list_org_group_policy_suggestions_with_http_info ( filter_org_group_id)
2412+ . await
2413+ {
2414+ Ok ( response_content) => {
2415+ if let Some ( e) = response_content. entity {
2416+ Ok ( e)
2417+ } else {
2418+ Err ( datadog:: Error :: Serde ( serde:: de:: Error :: custom (
2419+ "response content was None" ,
2420+ ) ) )
2421+ }
2422+ }
2423+ Err ( err) => Err ( err) ,
2424+ }
2425+ }
2426+
2427+ /// List suggested organization group policies. Requires a filter on org group ID.
2428+ pub async fn list_org_group_policy_suggestions_with_http_info (
2429+ & self ,
2430+ filter_org_group_id : uuid:: Uuid ,
2431+ ) -> Result <
2432+ datadog:: ResponseContent < crate :: datadogV2:: model:: OrgGroupPolicySuggestionListResponse > ,
2433+ datadog:: Error < ListOrgGroupPolicySuggestionsError > ,
2434+ > {
2435+ let local_configuration = & self . config ;
2436+ let operation_id = "v2.list_org_group_policy_suggestions" ;
2437+ if local_configuration. is_unstable_operation_enabled ( operation_id) {
2438+ warn ! ( "Using unstable operation {operation_id}" ) ;
2439+ } else {
2440+ let local_error = datadog:: UnstableOperationDisabledError {
2441+ msg : "Operation 'v2.list_org_group_policy_suggestions' is not enabled" . to_string ( ) ,
2442+ } ;
2443+ return Err ( datadog:: Error :: UnstableOperationDisabledError ( local_error) ) ;
2444+ }
2445+
2446+ let local_client = & self . client ;
2447+
2448+ let local_uri_str = format ! (
2449+ "{}/api/v2/org_group_policy_suggestions" ,
2450+ local_configuration. get_operation_host( operation_id)
2451+ ) ;
2452+ let mut local_req_builder =
2453+ local_client. request ( reqwest:: Method :: GET , local_uri_str. as_str ( ) ) ;
2454+
2455+ local_req_builder =
2456+ local_req_builder. query ( & [ ( "filter[org_group_id]" , & filter_org_group_id. to_string ( ) ) ] ) ;
2457+
2458+ // build headers
2459+ let mut headers = HeaderMap :: new ( ) ;
2460+ headers. insert ( "Accept" , HeaderValue :: from_static ( "application/json" ) ) ;
2461+
2462+ // build user agent
2463+ match HeaderValue :: from_str ( local_configuration. user_agent . as_str ( ) ) {
2464+ Ok ( user_agent) => headers. insert ( reqwest:: header:: USER_AGENT , user_agent) ,
2465+ Err ( e) => {
2466+ log:: warn!( "Failed to parse user agent header: {e}, falling back to default" ) ;
2467+ headers. insert (
2468+ reqwest:: header:: USER_AGENT ,
2469+ HeaderValue :: from_static ( datadog:: DEFAULT_USER_AGENT . as_str ( ) ) ,
2470+ )
2471+ }
2472+ } ;
2473+
2474+ // build auth
2475+ if let Some ( local_key) = local_configuration. auth_keys . get ( "apiKeyAuth" ) {
2476+ headers. insert (
2477+ "DD-API-KEY" ,
2478+ HeaderValue :: from_str ( local_key. key . as_str ( ) )
2479+ . expect ( "failed to parse DD-API-KEY header" ) ,
2480+ ) ;
2481+ } ;
2482+ if let Some ( local_key) = local_configuration. auth_keys . get ( "appKeyAuth" ) {
2483+ headers. insert (
2484+ "DD-APPLICATION-KEY" ,
2485+ HeaderValue :: from_str ( local_key. key . as_str ( ) )
2486+ . expect ( "failed to parse DD-APPLICATION-KEY header" ) ,
2487+ ) ;
2488+ } ;
2489+
2490+ local_req_builder = local_req_builder. headers ( headers) ;
2491+ let local_req = local_req_builder. build ( ) ?;
2492+ log:: debug!( "request content: {:?}" , local_req. body( ) ) ;
2493+ let local_resp = local_client. execute ( local_req) . await ?;
2494+
2495+ let local_status = local_resp. status ( ) ;
2496+ let local_content = local_resp. text ( ) . await ?;
2497+ log:: debug!( "response content: {}" , local_content) ;
2498+
2499+ if !local_status. is_client_error ( ) && !local_status. is_server_error ( ) {
2500+ match serde_json:: from_str :: <
2501+ crate :: datadogV2:: model:: OrgGroupPolicySuggestionListResponse ,
2502+ > ( & local_content)
2503+ {
2504+ Ok ( e) => {
2505+ return Ok ( datadog:: ResponseContent {
2506+ status : local_status,
2507+ content : local_content,
2508+ entity : Some ( e) ,
2509+ } )
2510+ }
2511+ Err ( e) => return Err ( datadog:: Error :: Serde ( e) ) ,
2512+ } ;
2513+ } else {
2514+ let local_entity: Option < ListOrgGroupPolicySuggestionsError > =
2515+ serde_json:: from_str ( & local_content) . ok ( ) ;
2516+ let local_error = datadog:: ResponseContent {
2517+ status : local_status,
2518+ content : local_content,
2519+ entity : local_entity,
2520+ } ;
2521+ Err ( datadog:: Error :: ResponseError ( local_error) )
2522+ }
2523+ }
2524+
23932525 /// List all organization groups that the requesting organization has access to.
23942526 pub async fn list_org_groups (
23952527 & self ,
0 commit comments