mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
feat: migration api for migrating routing rules to decision_engine (#8233)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -7,7 +7,8 @@ use crate::routing::{
|
||||
RoutingAlgorithmId, RoutingConfigRequest, RoutingDictionaryRecord, RoutingKind,
|
||||
RoutingLinkWrapper, RoutingPayloadWrapper, RoutingRetrieveLinkQuery,
|
||||
RoutingRetrieveLinkQueryWrapper, RoutingRetrieveQuery, RoutingVolumeSplit,
|
||||
RoutingVolumeSplitResponse, RoutingVolumeSplitWrapper, SuccessBasedRoutingConfig,
|
||||
RoutingVolumeSplitResponse, RoutingVolumeSplitWrapper, RuleMigrationError, RuleMigrationQuery,
|
||||
RuleMigrationResponse, RuleMigrationResult, SuccessBasedRoutingConfig,
|
||||
SuccessBasedRoutingPayloadWrapper, ToggleDynamicRoutingPath, ToggleDynamicRoutingQuery,
|
||||
ToggleDynamicRoutingWrapper,
|
||||
};
|
||||
@ -153,3 +154,27 @@ impl ApiEventMetric for RoutingVolumeSplit {
|
||||
Some(ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for RuleMigrationQuery {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for RuleMigrationResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for RuleMigrationResult {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for RuleMigrationError {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,3 +1538,50 @@ pub enum ContractUpdationStatusEventResponse {
|
||||
ContractUpdationSucceeded,
|
||||
ContractUpdationFailed,
|
||||
}
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct RuleMigrationQuery {
|
||||
pub profile_id: common_utils::id_type::ProfileId,
|
||||
pub merchant_id: common_utils::id_type::MerchantId,
|
||||
pub limit: Option<u32>,
|
||||
pub offset: Option<u32>,
|
||||
}
|
||||
|
||||
impl RuleMigrationQuery {
|
||||
pub fn validated_limit(&self) -> u32 {
|
||||
self.limit.unwrap_or(50).min(1000)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
pub struct RuleMigrationResult {
|
||||
pub success: Vec<RuleMigrationResponse>,
|
||||
pub errors: Vec<RuleMigrationError>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
pub struct RuleMigrationResponse {
|
||||
pub profile_id: common_utils::id_type::ProfileId,
|
||||
pub euclid_algorithm_id: common_utils::id_type::RoutingId,
|
||||
pub decision_engine_algorithm_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
pub struct RuleMigrationError {
|
||||
pub profile_id: common_utils::id_type::ProfileId,
|
||||
pub algorithm_id: common_utils::id_type::RoutingId,
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
impl RuleMigrationResponse {
|
||||
pub fn new(
|
||||
profile_id: common_utils::id_type::ProfileId,
|
||||
euclid_algorithm_id: common_utils::id_type::RoutingId,
|
||||
decision_engine_algorithm_id: String,
|
||||
) -> Self {
|
||||
Self {
|
||||
profile_id,
|
||||
euclid_algorithm_id,
|
||||
decision_engine_algorithm_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user