feat: add integrations

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2026-03-08 23:00:14 +01:00
parent 5a5f9a3003
commit 646581ff44
65 changed files with 7774 additions and 127 deletions

View File

@@ -5,9 +5,9 @@ use forage_core::auth::{
use forage_core::platform::{
Artifact, ArtifactContext, ArtifactDestination, ArtifactRef, ArtifactSource, CreatePolicyInput,
CreateReleasePipelineInput, CreateTriggerInput, Destination, DestinationType, Environment,
ForestPlatform, Organisation, OrgMember, PipelineStage, PipelineStageConfig, PlatformError,
Policy, PolicyConfig, ReleasePipeline, Trigger, UpdatePolicyInput,
UpdateReleasePipelineInput, UpdateTriggerInput,
ForestPlatform, NotificationPreference, Organisation, OrgMember, PipelineStage,
PipelineStageConfig, PlatformError, Policy, PolicyConfig, ReleasePipeline, Trigger,
UpdatePolicyInput, UpdateReleasePipelineInput, UpdateTriggerInput,
};
use forage_grpc::policy_service_client::PolicyServiceClient;
use forage_grpc::release_pipeline_service_client::ReleasePipelineServiceClient;
@@ -87,6 +87,14 @@ impl GrpcForestClient {
forage_grpc::event_service_client::EventServiceClient::new(self.channel.clone())
}
pub(crate) fn notification_client(
&self,
) -> forage_grpc::notification_service_client::NotificationServiceClient<Channel> {
forage_grpc::notification_service_client::NotificationServiceClient::new(
self.channel.clone(),
)
}
fn authed_request<T>(access_token: &str, msg: T) -> Result<Request<T>, AuthError> {
bearer_request(access_token, msg).map_err(AuthError::Other)
}
@@ -1620,6 +1628,63 @@ impl ForestPlatform for GrpcForestClient {
.map_err(map_platform_status)?;
Ok(resp.into_inner().content)
}
async fn get_notification_preferences(
&self,
access_token: &str,
) -> Result<Vec<NotificationPreference>, PlatformError> {
let req = platform_authed_request(
access_token,
forage_grpc::GetNotificationPreferencesRequest {},
)?;
let resp = self
.notification_client()
.get_notification_preferences(req)
.await
.map_err(map_platform_status)?;
Ok(resp
.into_inner()
.preferences
.into_iter()
.map(|p| {
let nt = forage_grpc::NotificationType::try_from(p.notification_type)
.unwrap_or(forage_grpc::NotificationType::Unspecified);
let ch = forage_grpc::NotificationChannel::try_from(p.channel)
.unwrap_or(forage_grpc::NotificationChannel::Unspecified);
NotificationPreference {
notification_type: nt.as_str_name().to_string(),
channel: ch.as_str_name().to_string(),
enabled: p.enabled,
}
})
.collect())
}
async fn set_notification_preference(
&self,
access_token: &str,
notification_type: &str,
channel: &str,
enabled: bool,
) -> Result<(), PlatformError> {
let nt = forage_grpc::NotificationType::from_str_name(notification_type)
.unwrap_or(forage_grpc::NotificationType::Unspecified) as i32;
let ch = forage_grpc::NotificationChannel::from_str_name(channel)
.unwrap_or(forage_grpc::NotificationChannel::Unspecified) as i32;
let req = platform_authed_request(
access_token,
forage_grpc::SetNotificationPreferenceRequest {
notification_type: nt,
channel: ch,
enabled,
},
)?;
self.notification_client()
.set_notification_preference(req)
.await
.map_err(map_platform_status)?;
Ok(())
}
}
#[cfg(test)]