diff options
author | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-02-09 14:16:04 -0800 |
---|---|---|
committer | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-02-09 14:20:42 -0800 |
commit | eebc178aa2c188ee25a4b2c6637b565279ae49f9 (patch) | |
tree | fcb2c9e0b8d87786e52b01a75d385e83c66a665c | |
parent | be355e888af5b332797aee7507fdd6ed93261d6d (diff) |
Add swagger.json API ref and refactor code base
This patch adds the API reference in the form of
swagger.json and refactors codebase to help in building
process using a Makefile.
Change-Id: I1ce11de6daf8defb563d8b6f319f05711057413b
Issue-ID: MUSIC-23
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
-rw-r--r-- | src/dkv/Gopkg.lock (renamed from Gopkg.lock) | 0 | ||||
-rw-r--r-- | src/dkv/Gopkg.toml (renamed from Gopkg.toml) | 0 | ||||
-rw-r--r-- | src/dkv/Makefile | 26 | ||||
-rw-r--r-- | src/dkv/api/consulConnection.go (renamed from api/consulConnection.go) | 0 | ||||
-rw-r--r-- | src/dkv/api/consulConnection_test.go (renamed from api/consulConnection_test.go) | 0 | ||||
-rw-r--r-- | src/dkv/api/endpointViews.go (renamed from api/endpointViews.go) | 0 | ||||
-rw-r--r-- | src/dkv/api/endpointViews_test.go (renamed from api/endpointViews_test.go) | 0 | ||||
-rw-r--r-- | src/dkv/api/propertiesReader.go (renamed from api/propertiesReader.go) | 0 | ||||
-rw-r--r-- | src/dkv/api/propertiesReader_test.go (renamed from api/propertiesReader_test.go) | 2 | ||||
-rw-r--r-- | src/dkv/api/utils.go (renamed from api/utils.go) | 0 | ||||
-rw-r--r-- | src/dkv/api/utils_test.go (renamed from api/utils_test.go) | 2 | ||||
-rw-r--r-- | src/dkv/configurations/sampleAAIConfig.properties (renamed from configurations/sampleAAIConfig.properties) | 0 | ||||
-rw-r--r-- | src/dkv/configurations/sampleAPPCConfig.properties (renamed from configurations/sampleAPPCConfig.properties) | 0 | ||||
-rw-r--r-- | src/dkv/main.go (renamed from main.go) | 2 | ||||
-rw-r--r-- | swagger.json | 96 |
15 files changed, 125 insertions, 3 deletions
diff --git a/Gopkg.lock b/src/dkv/Gopkg.lock index 33c42f6..33c42f6 100644 --- a/Gopkg.lock +++ b/src/dkv/Gopkg.lock diff --git a/Gopkg.toml b/src/dkv/Gopkg.toml index 3f608e7..3f608e7 100644 --- a/Gopkg.toml +++ b/src/dkv/Gopkg.toml diff --git a/src/dkv/Makefile b/src/dkv/Makefile new file mode 100644 index 0000000..5b7d979 --- /dev/null +++ b/src/dkv/Makefile @@ -0,0 +1,26 @@ +GOPATH := $(shell realpath "$(PWD)/../../") +BINARY=dkv +DEPENDENCIES := github.com/golang/dep/cmd/dep + +export GOPATH ... + +all: build test +deploy: build test + +build: deps format + echo $(GOPATH) + $(GOPATH)/bin/dep ensure + go build -o $(GOPATH)/target/$(BINARY) -v main.go + +clean: + go clean + rm -f $(GOPATH)/target/$(BINARY) + +test: + go test -v ./api/... + +format: + go fmt ./api/... + +deps: + go get -u $(DEPENDENCIES) diff --git a/api/consulConnection.go b/src/dkv/api/consulConnection.go index b8074e2..b8074e2 100644 --- a/api/consulConnection.go +++ b/src/dkv/api/consulConnection.go diff --git a/api/consulConnection_test.go b/src/dkv/api/consulConnection_test.go index 342542a..342542a 100644 --- a/api/consulConnection_test.go +++ b/src/dkv/api/consulConnection_test.go diff --git a/api/endpointViews.go b/src/dkv/api/endpointViews.go index 3c47ee5..3c47ee5 100644 --- a/api/endpointViews.go +++ b/src/dkv/api/endpointViews.go diff --git a/api/endpointViews_test.go b/src/dkv/api/endpointViews_test.go index f603af4..f603af4 100644 --- a/api/endpointViews_test.go +++ b/src/dkv/api/endpointViews_test.go diff --git a/api/propertiesReader.go b/src/dkv/api/propertiesReader.go index 018dabe..018dabe 100644 --- a/api/propertiesReader.go +++ b/src/dkv/api/propertiesReader.go diff --git a/api/propertiesReader_test.go b/src/dkv/api/propertiesReader_test.go index c564be5..342542a 100644 --- a/api/propertiesReader_test.go +++ b/src/dkv/api/propertiesReader_test.go @@ -16,4 +16,4 @@ package api -// TODO(sshank)
\ No newline at end of file +// TODO(sshank) diff --git a/api/utils.go b/src/dkv/api/utils.go index 8b87848..8b87848 100644 --- a/api/utils.go +++ b/src/dkv/api/utils.go diff --git a/api/utils_test.go b/src/dkv/api/utils_test.go index c564be5..342542a 100644 --- a/api/utils_test.go +++ b/src/dkv/api/utils_test.go @@ -16,4 +16,4 @@ package api -// TODO(sshank)
\ No newline at end of file +// TODO(sshank) diff --git a/configurations/sampleAAIConfig.properties b/src/dkv/configurations/sampleAAIConfig.properties index 6052315..6052315 100644 --- a/configurations/sampleAAIConfig.properties +++ b/src/dkv/configurations/sampleAAIConfig.properties diff --git a/configurations/sampleAPPCConfig.properties b/src/dkv/configurations/sampleAPPCConfig.properties index 484337f..484337f 100644 --- a/configurations/sampleAPPCConfig.properties +++ b/src/dkv/configurations/sampleAPPCConfig.properties diff --git a/main.go b/src/dkv/main.go index 59d9634..65a300a 100644 --- a/main.go +++ b/src/dkv/main.go @@ -18,7 +18,7 @@ package main import ( "github.com/gorilla/mux" - "distributed-kv-store/api" + "dkv/api" "log" "net/http" ) diff --git a/swagger.json b/swagger.json new file mode 100644 index 0000000..364bcd3 --- /dev/null +++ b/swagger.json @@ -0,0 +1,96 @@ +swagger: "2.0" +info: + description: "API reference for Distributed Key Value store." + version: "1.0.0" + title: "API reference for Distributed Key Value store" + contact: + email: "shashank.kumar.shankar@intel.com" + url: "https://wiki.onap.org/display/DW/Distributed+KV+Store" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +basePath: "/v1" +schemes: +- "http" +paths: + /loadconfigs: + post: + tags: + - "load configuration" + summary: "Load Key Values by reading configs into Consul" + description: "" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: "body" + name: "body" + description: "Load configuration from file system to be added into Consul" + required: true + schema: + $ref: "#/definitions/LoadRequest" + responses: + 200: + description: "successful operation" + schema: + $ref: "#/definitions/LoadResponse" + /getconfigs: + get: + tags: + - "get all keys" + summary: "Get all keys present in Consul." + description: "Returns a list of keys present in Consul." + produces: + - "application/json" + responses: + 200: + description: "successful operation" + schema: + $ref: "#/definitions/Gets" + /getconfig/{key}: + get: + tags: + - "get single key" + summary: "Get value for specific key present in Consul." + description: "Returns a key and value present in Consul." + produces: + - "application/json" + parameters: + - name: "key" + in: "path" + description: "Key used to query" + required: true + type: "string" + responses: + 200: + description: "successful operation" + schema: + $ref: "#/definitions/Get" +definitions: + LoadRequest: + type: "object" + properties: + type: + $ref: "#/definitions/Type" + Type: + type: "object" + properties: + file_path: + type: "string" + LoadResponse: + type: "object" + properties: + response: + type: "string" + Gets: + type: "object" + properties: + response: + items: + type: "string" + Get: + type: "object" + properties: + response: + type: "string" |