* Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
* Global Trust Authority is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v2 for more details.
*/
use clap::Subcommand;
use crate::entities::{CertType, ContentType, UpdateCertType, DeleteType, NonceType, PolicyDeleteType, TokenFormat};
#[derive(Subcommand)]
pub enum CertificateCommands {
Set {
#[clap(short, long)]
name: Option<String>,
#[clap(short, long)]
description: Option<String>,
#[clap(long = "cert-type", required = true, value_enum, num_args = 1.., value_delimiter = ',')]
cert_type: Vec<CertType>,
#[clap(long, allow_hyphen_values = true)]
content: Option<String>,
#[clap(short, long, allow_hyphen_values = true)]
crl_content: Option<String>,
#[clap(short, long)]
is_default: bool,
},
Delete {
#[clap(short, long = "delete-type", value_enum)]
delete_type: Option<DeleteType>,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
ids: Option<Vec<String>>,
#[clap(short, long = "cert-type", value_enum)]
cert_type: Option<CertType>,
},
Update {
#[clap(long, required = true)]
id: String,
#[clap(short, long)]
name: Option<String>,
#[clap(short, long)]
description: Option<String>,
#[clap(short, long = "cert-type", value_enum, num_args = 1.., value_delimiter = ',')]
cert_type: Option<Vec<UpdateCertType>>,
#[clap(short, long)]
is_default: Option<bool>,
},
Get {
#[clap(short, long = "cert-type", value_enum)]
cert_type: Option<CertType>,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
ids: Option<Vec<String>>,
#[clap(long)]
limit: Option<i64>,
#[clap(long)]
offset: Option<i64>,
},
}
#[derive(Subcommand)]
pub enum PolicyCommands {
Set {
#[clap(short, long)]
name: Option<String>,
#[clap(short, long)]
description: Option<String>,
#[clap(short = 't', long = "attester-types", value_delimiter = ',')]
attester_type: Vec<String>,
#[clap(long = "content-type", required = true, value_enum)]
content_type: ContentType,
#[clap(long, required = true)]
content: String,
#[clap(short, long)]
is_default: bool,
},
Delete {
#[clap(short, long = "delete-type", required = true, value_enum)]
delete_type: PolicyDeleteType,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
ids: Option<Vec<String>>,
#[clap(short = 't', long = "attester-type")]
attester_type: Option<String>,
},
Update {
#[clap(long, required = true)]
id: String,
#[clap(short, long)]
name: Option<String>,
#[clap(short, long)]
description: Option<String>,
#[clap(short = 't', long = "attester-types", value_delimiter = ',')]
attester_type: Option<Vec<String>>,
#[clap(long, value_enum)]
content_type: Option<ContentType>,
#[clap(long)]
content: Option<String>,
#[clap(short, long)]
is_default: Option<bool>,
},
Get {
#[clap(short, long)]
attester_type: Option<String>,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
ids: Option<Vec<String>>,
#[clap(long)]
limit: Option<i64>,
#[clap(long)]
offset: Option<i64>,
},
}
#[derive(Subcommand)]
pub enum RegisterCommands {
New {
#[clap(short = 'n', long)]
nowrite: bool,
},
Refresh {
#[clap(short, long)]
user: Option<String>,
#[clap(short = 'k', long = "apikey")]
apikey: Option<String>,
#[clap(short = 'n', long)]
nowrite: bool,
},
}
#[derive(Subcommand)]
pub enum BaselineCommands {
Set {
#[clap(short, long)]
name: Option<String>,
#[clap(short, long)]
description: Option<String>,
#[clap(short = 't', long = "attester-type", default_value = "tpm_ima")]
attester_type: String,
#[clap(short, long, required = true)]
content: String,
#[clap(long = "content-type")]
content_type: Option<String>,
#[clap(short, long)]
is_default: bool,
},
Delete {
#[clap(short, long = "delete-type", required = true, value_enum)]
delete_type: DeleteType,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
ids: Option<Vec<String>>,
#[clap(short = 't', long = "attester-type")]
attester_type: Option<String>,
},
Update {
#[clap(long, required = true)]
id: String,
#[clap(short, long)]
name: Option<String>,
#[clap(short, long)]
description: Option<String>,
#[clap(short = 't', long = "attester-type")]
attester_type: Option<String>,
#[clap(short, long)]
content: Option<String>,
#[clap(long = "content-type")]
content_type: Option<String>,
#[clap(short, long)]
is_default: Option<bool>,
},
Get {
#[clap(short = 't', long = "attester-type")]
attester_type: Option<String>,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
ids: Option<Vec<String>>,
#[clap(long)]
limit: Option<i64>,
#[clap(long)]
offset: Option<i64>,
},
}
#[derive(Subcommand)]
pub enum NonceCommands {
Get {
#[clap(short, long)]
out: Option<String>,
},
}
#[derive(Subcommand)]
pub enum EvidenceCommands {
Get {
#[clap(short = 's', long = "nonce-type", required = true, value_enum)]
nonce_type: NonceType,
#[clap(short = 'n', long)]
nonce: Option<String>,
#[clap(short = 'o', long, required = true)]
out: String,
#[clap(short = 'd', long)]
attester_data: Option<serde_json::Value>,
#[clap(short = 't', long = "attester-types", value_delimiter = ',')]
attester_types: Option<Vec<String>>,
#[clap(short = 'f', long = "token-format", value_enum)]
token_format: Option<TokenFormat>,
#[clap(short = 'i', long, value_delimiter = ',')]
attester_ids: Option<Vec<String>>,
},
}
#[derive(Subcommand)]
pub enum TokenCommands {
Verify {
#[clap(short, long)]
file: Option<String>,
#[clap(short, long, num_args = 1.., value_delimiter = ',')]
token: Option<Vec<String>>,
},
}