This is an expanded version of the final project I built for the CS 493 (Cloud Application Development) course at OSU. It is a REST API that supports all CRUD operations for trucks and loads. The data model and the request and response parameters for all endpoints are outlined below. The API is hosted on Google App Engine and the base URL is https://portfolio-johalj.uw.r.appspot.com/.
Sample response for POST /trucks endpoint
Some endpoints are protected and require an access token. To acquire this token, login/signup here. You will be redirected to a page that contains a JSON object. The id_token
property contains the access token.
- Data Model
- View All Users
- Create a Truck
- View a Truck
- View All Trucks
- Edit a Truck (Put)
- Edit a Truck (Patch)
- Delete a Truck
- Delete All Trucks
- Create a Load
- View a Load
- View All Loads
- Edit a Load (Put)
- Edit a Load (Patch)
- Delete a Load
- Delete All Loads
- Managing Loads: Load Assigned to Truck
- Managing Loads: Load Removed from Truck
The app stores three kinds of entities in Datastore: Users, Trucks, and Loads. Users and Trucks are related since each Truck has an owner
property which corresponds to the sub
property of a User. Users and Trucks have a one-to-many relationship. A single User can own many Trucks, but a Truck can only have one owner. Trucks and Loads are also related via a one-to-many relationship. A Truck can contain many Loads while a Load can only be on a single Truck.
Property | Data Type | Notes | Example |
---|---|---|---|
id |
Integer | The unique ID of the user (automatically generated by Datastore). | |
name |
String | The username of the user. | "[email protected]" |
sub |
String | The complete subject claim of the user's JWT. | "auth0|629b81bdcd1f83006faceb4d" |
Note: both the id
and sub
properties are unique identifiers, but the id
property is irrelevant to this application. The sub
property is used to identify users and it links the Users
kind to the Trucks
kind.
Property | Data Type | Notes | Example | Required? | Valid Request Parameters |
---|---|---|---|---|---|
id |
Integer | The unique ID of the truck. Datastore automatically generates it. | N/A | No | N/A |
owner |
String | The sub of the user that owns the truck. | "auth0|629b81bdcd1f83006faceb4d" | No | N/A |
truck_vin |
String | The vehicle identification number of the truck. | "1FUJBGAN04HM86987" | Yes | 17-character string (only alphanumeric characters) |
trailer_vin |
String | The vehicle identification number of trailer. | "1B3ES56C55D137449" | Yes | 17-character string (only alphanumeric characters) |
truck_model |
String | The model of the truck. | "Kenworth T680" | Yes | Maximum 50 characters (alphanumeric & spaces only) |
trailer_type |
String | The type of the trailer. | "Flatbed" | Yes | Maximum 20 characters (alphanumeric & spaces only) |
trailer_capacity |
Integer | The maximum weight (lbs) a trailer can hold. | 45000 | Yes | An integer between 1 and 100,000 |
loads |
Array | A list of the loads on the truck. | ["123", "456", "789"] | No | N/A |
Property | Data Type | Notes | Example | Required? | Valid Request Parameters |
---|---|---|---|---|---|
id |
Integer | The unique ID of the load. Datastore automatically generates it. | No | N/A | |
carrier |
String or Null | If the load is on a truck, then carrier is the id of the truck. Otherwise, it is null. | "5665248644169728" | No | N/A |
vendor |
String | The supplier of the item. | "Driscoll's" | Yes | Maximum 50 characters (letters, apostrophes, and spaces only) |
item |
String | The items in the load. | "Organic strawberries" | Yes | Maximum 50 characters (letters and spaces only) |
quantity |
Integer | The number of cases of the item. | 240 | Yes | An integer between 1 and 100,000 |
weight |
Floating point number | The weight (lbs) of the load. | 465.75 | Yes | A number between 1 and 100,000 |
List all the users.
GET /users
No.
None
None
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The response contains a property data which is a list of all the users in the database. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Status: 200 OK
{
"data": [
{
"sub": "auth0|629b9c27337c6c00708f13d5",
"name": "[email protected]",
"id": "5995848483733504"
},
{
"sub": "auth0|629bec02cd1f83006facf42b",
"name": "[email protected]",
"id": "6246730945265664"
},
{
"name": "[email protected]",
"sub": "auth0|629b81bdcd1f83006faceb4d",
"id": "6264616665481216"
}
]
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Allows you to create a new truck.
POST /trucks
Yes. The request must be accompanied by a valid bearer token.
None
Required
application/json
Name | Description | Required? |
---|---|---|
truck_vin | The vehicle identification number of the truck. | Yes |
trailer_vin | The vehicle identification number of the trailer. | Yes |
truck_model | The model of the truck (E.g. "Kenworth T680"). | Yes |
trailer_type | The model of the trailer (E.g. "Flatbed"). | Yes |
trailer_capacity | The maximum weight (lbs) a trailer can hold (E.g. 45000). | Yes |
{
"truck_vin": "1FUJBGAN04HM86987",
"trailer_vin": "1B3ES56C55D137449",
"truck_model": "Kenworth T680",
"trailer_type": "Refrigerated",
"trailer_capacity": 45000
}
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 201 Created | Extraneous attributes will be ignored. |
Failure | 400 Bad Request | The request is missing any of the required attributes. |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 415 Unsupported Media Type | The request is not JSON. |
Status 201 Created
{
"trailer_capacity": 45000,
"trailer_vin": "1B3ES56C55D137449",
"loads": [],
"trailer_type": "Refrigerated",
"truck_vin": "1FUJBGAN04HM86987",
"owner": "auth0|629b81bdcd1f83006faceb4d",
"truck_model": "Kenworth T680",
"id": "5284414665785344",
"self": "http://127.0.0.1:8080/trucks/5284414665785344"
}
Status: 400 Bad Request
{
"Error": "The request object is missing at least one of the required attributes"
}
Status: 401 Unauthorized Error
{
"Error": "Invalid token."
}
Status: 415 Unsupported Media Type
{
"Error": "Server only accepts application/json data."
}
Allows you to get an existing truck
GET /truck/:truck_id
Yes. The request must be accompanied by a valid bearer token.
Name | Description |
---|---|
truck_id | ID of the truck |
None
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 403 Forbidden | The bearer token is valid but does not correspond to the correct owner of the truck. |
Failure | 404 Not Found | No truck with this truck_id exists |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Status: 200 OK
{
"truck_vin": "1FUJBGAN04HM86987",
"loads": [
{
"id": "6523730297618432",
"self": "http://127.0.0.1:8080/loads/6523730297618432"
}
],
"trailer_capacity": 45000,
"trailer_vin": "1B3ES56C55D137449",
"truck_model": "Kenworth T680",
"trailer_type": "Refrigerated",
"owner": "auth0|629b81bdcd1f83006faceb4d",
"id": "5284414665785344",
"self": "http://127.0.0.1:8080/trucks/5284414665785344"
}
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 403 Forbidden
{
"Error": "You do not have access to this truck"
}
Status: 404 Not Found
{
"Error": "No truck with this truck_id exists"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
List all the trucks owned by a particular owner.
GET /trucks
Yes. The request must be accompanied by a valid bearer token.
None
None
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The response contains a property data which is a list of all the trucks owned by the specified owner. |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Status: 200 OK
{
"data": [
{
"trailer_type": "Refrigerated",
"truck_model": "Freightliner M2 106",
"owner": "auth0|629b81bdcd1f83006faceb4d",
"loads": [],
"truck_vin": "JH4KA4576KC031014",
"trailer_vin": "JH4DA3350HS000229",
"trailer_capacity": 40000,
"id": "4824921112838144",
"self": "http://127.0.0.1:8080/trucks/4824921112838144"
},
{
"trailer_vin": "1B3ES56C55D137449",
"trailer_capacity": 45000,
"truck_model": "Kenworth T680",
"owner": "auth0|629b81bdcd1f83006faceb4d",
"loads": [
{
"id": "6136585972088832",
"self": "http://127.0.0.1:8080/loads/6136585972088832"
}
],
"truck_vin": "1FUJBGAN04HM86987",
"trailer_type": "Refrigerated",
"id": "5010686065246208",
"self": "http://127.0.0.1:8080/trucks/5010686065246208"
},
{
"truck_vin": "1C3BF66P0GX570598",
"truck_model": "Peterbilt 389",
"loads": [],
"trailer_vin": "LM4AC113061105688",
"trailer_type": "Refrigerated",
"trailer_capacity": 45000,
"owner": "auth0|629b81bdcd1f83006faceb4d",
"id": "5566276323770368",
"self": "http://127.0.0.1:8080/trucks/5566276323770368"
},
{
"owner": "auth0|629b81bdcd1f83006faceb4d",
"truck_model": "Kenworth T800",
"trailer_type": "Flatbed",
"truck_vin": "1FABP21B4CK165368",
"trailer_capacity": 45000,
"trailer_vin": "3N1BC13E99L480541",
"loads": [],
"id": "6101517832552448",
"self": "http://127.0.0.1:8080/trucks/6101517832552448"
},
{
"owner": "auth0|629b81bdcd1f83006faceb4d",
"loads": [],
"truck_model": "Freightliner Cascadia",
"trailer_type": "Dry Van",
"trailer_capacity": 20000,
"trailer_vin": "1G4HP54KX24151104",
"truck_vin": "JTJZB1BA8A2400307",
"id": "6129226277191680",
"self": "http://127.0.0.1:8080/trucks/6129226277191680"
},
{
"truck_vin": "1GCCS1442W8181753",
"trailer_capacity": 30000,
"loads": [
{
"id": "6732143317221376",
"self": "http://127.0.0.1:8080/loads/6732143317221376"
},
{
"id": "6128839595917312",
"self": "http://127.0.0.1:8080/loads/6128839595917312"
}
],
"trailer_vin": "JH4DA9340PS000417",
"owner": "auth0|629b81bdcd1f83006faceb4d",
"trailer_type": "Flatbed",
"truck_model": "Mack Anthem",
"id": "6232295996391424",
"self": "http://127.0.0.1:8080/trucks/6232295996391424"
}
]
}
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Allows you to overwrite all attributes of a truck, except owner
and loads
.
Side effect : loads
will be reset to an empty array and any load entity that was previously on the truck will no longer have a carrier.
PUT /trucks/:truck_id
Yes. The request must be accompanied by a valid bearer token.
Name | Description |
---|---|
truck_id | ID of the truck |
Required
application/json
Name | Description | Required? |
---|---|---|
truck_vin | The vehicle identification number of the truck. | Yes |
trailer_vin | The vehicle identification number of the trailer. | Yes |
truck_model | The model of the truck (E.g. "Kenworth T680"). | Yes |
trailer_type | The model of the trailer (E.g. "Flatbed"). | Yes |
trailer_capacity | The maximum weight (lbs) a trailer can hold (E.g. 45000). | Yes |
{
"truck_vin": "1GCCS1442W8181753",
"trailer_vin": "JH4DA9340PS000417",
"truck_model": "Mack Anthem",
"trailer_type": "Dry Van",
"trailer_capacity": 28000
}
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The input can contain extraneous attributes. Any attributes aside from the required attributes listed above will be ignored. |
Failure | 400 Bad Request | The request is missing any of the required attributes. |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 403 Forbidden | The bearer token is valid but does not correspond to the correct owner of the truck. |
Failure | 404 Not Found | No truck with this truck_id exists. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Failure | 415 Unsupported Media Type | The request is not JSON. |
Status: 200 OK
{
"trailer_type": "Dry Van",
"truck_vin": "1GCCS1442W8181753",
"truck_model": "Mack Anthem",
"loads": [],
"owner": "auth0|629b81bdcd1f83006faceb4d",
"trailer_vin": "JH4DA9340PS000417",
"trailer_capacity": 28000,
"id": "6124252570845184",
"self": "http://127.0.0.1:8080/trucks/6124252570845184"
}
Status: 400 Bad Request
{
"Error": "The request object is missing at least one of the required attributes"
}
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 403 Forbidden
{
"Error": "You do not have access to this truck"
}
Status: 404 Not Found
{
"Error": "No truck with this truck_id exists"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Status: 415 Unsupported Media Type
{
"Error": "Server only accepts application/json data."
}
Allows you to overwrite any subset of attributes of a truck, excluding loads
and owner
. The attributes that weren't explicitly overwritten in the request will remain unchanged.
Note: the relationship between a truck and its loads will remain unchanged.
PATCH /trucks/:truck_id
Yes. The request must be accompanied by a valid bearer token.
Name | Description |
---|---|
truck_id | ID of the truck |
Required
application/json
Name | Description | Required? |
---|---|---|
truck_vin | The vehicle identification number of the truck. | No |
trailer_vin | The vehicle identification number of the trailer. | No |
truck_model | The model of the truck (E.g. "Kenworth T680"). | No |
trailer_type | The model of the trailer (E.g. "Flatbed"). | No |
trailer_capacity | The maximum weight (lbs) a trailer can hold (E.g. 45000). | No |
{
"truck_vin": "1GTEC14W1YZ246726",
"trailer_vin": "1J4RR5GT2BC512008"
}
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The input can contain extraneous attributes. Any attributes aside from the required attributes listed above will be ignored. |
Failure | 400 Bad Request | The request doesn't contain at least one of the required attributes. |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 403 Forbidden | The bearer token is valid but does not correspond to the correct owner of the truck. |
Failure | 404 Not Found | No truck with this truck_id exists. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Failure | 415 Unsupported Media Type | The request is not JSON. |
Status: 200 OK
{
"trailer_type": "Refrigerated",
"owner": "auth0|629b81bdcd1f83006faceb4d",
"loads": [
{
"id": "5563792926703616",
"self": "http://127.0.0.1:8080/loads/5563792926703616"
},
{
"id": "6689692833546240",
"self": "http://127.0.0.1:8080/loads/6689692833546240"
}
],
"truck_model": "Kenworth T680",
"trailer_vin": "1J4RR5GT2BC512008",
"trailer_capacity": 45000,
"truck_vin": "1GTEC14W1YZ246726",
"id": "4971907073966080",
"self": "http://127.0.0.1:8080/trucks/4971907073966080"
}
Status: 400 Bad Request
{
"Error": "The request object is missing at least one of the required attributes"
}
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 403 Forbidden
{
"Error": "You do not have access to this truck"
}
Status: 404 Not Found
{
"Error": "No truck with this truck_id exists"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Status: 415 Unsupported Media Type
{
"Error": "Server only accepts application/json data."
}
Allows you to delete a truck.
Side effect : If the truck contains a load, the deletion of the truck will update the load entity so that it no longer belongs to a truck.
DELETE /trucks/:truck_id
Yes. The request must be accompanied by a valid bearer token.
Name | Description |
---|---|
truck_id | ID of the truck |
None
No body
Success: No body
Failure: application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 204 No Content | |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 403 Forbidden | The bearer token is valid but does not correspond to the correct owner of the truck. |
Failure | 404 Not Found | No truck with this truck_id exists |
Status: 204 No Content
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 403 Forbidden
{
"Error": "You do not have access to this truck"
}
Status: 404 Not Found
{
"Error": "No truck with this truck_id exists"
}
Forbidden endpoint
DELETE /trucks
Yes. The request must be accompanied by a valid bearer token.
None
None
No body
application/json
Outcome | Status Code | Notes |
---|---|---|
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 405 Not Supported | This endpoint is not supported |
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 405 Not Supported
{
"Error": "This endpoint is not supported"
}
Allows you to create a new load.
POST /loads
No.
None
Required
application/json
Name | Description | Required? |
---|---|---|
item | The supplier of the item | Yes |
quantity | The items in the load. | Yes |
vendor | The number of cases of the item | Yes |
weight | The weight (lbs) of the load | Yes |
{
"item": "Organic strawberries",
"quantity": 240,
"vendor": "Driscoll's",
"weight": 2160
}
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 201 Created | The input can contain extraneous attributes. Any attributes aside from the required attributes listed above will be ignored. |
Failure | 400 Bad Request | The request is missing any of the required attributes. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Failure | 415 Unsupported Media Type | The request is not JSON. |
Status: 201 Created
{
"id": "6195449035751424",
"item": "Organic strawberries",
"quantity": 240,
"vendor": "Driscoll's",
"weight": 2160,
"carrier": null,
"self": "http://127.0.0.1:8080/loads/6195449035751424"
}
Status: 400 Bad Request
{
"Error": "The request object is missing at least one of the required attributes"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Status: 415 Unsupported Media Type
{
"Error": "Server only accepts application/json data."
}
Allows you to get an existing load.
GET /loads/:load_id
No.
Name | Description |
---|---|
load_id | ID of the load |
None
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | |
Failure | 404 Not Found | No load with this load_id exists |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Status: 200 OK
{
"carrier": {
"id": "6687202524266496",
"self": "http://127.0.0.1:8080/trucks/6687202524266496"
},
"weight": 1454,
"quantity": 288,
"item": "Blueberries",
"vendor": "Driscoll's",
"id": "5847751300481024",
"self": "http://127.0.0.1:8080/loads/5847751300481024"
}
Status: 404 Not Found
{
"Error": "No load with this load_id exists"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
List all the loads.
GET /loads
No.
None
None
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The response contains a data property which is a list of all the loads in the Load kind. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Status: 200 OK
{
"data": [
{
"carrier": null,
"quantity": 432,
"item": "Raspberries",
"vendor": "Driscoll's",
"weight": 2462.4,
"id": "4870064809443328",
"self": "http://127.0.0.1:8080/loads/4870064809443328"
},
{
"weight": 2160,
"carrier": null,
"vendor": "Driscoll's",
"quantity": 240,
"item": "Organic strawberries",
"id": "5110132711096320",
"self": "http://127.0.0.1:8080/loads/5110132711096320"
},
{
"weight": 880,
"item": "Avocados",
"vendor": "Taylor Farms",
"carrier": null,
"quantity": 160,
"id": "5116145900191744",
"self": "http://127.0.0.1:8080/loads/5116145900191744"
},
{
"carrier": {
"id": "6687202524266496",
"self": "http://127.0.0.1:8080/trucks/6687202524266496"
},
"quantity": 288,
"item": "Blueberries",
"vendor": "Driscoll's",
"weight": 1454,
"id": "5679095853613056",
"self": "http://127.0.0.1:8080/loads/5679095853613056"
},
{
"vendor": "Driscoll's",
"quantity": 360,
"item": "Chocolate caramel apples",
"weight": 3960,
"carrier": null,
"id": "5716561121771520",
"self": "http://127.0.0.1:8080/loads/5716561121771520"
}
]
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Allows you to overwrite all attributes of a load.
Side effect: carrier
will be reset to null and the truck carrying the load (if applicable) will no longer contain this load in its loads
property.
PUT /loads/:load_id
No.
Name | Description |
---|---|
load_id | ID of the load |
Required
application/json
Name | Description | Required? |
---|---|---|
item | The supplier of the item | Yes |
quantity | The items in the load. | Yes |
vendor | The number of cases of the item | Yes |
weight | The weight (lbs) of the load | Yes |
{
"item": "Blueberries",
"quantity": 288,
"vendor": "Hillcrest Produce",
"weight": 1454
}
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The input can contain extraneous attributes. Any attributes aside from the required attributes listed above will be ignored. |
Failure | 400 Bad Request | The request is missing any of the required attributes. |
Failure | 404 Not Found | No load with this load_id exists. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Failure | 415 Unsupported Media Type | The request is not JSON. |
Status: 200 OK
{
"weight": 1450,
"carrier": null,
"vendor": "Hillcrest Produce",
"quantity": 288,
"item": "Blueberries",
"id": "4899245085687808",
"self": "http://127.0.0.1:8080/loads/4899245085687808"
}
Status: 400 Bad Request
{
"Error": "The request object is missing at least one of the required attributes"
}
Status: 404 Not Found
{
"Error": "No load with this load_id exists"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Status: 415 Unsupported Media Type
{
"Error": "Server only accepts application/json data."
}
Allows you to overwrite any subset of attributes of a load, excluding carrier
. The attributes that weren't explicitly overwritten in the request will remain unchanged.
Note: the relationship between a load and the truck carrying it will remain unchanged.
PATCH /loads/:load_id
No.
Name | Description |
---|---|
load_id | ID of the load |
Required
application/json
Name | Description | Required? |
---|---|---|
item | The supplier of the item | No |
quantity | The items in the load. | No |
vendor | The number of cases of the item | No |
weight | The weight (lbs) of the load | No |
{
"item": "Kale"
}
application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 200 OK | The input can contain extraneous attributes. Any attributes aside from the required attributes listed above will be ignored. |
Failure | 400 Bad Request | The request doesn't contain at least one of the attributes list above. |
Failure | 404 Not Found | No load with this load_id exists. |
Failure | 406 Not Acceptable | The client wants a media type other than JSON. |
Failure | 415 Unsupported Media Type | The request is not JSON. |
Status: 200 OK
{
"quantity": 135,
"carrier": {
"id": "6687202524266496",
"self": "http://127.0.0.1:8080/trucks/6687202524266496"
},
"vendor": "Taylor Farms",
"item": "Kale",
"weight": 465.75,
"id": "6225742111178752",
"self": "http://127.0.0.1:8080/loads/6225742111178752"
}
Status: 400 Bad Request
{
"Error": "The request object is missing at least one of the required attributes"
}
Status: 404 Not Found
{
"Error": "No load with this load_id exists"
}
Status: 406 Not Acceptable
{
"Error": "This application only supports JSON responses"
}
Status: 415 Unsupported Media Type
{
"Error": "Server only accepts application/json data."
}
Allows you to delete a load.
Side effect: If the load is on a truck, the deletion of the load will update the truck entity so that it no longer contains the load.
DELETE /loads/:load_id
No.
Name | Description |
---|---|
load_id | ID of the load |
None
No body
Success: No body
Failure: application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 204 No Content | |
Failure | 404 Not Found | No load with this load_id exists |
Status: 204 No Content
Status: 404 Not Found
{
"Error": "No load with this load_id exists"
}
Forbidden endpoint
DELETE /loads
No.
None
None
No body
application/json
Outcome | Status Code | Notes |
---|---|---|
Failure | 405 Not Supported | This endpoint is not supported |
Status: 405 Not Supported
{
"Error": "This endpoint is not supported"
}
A load is assigned to a truck.
Note: A load cannot be assigned to multiple trucks.
PUT /trucks/:truck_id/loads/:load_id
Yes. The request must be accompanied by a valid bearer token.
Name | Description |
---|---|
truck_id | ID of the truck |
load_id | ID of the load |
None
No body
Success: No body
Failure: application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 204 No Content | Succeeds only if a truck exists with this truck_id, a load exists with this load_id and the load hasn't already been assigned to a truck. |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 403 Forbidden | The bearer token is valid but does not correspond to the correct owner of the truck or the load has already been assigned to a truck. |
Failure | 404 Not Found | The specified truck and/or load does not exist. |
Status: 204 No Content
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 403 Forbidden
{
"Error": "You do not have access to this truck"
}
Status: 403 Forbidden
{
"Error": "The load is already loaded on another truck"
}
Status: 404 Not Found
{
"Error": "The specified truck and/or load does not exist"
}
A load is removed from a truck.
DELETE /truck/:truck_id/loads/:load_id
Yes. The request must be accompanied by a valid bearer token.
Name | Description |
---|---|
load_id | ID of the load |
truck_id | ID of the truck |
None
No body
Success: No body
Failure: application/json
Outcome | Status Code | Notes |
---|---|---|
Success | 204 No Content | Succeeds only if a truck exists with this truck_id, a load exists with this load_id and the load is on the truck. |
Failure | 401 Unauthorized | The bearer token is missing or invalid. |
Failure | 403 Forbidden | The bearer token is valid but does not correspond to the correct owner of the truck. |
Failure | 404 Not Found | No truck with this truck_id is loaded with the load with this load_id. This could be because no truck with this truck_id exists, or because no load with load_id exists, or even if both truck_id and load_id are valid, the load with this load_id is not on this truck with this truck_id |
Status: 204 No Content
Status: 401 Unauthorized
{
"Error": "Invalid token."
}
Status: 403 Forbidden
{
"Error": "You do not have access to this truck"
}
Status: 404 Not Found
{
"Error": "No truck with this truck_id is loaded with the load with this load_id"
}