pub mod annotations;
pub mod bucket;
pub mod comments;
pub mod dataset;
pub mod emails;
pub mod integrations;
pub mod project;
pub mod quota;
pub mod source;
pub mod stream_exception;
pub mod streams;
pub mod user;
use self::{
annotations::CreateAnnotationsArgs, bucket::CreateBucketArgs, comments::CreateCommentsArgs,
dataset::CreateDatasetArgs, emails::CreateEmailsArgs, integrations::CreateIntegrationArgs,
project::CreateProjectArgs, quota::CreateQuotaArgs, source::CreateSourceArgs,
stream_exception::CreateStreamExceptionArgs, streams::CreateStreamsArgs, user::CreateUserArgs,
};
use crate::printer::Printer;
use anyhow::Result;
use reinfer_client::Client;
use scoped_threadpool::Pool;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub enum CreateArgs {
#[structopt(name = "bucket")]
Bucket(CreateBucketArgs),
#[structopt(name = "project")]
Project(CreateProjectArgs),
#[structopt(name = "source")]
Source(CreateSourceArgs),
#[structopt(name = "dataset")]
Dataset(CreateDatasetArgs),
#[structopt(name = "comments")]
Comments(CreateCommentsArgs),
#[structopt(name = "annotations")]
Annotations(CreateAnnotationsArgs),
#[structopt(name = "emails")]
Emails(CreateEmailsArgs),
#[structopt(name = "user")]
User(CreateUserArgs),
#[structopt(name = "stream-exception")]
StreamException(CreateStreamExceptionArgs),
#[structopt(name = "quota")]
Quota(CreateQuotaArgs),
#[structopt(name = "stream")]
Stream(CreateStreamsArgs),
#[structopt(name = "streams")]
Streams(CreateStreamsArgs),
#[structopt(name = "integration")]
Integration(CreateIntegrationArgs),
#[structopt(name = "integrations")]
Integrations(CreateIntegrationArgs),
}
pub fn run(
create_args: &CreateArgs,
client: Client,
printer: &Printer,
pool: &mut Pool,
) -> Result<()> {
match create_args {
CreateArgs::Bucket(bucket_args) => bucket::create(&client, bucket_args, printer),
CreateArgs::Source(source_args) => source::create(&client, source_args, printer),
CreateArgs::Dataset(dataset_args) => dataset::create(&client, dataset_args, printer),
CreateArgs::Project(project_args) => project::create(&client, project_args, printer),
CreateArgs::Comments(comments_args) => comments::create(&client, comments_args, pool),
CreateArgs::Annotations(annotations_args) => {
annotations::create(&client, annotations_args, pool)
}
CreateArgs::Emails(emails_args) => emails::create(&client, emails_args),
CreateArgs::User(user_args) => user::create(&client, user_args, printer),
CreateArgs::StreamException(stream_exception_args) => {
stream_exception::create(&client, stream_exception_args, printer)
}
CreateArgs::Quota(quota_args) => quota::create(&client, quota_args),
CreateArgs::Stream(stream_args) | CreateArgs::Streams(stream_args) => {
streams::create(&client, stream_args)
}
CreateArgs::Integration(integration_args) | CreateArgs::Integrations(integration_args) => {
integrations::create(&client, integration_args)
}
}
}