use crate::errors::DHResult;
use crate::models::cursor::QueryCursorResponse;
use crate::models::project::{GetProjectResponse, ListProjectResponse};
use crate::models::record::{FieldType, ReadDataResponse, WriteDataResponse};
use crate::models::shard::{ListShardResponse, MergeShardResponse, SplitShardResponse};
use crate::models::subscription::{
CreateSubscriptionRes, GetSubscriptionRes, ListSubscriptionRes, SubscriptionOffset,
SubscriptionSessionOptRes,
};
use crate::models::topic::{GetTopicResponse, ListTopicResponse};
use crate::models::EmptyResponse;
use crate::payload::cursor::CursorType;
use crate::payload::data::{ReadDataPayload, WriteDataPayload};
use crate::payload::topics::CreateTopicPayload;
use async_trait::async_trait;
use std::collections::HashMap;
#[async_trait]
pub trait DatahubClientTrait {
async fn list_project(&mut self) -> DHResult<ListProjectResponse>;
async fn create_project(
&mut self,
project_name: &str,
comment: &str,
) -> DHResult<EmptyResponse>;
async fn get_project(&mut self, project_name: &str) -> DHResult<GetProjectResponse>;
async fn update_project(
&mut self,
project_name: &str,
comment: &str,
) -> DHResult<EmptyResponse>;
async fn delete_project(&mut self, project_name: &str) -> DHResult<EmptyResponse>;
async fn create_topic(
&mut self,
project_name: &str,
topic_name: &str,
create_topic_payload: &CreateTopicPayload,
) -> DHResult<EmptyResponse>;
async fn get_topic(
&mut self,
project_name: &str,
topic_name: &str,
) -> DHResult<GetTopicResponse>;
async fn list_topic(&mut self, project_name: &str) -> DHResult<ListTopicResponse>;
async fn update_topic(
&mut self,
project_name: &str,
topic_name: &str,
comment: &str,
) -> DHResult<EmptyResponse>;
async fn delete_topic(
&mut self,
project_name: &str,
topic_name: &str,
) -> DHResult<EmptyResponse>;
async fn append_filed(
&mut self,
project_name: &str,
topic_name: &str,
field_name: &str,
field_type: FieldType,
) -> DHResult<EmptyResponse>;
async fn list_shard(
&mut self,
project_name: &str,
topic_name: &str,
) -> DHResult<ListShardResponse>;
async fn split_shard(
&mut self,
project_name: &str,
topic_name: &str,
shard_id: &str,
split_key: &str,
) -> DHResult<SplitShardResponse>;
async fn merge_shard(
&mut self,
project_name: &str,
topic_name: &str,
shard_id: &str,
adjacent_shard_id: &str,
) -> DHResult<MergeShardResponse>;
async fn get_cursor(
&mut self,
project_name: &str,
topic_name: &str,
shard_id: &str,
cursor_type: CursorType,
parameter: i64,
) -> DHResult<QueryCursorResponse>;
async fn write_data(
&mut self,
project_name: &str,
topic_name: &str,
write_data_payload: &WriteDataPayload,
) -> DHResult<WriteDataResponse>;
async fn read_data(
&mut self,
project_name: &str,
topic_name: &str,
shard_id: &str,
read_data_payload: &ReadDataPayload,
) -> DHResult<ReadDataResponse>;
async fn create_subscriptions(
&mut self,
project_name: &str,
topic_name: &str,
comment: &str,
) -> DHResult<CreateSubscriptionRes>;
async fn get_subscription(
&mut self,
project_name: &str,
topic_name: &str,
sub_id: &str,
) -> DHResult<GetSubscriptionRes>;
async fn list_subscriptions(
&mut self,
project_name: &str,
topic_name: &str,
page_index: u32,
page_size: u32,
) -> DHResult<ListSubscriptionRes>;
async fn delete_subscription(
&mut self,
project_name: &str,
topic_name: &str,
sub_id: &str,
) -> DHResult<EmptyResponse>;
async fn set_subscription_state(
&mut self,
project_name: &str,
topic_name: &str,
sub_id: &str,
state: i32,
) -> DHResult<EmptyResponse>;
async fn open_subscription_session(
&mut self,
project_name: &str,
topic_name: &str,
sub_id: &str,
shard_ids: &[&str],
) -> DHResult<SubscriptionSessionOptRes>;
async fn get_subscription_offset(
&mut self,
project_name: &str,
topic_name: &str,
sub_id: &str,
shard_ids: &[&str],
) -> DHResult<SubscriptionSessionOptRes>;
async fn commit_subscription_offset(
&mut self,
project_name: &str,
topic_name: &str,
sub_id: &str,
offset_map: &HashMap<String, SubscriptionOffset>,
) -> DHResult<EmptyResponse>;
}