Skip to content

Commit

Permalink
Remove unused name_or_id query param on bgp announce set list (#6498)
Browse files Browse the repository at this point in the history
Closes #6467 

Happy to throw this out @internet-diglett if it conflicts with anything
you're doing, but it's small enough that I think you might be able to
just merge it into yours.
  • Loading branch information
david-crespo authored Sep 10, 2024
1 parent 8dac36a commit a460e59
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 38 deletions.
4 changes: 2 additions & 2 deletions nexus/db-queries/src/db/datastore/bgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl DataStore {
.transaction(&conn, |conn| {
let err = err.clone();
async move {
let name_or_id = sel.name_or_id.clone();
let name_or_id = sel.announce_set.clone();

let announce_id: Uuid = match name_or_id {
NameOrId::Id(id) => announce_set_dsl::bgp_announce_set
Expand Down Expand Up @@ -700,7 +700,7 @@ impl DataStore {
use db::schema::bgp_config::dsl as bgp_config_dsl;

let conn = self.pool_connection_authorized(opctx).await?;
let name_or_id = sel.name_or_id.clone();
let name_or_id = sel.announce_set.clone();

let err = OptionalError::new();
self.transaction_retry_wrapper("bgp_delete_announce_set")
Expand Down
4 changes: 2 additions & 2 deletions nexus/external-api/output/nexus_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ networking_allow_list_view GET /v1/system/networking/allow-li
networking_bfd_disable POST /v1/system/networking/bfd-disable
networking_bfd_enable POST /v1/system/networking/bfd-enable
networking_bfd_status GET /v1/system/networking/bfd-status
networking_bgp_announce_set_delete DELETE /v1/system/networking/bgp-announce-set/{name_or_id}
networking_bgp_announce_set_delete DELETE /v1/system/networking/bgp-announce-set/{announce_set}
networking_bgp_announce_set_list GET /v1/system/networking/bgp-announce-set
networking_bgp_announce_set_update PUT /v1/system/networking/bgp-announce-set
networking_bgp_announcement_list GET /v1/system/networking/bgp-announce-set/{name_or_id}/announcement
networking_bgp_announcement_list GET /v1/system/networking/bgp-announce-set/{announce_set}/announcement
networking_bgp_config_create POST /v1/system/networking/bgp
networking_bgp_config_delete DELETE /v1/system/networking/bgp
networking_bgp_config_list GET /v1/system/networking/bgp
Expand Down
8 changes: 3 additions & 5 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,15 +1565,13 @@ pub trait NexusExternalApi {
}]
async fn networking_bgp_announce_set_list(
rqctx: RequestContext<Self::Context>,
query_params: Query<
PaginatedByNameOrId<params::OptionalBgpAnnounceSetSelector>,
>,
query_params: Query<PaginatedByNameOrId>,
) -> Result<HttpResponseOk<Vec<BgpAnnounceSet>>, HttpError>;

/// Delete BGP announce set
#[endpoint {
method = DELETE,
path = "/v1/system/networking/bgp-announce-set/{name_or_id}",
path = "/v1/system/networking/bgp-announce-set/{announce_set}",
tags = ["system/networking"],
}]
async fn networking_bgp_announce_set_delete(
Expand All @@ -1586,7 +1584,7 @@ pub trait NexusExternalApi {
/// Get originated routes for a specified BGP announce set
#[endpoint {
method = GET,
path = "/v1/system/networking/bgp-announce-set/{name_or_id}/announcement",
path = "/v1/system/networking/bgp-announce-set/{announce_set}/announcement",
tags = ["system/networking"],
}]
async fn networking_bgp_announcement_list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl BackgroundTask for SwitchPortSettingsManager {
.bgp_announcement_list(
opctx,
&params::BgpAnnounceSetSelector {
name_or_id: bgp_config
announce_set: bgp_config
.bgp_announce_set_id
.into(),
},
Expand Down
4 changes: 1 addition & 3 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3139,9 +3139,7 @@ impl NexusExternalApi for NexusExternalApiImpl {

async fn networking_bgp_announce_set_list(
rqctx: RequestContext<ApiContext>,
query_params: Query<
PaginatedByNameOrId<params::OptionalBgpAnnounceSetSelector>,
>,
query_params: Query<PaginatedByNameOrId>,
) -> Result<HttpResponseOk<Vec<BgpAnnounceSet>>, HttpError> {
let apictx = rqctx.context();
let handler = async {
Expand Down
15 changes: 4 additions & 11 deletions nexus/types/src/external_api/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,25 +1675,18 @@ pub struct BgpAnnounceSetCreate {
pub announcement: Vec<BgpAnnouncementCreate>,
}

/// Optionally select a BGP announce set by a name or id.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
pub struct OptionalBgpAnnounceSetSelector {
/// A name or id to use when s electing BGP port settings
pub name_or_id: Option<NameOrId>,
}

/// Select a BGP announce set by a name or id.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
pub struct BgpAnnounceSetSelector {
/// A name or id to use when selecting BGP port settings
pub name_or_id: NameOrId,
/// Name or ID of the announce set
pub announce_set: NameOrId,
}

/// List BGP announce set with an optional name or id.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
pub struct BgpAnnounceListSelector {
/// A name or id to use when selecting BGP config.
pub name_or_id: Option<NameOrId>,
/// Name or ID of the announce set
pub announce_set: Option<NameOrId>,
}

/// Selector used for querying imported BGP routes.
Expand Down
20 changes: 6 additions & 14 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -6554,14 +6554,6 @@
"minimum": 1
}
},
{
"in": "query",
"name": "name_or_id",
"description": "A name or id to use when s electing BGP port settings",
"schema": {
"$ref": "#/components/schemas/NameOrId"
}
},
{
"in": "query",
"name": "page_token",
Expand Down Expand Up @@ -6642,7 +6634,7 @@
}
}
},
"/v1/system/networking/bgp-announce-set/{name_or_id}": {
"/v1/system/networking/bgp-announce-set/{announce_set}": {
"delete": {
"tags": [
"system/networking"
Expand All @@ -6652,8 +6644,8 @@
"parameters": [
{
"in": "path",
"name": "name_or_id",
"description": "A name or id to use when selecting BGP port settings",
"name": "announce_set",
"description": "Name or ID of the announce set",
"required": true,
"schema": {
"$ref": "#/components/schemas/NameOrId"
Expand All @@ -6673,7 +6665,7 @@
}
}
},
"/v1/system/networking/bgp-announce-set/{name_or_id}/announcement": {
"/v1/system/networking/bgp-announce-set/{announce_set}/announcement": {
"get": {
"tags": [
"system/networking"
Expand All @@ -6683,8 +6675,8 @@
"parameters": [
{
"in": "path",
"name": "name_or_id",
"description": "A name or id to use when selecting BGP port settings",
"name": "announce_set",
"description": "Name or ID of the announce set",
"required": true,
"schema": {
"$ref": "#/components/schemas/NameOrId"
Expand Down

0 comments on commit a460e59

Please sign in to comment.