From 82915c25f6bfa0ad780525ecc89fd6f1f687bc11 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Thu, 20 Jun 2024 11:29:56 -0500 Subject: [PATCH] rename IP pools list and view endpoints --- end-to-end-tests/src/bin/commtest.rs | 58 +++++++++++----------- nexus/src/external_api/http_entrypoints.rs | 27 ++++++---- nexus/tests/output/nexus_tags.txt | 8 +-- openapi/nexus.json | 14 +++--- 4 files changed, 58 insertions(+), 49 deletions(-) diff --git a/end-to-end-tests/src/bin/commtest.rs b/end-to-end-tests/src/bin/commtest.rs index 05e15faafc..ee470cb635 100644 --- a/end-to-end-tests/src/bin/commtest.rs +++ b/end-to-end-tests/src/bin/commtest.rs @@ -279,37 +279,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 diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index 350836441e..c27d64224a 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -116,17 +116,17 @@ pub(crate) fn external_api() -> NexusApiDescription { api.register(project_update)?; api.register(project_policy_view)?; api.register(project_policy_update)?; - api.register(project_ip_pool_list)?; - api.register(project_ip_pool_view)?; + api.register(ip_pool_list)?; + api.register(ip_pool_view)?; // Operator-Accessible IP Pools API - api.register(ip_pool_list)?; + api.register(system_ip_pool_list)?; + api.register(system_ip_pool_view)?; api.register(ip_pool_create)?; api.register(ip_pool_silo_list)?; api.register(ip_pool_silo_link)?; api.register(ip_pool_silo_unlink)?; api.register(ip_pool_silo_update)?; - api.register(ip_pool_view)?; api.register(ip_pool_delete)?; api.register(ip_pool_update)?; // Variants for internal services @@ -1506,12 +1506,14 @@ async fn project_policy_update( // IP Pools /// List IP pools +/// +/// List IP pools linked to current silo. #[endpoint { method = GET, path = "/v1/ip-pools", - tags = ["projects"], + tags = ["silos"], }] -async fn project_ip_pool_list( +async fn ip_pool_list( rqctx: RequestContext, query_params: Query, ) -> Result>, HttpError> { @@ -1546,12 +1548,14 @@ async fn project_ip_pool_list( } /// Fetch IP pool +/// +/// Fetch IP pool linked to current silo. #[endpoint { method = GET, path = "/v1/ip-pools/{pool}", - tags = ["projects"], + tags = ["silos"], }] -async fn project_ip_pool_view( +async fn ip_pool_view( rqctx: RequestContext, path_params: Path, ) -> Result, HttpError> { @@ -1574,13 +1578,16 @@ async fn project_ip_pool_view( .await } +// Note system_ prefix only on list and view because they need to be distinguished +// from silo-scoped list and view + /// List IP pools #[endpoint { method = GET, path = "/v1/system/ip-pools", tags = ["system/networking"], }] -async fn ip_pool_list( +async fn system_ip_pool_list( rqctx: RequestContext, query_params: Query, ) -> Result>, HttpError> { @@ -1647,7 +1654,7 @@ async fn ip_pool_create( path = "/v1/system/ip-pools/{pool}", tags = ["system/networking"], }] -async fn ip_pool_view( +async fn system_ip_pool_view( rqctx: RequestContext, path_params: Path, ) -> Result, HttpError> { diff --git a/nexus/tests/output/nexus_tags.txt b/nexus/tests/output/nexus_tags.txt index a32fe5c4b9..19aa2275a0 100644 --- a/nexus/tests/output/nexus_tags.txt +++ b/nexus/tests/output/nexus_tags.txt @@ -85,8 +85,6 @@ API operations found with tag "projects" OPERATION ID METHOD URL PATH 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 @@ -115,6 +113,8 @@ certificate_list GET /v1/certificates certificate_view GET /v1/certificates/{certificate} group_list GET /v1/groups group_view GET /v1/groups/{group_id} +ip_pool_list GET /v1/ip-pools +ip_pool_view GET /v1/ip-pools/{pool} policy_update PUT /v1/policy policy_view GET /v1/policy user_list GET /v1/users @@ -155,7 +155,6 @@ API operations found with tag "system/networking" 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 @@ -169,7 +168,6 @@ 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} networking_address_lot_block_list GET /v1/system/networking/address-lot/{address_lot}/blocks networking_address_lot_create POST /v1/system/networking/address-lot networking_address_lot_delete DELETE /v1/system/networking/address-lot/{address_lot} @@ -195,6 +193,8 @@ networking_switch_port_settings_create POST /v1/system/networking/switch-p networking_switch_port_settings_delete DELETE /v1/system/networking/switch-port-settings networking_switch_port_settings_list GET /v1/system/networking/switch-port-settings networking_switch_port_settings_view GET /v1/system/networking/switch-port-settings/{port} +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/silos" OPERATION ID METHOD URL PATH diff --git a/openapi/nexus.json b/openapi/nexus.json index 01ec9aeb56..4beb115354 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -2679,10 +2679,11 @@ "/v1/ip-pools": { "get": { "tags": [ - "projects" + "silos" ], "summary": "List IP pools", - "operationId": "project_ip_pool_list", + "description": "List IP pools linked to current silo.", + "operationId": "ip_pool_list", "parameters": [ { "in": "query", @@ -2738,10 +2739,11 @@ "/v1/ip-pools/{pool}": { "get": { "tags": [ - "projects" + "silos" ], "summary": "Fetch IP pool", - "operationId": "project_ip_pool_view", + "description": "Fetch IP pool linked to current silo.", + "operationId": "ip_pool_view", "parameters": [ { "in": "path", @@ -5267,7 +5269,7 @@ "system/networking" ], "summary": "List IP pools", - "operationId": "ip_pool_list", + "operationId": "system_ip_pool_list", "parameters": [ { "in": "query", @@ -5361,7 +5363,7 @@ "system/networking" ], "summary": "Fetch IP pool", - "operationId": "ip_pool_view", + "operationId": "system_ip_pool_view", "parameters": [ { "in": "path",