Skip to content

Constants

New feature

Since 6.10.15

Purpose

A DSL that exposes commons constants from Platform 6.

Methods

Binding name: p6.const


mime

Provides access to common MIME types.

Syntax

string p6.const.mime.[type]

Available types:

  • JSON → application/json
  • XML → application/xml
  • CSV → text/csv
  • PDF → application/pdf
  • XLSX → application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • XLS → application/vnd.ms-excel
  • ZIP → application/zip
  • HTML → text/html
  • TEXT → text/plain
  • OCTET → application/octet-stream
Example
rest("/apis/sample")
    .post("/data")
    .consumes(p6.const.mime.JSON)
    .produces(p6.const.mime.JSON)
    .to("p6cmb://scripts?platform6.request.action=execute&id=simpleScript")
    .routeId("RestCall")

service request

Provides access to common service request constants.

Syntax

string p6.const.service.request.[type]

Available types:

  • USER → platform6.request.user
  • ACTION → platform6.request.action
  • COMMON_ACTION → platform6.request.common.action
Example
final def cm = [headers: [
     (p6.const.service.request.ACTION) : 'status'
 ]]
p6.service.request('platform6.scripts', cm, {
    cmr, e ->
        println cmr
        if( null != e) throw e
})

service response

Provides access to common service response constants.

Syntax

string p6.const.service.response.[type]

Available types:

  • STATUS → platform6.response.status
  • VALUE → platform6.response.value
  • EXCEPTION → platform6.response.exception
  • EXCEPTION_MSG → platform6.response.exception.message
  • UNCAUGHT_EXCEPTION → platform6.response.uncaught.exception
Example
if (p6.pipeline.get(p6.const.service.response.STATUS) == 'ERROR') {
    p6.log.error 'Service error: ' + p6.pipeline.get(p6.const.service.response.EXCEPTION_MSG)
} else {
    p6.log.info 'Service OK: ' + p6.pipeline.get(p6.const.service.response.VALUE)
}