Sign inSign up

gustosilva/dynamodb-api

By gustosilva

•Updated over 3 years ago

API feita para testar a integração do Spring boot com o AWS DynamoDB

Image
0

10K+

gustosilva/dynamodb-api repository overview

⁠dynamoDB-API

API feita para testar a integração do Spring boot com o AWS DynamoDB.

⁠Tabela de Conteúdos

⁠Features

  • Cadastro de dados de funcionários e seus respectivos departamentos

  • Consulta de dados de funcionários e seus respectivos departamentos

  • Atualização de dados de funcionários e seus respectivos departamentos

  • Exclusão de dados de funcionários e seus respectivos departamentos

⁠Contrato da API

{
  "swagger": "2.0",
  "info": {
    "description": "API using Spring Boot for dynamoDB testing",
    "version": "1.0.0",
    "title": "DynamoDB API",
    "license": {
      "name": "Apache License Version 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0"
    }
  },
  "host": "localhost:8080",
  "basePath": "/",
  "tags": [
    {
      "name": "employee-controller",
      "description": "Employee Controller"
    }
  ],
  "paths": {
    "/employee": {
      "post": {
        "tags": [
          "employee-controller"
        ],
        "summary": "Saves a new employee",
        "description": "Saves a new employee in dynamoDB",
        "operationId": "saveEmployeeUsingPOST",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "*/*"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "employee",
            "description": "Form for creation of user",
            "required": true,
            "schema": {
              "$ref": "#/definitions/EmployeeInput"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/Employee"
            }
          },
          "201": {
            "description": "Created"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          }
        },
        "deprecated": false
      }
    },
    "/employee/{id}": {
      "get": {
        "tags": [
          "employee-controller"
        ],
        "summary": "Get data of specific employee",
        "description": "Get data of specific employee in dynamoDB",
        "operationId": "getEmployeeUsingGET",
        "produces": [
          "*/*"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Employee id",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/EmployeeDto"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          }
        },
        "deprecated": false
      },
      "put": {
        "tags": [
          "employee-controller"
        ],
        "summary": "Update data of specific employee",
        "description": "Update data of specific employee in dynamoDB",
        "operationId": "updateEmployeeUsingPUT",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "*/*"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "employee",
            "description": "Form to update user",
            "required": true,
            "schema": {
              "$ref": "#/definitions/EmployeeInput"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Employee id",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/EmployeeDto"
            }
          },
          "201": {
            "description": "Created"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          }
        },
        "deprecated": false
      },
      "delete": {
        "tags": [
          "employee-controller"
        ],
        "summary": "Deletes specific employee",
        "description": "Deletes employee in dynamoDB",
        "operationId": "deleteEmployeeUsingDELETE",
        "produces": [
          "*/*"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Employee id",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "deprecated": false
      }
    }
  },
  "definitions": {
    "Department": {
      "type": "object",
      "properties": {
        "departmentCode": {
          "type": "string"
        },
        "departmentName": {
          "type": "string"
        }
      },
      "title": "Department"
    },
    "Employee": {
      "type": "object",
      "properties": {
        "department": {
          "$ref": "#/definitions/Department"
        },
        "email": {
          "type": "string"
        },
        "employeeId": {
          "type": "string"
        },
        "firstName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        }
      },
      "title": "Employee"
    },
    "EmployeeDto": {
      "type": "object",
      "properties": {
        "departamentCode": {
          "type": "string"
        },
        "departamentName": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "firstName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        }
      },
      "title": "EmployeeDto"
    },
    "EmployeeInput": {
      "type": "object",
      "properties": {
        "department": {
          "$ref": "#/definitions/Department"
        },
        "email": {
          "type": "string"
        },
        "employeeId": {
          "type": "string"
        },
        "firstName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        }
      },
      "title": "EmployeeInput"
    }
  }
}

⁠Endpoints da Aplicação

⁠/employee
⁠POST
⁠Summary:

Saves a new employee

⁠Description:

Saves a new employee in dynamoDB

⁠Parameters
NameLocated inDescriptionRequiredSchema
employeebodyForm for creation of userYesEmployeeInput⁠
⁠Responses
CodeDescriptionSchema
200OKEmployee⁠
201Created
401Unauthorized
403Forbidden
404Not Found
⁠/employee/{id}
⁠GET
⁠Summary:

Get data of specific employee

⁠Description:

Get data of specific employee in dynamoDB

⁠Parameters
NameLocated inDescriptionRequiredSchema
idpathEmployee idYesstring
⁠Responses
CodeDescriptionSchema
200OKEmployeeDto⁠
401Unauthorized
403Forbidden
404Not Found
⁠PUT
⁠Summary:

Update data of specific employee

⁠Description:

Update data of specific employee in dynamoDB

⁠Parameters
NameLocated inDescriptionRequiredSchema
employeebodyForm to update userYesEmployeeInput⁠
idpathEmployee idYesstring
⁠Responses
CodeDescriptionSchema
200OKEmployeeDto⁠
201Created
401Unauthorized
403Forbidden
404Not Found
⁠DELETE
⁠Summary:

Deletes specific employee

⁠Description:

Deletes employee in dynamoDB

⁠Parameters
NameLocated inDescriptionRequiredSchema
idpathEmployee idYesstring
⁠Responses
CodeDescription
200OK
204No Content
401Unauthorized
403Forbidden
⁠Models
⁠Department
NameTypeDescriptionRequired
departmentCodestringNo
departmentNamestringNo
⁠Employee
NameTypeDescriptionRequired
departmentDepartment⁠No
emailstringNo
employeeIdstringNo
firstNamestringNo
lastNamestringNo
⁠EmployeeDto
NameTypeDescriptionRequired
departamentCodestringNo
departamentNamestringNo
emailstringNo
firstNamestringNo
lastNamestringNo
⁠EmployeeInput
NameTypeDescriptionRequired
departmentDepartment⁠No
emailstringNo
employeeIdstringNo
firstNamestringNo
lastNamestringNo

Coleção para testar os endpoints da aplicação

Run in Insomnia}

⁠Pré-requisitos e como rodar a aplicação/testes

Pré-requisitos para rodar localmente:

  • JDK 11 ou superior
  • Maven 3
  • Uma conta na AWS com uma tabela chamada empoyee no dynamoDB
    • Um usuário com as permissões (de preferencia a de full access ao bd)

Para rodar via docker, rode os comandos abaixo:

# Baixar a imagem
docker pull gustosilva/dynamodb-api:latest

# Gerar o containter
docker run \
  --env ACCESS_KEY=<ACCESS_KEY> \
  --env SECRET_KEY=<SECRET_KEY> \
  --env SERVICE_ENDPOINT=<SERVICE_ENDPOINT> \
  --env SIGNING_REGION=<SIGNING_REGION> \
  -p 8080:8080 gustosilva/dynamodb-api:latest
⁠Tecnologias utilizadas

Projeto feito usando Java 11 e Maven 3.8 como ferramenta de build.

⁠Dependencias
  • spring validation
  • spring web
  • lombok
  • spring test
  • spring cache
  • modelmapper
  • aws-java-sdk-dynamodb
  • springfox-swagger2
  • springfox-swagger-ui
⁠Licença

Apache License Version 2.0⁠

⁠Autor

Feito por Gustavo Silva:


Tag summary

Content type

Image

Digest

sha256:92f4fde34…

Size

353.1 MB

Last updated

over 3 years ago

docker pull gustosilva/dynamodb-api