Distributed KV store Documentation

Installation

As for current release, project is packaged as a single Docker Container. For subsequent releases, it will be integrated with OOM.

# Set Datastore as Consul
DATASTORE="consul"
# Set IP address of where Consul is running
DATASTORE_IP="localhost"
# Set mountpath inside the container where persistent data is stored.
MOUNTPATH="/dkv_mount_path/configs/"
# Place all Config data which needs to be loaded in default directory.
DEFAULT_CONFIGS=$(pwd)/mountpath/default
# Create the directories.
mkdir -p mountpath/default
# Login to Nexus.
docker login -u docker -p docker nexus3.onap.org:10001
# Pull distributed-kv-store image.
docker pull nexus3.onap.org:10001/onap/music/distributed-kv-store
# Run the distributed-kv-store image.
docker run -e DATASTORE=$DATASTORE -e DATASTORE_IP=$DATASTORE_IP -e MOUNTPATH=$MOUNTPATH -d \
       --name dkv \
       -v $DEFAULT_CONFIGS:/dkv_mount_path/configs/default \
       -p 8200:8200 -p 8080:8080 nexus3.onap.org:10001/onap/music/distributed-kv-store

Offered APIs

POST /register

Endpoint to Register new domain

  • Description:

  • Consumes: [‘application/json’]

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

body

body

Register new domain.

Responses

200 - successful operation

GET /register/{token}

Check if domain is registered.

  • Description: Check if domain is registered identified by token.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

token

path

Token used to query

string

Responses

200 - successful operation

DELETE /register/{token}

Delete registered domain.

  • Description: Deletes a registered domain identified by token.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

token

path

Token used to delete

string

Responses

200 - successful operation

POST /register/{token}/subdomain

Endpoint to Register new subdomain

  • Description:

  • Consumes: [‘application/json’]

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

token

path

Token used to identify domain.

string

body

body

Register new subdomain.

Responses

200 - successful operation

DELETE /register/{token}/subdomain/{subdomain}

Delete registered subdomain.

  • Description: Deletes a registered subdomain identified by token and subdomain.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

token

path

Token used to delete

string

subdomain

path

Subdomain used to delete

string

Responses

200 - successful operation

POST /config

Endpoint to upload configuration.

  • Description: Endpoint to upload configuration.

  • Consumes: [‘multipart/form-data’]

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

configFile

formData

Config file to be uploaded.

file

token

formData

Token to identify domain to upload config file to.

string

subdomain

formData

Subdomain to identify subdomain to upload config file to.

string

Responses

200 - successful operation

GET /config/{token}/{filename}

Get config file.

  • Description: Get config file identified by token and filename.

  • Produces: [‘file’]

Parameters

Name

Position

Description

Type

token

path

Token used to get config file.

string

filename

path

Filename used to get config file.

string

Responses

200 - successful operation

DELETE /config/{token}/{filename}

Delete config file.

  • Description: Deletes a config file identified by token and filename.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

token

path

Token used to delete

string

filename

path

Filename used to delete

string

Responses

200 - successful operation

GET /config/{token}/{subdomain}/{filename}

Get config file from subdomain.

  • Description: Get config file identified by token, filename and subdomain.

  • Produces: [‘file’]

Parameters

Name

Position

Description

Type

token

path

Token used to get config file.

string

subdomain

path

Subdomain used to get config file.

string

filename

path

Filename used to get config file.

string

Responses

200 - successful operation

DELETE /config/{token}/{subdomain}/{filename}

Delete config file from subdomain.

  • Description: Deletes a config file identified by token, filename and subdomain.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

token

path

Token used to delete config file.

string

subdomain

path

Subdomain used to delete config file.

string

filename

path

Filename used to delete config file.

string

Responses

200 - successful operation

POST /config/load

Load config into Consul.

  • Description: Load config into Consul upon hitting the endpoint.

  • Consumes: [‘application/json’]

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

body

body

Load configuration from file system to be added into Consul

Responses

200 - successful operation

GET /config/load-default

Load default config into Consul.

  • Description: Load default config into Consul upon hitting the endpoint.

  • Produces: [‘application/json’]

Responses

200 - successful operation

GET /getconfigs

Get all keys present in Consul.

  • Description: Returns a list of keys present in Consul.

  • Produces: [‘application/json’]

Responses

200 - successful operation

GET /getconfig/{key}

Get value for specific key present in Consul.

  • Description: Returns a key and value present in Consul.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

key

path

Key used to query Consul.

string

Responses

200 - successful operation

DELETE /deleteconfig/{key}

Delete value for specific key present in Consul.

  • Description: Deletes a specific key.

  • Produces: [‘application/json’]

Parameters

Name

Position

Description

Type

key

path

Key used to delete

string

Responses

200 - successful operation

Sample Commands

## Load default configuration
curl -X GET localhost:8080/v1/config/load-default

## Check if Keys were loaded into Consul
curl -X GET localhost:8080/v1/getconfigs

## Check value for a single key
curl -X GET localhost:8080/v1/getconfig/<key>

## Register new domain
curl -X POST -d '{"domain":"new_project"}' localhost:8080/v1/register
export TOKEN=
## Register new sub domain
curl -X POST -d '{"subdomain":"sub_project"}' localhost:8080/v1/register/$TOKEN/subdomain

## Check if a domain is already registered.
curl -X GET localhost:8080/v1/register/$TOKEN

## Upload properties file to domain or subdomain.
curl -X POST -F 'token=$TOKEN' -F 'configFile=@./example.properties' localhost:8080/v1/config
curl -X POST -F 'token=$TOKEN' -F 'subdomain=sub_domain' -F 'configFile=@./example.properties' localhost:8080/v1/config

## Load properties file into Consul
curl -X POST -d '{"token":"$TOKEN", "filename": "example.properties"}' localhost:8080/v1/config/load

## Fetch properties file
curl -X GET localhost:8080/v1/config/$TOKEN/example.properties
curl -X GET localhost:8080/v1/config/$TOKEN/sub_domain/example.properties

## Delete properties file
curl -X DELETE localhost:8080/v1/config/$TOKEN/example.properties
curl -X DELETE localhost:8080/v1/config/$TOKEN/sub_domain/example.properties

## Delete project/sub project
curl -X DELETE localhost:8080/v1/register/$TOKEN/sub_domain/sub-domain
curl -X DELETE localhost:8080/v1/register/$TOKEN