- Go v1.25+
- Docker
- Kubernetes cluster (tested with minikube)
- Docker compose also works and compose file is also included in this repository
- Clone this repository
- Build the api image with
docker build -t devices-api -f Dockerfile .
and rundocker compose up
- If
bash
is installed in your system, you can also executebuild.sh
to build and run composer
If minikube is installed you can also apply
all .yaml files inside the kubernetes folder kubectl apply -f filename.yaml
Documentation of each endpoint can be found on the swagger page, accessible by default at localhost:9001/swagger/index.html
develop a REST API capable of persisting and managing device resources.
In PostgreSQL
- ID
UUID
- Name
varchar(250)
- Brand
varchar(250)
- CreatedAt
TIMESTAMPTZ
- State:
ENUM
- Available
- In-Use
- Inactive
- Create a new device.
POST
- Fully and/or partially update an existing device.
PUT
- Fetch a single device.
GET
- Fetch all devices.
GET
- Fetch devices by brand.
GET
- Fetch devices by state.
GET
- Delete a single device.
DELETE
- Creation time cannot be updated.
- Name and brand properties cannot be updated if the device is in use.
- In use devices cannot be deleted.
go test $(go list ./... | grep -v '/docs') -coverprofile=cover.out && go tool cover -html=cover.out -o cover.html