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
93 changes: 89 additions & 4 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52263,14 +52263,31 @@ components:
TeamSyncAttributes:
description: Team sync attributes.
properties:
frequency:
$ref: '#/components/schemas/TeamSyncAttributesFrequency'
source:
$ref: '#/components/schemas/TeamSyncAttributesSource'
sync_membership:
$ref: '#/components/schemas/TeamSyncAttributesSyncMembership'
type:
$ref: '#/components/schemas/TeamSyncAttributesType'
required:
- source
- type
type: object
TeamSyncAttributesFrequency:
description: How often the sync process should be run. Defaults to `once` when
not provided.
enum:
- once
- continuously
- paused
example: once
type: string
x-enum-varnames:
- ONCE
- CONTINUOUSLY
- PAUSED
TeamSyncAttributesSource:
description: The external source platform for team synchronization. Only "github"
is supported.
Expand All @@ -52280,15 +52297,22 @@ components:
type: string
x-enum-varnames:
- GITHUB
TeamSyncAttributesSyncMembership:
description: Whether to sync members from the external team to the Datadog team.
Defaults to `false` when not provided.
example: true
type: boolean
TeamSyncAttributesType:
description: The type of synchronization operation. Only "link" is supported,
which links existing teams by matching names.
description: The type of synchronization operation. "link" connects teams by
matching names. "provision" creates new teams when no match is found.
enum:
- link
- provision
example: link
type: string
x-enum-varnames:
- LINK
- PROVISION
TeamSyncBulkType:
description: Team sync bulk type.
enum:
Expand All @@ -52298,10 +52322,15 @@ components:
x-enum-varnames:
- TEAM_SYNC_BULK
TeamSyncData:
description: Team sync data.
description: A configuration governing syncing between Datadog teams and teams
from an external system.
properties:
attributes:
$ref: '#/components/schemas/TeamSyncAttributes'
id:
description: The sync's identifier
example: aeadc05e-98a8-11ec-ac2c-da7ad0900001
type: string
type:
$ref: '#/components/schemas/TeamSyncBulkType'
required:
Expand All @@ -52322,6 +52351,15 @@ components:
required:
- data
type: object
TeamSyncResponse:
description: Team sync configurations response.
properties:
data:
description: List of team sync configurations
items:
$ref: '#/components/schemas/TeamSyncData'
type: array
type: object
TeamTarget:
description: Represents a team target for an escalation policy step, including
the team's ID and resource type.
Expand Down Expand Up @@ -81182,6 +81220,52 @@ paths:

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/team/sync:
get:
description: 'Get all team synchronization configurations.

Returns a list of configurations used for linking or provisioning teams with
external sources like GitHub.'
operationId: GetTeamSync
parameters:
- description: Filter by the external source platform for team synchronization
in: query
name: filter[source]
required: true
schema:
$ref: '#/components/schemas/TeamSyncAttributesSource'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/TeamSyncResponse'
description: OK
'403':
$ref: '#/components/responses/ForbiddenResponse'
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Team sync configurations not found
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- teams_read
summary: Get team sync configurations
tags:
- Teams
x-permission:
operator: OR
permissions:
- teams_read
x-unstable: '**Note**: This endpoint is in Preview. To request access, fill
out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/).

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
post:
description: 'This endpoint attempts to link your existing Datadog teams with
GitHub teams by matching their names.
Expand All @@ -81208,7 +81292,8 @@ paths:
using a normalized exact match; case is ignored and spaces are removed. No
modifications are made

to teams in GitHub. This will not create new Teams in Datadog.'
to teams in GitHub. This only creates new teams in Datadog when type is set
to `provision`.'
operationId: SyncTeams
requestBody:
content:
Expand Down
17 changes: 17 additions & 0 deletions examples/v2_teams_GetTeamSync.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Get team sync configurations returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_teams::TeamsAPI;
use datadog_api_client::datadogV2::model::TeamSyncAttributesSource;

#[tokio::main]
async fn main() {
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.GetTeamSync", true);
let api = TeamsAPI::with_config(configuration);
let resp = api.get_team_sync(TeamSyncAttributesSource::GITHUB).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 @@ -256,6 +256,7 @@ impl Default for Configuration {
("v2.create_sca_resolve_vulnerable_symbols".to_owned(), false),
("v2.create_sca_result".to_owned(), false),
("v2.add_member_team".to_owned(), false),
("v2.get_team_sync".to_owned(), false),
("v2.list_member_teams".to_owned(), false),
("v2.remove_member_team".to_owned(), false),
("v2.sync_teams".to_owned(), false),
Expand Down
128 changes: 126 additions & 2 deletions src/datadogV2/api/api_teams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ pub enum GetTeamPermissionSettingsError {
UnknownValue(serde_json::Value),
}

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

/// GetUserMembershipsError is a struct for typed errors of method [`TeamsAPI::get_user_memberships`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -1848,6 +1856,122 @@ impl TeamsAPI {
}
}

/// Get all team synchronization configurations.
/// Returns a list of configurations used for linking or provisioning teams with external sources like GitHub.
pub async fn get_team_sync(
&self,
filter_source: crate::datadogV2::model::TeamSyncAttributesSource,
) -> Result<crate::datadogV2::model::TeamSyncResponse, datadog::Error<GetTeamSyncError>> {
match self.get_team_sync_with_http_info(filter_source).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),
}
}

/// Get all team synchronization configurations.
/// Returns a list of configurations used for linking or provisioning teams with external sources like GitHub.
pub async fn get_team_sync_with_http_info(
&self,
filter_source: crate::datadogV2::model::TeamSyncAttributesSource,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::TeamSyncResponse>,
datadog::Error<GetTeamSyncError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_team_sync";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_team_sync' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/team/sync",
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[source]", &filter_source.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::TeamSyncResponse>(&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<GetTeamSyncError> = 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))
}
}

/// Get a list of memberships for a user
pub async fn get_user_memberships(
&self,
Expand Down Expand Up @@ -2426,7 +2550,7 @@ impl TeamsAPI {
/// [A GitHub organization must be connected to your Datadog account](<https://docs.datadoghq.com/integrations/github/>),
/// and the GitHub App integrated with Datadog must have the `Members Read` permission. Matching is performed by comparing the Datadog team handle to the GitHub team slug
/// using a normalized exact match; case is ignored and spaces are removed. No modifications are made
/// to teams in GitHub. This will not create new Teams in Datadog.
/// to teams in GitHub. This only creates new teams in Datadog when type is set to `provision`.
pub async fn sync_teams(
&self,
body: crate::datadogV2::model::TeamSyncRequest,
Expand All @@ -2447,7 +2571,7 @@ impl TeamsAPI {
/// [A GitHub organization must be connected to your Datadog account](<https://docs.datadoghq.com/integrations/github/>),
/// and the GitHub App integrated with Datadog must have the `Members Read` permission. Matching is performed by comparing the Datadog team handle to the GitHub team slug
/// using a normalized exact match; case is ignored and spaces are removed. No modifications are made
/// to teams in GitHub. This will not create new Teams in Datadog.
/// to teams in GitHub. This only creates new teams in Datadog when type is set to `provision`.
pub async fn sync_teams_with_http_info(
&self,
body: crate::datadogV2::model::TeamSyncRequest,
Expand Down
12 changes: 8 additions & 4 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6630,18 +6630,22 @@ pub mod model_team_connection_create_request;
pub use self::model_team_connection_create_request::TeamConnectionCreateRequest;
pub mod model_team_connection_create_data;
pub use self::model_team_connection_create_data::TeamConnectionCreateData;
pub mod model_team_sync_request;
pub use self::model_team_sync_request::TeamSyncRequest;
pub mod model_team_sync_attributes_source;
pub use self::model_team_sync_attributes_source::TeamSyncAttributesSource;
pub mod model_team_sync_response;
pub use self::model_team_sync_response::TeamSyncResponse;
pub mod model_team_sync_data;
pub use self::model_team_sync_data::TeamSyncData;
pub mod model_team_sync_attributes;
pub use self::model_team_sync_attributes::TeamSyncAttributes;
pub mod model_team_sync_attributes_source;
pub use self::model_team_sync_attributes_source::TeamSyncAttributesSource;
pub mod model_team_sync_attributes_frequency;
pub use self::model_team_sync_attributes_frequency::TeamSyncAttributesFrequency;
pub mod model_team_sync_attributes_type;
pub use self::model_team_sync_attributes_type::TeamSyncAttributesType;
pub mod model_team_sync_bulk_type;
pub use self::model_team_sync_bulk_type::TeamSyncBulkType;
pub mod model_team_sync_request;
pub use self::model_team_sync_request::TeamSyncRequest;
pub mod model_add_member_team_request;
pub use self::model_add_member_team_request::AddMemberTeamRequest;
pub mod model_member_team;
Expand Down
Loading