Public | Automated Build

Last pushed: 2 months ago
Short Description
Planning service of the Finacobar project.
Full Description

Finacobar - Account

This is the planning item service of the Finacobar project.
The service provides a REST interface to run CRUD actions on planning items.

API Description

swagger: '2.0'
info:
  title: Finacobar Planning
  description:  Service for planning items of the Finacobar project.
  version: "1.0.0"

schemes:
  - http
  - https

basePath: /planningservice/v1
produces:
  - application/json
paths:
  /planningitems:
    get:
      summary: Get all planning items.
      description: Returns a list of all available planning items with all details.
      responses:
        200:
          description: An array of planning items
          schema:
            $ref: '#/definitions/PlanningItemList'
        400:
          description: Bad Request
          schema:
            $ref: '#/definitions/Error'
        404:
          description: Not found. There are no planning items.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: Unexpected error.
          schema:
            $ref: '#/definitions/Error'
    post:
      summary: Create Planning item.
      description: Create a new planning item with the passed values.
      parameters:
        - in: body
          name: body
          description: Plamnning item object that should be added. A passed id will be overwritten.
          required: true
          schema:
            $ref: "#/definitions/PlanningItem"
      responses:
        201:
          description: The created planning item with its new id.
          schema:
            $ref: '#/definitions/PlanningItem'
        400:
          description: Bad Request.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: Unexpected error.
          schema:
            $ref: '#/definitions/Error'

  /planningitems/{id}:
    get:
      summary: Get Planning item.
      description: Returns information about a planning item.
      parameters:
        - in: path
          name: id
          type: string
          required: true
          description: Id of a planning items
      responses:
        200:
          description: Planning item with its values.
          schema:
            $ref: '#/definitions/PlanningItem'
        400:
          description: Bad Request.
          schema:
            $ref: '#/definitions/Error'
        404:
          description: Not found. There is no planning item for the passed id.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: Unexpected error.
          schema:
            $ref: '#/definitions/Error'
    put:
      summary: Update Planning item.
      description: Upate a planning item with passed values.
      parameters:
        - in: path
          name: id
          type: string
          required: true
          description: Id of a planning item
        - in: body
          name: planningitem
          schema:
            $ref: '#/definitions/PlanningItem'
          required: true
          description: Planning item values.
      responses:
        200:
          description: Planning item with its values.
          schema:
            $ref: '#/definitions/PlanningItem'
        400:
          description: Bad Request.
          schema:
            $ref: '#/definitions/Error'
        404:
          description: Not found. There is no planning item for the passed id.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: Unexpected error.
          schema:
            $ref: '#/definitions/Error'
    delete:
      summary: Delete Planning item.
      description: Delete the planning item for the passed id.
      parameters:
        - in: path
          name: id
          type: string
          required: true
          description: Id of a planning item
      responses:
        200:
          description: Planning item deleted successfully.
        400:
          description: Bad Request.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: Unexpected error.
          schema:
            $ref: '#/definitions/Error'
    options:
      summary: Options.
      responses:
        200:
          description: Empty response.

definitions:
  PlanningItem:
    type: object
    properties:
      id:
        type: string
        description: Unique identifier of a planning item.
      accountid:
        type: string
        description: Id of an account a planning item belongs to.
      description:
        type: string
        description: Description for a planning item.
      posteeon:
        type: string
        description: Date when planing is posted.
      amount:
        type: number
        description: Amount of a planning item.
      vendorid:
        type: string
        description: Id of a vendor accout to collect cost or revenues.
      vendorgroup:
        type: string
        description: Group of vendor accouts to collect cost or revenues.
      type:
        type: string
        description: Type of a planning item. Revenue or Cost.
      createdon:
        type: string
        description: Timestamp when a planning item was created.
  PlanningItemList:
    type: object
    properties:
      accounts:
        type: array
        items:
          $ref: '#/definitions/PlanningItem'
  Error:
    type: object
    properties:
      message:
        type: string
        description: Error desription.

Persistence

This service needs a mongodb service to persist account values. By default the service looks at localhost or on a host named "mongo" for a mongodb service. There are two different ways to define the mongodb connection settings. You can use a config file or an existing Consul service registry.

Config File
The config file is placed at /etc/finacobar/config.json. See "Configuration & Credentials" for a detailed description of all available options.

Consul
You can run this service with "--consul-agent=${DOCKER_BRIDGE}" param to specify the location of a running consul service registry. The service wil search for a mongdb service in the Consul service registry. It will connect to a mongodb service which name contains "mgo" or "mongo".

Credentials
Login credentials for both types of connection setup are placed in an env file: /etc/finacobar/credentials.env. See "Configuration & Credentials" for mpre details.

Authentication

For authentication this service uses JWT with an inplementation of Auth0. See configuration for more details.

Configuration & Credentials

There are two files to set up config and credentials. The service expects the config file at "/etc/finacobar/config.json" and the file with credentials at "/etc/finacobar/credentials.env".

Configuration
List of all available config options.
Example:

{
    "MongoDB_Hosts":                ["localhost","mongo"],
    "MongoDB_Name":                    "finacobar",
    "MongoDB_Collection_Prefix":    "planningitems",
    "Service_Port":                    "8080",
    "Auth0_Client_Id":                "{YOUR AUTH0 CLIENT ID}",
    "Auth0_API_Issuer":                "{YOUR AUTH0 API ISSUER}",
    "Auth0_API_Audience":            "{YOUR AUTH0 API AUDIENCE}",
    "Auth0_JWKS_URI":                "{YOUR AUTH0 JWKS URI}",
    "Auth0_Token_URL":                "{YOUR AUTH0 TOKEN URL}"
}

MongoDBHosts
List of host where a mongodb service is running. Not necessary if you use Consul to discover a mongdb service.

MongoDBName
Database name in mongodb, which is used to persit accounts.

MongoDB_Collection_Prefix
Collection prefix which contains the account objects. This prefix is combined with the user id to create the collection name. If not defined the service will use "planningitems" as collection prefix.

ServicePort
Port binding for the account service. If you don't define a service port, the port 8080 is used. If you want to change the port, you've to update the port in Dokerfile ´, too.

Auth0_Client_Id
The id of the client, you've created for this service at Auth0.

Auth0_API_Issuer
Issuer from Auth0.

Auth0_JWKS_URI
JWKS URI used to validate a passed token.

Auth0_API_Audience
API audience from Auth0. Only necessary if you want to run the tests for this service.

Auth0_Token_URL
URL from Auth0 to get token for testing. Not necessary to run the service.

Credentials
The credentials file contains settings for MongoDB and Auth0. The file content is loaded at startup to the environment.

DBUser={YOUR_MONGODB_USER}
DBPass={YOUR_MONGODB_PASSWORD}
AUTH0_CLIENT_SECRET={YOUR_AITH0_CLIENT_SECRET}

DBUser
Username to login at a MongoDB service.

DBPass
Password for MongoDB.

AUTH0_CLIENT_SECRET
Secret for ta client you've created at Auth0. This credentials are used to get a valid token for testing.
Not necessary to run the service.

Volume for Settings and Credentials
You can map a volume to "/etc/finacobar" to use your own config and credetials.

Docker Pull Command
Owner
tommzn
Source Repository

Comments (0)