diff --git a/deploy.sh b/deploy.sh index ef2fdca..3191f02 100644 --- a/deploy.sh +++ b/deploy.sh @@ -8,19 +8,16 @@ function main() { go test ./... fi GOOS=linux GOARCH=arm GOARM=5 gobuild $exec - for authed in dndex; do # dndex-auth; do - scp ./public/swagger/* zach@tickle.lan:./$authed/files/swagger/ - scp $exec zach@tickle.lan:./$authed/dndex.new - ssh zach@tickle.lan bash -c "true; while [ -e ./$authed/dndex.new ]; do printf '.'; sleep 3; done; echo" - done & - wait - GOOS=linux gobuild $exec - echo scp $exec bel@remote.blapointe.com:/home/bel/services/bin/dndex.new - echo ssh bel@remote.blapointe.com bash -c 'true; md5sum ./services/bin/dndex*; while [ -e ./services/bin/dndex.new ]; do printf "."; sleep 3; done; md5sum ./services/bin/dndex*' - rm $exec + scp -r ./public/swagger/* zach@tickle.lan:./dndex1/files/swagger/ + scp $exec zach@tickle.lan:./dndex1/dndex.new + ssh zach@tickle.lan bash -c "true; while [ -e ./dndex1/dndex.new ]; do printf '.'; sleep 3; done; echo" if [ -n "$BIG" ]; then + GOOS=linux gobuild $exec + echo scp $exec bel@remote.blapointe.com:/home/bel/services/bin/dndex.new + echo ssh bel@remote.blapointe.com bash -c 'true; md5sum ./services/bin/dndex*; while [ -e ./services/bin/dndex.new ]; do printf "."; sleep 3; done; md5sum ./services/bin/dndex*' big fi + rm $exec } function gobuild() { diff --git a/init.sh b/init.sh deleted file mode 100644 index 6b155d8..0000000 --- a/init.sh +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/bash - -port=57017 - -if false && ! curl -sS localhost:$port > /dev/null; then - prefix=/tmp/whodunit.db - mkdir -p $prefix/data - mongod \ - --dbpath $prefix/data \ - --logpath $prefix/log \ - --pidfilepath $prefix/pid \ - --port $port \ - --fork -fi - -mshell() { - mongo \ - --quiet \ - --port $port \ - --eval "$*" -} - -remove() { - mshell \ - 'db.getSiblingDB("db")["col"].remove({})' -} - -export DBURI=${DB_URI:-"mongodb://localhost:$port"} - -export DRIVERTYPE=boltdb -export DBURI=$(mktemp) diff --git a/public/swagger/v1/entities/id.yaml b/public/swagger/v1/entities/id.yaml new file mode 100644 index 0000000..399500b --- /dev/null +++ b/public/swagger/v1/entities/id.yaml @@ -0,0 +1,66 @@ +paths: + summary: "Interact with one entity within a namespace" + delete: + description: "Delete an existing entity" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + responses: + 200: + $ref: "#/components/schemas/responseOK" + + get: + description: "Get an existing entity" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + responses: + 200: + $ref: "#/components/schemas/responseOneResolved" + + put: + description: "Replace an existing entity" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + requestBody: + $ref: "#/components/schemas/requestOne" + responses: + 200: + $ref: "#/components/schemas/responseOne" + + patch: + description: "Update an existing entity" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + requestBody: + $ref: "#/components/schemas/requestOne" + responses: + 200: + $ref: "#/components/schemas/responseOne" + +components: + parameters: + token: + $ref: "../swagger.yaml#/components/parameters/token" + id: + $ref: "../swagger.yaml#/components/parameters/id" + + schemas: + requestOne: + $ref: "../swagger.yaml#/components/schemas/requestOne" + responseOne: + $ref: "../swagger.yaml#/components/schemas/responseOne" + responseOneResolved: + $ref: "../swagger.yaml#/components/schemas/responseOneResolved" + responseOK: + $ref: "../swagger.yaml#/components/schemas/responseOK" diff --git a/public/swagger/v1/entities/idsub.yaml b/public/swagger/v1/entities/idsub.yaml new file mode 100644 index 0000000..61cedfc --- /dev/null +++ b/public/swagger/v1/entities/idsub.yaml @@ -0,0 +1,71 @@ +paths: + summary: "Interact with one field of one entity within a namespace" + delete: + description: "Delete an existing entity's field's value" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/path" + responses: + 200: + $ref: "#/components/schemas/responseOne" + + get: + description: "Get an existing entity's field's value" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/path" + responses: + 200: + $ref: "#/components/schemas/responseOne" + + put: + description: "Replace an existing entity's field's value" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/path" + requestBody: + $ref: "#/components/schemas/requestOne" + responses: + 200: + $ref: "#/components/schemas/responseOne" + + patch: + description: "Update an existing entity's field's value" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + - $ref: "#/components/parameters/id" + - $ref: "#/components/parameters/path" + requestBody: + $ref: "#/components/schemas/requestOne" + responses: + 200: + $ref: "#/components/schemas/responseOne" + +components: + parameters: + token: + $ref: "../swagger.yaml#/components/parameters/token" + id: + $ref: "../swagger.yaml#/components/parameters/id" + path: + $ref: "../swagger.yaml#/components/parameters/path" + schemas: + responseOne: + $ref: "../swagger.yaml#/components/schemas/responseOne" + requestOne: + $ref: "../swagger.yaml#/components/schemas/requestOne" + objectOne: + $ref: "../swagger.yaml#/components/schemas/objectOne" + responseOK: + $ref: "../swagger.yaml#/components/schemas/responseOK" diff --git a/public/swagger/v1/entities/index.yaml b/public/swagger/v1/entities/index.yaml new file mode 100644 index 0000000..4fdc5f6 --- /dev/null +++ b/public/swagger/v1/entities/index.yaml @@ -0,0 +1,44 @@ +paths: + summary: "Interact with all entities within a namespace" + get: + description: "Get names and IDs of all entities" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + responses: + 200: + content: + applicaiton/json: + schema: + type: array + items: + type: object + properties: + Name: string + ID: string + example: + Name: John Smith + ID: abc-123 + + post: + description: "Create a new entity" + tags: + - entities + parameters: + - $ref: "#/components/parameters/token" + requestBody: + $ref: "#/components/schemas/requestOne" + responses: + 200: + $ref: "#/components/schemas/responseOne" + +components: + parameters: + token: + $ref: "../swagger.yaml#/components/parameters/token" + schemas: + requestOne: + $ref: "../swagger.yaml#/components/schemas/requestOne" + responseOne: + $ref: "../swagger.yaml#/components/schemas/responseOne" diff --git a/public/swagger/v1/swagger.yaml b/public/swagger/v1/swagger.yaml index 15c15dc..5af4943 100644 --- a/public/swagger/v1/swagger.yaml +++ b/public/swagger/v1/swagger.yaml @@ -12,8 +12,7 @@ info: version: 0.1.0 servers: -- url: http://api.dndex.lan:8080/ -- url: http://authapi.dndex.lan:8080/ +- url: http://api1.dndex.lan:8080/ paths: /version: @@ -24,11 +23,22 @@ paths: $ref: "./users/register.yaml#/paths" /users/login: $ref: "./users/login.yaml#/paths" - #/entities: - # $ref: "./entities.yaml#/paths" + /entities: + $ref: "./entities/index.yaml#/paths" + /entities/{id}: + $ref: "./entities/id.yaml#/paths" + /entities/{id}/{path}: + $ref: "./entities/idsub.yaml#/paths" components: parameters: + id: + name: id + in: path + required: true + schema: + type: string + path: name: path in: path @@ -44,13 +54,27 @@ components: type: string schemas: + responseOneResolved: + content: + application/json: + schema: + $ref: "#/components/schemas/objectOneResolved" + + responseOne: + content: + application/json: + schema: + $ref: "#/components/schemas/objectOne" + responseOK: content: application/json: - properties: - ok: - type: boolean - example: true + schema: + type: object + properties: + ok: + type: boolean + example: true requestForm: content: @@ -59,40 +83,53 @@ components: type: string example: http://imgur.com/big-tiddy-goth-gf.jpg - objectID: - title: "one ID" - type: string - example: "abc-123-def-456" + requestOne: + content: + application/json: + schema: + $ref: "#/components/schemas/objectOne" - objectOne: - title: "one entity" + oneID: { type: string, example: "abc-123-def-456" } + oneName: { type: string, example: "Jeff Snow" } + oneType: { type: string, example: "Doggo" } + oneTitle: { type: string, example: "Meme Lord" } + oneText: { type: string, example: "Lorem ipsum" } + oneModified: { type: int, example: 1234567890 } + oneAttachments: + type: object + additionalProperties: + type: object + properties: + location: + type: string + example: + "abc-123-def-456": + location: "/__files__/my/file.txt" + + objectOneResolved: type: object properties: - _id: - $ref: "/components/schemas/objectID" - name: - type: string - example: "Jeff Snow" - type: - type: string - example: "doggo" - title: - type: string - example: "Meme Lord" - text: - type: string - example: "Lorem ipsum" - modified: - type: int - example: 8675309 - attachments: + _id: { $ref: "#/components/schemas/oneID" } + name: { $ref: "#/components/schemas/oneName" } + type: { $ref: "#/components/schemas/oneType" } + title: { $ref: "#/components/schemas/oneTitle" } + text: { $ref: "#/components/schemas/oneText" } + modified: { $ref: "#/components/schemas/oneModified" } + attachments: { $ref: "#/components/schemas/oneAttachments" } + connections: type: object - additionalProperties: - type: object - properties: - location: - type: string - example: "/files/my/file.txt" + additionalProperties: { $ref: "#/components/schemas/objectOne" } + + objectOne: + type: object + properties: + _id: { $ref: "#/components/schemas/oneID" } + name: { $ref: "#/components/schemas/oneName" } + type: { $ref: "#/components/schemas/oneType" } + title: { $ref: "#/components/schemas/oneTitle" } + text: { $ref: "#/components/schemas/oneText" } + modified: { $ref: "#/components/schemas/oneModified" } + attachments: { $ref: "#/components/schemas/oneAttachments" } connections: type: object additionalProperties: @@ -100,7 +137,9 @@ components: properties: relationship: type: string - example: "friendly" + example: + "abc-123-def-456": + relationship: "friendly" securitySchemes: token: diff --git a/public/swagger/v1/users/login.yaml b/public/swagger/v1/users/login.yaml index e7473e5..6846361 100644 --- a/public/swagger/v1/users/login.yaml +++ b/public/swagger/v1/users/login.yaml @@ -13,3 +13,16 @@ paths: DnDex-User: type: string example: "namespace" + responses: + 200: + content: + application/json: + schema: + type: object + properties: + token: + type: string + example: abc-123 + salt: + type: string + example: def-456 diff --git a/public/swagger/v1/users/register.yaml b/public/swagger/v1/users/register.yaml index 6046c7b..d360b09 100644 --- a/public/swagger/v1/users/register.yaml +++ b/public/swagger/v1/users/register.yaml @@ -15,3 +15,11 @@ paths: DnDex-Auth: type: string example: "password" + responses: + 200: + $ref: "#/components/schemas/responseOK" + +components: + schemas: + responseOK: + $ref: "../swagger.yaml#/components/schemas/responseOK" diff --git a/public/swagger/v1/version.yaml b/public/swagger/v1/version.yaml index c2de714..e19c447 100644 --- a/public/swagger/v1/version.yaml +++ b/public/swagger/v1/version.yaml @@ -13,3 +13,4 @@ paths: version: type: string example: "02c5d795cf631a33528234a9cf52907c6cd34834" +