1pub mod error;
2mod operations;
3mod state;
4
5pub use state::DataSyncState;
6
7use async_trait::async_trait;
8use awsim_core::{AccountRegionStore, AwsError, Protocol, RequestContext, ServiceHandler};
9use serde_json::Value;
10use tracing::debug;
11
12pub struct DataSyncService {
13 store: AccountRegionStore<DataSyncState>,
14}
15
16impl DataSyncService {
17 pub fn new() -> Self {
18 Self {
19 store: AccountRegionStore::new(),
20 }
21 }
22}
23
24impl Default for DataSyncService {
25 fn default() -> Self {
26 Self::new()
27 }
28}
29
30#[async_trait]
31impl ServiceHandler for DataSyncService {
32 fn service_name(&self) -> &str {
33 "datasync"
34 }
35
36 fn signing_name(&self) -> &str {
37 "datasync"
38 }
39
40 fn protocol(&self) -> Protocol {
41 Protocol::AwsJson1_1
42 }
43
44 async fn handle(
45 &self,
46 operation: &str,
47 input: Value,
48 ctx: &RequestContext,
49 ) -> Result<Value, AwsError> {
50 debug!(operation, "DataSync request");
51 let state = self.store.get(&ctx.account_id, &ctx.region);
52
53 match operation {
54 "CreateLocationS3" => operations::locations::create_location_s3(&state, &input, ctx),
55 "CreateLocationNfs" => operations::locations::create_location_nfs(&state, &input, ctx),
56 "CreateLocationSmb" => operations::locations::create_location_smb(&state, &input, ctx),
57 "CreateLocationEfs" => operations::locations::create_location_efs(&state, &input, ctx),
58 "DescribeLocationS3" => {
59 operations::locations::describe_location_s3(&state, &input, ctx)
60 }
61 "ListLocations" => operations::locations::list_locations(&state, &input, ctx),
62 "DeleteLocation" => operations::locations::delete_location(&state, &input, ctx),
63 "CreateTask" => operations::tasks::create_task(&state, &input, ctx),
64 "DescribeTask" => operations::tasks::describe_task(&state, &input, ctx),
65 "ListTasks" => operations::tasks::list_tasks(&state, &input, ctx),
66 "UpdateTask" => operations::tasks::update_task(&state, &input, ctx),
67 "DeleteTask" => operations::tasks::delete_task(&state, &input, ctx),
68 "StartTaskExecution" => {
69 operations::executions::start_task_execution(&state, &input, ctx)
70 }
71 "DescribeTaskExecution" => {
72 operations::executions::describe_task_execution(&state, &input, ctx)
73 }
74 "ListTaskExecutions" => {
75 operations::executions::list_task_executions(&state, &input, ctx)
76 }
77 "CancelTaskExecution" => {
78 operations::executions::cancel_task_execution(&state, &input, ctx)
79 }
80 _ => Err(AwsError::unknown_operation(operation)),
81 }
82 }
83}