use structopt::StructOpt;
use garage_util::version::garage_version;
use crate::cli::local::convert_db;
#[derive(StructOpt, Debug)]
pub enum Command {
#[structopt(name = "server", version = garage_version())]
Server,
#[structopt(name = "status", version = garage_version())]
Status,
#[structopt(name = "node", version = garage_version())]
Node(NodeOperation),
#[structopt(name = "layout", version = garage_version())]
Layout(LayoutOperation),
#[structopt(name = "bucket", version = garage_version())]
Bucket(BucketOperation),
#[structopt(name = "key", version = garage_version())]
Key(KeyOperation),
#[structopt(name = "admin-token", version = garage_version())]
AdminToken(AdminTokenOperation),
#[structopt(name = "repair", version = garage_version())]
Repair(RepairOpt),
#[structopt(name = "offline-repair", version = garage_version())]
OfflineRepair(OfflineRepairOpt),
#[structopt(name = "stats", version = garage_version())]
Stats(StatsOpt),
#[structopt(name = "worker", version = garage_version())]
Worker(WorkerOperation),
#[structopt(name = "block", version = garage_version())]
Block(BlockOperation),
#[structopt(name = "meta", version = garage_version())]
Meta(MetaOperation),
#[structopt(name = "convert-db", version = garage_version())]
ConvertDb(convert_db::ConvertDbOpt),
#[structopt(name = "admin-api-schema", version = garage_version(), setting(structopt::clap::AppSettings::Hidden))]
AdminApiSchema,
#[structopt(name = "json-api", version = garage_version())]
JsonApi {
endpoint: String,
#[structopt(default_value = "null")]
payload: String,
},
}
#[derive(StructOpt, Debug)]
pub enum NodeOperation {
#[structopt(name = "id", version = garage_version())]
NodeId(NodeIdOpt),
#[structopt(name = "connect", version = garage_version())]
Connect(ConnectNodeOpt),
}
#[derive(StructOpt, Debug)]
pub struct NodeIdOpt {
#[structopt(short = "q", long = "quiet")]
pub(crate) quiet: bool,
}
#[derive(StructOpt, Debug)]
pub struct ConnectNodeOpt {
pub(crate) node: String,
}
#[derive(StructOpt, Debug)]
pub enum LayoutOperation {
#[structopt(name = "assign", version = garage_version())]
Assign(AssignRoleOpt),
#[structopt(name = "remove", version = garage_version())]
Remove(RemoveRoleOpt),
#[structopt(name = "config", version = garage_version())]
Config(ConfigLayoutOpt),
#[structopt(name = "show", version = garage_version())]
Show,
#[structopt(name = "apply", version = garage_version())]
Apply(ApplyLayoutOpt),
#[structopt(name = "revert", version = garage_version())]
Revert(RevertLayoutOpt),
#[structopt(name = "history", version = garage_version())]
History,
#[structopt(name = "skip-dead-nodes", version = garage_version())]
SkipDeadNodes(SkipDeadNodesOpt),
}
#[derive(StructOpt, Debug)]
pub struct AssignRoleOpt {
#[structopt(required = true)]
pub(crate) node_ids: Vec<String>,
#[structopt(short = "z", long = "zone")]
pub(crate) zone: Option<String>,
#[structopt(short = "c", long = "capacity")]
pub(crate) capacity: Option<bytesize::ByteSize>,
#[structopt(short = "g", long = "gateway")]
pub(crate) gateway: bool,
#[structopt(short = "t", long = "tag")]
pub(crate) tags: Vec<String>,
#[structopt(long = "replace")]
pub(crate) replace: Vec<String>,
}
#[derive(StructOpt, Debug)]
pub struct RemoveRoleOpt {
pub(crate) node_id: String,
}
#[derive(StructOpt, Debug)]
pub struct ConfigLayoutOpt {
#[structopt(short = "r", long = "redundancy")]
pub(crate) redundancy: Option<String>,
}
#[derive(StructOpt, Debug)]
pub struct ApplyLayoutOpt {
#[structopt(long = "version")]
pub(crate) version: Option<u64>,
}
#[derive(StructOpt, Debug)]
pub struct RevertLayoutOpt {
#[structopt(long = "yes")]
pub(crate) yes: bool,
}
#[derive(StructOpt, Debug)]
pub struct SkipDeadNodesOpt {
#[structopt(long = "version")]
pub(crate) version: u64,
#[structopt(long = "allow-missing-data")]
pub(crate) allow_missing_data: bool,
}
#[derive(StructOpt, Debug)]
pub enum BucketOperation {
#[structopt(name = "list", version = garage_version())]
List,
#[structopt(name = "info", version = garage_version())]
Info(BucketOpt),
#[structopt(name = "create", version = garage_version())]
Create(BucketOpt),
#[structopt(name = "delete", version = garage_version())]
Delete(DeleteBucketOpt),
#[structopt(name = "alias", version = garage_version())]
Alias(AliasBucketOpt),
#[structopt(name = "unalias", version = garage_version())]
Unalias(UnaliasBucketOpt),
#[structopt(name = "allow", version = garage_version())]
Allow(PermBucketOpt),
#[structopt(name = "deny", version = garage_version())]
Deny(PermBucketOpt),
#[structopt(name = "website", version = garage_version())]
Website(WebsiteOpt),
#[structopt(name = "set-quotas", version = garage_version())]
SetQuotas(SetQuotasOpt),
#[structopt(name = "cleanup-incomplete-uploads", version = garage_version())]
CleanupIncompleteUploads(CleanupIncompleteUploadsOpt),
#[structopt(name = "inspect-object", version = garage_version())]
InspectObject(InspectObjectOpt),
}
#[derive(StructOpt, Debug)]
pub struct WebsiteOpt {
#[structopt(long = "allow")]
pub allow: bool,
#[structopt(long = "deny")]
pub deny: bool,
pub bucket: String,
#[structopt(short = "i", long = "index-document", default_value = "index.html")]
pub index_document: String,
#[structopt(short = "e", long = "error-document")]
pub error_document: Option<String>,
}
#[derive(StructOpt, Debug)]
pub struct BucketOpt {
pub name: String,
}
#[derive(StructOpt, Debug)]
pub struct DeleteBucketOpt {
pub name: String,
#[structopt(long = "yes")]
pub yes: bool,
}
#[derive(StructOpt, Debug)]
pub struct AliasBucketOpt {
pub existing_bucket: String,
pub new_name: String,
#[structopt(long = "local")]
pub local: Option<String>,
}
#[derive(StructOpt, Debug)]
pub struct UnaliasBucketOpt {
pub name: String,
#[structopt(long = "local")]
pub local: Option<String>,
}
#[derive(StructOpt, Debug)]
pub struct PermBucketOpt {
#[structopt(long = "key")]
pub key_pattern: String,
#[structopt(long = "read")]
pub read: bool,
#[structopt(long = "write")]
pub write: bool,
#[structopt(long = "owner")]
pub owner: bool,
pub bucket: String,
}
#[derive(StructOpt, Debug)]
pub struct SetQuotasOpt {
pub bucket: String,
#[structopt(long = "max-size")]
pub max_size: Option<String>,
#[structopt(long = "max-objects")]
pub max_objects: Option<String>,
}
#[derive(StructOpt, Debug)]
pub struct CleanupIncompleteUploadsOpt {
#[structopt(long = "older-than", default_value = "1d")]
pub older_than: String,
#[structopt(required = true)]
pub buckets: Vec<String>,
}
#[derive(StructOpt, Debug)]
pub struct InspectObjectOpt {
pub bucket: String,
pub key: String,
}
#[derive(StructOpt, Debug)]
pub enum KeyOperation {
#[structopt(name = "list", version = garage_version())]
List,
#[structopt(name = "info", version = garage_version())]
Info(KeyInfoOpt),
#[structopt(name = "create", version = garage_version())]
Create(KeyNewOpt),
#[structopt(name = "rename", version = garage_version())]
Rename(KeyRenameOpt),
#[structopt(name = "delete", version = garage_version())]
Delete(KeyDeleteOpt),
#[structopt(name = "allow", version = garage_version())]
Allow(KeyPermOpt),
#[structopt(name = "deny", version = garage_version())]
Deny(KeyPermOpt),
#[structopt(name = "import", version = garage_version())]
Import(KeyImportOpt),
#[structopt(name = "set", version = garage_version())]
Set(KeySetOpt),
#[structopt(name = "delete-expired", version = garage_version())]
DeleteExpired {
#[structopt(long = "yes")]
yes: bool,
},
}
#[derive(StructOpt, Debug)]
pub struct KeyInfoOpt {
pub key_pattern: String,
#[structopt(long = "show-secret")]
pub show_secret: bool,
}
#[derive(StructOpt, Debug)]
pub struct KeyNewOpt {
#[structopt(default_value = "Unnamed key")]
pub name: String,
#[structopt(long = "expires-in")]
pub expires_in: Option<String>,
}
#[derive(StructOpt, Debug)]
pub struct KeySetOpt {
pub key_pattern: String,
#[structopt(long = "expires-in")]
pub expires_in: Option<String>,
#[structopt(long = "never-expires")]
pub never_expires: bool,
}
#[derive(StructOpt, Debug)]
pub struct KeyRenameOpt {
pub key_pattern: String,
pub new_name: String,
}
#[derive(StructOpt, Debug)]
pub struct KeyDeleteOpt {
pub key_pattern: String,
#[structopt(long = "yes")]
pub yes: bool,
}
#[derive(StructOpt, Debug)]
pub struct KeyPermOpt {
pub key_pattern: String,
#[structopt(long = "create-bucket")]
pub create_bucket: bool,
}
#[derive(StructOpt, Debug)]
pub struct KeyImportOpt {
pub key_id: String,
pub secret_key: String,
#[structopt(short = "n", default_value = "Imported key")]
pub name: String,
#[structopt(long = "yes")]
pub yes: bool,
}
#[derive(StructOpt, Debug)]
pub enum AdminTokenOperation {
#[structopt(name = "list", version = garage_version())]
List,
#[structopt(name = "info", version = garage_version())]
Info {
api_token: String,
},
#[structopt(name = "create", version = garage_version())]
Create(AdminTokenCreateOp),
#[structopt(name = "rename", version = garage_version())]
Rename {
api_token: String,
new_name: String,
},
#[structopt(name = "set", version = garage_version())]
Set(AdminTokenSetOp),
#[structopt(name = "delete", version = garage_version())]
Delete {
api_token: String,
#[structopt(long = "yes")]
yes: bool,
},
#[structopt(name = "delete-expired", version = garage_version())]
DeleteExpired {
#[structopt(long = "yes")]
yes: bool,
},
}
#[derive(StructOpt, Debug, Clone)]
pub struct AdminTokenCreateOp {
pub name: Option<String>,
#[structopt(long = "expires-in")]
pub expires_in: Option<String>,
#[structopt(long = "scope")]
pub scope: Option<String>,
#[structopt(short = "q", long = "quiet")]
pub quiet: bool,
}
#[derive(StructOpt, Debug, Clone)]
pub struct AdminTokenSetOp {
pub api_token: String,
#[structopt(long = "expires-in")]
pub expires_in: Option<String>,
#[structopt(long = "never-expires")]
pub never_expires: bool,
#[structopt(long = "scope")]
pub scope: Option<String>,
}
#[derive(StructOpt, Debug, Clone)]
pub struct RepairOpt {
#[structopt(short = "a", long = "all-nodes")]
pub all_nodes: bool,
#[structopt(long = "yes")]
pub yes: bool,
#[structopt(subcommand)]
pub what: RepairWhat,
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone)]
pub enum RepairWhat {
#[structopt(name = "tables", version = garage_version())]
Tables,
#[structopt(name = "blocks", version = garage_version())]
Blocks,
#[structopt(name = "clear-resync-queue", version = garage_version())]
ClearResyncQueue,
#[structopt(name = "versions", version = garage_version())]
Versions,
#[structopt(name = "mpu", version = garage_version())]
MultipartUploads,
#[structopt(name = "block-refs", version = garage_version())]
BlockRefs,
#[structopt(name = "block-rc", version = garage_version())]
BlockRc,
#[structopt(name = "aliases", version = garage_version())]
Aliases,
#[structopt(name = "scrub", version = garage_version())]
Scrub {
#[structopt(subcommand)]
cmd: ScrubCmd,
},
#[structopt(name = "rebalance", version = garage_version())]
Rebalance,
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone)]
pub enum ScrubCmd {
#[structopt(name = "start", version = garage_version())]
Start,
#[structopt(name = "pause", version = garage_version())]
Pause,
#[structopt(name = "resume", version = garage_version())]
Resume,
#[structopt(name = "cancel", version = garage_version())]
Cancel,
}
#[derive(StructOpt, Debug, Clone)]
pub struct OfflineRepairOpt {
#[structopt(long = "yes")]
pub yes: bool,
#[structopt(subcommand)]
pub what: OfflineRepairWhat,
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone)]
pub enum OfflineRepairWhat {
#[cfg(feature = "k2v")]
#[structopt(name = "k2v_item_counters", version = garage_version())]
K2VItemCounters,
#[structopt(name = "object_counters", version = garage_version())]
ObjectCounters,
}
#[derive(StructOpt, Debug, Clone)]
pub struct StatsOpt {
#[structopt(short = "a", long = "all-nodes")]
pub all_nodes: bool,
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone)]
pub enum WorkerOperation {
#[structopt(name = "list", version = garage_version())]
List {
#[structopt(flatten)]
opt: WorkerListOpt,
},
#[structopt(name = "info", version = garage_version())]
Info { tid: usize },
#[structopt(name = "get", version = garage_version())]
Get {
#[structopt(short = "a", long = "all-nodes")]
all_nodes: bool,
variable: Option<String>,
},
#[structopt(name = "set", version = garage_version())]
Set {
#[structopt(short = "a", long = "all-nodes")]
all_nodes: bool,
variable: String,
value: String,
},
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone, Copy)]
pub struct WorkerListOpt {
#[structopt(short = "b", long = "busy")]
pub busy: bool,
#[structopt(short = "e", long = "errors")]
pub errors: bool,
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone)]
pub enum BlockOperation {
#[structopt(name = "list-errors", version = garage_version())]
ListErrors,
#[structopt(name = "info", version = garage_version())]
Info {
hash: String,
},
#[structopt(name = "retry-now", version = garage_version())]
RetryNow {
#[structopt(long = "all")]
all: bool,
blocks: Vec<String>,
},
#[structopt(name = "purge", version = garage_version())]
Purge {
#[structopt(long = "yes")]
yes: bool,
#[structopt(required = true)]
blocks: Vec<String>,
},
}
#[derive(StructOpt, Debug, Eq, PartialEq, Clone, Copy)]
pub enum MetaOperation {
#[structopt(name = "snapshot", version = garage_version())]
Snapshot {
#[structopt(long = "all")]
all: bool,
},
}