Skip to content
Open
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
58 changes: 29 additions & 29 deletions end-to-end-tests/src/bin/commtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,37 +280,37 @@ async fn rack_prepare(
})?;

let pool_name = "default";
api_retry!(
if let Err(e) = oxide.ip_pool_view().pool("default").send().await {
if let Some(reqwest::StatusCode::NOT_FOUND) = e.status() {
print!("default ip pool does not exist, creating ...");
oxide
.ip_pool_create()
.body(IpPoolCreate {
name: pool_name.parse().unwrap(),
description: "Default IP pool".to_string(),
})
.send()
.await?;
oxide
.ip_pool_silo_link()
.pool(pool_name)
.body(IpPoolLinkSilo {
silo: NameOrId::Name("recovery".parse().unwrap()),
is_default: true,
})
.send()
.await?;
println!("done");
Ok(())
} else {
Err(e)
}
} else {
println!("default ip pool already exists");
api_retry!(if let Err(e) =
oxide.system_ip_pool_view().pool("default").send().await
{
if let Some(reqwest::StatusCode::NOT_FOUND) = e.status() {
print!("default ip pool does not exist, creating ...");
oxide
.ip_pool_create()
.body(IpPoolCreate {
name: pool_name.parse().unwrap(),
description: "Default IP pool".to_string(),
})
.send()
.await?;
oxide
.ip_pool_silo_link()
.pool(pool_name)
.body(IpPoolLinkSilo {
silo: NameOrId::Name("recovery".parse().unwrap()),
is_default: true,
})
.send()
.await?;
println!("done");
Ok(())
} else {
Err(e)
}
)?;
} else {
println!("default ip pool already exists");
Ok(())
})?;

let pool = api_retry!(
oxide
Expand Down
8 changes: 4 additions & 4 deletions nexus/external-api/output/nexus_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ system_policy_view GET /v1/system/policy

API operations found with tag "projects"
OPERATION ID METHOD URL PATH
ip_pool_list GET /v1/ip-pools
ip_pool_view GET /v1/ip-pools/{pool}
project_create POST /v1/projects
project_delete DELETE /v1/projects/{project}
project_ip_pool_list GET /v1/ip-pools
project_ip_pool_view GET /v1/ip-pools/{pool}
project_list GET /v1/projects
project_policy_update PUT /v1/projects/{project}/policy
project_policy_view GET /v1/projects/{project}/policy
Expand Down Expand Up @@ -215,7 +215,6 @@ API operations found with tag "system/ip-pools"
OPERATION ID METHOD URL PATH
ip_pool_create POST /v1/system/ip-pools
ip_pool_delete DELETE /v1/system/ip-pools/{pool}
ip_pool_list GET /v1/system/ip-pools
ip_pool_range_add POST /v1/system/ip-pools/{pool}/ranges/add
ip_pool_range_list GET /v1/system/ip-pools/{pool}/ranges
ip_pool_range_remove POST /v1/system/ip-pools/{pool}/ranges/remove
Expand All @@ -229,7 +228,8 @@ ip_pool_silo_unlink DELETE /v1/system/ip-pools/{pool}/sil
ip_pool_silo_update PUT /v1/system/ip-pools/{pool}/silos/{silo}
ip_pool_update PUT /v1/system/ip-pools/{pool}
ip_pool_utilization_view GET /v1/system/ip-pools/{pool}/utilization
ip_pool_view GET /v1/system/ip-pools/{pool}
system_ip_pool_list GET /v1/system/ip-pools
system_ip_pool_view GET /v1/system/ip-pools/{pool}

API operations found with tag "system/metrics"
OPERATION ID METHOD URL PATH
Expand Down
12 changes: 8 additions & 4 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,14 @@ pub trait NexusExternalApi {
// IP Pools

/// List IP pools
///
/// For the current silo.
#[endpoint {
method = GET,
path = "/v1/ip-pools",
tags = ["projects"],
}]
async fn project_ip_pool_list(
async fn ip_pool_list(
rqctx: RequestContext<Self::Context>,
query_params: Query<PaginatedByNameOrId>,
) -> Result<HttpResponseOk<ResultsPage<views::SiloIpPool>>, HttpError>;
Expand All @@ -685,18 +687,20 @@ pub trait NexusExternalApi {
path = "/v1/ip-pools/{pool}",
tags = ["projects"],
}]
async fn project_ip_pool_view(
async fn ip_pool_view(
rqctx: RequestContext<Self::Context>,
path_params: Path<params::IpPoolPath>,
) -> Result<HttpResponseOk<views::SiloIpPool>, HttpError>;

/// List IP pools
///
/// List all IP pools regardless of silo links.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "across all silos" is clearer to me, but I'll leave this one up to you!

#[endpoint {
method = GET,
path = "/v1/system/ip-pools",
tags = ["system/ip-pools"],
}]
async fn ip_pool_list(
async fn system_ip_pool_list(
rqctx: RequestContext<Self::Context>,
query_params: Query<PaginatedByNameOrId>,
) -> Result<HttpResponseOk<ResultsPage<views::IpPool>>, HttpError>;
Expand All @@ -718,7 +722,7 @@ pub trait NexusExternalApi {
path = "/v1/system/ip-pools/{pool}",
tags = ["system/ip-pools"],
}]
async fn ip_pool_view(
async fn system_ip_pool_view(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should have a description as well no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to know how it differs from the other fetch IP pool endpoint, otherwise it's not too obvious?

rqctx: RequestContext<Self::Context>,
path_params: Path<params::IpPoolPath>,
) -> Result<HttpResponseOk<views::IpPool>, HttpError>;
Expand Down
8 changes: 4 additions & 4 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ impl NexusExternalApi for NexusExternalApiImpl {

// IP Pools

async fn project_ip_pool_list(
async fn ip_pool_list(
rqctx: RequestContext<ApiContext>,
query_params: Query<PaginatedByNameOrId>,
) -> Result<HttpResponseOk<ResultsPage<views::SiloIpPool>>, HttpError> {
Expand Down Expand Up @@ -1128,7 +1128,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
.await
}

async fn project_ip_pool_view(
async fn ip_pool_view(
rqctx: RequestContext<ApiContext>,
path_params: Path<params::IpPoolPath>,
) -> Result<HttpResponseOk<views::SiloIpPool>, HttpError> {
Expand All @@ -1152,7 +1152,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
.await
}

async fn ip_pool_list(
async fn system_ip_pool_list(
rqctx: RequestContext<ApiContext>,
query_params: Query<PaginatedByNameOrId>,
) -> Result<HttpResponseOk<ResultsPage<IpPool>>, HttpError> {
Expand Down Expand Up @@ -1204,7 +1204,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
.await
}

async fn ip_pool_view(
async fn system_ip_pool_view(
rqctx: RequestContext<ApiContext>,
path_params: Path<params::IpPoolPath>,
) -> Result<HttpResponseOk<views::IpPool>, HttpError> {
Expand Down
10 changes: 6 additions & 4 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5286,7 +5286,8 @@
"projects"
],
"summary": "List IP pools",
"operationId": "project_ip_pool_list",
"description": "For the current silo.",
"operationId": "ip_pool_list",
"parameters": [
{
"in": "query",
Expand Down Expand Up @@ -5345,7 +5346,7 @@
"projects"
],
"summary": "Fetch IP pool",
"operationId": "project_ip_pool_view",
"operationId": "ip_pool_view",
"parameters": [
{
"in": "path",
Expand Down Expand Up @@ -8247,7 +8248,8 @@
"system/ip-pools"
],
"summary": "List IP pools",
"operationId": "ip_pool_list",
"description": "List all IP pools regardless of silo.",
"operationId": "system_ip_pool_list",
"parameters": [
{
"in": "query",
Expand Down Expand Up @@ -8341,7 +8343,7 @@
"system/ip-pools"
],
"summary": "Fetch IP pool",
"operationId": "ip_pool_view",
"operationId": "system_ip_pool_view",
"parameters": [
{
"in": "path",
Expand Down
Loading