From ee930f0a2ff9a1e65a0d6efe817c95cd4a81f7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Thu, 31 Oct 2024 11:21:35 -0500 Subject: [PATCH] Rename Path parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renames the following parameters: - bna_id -> rating_id - id -> price_id Signed-off-by: Rémy Greinhofer --- effortless/src/api.rs | 2 +- lambdas/requests.rest | 28 +++++++++---------- .../bin/price-fargate/get-price-fargate.rs | 2 +- .../src/bin/ratings/get-ratings-analysis.rs | 2 +- lambdas/src/bin/ratings/get-ratings-cities.rs | 2 +- lambdas/src/bin/ratings/get-ratings.rs | 4 +-- lambdas/src/core/resource/price/endpoint.rs | 6 ++-- lambdas/src/core/resource/ratings/db.rs | 4 +-- lambdas/src/core/resource/ratings/endpoint.rs | 8 +++--- lambdas/src/core/resource/ratings/mod.rs | 10 +++---- lambdas/src/fixtures/get-bnas-bna_id.json | 4 +-- .../src/fixtures/get-cities-bnas-bna_id.json | 4 +-- lambdas/tests/endpoints/ratings.hurl | 12 ++++---- lambdas/tests/localhost.vars | 4 +-- lambdas/tests/smoke/public-readonly.hurl | 4 +-- lambdas/tests/staging.vars | 4 +-- openapi.yaml | 16 +++++------ 17 files changed, 58 insertions(+), 58 deletions(-) diff --git a/effortless/src/api.rs b/effortless/src/api.rs index dfbbbf2..9885cf8 100644 --- a/effortless/src/api.rs +++ b/effortless/src/api.rs @@ -367,7 +367,7 @@ mod tests { .body(Body::Empty) .expect("failed to build request") .with_path_parameters(HashMap::from([( - "bna_id".to_string(), + "rating_id".to_string(), "eac1dbfb-2137-44c5-be59-71fc613f2963".to_string(), )])) .with_request_context(lambda_http::request::RequestContext::ApiGatewayV2( diff --git a/lambdas/requests.rest b/lambdas/requests.rest index 37a77c3..bbcfcb2 100644 --- a/lambdas/requests.rest +++ b/lambdas/requests.rest @@ -1,22 +1,22 @@ @host=https://api.peopleforbikes.xyz # Austin, TX, USA. @city_id=ef8384d5-b96f-439d-a83b-bc801735ddc6 -@bna_id=1a759b85-cd87-4bb1-9efa-5789e38e9982 +@rating_id=1a759b85-cd87-4bb1-9efa-5789e38e9982 @country=United States @region=Texas @name=Austin ### # Query the first page of the bnas. -GET {{host}}/bnas +GET {{host}}/ratings ### # Query a specific bna run. -GET {{host}}/bnas/{{bna_id}} +GET {{host}}/ratings/{{rating_id}} ### # Query a specific bna run and its associated city. -GET {{host}}/bnas/{{bna_id}}/city +GET {{host}}/ratings/{{rating_id}}/city ### # Query the first page of the cities. @@ -28,7 +28,7 @@ GET {{host}}/cities/{{country}}/{{region}}/{{name}} ### # Query all the BNAs of a specific city. -GET {{host}}/cities/{{country}}/{{region}}/{{name}}/bnas +GET {{host}}/cities/{{country}}/{{region}}/{{name}}/ratings ### # Query all the Census of a specific city. @@ -122,7 +122,7 @@ Authorization: Bearer {{cognito_access}} ### # Collect the list of analysis that completed. -GET {{host}}/bnas/results +GET {{host}}/ratings/results Authorization: Bearer {{cognito_access}} ### @@ -148,7 +148,7 @@ Authorization: Bearer {{cognito_access}} @state_machine_id=e6aade5a-b343-120b-dbaa-bd916cd99221 ### Create a new BNA analysis performed by the Brokenspoke-analyzer pipeline. -POST {{host}}/bnas/analysis +POST {{host}}/ratings/analysis content-type: application/json Authorization: Bearer {{cognito_access}} @@ -163,15 +163,15 @@ Authorization: Bearer {{cognito_access}} } ### Query the BNA analysis performed by the Brokenspoke-analyzer pipeline. -GET {{host}}/bnas/analysis +GET {{host}}/ratings/analysis Authorization: Bearer {{cognito_access}} ### Query a specific BNA analysis performed by the Brokenspoke-analyzer pipeline. -GET {{host}}/bnas/analysis/{{state_machine_id}} +GET {{host}}/ratings/analysis/{{state_machine_id}} Authorization: Bearer {{cognito_access}} ### Update an existing BNA analysis performed by the Brokenspoke-analyzer pipeline. -PATCH {{host}}/bnas/analysis/{{state_machine_id}} +PATCH {{host}}/ratings/analysis/{{state_machine_id}} content-type: application/json Authorization: Bearer {{cognito_access}} @@ -180,7 +180,7 @@ Authorization: Bearer {{cognito_access}} } ### Create a new BNA . -POST {{host}}/bnas +POST {{host}}/ratings content-type: application/json Authorization: Bearer {{cognito_access}} @@ -239,11 +239,11 @@ Authorization: Bearer {{cognito_access}} # Bellow this point are the tests from schemathesis. ################################################################################ -GET {{host}}/bnas/1 +GET {{host}}/ratings/1 X-Schemathesis-TestCaseId: 3bf4a72a4cc04ed589c5eedaf57b3ca2 ### -GET {{host}}/bnas/0/city +GET {{host}}/ratings/0/city X-Schemathesis-TestCaseId: 9fa24d92de444fd28180df72fa1fabd6 ### @@ -255,5 +255,5 @@ GET {{host}}/cities/0 X-Schemathesis-TestCaseId: 6c4cbf8880594f3d921ed1c3fe474a7f ### -GET {{host}}/cities/0/bnas +GET {{host}}/cities/0/ratings X-Schemathesis-TestCaseId: 1f951094a7f14597bb50cafc52b812e0 diff --git a/lambdas/src/bin/price-fargate/get-price-fargate.rs b/lambdas/src/bin/price-fargate/get-price-fargate.rs index 050565e..87c3993 100644 --- a/lambdas/src/bin/price-fargate/get-price-fargate.rs +++ b/lambdas/src/bin/price-fargate/get-price-fargate.rs @@ -62,7 +62,7 @@ async fn function_handler(event: Request) -> Result, Error> { } // Retrieve the ID of the entry to retrieve. - let parameter = "id"; + let parameter = "price_id"; let id = event.path_parameter::(parameter); // Retrieve a specific entry if an id was specified. diff --git a/lambdas/src/bin/ratings/get-ratings-analysis.rs b/lambdas/src/bin/ratings/get-ratings-analysis.rs index 4bb6125..ae18878 100644 --- a/lambdas/src/bin/ratings/get-ratings-analysis.rs +++ b/lambdas/src/bin/ratings/get-ratings-analysis.rs @@ -29,7 +29,7 @@ async fn function_handler(event: Request) -> Result, Error> { // Retrieve a specific entry. debug!("Processing the requests..."); - match get_ratings_analysis_adaptor(params.bna_id, ctx).await { + match get_ratings_analysis_adaptor(params.rating_id, ctx).await { Ok(v) => return Ok(v.into_response().await), Err(e) => return Ok(APIErrors::from(e).into()), } diff --git a/lambdas/src/bin/ratings/get-ratings-cities.rs b/lambdas/src/bin/ratings/get-ratings-cities.rs index edb8880..ed355de 100644 --- a/lambdas/src/bin/ratings/get-ratings-cities.rs +++ b/lambdas/src/bin/ratings/get-ratings-cities.rs @@ -24,7 +24,7 @@ async fn function_handler(event: Request) -> Result, Error> { .to_string(), ); - match get_ratings_city_adaptor(params.bna_id, ctx).await { + match get_ratings_city_adaptor(params.rating_id, ctx).await { Ok(v) => Ok(v.into_response().await), Err(e) => Ok(APIErrors::from(e).into()), } diff --git a/lambdas/src/bin/ratings/get-ratings.rs b/lambdas/src/bin/ratings/get-ratings.rs index a5e576c..2e1df62 100644 --- a/lambdas/src/bin/ratings/get-ratings.rs +++ b/lambdas/src/bin/ratings/get-ratings.rs @@ -89,7 +89,7 @@ async fn function_handler(event: Request) -> Result, Error> { Err(e) => return Ok(e.into()), }; - let select = Summary::find_by_id(params.bna_id); + let select = Summary::find_by_id(params.rating_id); let res = match queries.component { BNAComponent::All => { let model = select @@ -291,7 +291,7 @@ mod tests { // .body(Body::Empty) // .expect("failed to build request") // .with_path_parameters(HashMap::from([( - // "bna_id".to_string(), + // "rating_id".to_string(), // "837082b8-c8a0-469e-b310-c868d7f140a2".to_string(), // Santa Monica, CA // )])) // .with_request_context(lambda_http::request::RequestContext::ApiGatewayV2( diff --git a/lambdas/src/core/resource/price/endpoint.rs b/lambdas/src/core/resource/price/endpoint.rs index 74b9dfc..beebc8d 100644 --- a/lambdas/src/core/resource/price/endpoint.rs +++ b/lambdas/src/core/resource/price/endpoint.rs @@ -17,7 +17,7 @@ use super::{ pub fn routes() -> Router { Router::new() .route("/prices/fargate", get(get_prices_fargate)) - .route("/prices/fargate/:id", get(get_price_fargate)) + .route("/prices/fargate/:price_id", get(get_price_fargate)) } pub async fn get_prices_fargate( @@ -29,8 +29,8 @@ pub async fn get_prices_fargate( } pub async fn get_price_fargate( - Path(id): Path, + Path(price_id): Path, ctx: Context, ) -> Result, ExecutionError> { - get_price_fargate_adaptor(id, ctx).await.map(Json) + get_price_fargate_adaptor(price_id, ctx).await.map(Json) } diff --git a/lambdas/src/core/resource/ratings/db.rs b/lambdas/src/core/resource/ratings/db.rs index f0a424f..15df2dc 100644 --- a/lambdas/src/core/resource/ratings/db.rs +++ b/lambdas/src/core/resource/ratings/db.rs @@ -71,10 +71,10 @@ pub async fn fetch_ratings_summaries( // pub async fn fetch_ratings_summary( // db: &DatabaseConnection, -// bna_id: Uuid, +// rating_id: Uuid, // component: Option, // ) -> Result, sea_orm::DbErr> { -// let select = summary::Entity::find_by_id(bna_id); +// let select = summary::Entity::find_by_id(rating_id); // let component = component.unwrap_or(BNAComponent::All); // let res = match component { // BNAComponent::All => { diff --git a/lambdas/src/core/resource/ratings/endpoint.rs b/lambdas/src/core/resource/ratings/endpoint.rs index 57ec1ee..2b94764 100644 --- a/lambdas/src/core/resource/ratings/endpoint.rs +++ b/lambdas/src/core/resource/ratings/endpoint.rs @@ -18,8 +18,8 @@ use uuid::Uuid; pub fn routes() -> Router { Router::new() .route("/ratings", get(get_ratings)) - .route("/ratings/:bna_id", get(get_rating)) - .route("/ratings/:bna_id/city", get(get_ratings_city)) + .route("/ratings/:rating_id", get(get_rating)) + .route("/ratings/:rating_id/city", get(get_ratings_city)) .route( "/ratings/analyses", get(get_ratings_analyses).post(post_ratings_analysis), @@ -45,10 +45,10 @@ async fn get_rating( } async fn get_ratings_city( - Path(bna_id): Path, + Path(rating_id): Path, ctx: Context, ) -> Result, ExecutionError> { - get_ratings_city_adaptor(bna_id, ctx).await.map(Json) + get_ratings_city_adaptor(rating_id, ctx).await.map(Json) } async fn get_ratings_analyses( diff --git a/lambdas/src/core/resource/ratings/mod.rs b/lambdas/src/core/resource/ratings/mod.rs index 84d6fa7..5790d4c 100644 --- a/lambdas/src/core/resource/ratings/mod.rs +++ b/lambdas/src/core/resource/ratings/mod.rs @@ -32,9 +32,9 @@ impl FromStr for BNAComponent { } } -/// Path parameters for the /bnas enpoint. +/// Path parameters for the /ratings enpoint. pub struct BNAPathParameters { - pub bna_id: Uuid, + pub rating_id: Uuid, } /// Query parameters for the /bnas enpoint. @@ -43,10 +43,10 @@ pub struct BNAQueryParameters { } pub fn extract_path_parameters(event: &Request) -> Result { - let bna_id = - parse_path_parameter::(event, "bna_id")?.expect("no bna_id parameter provided"); + let rating_id = + parse_path_parameter::(event, "rating_id")?.expect("no rating_id parameter provided"); - Ok(BNAPathParameters { bna_id }) + Ok(BNAPathParameters { rating_id }) } pub fn extract_query_parameters(event: &Request) -> Result { diff --git a/lambdas/src/fixtures/get-bnas-bna_id.json b/lambdas/src/fixtures/get-bnas-bna_id.json index 05b44e4..0dac505 100644 --- a/lambdas/src/fixtures/get-bnas-bna_id.json +++ b/lambdas/src/fixtures/get-bnas-bna_id.json @@ -1,5 +1,5 @@ { - "resource": "/bnas/{bna_id}", + "resource": "/bnas/{rating_id}", "path": "/bnas/9b5b76d8-f628-4367-bd1d-12e6423aacea", "httpMethod": "GET", "headers": { @@ -42,7 +42,7 @@ }, "queryStringParameters": null, "pathParameters": { - "bna_id": "9b5b76d8-f628-4367-bd1d-12e6423aacea" + "rating_id": "9b5b76d8-f628-4367-bd1d-12e6423aacea" }, "multiValueQueryStringParameters": null, "stageVariables": null, diff --git a/lambdas/src/fixtures/get-cities-bnas-bna_id.json b/lambdas/src/fixtures/get-cities-bnas-bna_id.json index f554274..597310c 100644 --- a/lambdas/src/fixtures/get-cities-bnas-bna_id.json +++ b/lambdas/src/fixtures/get-cities-bnas-bna_id.json @@ -1,5 +1,5 @@ { - "resource": "/cities/{city_id}/bnas/{bna_id}", + "resource": "/cities/{city_id}/bnas/{rating_id}", "path": "/cities/1208800/bnas/9b5b76d8-f628-4367-bd1d-12e6423aacea", "httpMethod": "GET", "headers": { @@ -44,7 +44,7 @@ "multiValueQueryStringParameters": null, "pathParameters": { "city_id": "1208800", - "bna_id": "9b5b76d8-f628-4367-bd1d-12e6423aacea" + "rating_id": "9b5b76d8-f628-4367-bd1d-12e6423aacea" }, "stageVariables": null, "requestContext": { diff --git a/lambdas/tests/endpoints/ratings.hurl b/lambdas/tests/endpoints/ratings.hurl index 944c1bb..16064cd 100644 --- a/lambdas/tests/endpoints/ratings.hurl +++ b/lambdas/tests/endpoints/ratings.hurl @@ -9,7 +9,7 @@ rating_id: jsonpath "$.[0].id" # Queries a specific bna run. -GET {{host}}/ratings/{{bna_id}} +GET {{host}}/ratings/{{rating_id}} HTTP 200 @@ -19,24 +19,24 @@ GET {{host}}/ratings/1 HTTP 400 # Queries a non-existing bna run -GET {{host}}/ratings/{{fake_bna_id}} +GET {{host}}/ratings/{{fake_rating_id}} HTTP 404 [Asserts] jsonpath "$.errors" count == 1 -jsonpath "$.errors[0].source.pointer" == "/ratings/{{fake_bna_id}}" +jsonpath "$.errors[0].source.pointer" == "/ratings/{{fake_rating_id}}" # Queries a specific bna run and its associated city. -GET {{host}}/ratings/{{bna_id}}/city +GET {{host}}/ratings/{{rating_id}}/city HTTP 200 [Asserts] jsonpath "$" count > 0 # Queries a non-existing bna run and its associated city. -GET {{host}}/ratings/{{fake_bna_id}}/city +GET {{host}}/ratings/{{fake_rating_id}}/city HTTP 404 [Asserts] jsonpath "$.errors" count == 1 -jsonpath "$.errors[0].source.pointer" == "/ratings/{{fake_bna_id}}/city" +jsonpath "$.errors[0].source.pointer" == "/ratings/{{fake_rating_id}}/city" diff --git a/lambdas/tests/localhost.vars b/lambdas/tests/localhost.vars index fe72b3e..3a9c310 100644 --- a/lambdas/tests/localhost.vars +++ b/lambdas/tests/localhost.vars @@ -1,8 +1,8 @@ host=http://localhost:3000 -bna_id=1a759b85-cd87-4bb1-9efa-5789e38e9982 +rating_id=1a759b85-cd87-4bb1-9efa-5789e38e9982 max_page_size=50 country=United%20States region=Texas name=Austin city_id=ef8384d5-b96f-439d-a83b-bc801735ddc6 -fake_bna_id=11111111-2222-3333-4444-555555555555 +fake_rating_id=11111111-2222-3333-4444-555555555555 diff --git a/lambdas/tests/smoke/public-readonly.hurl b/lambdas/tests/smoke/public-readonly.hurl index bc56559..26c6c97 100644 --- a/lambdas/tests/smoke/public-readonly.hurl +++ b/lambdas/tests/smoke/public-readonly.hurl @@ -3,11 +3,11 @@ GET {{host}}/ratings HTTP 200 # Query a specific bna run. -GET {{host}}/ratings/{{bna_id}} +GET {{host}}/ratings/{{rating_id}} HTTP 200 # Query a specific bna run and its associated city. -GET {{host}}/ratings/{{bna_id}}/city +GET {{host}}/ratings/{{rating_id}}/city HTTP 200 # Query the first page of the cities. diff --git a/lambdas/tests/staging.vars b/lambdas/tests/staging.vars index 96bab88..0474482 100644 --- a/lambdas/tests/staging.vars +++ b/lambdas/tests/staging.vars @@ -1,8 +1,8 @@ host=https://api.peopleforbikes.xyz -bna_id=1a759b85-cd87-4bb1-9efa-5789e38e9982 +rating_id=1a759b85-cd87-4bb1-9efa-5789e38e9982 max_page_size=100 country=United%20States region=Texas name=Austin city_id=ef8384d5-b96f-439d-a83b-bc801735ddc6 -fake_bna_id=11111111-2222-3333-4444-555555555555 +fake_rating_id=11111111-2222-3333-4444-555555555555 diff --git a/openapi.yaml b/openapi.yaml index 3c30406..d97cb3e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -126,7 +126,7 @@ paths: - Authorizer: [] parameters: - $ref: "#/components/parameters/analysis_id" - /ratings/{bna_id}: + /ratings/{rating_id}: get: operationId: getRating summary: Get a specific city rating summary @@ -141,9 +141,9 @@ paths: 404: $ref: "#/components/responses/not_found" parameters: - - $ref: "#/components/parameters/bna_id" + - $ref: "#/components/parameters/rating_id" - $ref: "#/components/parameters/component" - /ratings/{bna_id}/city: + /ratings/{rating_id}/city: get: operationId: getRatingCity summary: Get a specific city rating summary and its associated city details @@ -158,7 +158,7 @@ paths: 404: $ref: "#/components/responses/not_found" parameters: - - $ref: "#/components/parameters/bna_id" + - $ref: "#/components/parameters/rating_id" /cities: get: operationId: getCities @@ -555,7 +555,7 @@ components: bna: type: object properties: - bna_id: + rating_id: type: string description: "Analysis identifier" example: "1a759b85-cd87-4bb1-9efa-5789e38e9982" @@ -709,7 +709,7 @@ components: bna_summary: type: object properties: - bna_id: + rating_id: type: string description: "Analysis identifier" example: "1a759b85-cd87-4bb1-9efa-5789e38e9982" @@ -1346,8 +1346,8 @@ components: $ref: "#/components/schemas/submission" parameters: - bna_id: - name: "bna_id" + rating_id: + name: "rating_id" in: "path" description: "Analysis identifier" required: true