Skip to content

Instantly share code, notes, and snippets.

@mageddo
Created January 17, 2020 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mageddo/3d2111b37f1fa1405570143b8587035b to your computer and use it in GitHub Desktop.
Save mageddo/3d2111b37f1fa1405570143b8587035b to your computer and use it in GitHub Desktop.
Simple way to create REST docs

Listar arquivos de um diretório

GET /op/files/ HTTP/1.1

Parameters

Name Type Decription
path string Diretório do qual serão listados os arquivos e sub diretórios

Reponse

HTTP/1.1 200
[
  ".bashrc",
  "Downloads",
  "Documents"
]

Exemplo

watch "curl -s -w '\n' -X GET $BASE_URL'/op/files/?path=/export/shared/arquivos_gerados/CREDENCIADOR/OUT' | python -m json.tool"

Baixa um arquivo

GET /op/files/download HTTP/1.1

Parameters

Name Type Decription
decrypt boolean Se deve tentar decriptar o arquivo que irá baixar (default=true)
path string Nome do arquivo que será baixado
configEnviromentId integer id do ConfigEnvironment que define os certificados da encriptação

Reponse

HTTP/1.1 200
<file binary data>

Exemplo

FILE_NAME=ASLC027_08561701_20170904_00005_ERR && \
curl -s -X GET "$BASE_URL/op/files/download?decrypt=true&configEnviromentId=1&path=/export/shared/arquivos_gerados/CREDENCIADOR/IN/$FILE_NAME" > $FILE_NAME

Upload de um arquivo

POST /op/files HTTP/1.1

Parameters

Name Type Decription
encrypt boolean Se deve encriptar o arquivo (default=true)
file binary bytes do arquivo a ser upado
path string Caminho onde será escrito o arquivo
charset string Charset em que está o arquivo que está sendo upado (default=UTF-8)
overwrite boolean Sobrescrever o arquivo original caso ja exista (default=false)
configEnviromentId integer id do ConfigEnvironment que define os certificados da encriptação

Reponse

HTTP/1.1 201
122605 written to: /export/shared/arquivos_gerados/CREDENCIADOR/OUT/ASLC027_08561701_20170904_00006

Exemplo

SOURCE='~/ASLC027_08561701_20170904_00006' && \
TARGET='/export/shared/arquivos_gerados/CREDENCIADOR/OUT/ASLC027_08561701_20170904_00006' && \
curl -v -s -w '\n' -X POST -F "overwrite=false" -F "encrypt=true" -F "configEnviromentId=1" -F "charset=UTF-8" -F "path=$TARGET" -F "file=@$SOURCE" \
"$BASE_URL/op/files"

Deletar um arquivo

DELETE /op/files HTTP/1.1

Parameters

Name Type Decription
path string Caminho do arquivo a ser deletado

Reponse

HTTP/1.1 200
success

Exemplo

curl -X DELETE "$BASE_URL/op/files/?path=/export/shared/arquivos_gerados/CREDENCIADOR/OUT/ASLC027_08561701_20180427_00039"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment