RAML: Enable module for tenant may return 400

#%RAML 0.8
title: Okapi Core API
version: 0.1
baseUri: https://okapi.cloud
## mediaType:  application/json
schemas:
  - DeploymentDescriptor: !include DeploymentDescriptor.json
  - LaunchDescriptor: !include LaunchDescriptor.json
  - DeploymentDescriptorList: !include DeploymentDescriptorList.json
  - ModuleDescriptor: !include ModuleDescriptor.json
  - ModuleList: !include ModuleList.json
  - TenantDescriptor: !include TenantDescriptor.json
  - TenantList: !include TenantList.json
  - TenantModuleDescriptor: !include TenantModuleDescriptor.json
  - TenantModuleDescriptorList: !include TenantModuleDescriptorList.json
  - HealthStatus: !include HealthStatus.json
  - HealthStatusList: !include HealthStatusList.json
  - HealthDescriptor: !include HealthDescriptor.json
  - HealthDescriptorList: !include HealthDescriptorList.json
  - NodeDescriptor: !include NodeDescriptor.json
  - NodeDescriptorList: !include NodeDescriptorList.json
  - EnvEntry: !include EnvEntry.json
  - EnvEntryList: !include EnvEntryList.json
  - Permission: !include Permission.json

# DEPLOYMENT SERVICE
/_/deployment/modules:
  post:
    description: deploy (launch process, start a container, etc) instance of a
      particular service, according to the deployment descriptor
    body:
      application/json:
        schema: DeploymentDescriptor
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the descriptor of the deployed instance
        body:
          application/json:
            schema: DeploymentDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: list all deployed instances
    responses:
      200:
        body:
          application/json:
            schema: DeploymentDescriptorList

  /{instance_id}:
    get:
      description: retrieve deployment descriptor for a particular instance
      responses:
        200:
          body:
            application/json:
              schema: DeploymentDescriptor
    delete:
      description: shutdown instance
      responses:
        204:

# DISCOVERY SERVICE

/_/discovery/modules:
  post:
    description: register instance under a specified service id
    body:
      application/json:
        schema: DeploymentDescriptor
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the registered instance
        body:
          application/json:
            schema: DeploymentDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: return all instances
    responses:
      200:
        description: Created
        headers:
          Location:
            description: URI to the registered instance
        body:
          application/json:
            schema: DeploymentDescriptorList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{service_id}:
    get:
      description: list all instances for a particular service
      responses:
        200:
          body:
            application/json:
              schema: DeploymentDescriptorList
        400:
          description: Bad Request
          body:
            text/plain:
        500:
          description: Server Error
          body:
            text/plain:
    /{instance_id}:
      get:
        description: update registration of a specified instance
        responses:
          200:
            body:
              application/json:
                schema: DeploymentDescriptor
      put:
        description: update registration of a specified instance
        responses:
          200:
            body:
              application/json:
                schema: DeploymentDescriptor
      delete:
        description: remove registration for a given instance
        responses:
          204:

/_/discovery/health:
  get:
    description: get health info for all services
    responses:
      200:
        body:
          application/json:
            schema: HealthDescriptorList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{service_id}:
    get:
      description: health for all instances for a particular service
      responses:
        200:
          body:
            application/json:
              schema: HealthDescriptorList
    /{instance_id}:
      get:
        description: get health for a particular instance
        responses:
          200:
            body:
              application/json:
                schema: HealthDescriptor
/_/discovery/nodes:
  get:
    description: get list of all nodes
    responses:
      200:
        body:
          application/json:
            schema: NodeDescriptorList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{node_id}:
    get:
      description: get info for one node
      responses:
        200:
          body:
            application/json:
              schema: NodeDescriptor
        400:
          description: Bad Request
          body:
            text/plain:
        404:
          description: Not Found
          body:
            text/plain:
        500:
          description: Server Error
          body:
            text/plain:

# PROXY SERVICE

/_/proxy/modules:
  post:
    description: announce new module to the proxy, once successful a module
      can be selected for a specific tenant
    body:
      application/json:
        schema: ModuleDescriptor
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the created module instance
        body:
          application/json:
            schema: ModuleDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: list all available modules
    responses:
      200:
        body:
          application/json:
            schema: ModuleList

  /{module_id}:
    get:
      description: retrieve descriptor for a particular module
      responses:
        200:
          body:
            application/json:
              schema: ModuleDescriptor
    put:
      description: update descriptor of a particular module
      body:
        application/json:
          schema: ModuleDescriptor
      responses:
        200:
          body:
            application/json:
              schema: ModuleDescriptor
    delete:
      description: remove module descriptor for a particular module, module
        will no longer be selectable by tenants
      responses:
        204:

/_/proxy/tenants:
  post:
    description: create a new tenant
    body:
      application/json:
        schema: TenantDescriptor
    responses:
      201:
        description: tenant has been created
        headers:
          Location:
            description: URI to the created tenant
        body:
          application/json:
            schema: TenantDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
  get:
    description: list all tenants
    responses:
      200:
        description: list of tenants in a brief format
        body:
          application/json:
            schema: TenantList
  /{tenant_id}:
    get:
      description: retrieve a tenant
      responses:
        200:
          body:
            application/json:
              schema: TenantDescriptor
        404:
          description: Not Found
          body:
            text/plain:
    put:
      description: update a tenant
      body:
        application/json:
          schema: TenantDescriptor
      responses:
        200:
          body:
            application/json:
              schema: TenantDescriptor
        400:
          description: Bad Request
          body:
            text/plain:
        404:
          description: Not Found
          body:
            text/plain:
    delete:
      description: remove a tenant
      responses:
        204:

    /modules:
      get:
        description: selection of modules by the tenant
        responses:
          200:
            body:
              application/json:
                schema: TenantModuleDescriptorList
      post:
        description: enable a module for a specified tenant
        body:
          application/json:
            schema: TenantModuleDescriptor
        responses:
          201:
            description: Created
            headers:
              Location:
                description: URI to the created tenant
            body:
              application/json:
                schema: TenantModuleDescriptor
          400:
            description: Bad Request
            body:
              text/plain:
          404:
            description: Not Found
            body:
              text/plain:
          500:
            description: Server error
            body:
              text/plain:
      /{module_id}:
        get:
          description: look up particular module selection
          responses:
            200:
              body:
                application/json:
                  schema: TenantModuleDescriptor
            404:
              description: Not Found
              body:
                text/plain:
        post:
          description: update a module for a specified tenant.
          body:
            application/json:
              schema: TenantModuleDescriptor
          responses:
            201:
              description: Created
              headers:
                Location:
                  description: URI to the created tenant
              body:
                application/json:
                  schema: TenantModuleDescriptor
            400:
              description: Client Error
              body:
                text/plain:
            404:
              description: Not Found
              body:
                text/plain:
            500:
              description: Server Error
              body:
                text/plain:
        delete:
          description: remove particular module selection
          responses:
            204:
/_/proxy/health:
  get:
    description: Check health of all modules
    responses:
      200:
        description: OK
        body:
          application/json:
            schema: HealthStatusList
      500:
        description: Server Error

/_/env:
  post:
    description: add environment entry
    body:
      application/json:
        schema: EnvEntry
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the environment entry instance
        body:
          application/json:
            schema: EnvEntry
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: get list of all environment
    responses:
      200:
        body:
          application/json:
            schema: EnvEntryList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{id}:
    get:
      description: get info for one environment variable
      responses:
        200:
          body:
            application/json:
              schema: EnvEntry
        400:
          description: Bad Request
          body:
            text/plain:
        404:
          description: Not Found
          body:
            text/plain:
        500:
          description: Server Error
          body:
            text/plain:
    delete:
      description: remove environment variable
      responses:
        204:

#TODO implement single module health check

#%RAML 0.8
title: Okapi Core API
version: 0.1
baseUri: https://okapi.cloud
## mediaType:  application/json
schemas:
  - DeploymentDescriptor: !include DeploymentDescriptor.json
  - LaunchDescriptor: !include LaunchDescriptor.json
  - DeploymentDescriptorList: !include DeploymentDescriptorList.json
  - ModuleDescriptor: !include ModuleDescriptor.json
  - ModuleList: !include ModuleList.json
  - TenantDescriptor: !include TenantDescriptor.json
  - TenantList: !include TenantList.json
  - TenantModuleDescriptor: !include TenantModuleDescriptor.json
  - TenantModuleDescriptorList: !include TenantModuleDescriptorList.json
  - HealthStatus: !include HealthStatus.json
  - HealthStatusList: !include HealthStatusList.json
  - HealthDescriptor: !include HealthDescriptor.json
  - HealthDescriptorList: !include HealthDescriptorList.json
  - NodeDescriptor: !include NodeDescriptor.json
  - NodeDescriptorList: !include NodeDescriptorList.json
  - EnvEntry: !include EnvEntry.json
  - EnvEntryList: !include EnvEntryList.json
  - Permission: !include Permission.json

# DEPLOYMENT SERVICE
/_/deployment/modules:
  post:
    description: deploy (launch process, start a container, etc) instance of a
      particular service, according to the deployment descriptor
    body:
      application/json:
        schema: DeploymentDescriptor
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the descriptor of the deployed instance
        body:
          application/json:
            schema: DeploymentDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: list all deployed instances
    responses:
      200:
        body:
          application/json:
            schema: DeploymentDescriptorList

  /{instance_id}:
    get:
      description: retrieve deployment descriptor for a particular instance
      responses:
        200:
          body:
            application/json:
              schema: DeploymentDescriptor
    delete:
      description: shutdown instance
      responses:
        204:

# DISCOVERY SERVICE

/_/discovery/modules:
  post:
    description: register instance under a specified service id
    body:
      application/json:
        schema: DeploymentDescriptor
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the registered instance
        body:
          application/json:
            schema: DeploymentDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: return all instances
    responses:
      200:
        description: Created
        headers:
          Location:
            description: URI to the registered instance
        body:
          application/json:
            schema: DeploymentDescriptorList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{service_id}:
    get:
      description: list all instances for a particular service
      responses:
        200:
          body:
            application/json:
              schema: DeploymentDescriptorList
        400:
          description: Bad Request
          body:
            text/plain:
        500:
          description: Server Error
          body:
            text/plain:
    /{instance_id}:
      get:
        description: update registration of a specified instance
        responses:
          200:
            body:
              application/json:
                schema: DeploymentDescriptor
      put:
        description: update registration of a specified instance
        responses:
          200:
            body:
              application/json:
                schema: DeploymentDescriptor
      delete:
        description: remove registration for a given instance
        responses:
          204:

/_/discovery/health:
  get:
    description: get health info for all services
    responses:
      200:
        body:
          application/json:
            schema: HealthDescriptorList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{service_id}:
    get:
      description: health for all instances for a particular service
      responses:
        200:
          body:
            application/json:
              schema: HealthDescriptorList
    /{instance_id}:
      get:
        description: get health for a particular instance
        responses:
          200:
            body:
              application/json:
                schema: HealthDescriptor
/_/discovery/nodes:
  get:
    description: get list of all nodes
    responses:
      200:
        body:
          application/json:
            schema: NodeDescriptorList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{node_id}:
    get:
      description: get info for one node
      responses:
        200:
          body:
            application/json:
              schema: NodeDescriptor
        400:
          description: Bad Request
          body:
            text/plain:
        404:
          description: Not Found
          body:
            text/plain:
        500:
          description: Server Error
          body:
            text/plain:

# PROXY SERVICE

/_/proxy/modules:
  post:
    description: announce new module to the proxy, once successful a module
      can be selected for a specific tenant
    body:
      application/json:
        schema: ModuleDescriptor
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the created module instance
        body:
          application/json:
            schema: ModuleDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: list all available modules
    responses:
      200:
        body:
          application/json:
            schema: ModuleList

  /{module_id}:
    get:
      description: retrieve descriptor for a particular module
      responses:
        200:
          body:
            application/json:
              schema: ModuleDescriptor
    put:
      description: update descriptor of a particular module
      body:
        application/json:
          schema: ModuleDescriptor
      responses:
        200:
          body:
            application/json:
              schema: ModuleDescriptor
    delete:
      description: remove module descriptor for a particular module, module
        will no longer be selectable by tenants
      responses:
        204:

/_/proxy/tenants:
  post:
    description: create a new tenant
    body:
      application/json:
        schema: TenantDescriptor
    responses:
      201:
        description: tenant has been created
        headers:
          Location:
            description: URI to the created tenant
        body:
          application/json:
            schema: TenantDescriptor
      400:
        description: Bad Request
        body:
          text/plain:
  get:
    description: list all tenants
    responses:
      200:
        description: list of tenants in a brief format
        body:
          application/json:
            schema: TenantList
  /{tenant_id}:
    get:
      description: retrieve a tenant
      responses:
        200:
          body:
            application/json:
              schema: TenantDescriptor
        404:
          description: Not Found
          body:
            text/plain:
    put:
      description: update a tenant
      body:
        application/json:
          schema: TenantDescriptor
      responses:
        200:
          body:
            application/json:
              schema: TenantDescriptor
        400:
          description: Bad Request
          body:
            text/plain:
        404:
          description: Not Found
          body:
            text/plain:
    delete:
      description: remove a tenant
      responses:
        204:

    /modules:
      get:
        description: selection of modules by the tenant
        responses:
          200:
            body:
              application/json:
                schema: TenantModuleDescriptorList
      post:
        description: enable a module for a specified tenant
        body:
          application/json:
            schema: TenantModuleDescriptor
        responses:
          201:
            description: Created
            headers:
              Location:
                description: URI to the created tenant
            body:
              application/json:
                schema: TenantModuleDescriptor
          404:
            description: Not Found
            body:
              text/plain:
          500:
            description: Server error
            body:
              text/plain:
      /{module_id}:
        get:
          description: look up particular module selection
          responses:
            200:
              body:
                application/json:
                  schema: TenantModuleDescriptor
            404:
              description: Not Found
              body:
                text/plain:
        post:
          description: update a module for a specified tenant.
          body:
            application/json:
              schema: TenantModuleDescriptor
          responses:
            201:
              description: Created
              headers:
                Location:
                  description: URI to the created tenant
              body:
                application/json:
                  schema: TenantModuleDescriptor
            400:
              description: Client Error
              body:
                text/plain:
            404:
              description: Not Found
              body:
                text/plain:
            500:
              description: Server Error
              body:
                text/plain:
        delete:
          description: remove particular module selection
          responses:
            204:
/_/proxy/health:
  get:
    description: Check health of all modules
    responses:
      200:
        description: OK
        body:
          application/json:
            schema: HealthStatusList
      500:
        description: Server Error

/_/env:
  post:
    description: add environment entry
    body:
      application/json:
        schema: EnvEntry
    responses:
      201:
        description: Created
        headers:
          Location:
            description: URI to the environment entry instance
        body:
          application/json:
            schema: EnvEntry
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  get:
    description: get list of all environment
    responses:
      200:
        body:
          application/json:
            schema: EnvEntryList
      400:
        description: Bad Request
        body:
          text/plain:
      500:
        description: Server Error
        body:
          text/plain:
  /{id}:
    get:
      description: get info for one environment variable
      responses:
        200:
          body:
            application/json:
              schema: EnvEntry
        400:
          description: Bad Request
          body:
            text/plain:
        404:
          description: Not Found
          body:
            text/plain:
        500:
          description: Server Error
          body:
            text/plain:
    delete:
      description: remove environment variable
      responses:
        204:

#TODO implement single module health check