You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added more APIs for the vehicle microservice and update README (#79)
## Description of changes:
Updated the Vehicle Inventory Microservice to support a bunch of new
APIs as well as a new table called VehiclePurchaseHistory that will
store date and price for a certain vehicle model. The new APIs include
some GET/POST/DELETE APIs for the Vehicle model and
VehiclePurchaseHistory model as well as an extra API that POSTs to the
image service.
## Testing
Tested all the following APIs and they are working as expected:
1. `GET /vehicle-inventory/heatlh-check/`
2. `GET /vehicle-inventory/`
3. `POST /vehicle-inventory/`
4. `GET /vehicle-inventory/<int>`
5. `DELETE /vehicle-inventory/<int>`
6. `GET /vehicle-inventory/name/<str>`
7. `GET /vehicle-inventory/<int>/image`
8. `GET /vehicle-inventory/image/<image_name>`
9. `POST /vehicle-inventory/image/<image_name>`
10. `GET /vehicle-inventory/history/`
11. `POST /vehicle-inventory/history/`
12. `GET /vehicle-inventory/history/<int>`
13. `DELETE /vehicle-inventory/history/<int>`
14. `GET /vehicle-inventory/history/<int>/vehicle`
```
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/health-check/
Vehicle Inventory Service up and running!%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/
{'id': 2, 'make': 'BMW', 'model': 'M340', 'year': 2022, 'image_name': 'newCar.jpg'}%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/1
Vehicle with id=1 is not found%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/2
{'id': 2, 'make': 'BMW', 'model': 'M340', 'year': 2022, 'image_name': 'newCar.jpg'}%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/2/image
{'ResponseMetadata': {'RequestId': '970QZM0ZRXA84CPN', 'HostId': 'UdimS4YvRKrpv2tv5r0LSXXdLC8SZehGWvCZA9EqQpT4QXqi0s3jF0uB+krjA9bCiWtKArQETZrLsqc8gLrLSUMpNnpBKw9z', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'UdimS4YvRKrpv2tv5r0LSXXdLC8SZehGWvCZA9EqQpT4QXqi0s3jF0uB+krjA9bCiWtKArQETZrLsqc8gLrLSUMpNnpBKw9z', 'x-amz-request-id': '970QZM0ZRXA84CPN', 'date': 'Tue, 27 Feb 2024 22:22:19 GMT', 'last-modified': 'Tue, 27 Feb 2024 22:06:50 GMT', 'etag': '"d41d8cd98f00b204e9800998ecf8427e"', 'x-amz-server-side-encryption': 'AES256', 'accept-ranges': 'bytes', 'content-type': 'binary/octet-stream', 'server': 'AmazonS3', 'content-length': '0'}, 'RetryAttempts': 0}, 'AcceptRanges': 'bytes', 'LastModified': datetime.datetime(2024, 2, 27, 22, 6, 50, tzinfo=tzutc()), 'ContentLength': 0, 'ETag': '"d41d8cd98f00b204e9800998ecf8427e"', 'ContentType': 'binary/octet-stream', 'ServerSideEncryption': 'AES256', 'Metadata': {}, 'Body': <botocore.response.StreamingBody object at 0x7f99808db940>}%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/image/newCar.jpg
{'ResponseMetadata': {'RequestId': '3HDD29P1QGH9HTB2', 'HostId': '0KYMPvXr2Xo4rx93XgdKdzYIpzQy4+ZWgeDxVvzxvkv0fnAQbHg0esgG5BRCWtMdwha6dqI7D+g=', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': '0KYMPvXr2Xo4rx93XgdKdzYIpzQy4+ZWgeDxVvzxvkv0fnAQbHg0esgG5BRCWtMdwha6dqI7D+g=', 'x-amz-request-id': '3HDD29P1QGH9HTB2', 'date': 'Tue, 27 Feb 2024 22:22:36 GMT', 'last-modified': 'Tue, 27 Feb 2024 22:06:50 GMT', 'etag': '"d41d8cd98f00b204e9800998ecf8427e"', 'x-amz-server-side-encryption': 'AES256', 'accept-ranges': 'bytes', 'content-type': 'binary/octet-stream', 'server': 'AmazonS3', 'content-length': '0'}, 'RetryAttempts': 0}, 'AcceptRanges': 'bytes', 'LastModified': datetime.datetime(2024, 2, 27, 22, 6, 50, tzinfo=tzutc()), 'ContentLength': 0, 'ETag': '"d41d8cd98f00b204e9800998ecf8427e"', 'ContentType': 'binary/octet-stream', 'ServerSideEncryption': 'AES256', 'Metadata': {}, 'Body': <botocore.response.StreamingBody object at 0x7f99808dbeb0>}%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/history/
{'id': 5, 'vehicle_id': 2, 'purchase_date': datetime.date(2024, 2, 27), 'purchase_price': 66000}%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/history/5
{'id': 5, 'vehicle_id': 2, 'purchase_date': datetime.date(2024, 2, 27), 'purchase_price': 66000}%
asakem@88665a24d661 vehicle-dealership-sample-app % curl -X GET http://0.0.0.0:8001/vehicle-inventory/history/5/vehicle
{'id': 2, 'make': 'BMW', 'model': 'M340', 'year': 2022, 'image_name': 'newCar.jpg'}%
```
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
@@ -119,10 +120,27 @@ They should be accessible through `0.0.0.0:8000` for the image service and `0.0.
119
120
## APIs
120
121
121
122
The following are the APIs and what they do:
122
-
1. GET /vehicle-inventory/: returns all the vehicles entries for postgres db
123
-
2. POST /vehicle-inventory/: puts vehicle into db. For example: `curl -X POST http://0.0.0.0:8001/vehicle-inventory/ -d '{"make": "BMW","model": "M340","year": 2022,"image_name": "newCar.jpg"}'`
124
-
3. GET /vehicle-inventory/<int>: returns vehicle entry with id = <int>
125
-
4. GET /vehicle-inventory/<int>/image: returns image file information from S3 for the specific vehicle by calling the image microservice
126
-
5. GET /images/name/<image_name>: returns image information for <image_name> from S3 if present.
127
-
6. POST /images/name/<image_name>: creates an empty file in S3. This is an async endpoint since it will put image name in an SQS queue and not wait for the file to be created in S3. Instead, a long running thread will poll SQS and then create the image file later.
128
-
7. GET /image/remote-image: makes a remote http call to google.com.
123
+
1.`GET /vehicle-inventory/heatlh-check/`: returns 200 if the vehicle service is up and running.
124
+
2.`GET /vehicle-inventory/`: returns all the vehicles entries for postgres db
125
+
3.`POST /vehicle-inventory/`: puts vehicle into db. For example: `curl -X POST http://0.0.0.0:8001/vehicle-inventory/
0 commit comments