Skip to content

Commit

Permalink
Rename Path parameters
Browse files Browse the repository at this point in the history
Renames the following parameters:
- bna_id -> rating_id
- id -> price_id

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho committed Oct 31, 2024
1 parent 3bc6eaf commit ee930f0
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion effortless/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
28 changes: 14 additions & 14 deletions lambdas/requests.rest
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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}}

###
Expand All @@ -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}}

Expand All @@ -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}}

Expand All @@ -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}}

Expand Down Expand Up @@ -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

###
Expand All @@ -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
2 changes: 1 addition & 1 deletion lambdas/src/bin/price-fargate/get-price-fargate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn function_handler(event: Request) -> Result<Response<Body>, Error> {
}

// Retrieve the ID of the entry to retrieve.
let parameter = "id";
let parameter = "price_id";
let id = event.path_parameter::<i32>(parameter);

// Retrieve a specific entry if an id was specified.
Expand Down
2 changes: 1 addition & 1 deletion lambdas/src/bin/ratings/get-ratings-analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async fn function_handler(event: Request) -> Result<Response<Body>, 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()),
}
Expand Down
2 changes: 1 addition & 1 deletion lambdas/src/bin/ratings/get-ratings-cities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn function_handler(event: Request) -> Result<Response<Body>, 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()),
}
Expand Down
4 changes: 2 additions & 2 deletions lambdas/src/bin/ratings/get-ratings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async fn function_handler(event: Request) -> Result<Response<Body>, 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
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions lambdas/src/core/resource/price/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -29,8 +29,8 @@ pub async fn get_prices_fargate(
}

pub async fn get_price_fargate(
Path(id): Path<i32>,
Path(price_id): Path<i32>,
ctx: Context,
) -> Result<Json<Value>, ExecutionError> {
get_price_fargate_adaptor(id, ctx).await.map(Json)
get_price_fargate_adaptor(price_id, ctx).await.map(Json)
}
4 changes: 2 additions & 2 deletions lambdas/src/core/resource/ratings/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BNAComponent>,
// ) -> Result<Option<BNA>, 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 => {
Expand Down
8 changes: 4 additions & 4 deletions lambdas/src/core/resource/ratings/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -45,10 +45,10 @@ async fn get_rating(
}

async fn get_ratings_city(
Path(bna_id): Path<Uuid>,
Path(rating_id): Path<Uuid>,
ctx: Context,
) -> Result<Json<Value>, 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(
Expand Down
10 changes: 5 additions & 5 deletions lambdas/src/core/resource/ratings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -43,10 +43,10 @@ pub struct BNAQueryParameters {
}

pub fn extract_path_parameters(event: &Request) -> Result<BNAPathParameters, APIErrors> {
let bna_id =
parse_path_parameter::<Uuid>(event, "bna_id")?.expect("no bna_id parameter provided");
let rating_id =
parse_path_parameter::<Uuid>(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<BNAQueryParameters, APIErrors> {
Expand Down
4 changes: 2 additions & 2 deletions lambdas/src/fixtures/get-bnas-bna_id.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resource": "/bnas/{bna_id}",
"resource": "/bnas/{rating_id}",
"path": "/bnas/9b5b76d8-f628-4367-bd1d-12e6423aacea",
"httpMethod": "GET",
"headers": {
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lambdas/src/fixtures/get-cities-bnas-bna_id.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
12 changes: 6 additions & 6 deletions lambdas/tests/endpoints/ratings.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
4 changes: 2 additions & 2 deletions lambdas/tests/localhost.vars
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions lambdas/tests/smoke/public-readonly.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lambdas/tests/staging.vars
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit ee930f0

Please sign in to comment.