• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 3977575075

pending completion
3977575075

push

github

GitHub
Chore/apply flags config (#664)

139 of 139 new or added lines in 10 files covered. (100.0%)

22504 of 34428 relevant lines covered (65.37%)

72228.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dozer-admin/src/services/api_config_service.rs
1
use dozer_types::models::api_config::{default_api_config, ApiConfig};
2

3
use crate::{
4
    db::{persistable::Persistable, pool::DbPool},
5
    server::dozer_admin_grpc::{
6
        CreateApiConfigRequest, CreateApiConfigResponse, ErrorResponse, GetApiConfigRequest,
7
        GetApiConfigResponse, UpdateApiConfigRequest, UpdateApiConfigResponse,
8
    },
9
};
10

11
pub struct ApiConfigService {
12
    db_pool: DbPool,
13
}
14
impl ApiConfigService {
15
    pub fn new(db_pool: DbPool) -> Self {
×
16
        Self { db_pool }
×
17
    }
×
18
}
19
impl ApiConfigService {
20
    pub fn create_api_config(
×
21
        &self,
×
22
        input: CreateApiConfigRequest,
×
23
    ) -> Result<CreateApiConfigResponse, ErrorResponse> {
×
24
        let mut api_config = default_api_config();
×
25
        if input.grpc.is_some() {
×
26
            api_config.grpc = input.grpc;
×
27
        }
×
28
        if input.rest.is_some() {
×
29
            api_config.rest = input.rest;
×
30
        }
×
31
        if input.api_internal.is_some() {
×
32
            api_config.api_internal = input.api_internal;
×
33
        }
×
34
        if input.pipeline_internal.is_some() {
×
35
            api_config.pipeline_internal = input.pipeline_internal;
×
36
        }
×
37
        api_config.app_id = Some(input.app_id);
×
38
        api_config.auth = input.auth;
×
39
        api_config
×
40
            .save(self.db_pool.clone())
×
41
            .map_err(|err| ErrorResponse {
×
42
                message: err.to_string(),
×
43
            })?;
×
44
        Ok(CreateApiConfigResponse {
×
45
            config: Some(api_config),
×
46
        })
×
47
    }
×
48

49
    pub fn update(
×
50
        &self,
×
51
        input: UpdateApiConfigRequest,
×
52
    ) -> Result<UpdateApiConfigResponse, ErrorResponse> {
×
53
        let mut config_by_id = ApiConfig::by_id(self.db_pool.clone(), input.id, input.app_id)
×
54
            .map_err(|err| ErrorResponse {
×
55
                message: err.to_string(),
×
56
            })?;
×
57

58
        if input.grpc.is_some() {
×
59
            config_by_id.grpc = input.grpc;
×
60
        }
×
61
        if input.rest.is_some() {
×
62
            config_by_id.rest = input.rest;
×
63
        }
×
64
        if input.api_internal.is_some() {
×
65
            config_by_id.api_internal = input.api_internal;
×
66
        }
×
67
        if input.pipeline_internal.is_some() {
×
68
            config_by_id.pipeline_internal = input.pipeline_internal;
×
69
        }
×
70
        config_by_id.auth = input.auth;
×
71
        config_by_id
×
72
            .upsert(self.db_pool.clone())
×
73
            .map_err(|err| ErrorResponse {
×
74
                message: err.to_string(),
×
75
            })?;
×
76
        Ok(UpdateApiConfigResponse {
×
77
            config: Some(config_by_id),
×
78
        })
×
79
    }
×
80
    pub fn get_api_config(
×
81
        &self,
×
82
        request: GetApiConfigRequest,
×
83
    ) -> Result<GetApiConfigResponse, ErrorResponse> {
×
84
        let api_config = ApiConfig::by_id(self.db_pool.to_owned(), "".to_owned(), request.app_id)
×
85
            .map_err(|op| ErrorResponse {
×
86
            message: op.to_string(),
×
87
        })?;
×
88
        Ok(GetApiConfigResponse {
×
89
            config: Some(api_config),
×
90
        })
×
91
    }
×
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc