aboutsummaryrefslogtreecommitdiffstats
path: root/lib/api-config/src/schema/implementation.rs
blob: ed43c31bdff3fed9ba4939aeb704605cfda7f0e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use async_trait::async_trait;
use tracing::debug;
use warden_core::pagination::{Connection, PaginationArgs};

use crate::schema::{self, SchemaDriver, SchemaService, TransactionSchema};

#[async_trait]
impl SchemaDriver for SchemaService {
    #[tracing::instrument(skip(self, schema))]
    async fn create_schema(
        &self,
        kind: &str,
        version: &str,
        schema: &serde_json::Value,
    ) -> Result<TransactionSchema, crate::ConfigurationError> {
        schema::create_schema::create_schema(self, kind, version, schema).await
    }

    #[tracing::instrument(skip(self))]
    async fn delete_schema(
        &self,
        kind: &str,
        version: &str,
    ) -> Result<(), crate::ConfigurationError> {
        schema::delete_schema::delete_schema(self, kind, version).await
    }

    #[tracing::instrument(skip(self))]
    async fn get_schema(
        &self,
        kind: &str,
        version: &str,
    ) -> Result<Option<TransactionSchema>, crate::ConfigurationError> {
        schema::get_schema::get_schema(self, kind, version).await
    }

    #[tracing::instrument(skip(self, schema))]
    async fn update_schema(
        &self,
        kind: &str,
        version: &str,
        schema: &serde_json::Value,
    ) -> Result<Option<TransactionSchema>, crate::ConfigurationError> {
        schema::update_schema::update_schema(self, kind, version, schema).await
    }

    #[tracing::instrument(skip(self))]
    async fn list_schemas(
        &self,
        input: &PaginationArgs,
        limit: i64,
    ) -> Result<Connection<TransactionSchema>, crate::ConfigurationError> {
        debug!("getting transaction schemas");
        schema::list_schemas::list_schemas(self, input, limit).await
    }
}