Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/commands/endpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ async fn list(a: ListArgs, ctx: Ctx) -> Result<(), CliError> {
}

async fn create(a: CreateArgs, ctx: Ctx) -> Result<(), CliError> {
let missing: Vec<&str> = [
("--chain", a.chain.is_none()),
("--network", a.network.is_none()),
]
.iter()
.filter_map(|(name, missing)| if *missing { Some(*name) } else { None })
.collect();
if !missing.is_empty() {
return Err(CliError::Arg(format!(
"'endpoint create' requires {}. Run 'qn chain list' to see available chains.",
missing.join(" and "),
)));
}
let req = CreateEndpointRequest {
chain: a.chain,
network: a.network,
Expand All @@ -243,6 +256,9 @@ async fn show(id: &str, ctx: Ctx) -> Result<(), CliError> {
}

async fn update(a: UpdateArgs, ctx: Ctx) -> Result<(), CliError> {
if a.label.is_none() {
return Err(CliError::Arg("'endpoint update' requires --label.".into()));
}
let req = UpdateEndpointRequest { label: a.label };
ctx.sdk.admin.update_endpoint(&a.id, &req).await?;
ctx.out.note(&format!("✓ Updated endpoint {}", a.id));
Expand Down
17 changes: 17 additions & 0 deletions src/commands/endpoint/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,23 @@ async fn options_show(id: &str, ctx: Ctx) -> Result<(), CliError> {
}

async fn set_options(a: SetOptionsArgs, ctx: Ctx) -> Result<(), CliError> {
if a.tokens.is_none()
&& a.referrers.is_none()
&& a.jwts.is_none()
&& a.ips.is_none()
&& a.domain_masks.is_none()
&& a.hsts.is_none()
&& a.cors.is_none()
&& a.request_filters.is_none()
&& a.ip_custom_header.is_none()
{
return Err(CliError::Arg(
"'endpoint security set-options' requires at least one of: \
--tokens, --referrers, --jwts, --ips, --domain-masks, --hsts, \
--cors, --request-filters, --ip-custom-header."
.into(),
));
}
let options = SecurityOptionsUpdate {
tokens: a.tokens.map(|t| t.as_str().to_string()),
referrers: a.referrers.map(|t| t.as_str().to_string()),
Expand Down
5 changes: 5 additions & 0 deletions src/commands/team.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ async fn endpoints(id: i64, ctx: Ctx) -> Result<(), CliError> {
}

async fn set_endpoints(a: SetEndpointsArgs, ctx: Ctx) -> Result<(), CliError> {
if a.endpoint_ids.is_empty() {
return Err(CliError::Arg(
"'team set-endpoints' requires at least one endpoint id.".into(),
));
}
let req = UpdateTeamEndpointsRequest {
endpoint_ids: a.endpoint_ids.clone(),
};
Expand Down
Loading
Loading