Skip to content

Instantly share code, notes, and snippets.

@menduz
Last active December 6, 2017 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menduz/e5b60d0ecbb09bf2c1bebaecbf168e39 to your computer and use it in GitHub Desktop.
Save menduz/e5b60d0ecbb09bf2c1bebaecbf168e39 to your computer and use it in GitHub Desktop.
Untitled project
{
"message": "Hello world!"
}
import * from dw::http::Server
import * from dw::http::Client
import * from versions
---
api({
host: "0.0.0.0",
port: 8080
}, {
"/": {
GET: (request) -> {
body: generate() as Binary,
headers: {
'Content-Type': 'text/html',
}
}
}
})
%dw 2.0
output text/plain
---
versions::generate()
%dw 2.0
import * from dw::http::Client
var config = {
services: {
devx: {
analytics: {
domain: 'https://bat-analytics.devx.msap.io'
},
artifacts: {
domain: 'https://bat-artifacts.devx.msap.io'
},
results: {
domain: 'https://bat-results.devx.msap.io'
},
scheduler: {
domain: 'https://bat-scheduler.devx.msap.io'
},
execution: {
domain: 'https://bat-execution.devx.msap.io'
},
cliXapi: {
domain: 'https://bat-cli-xapi.devx.msap.io'
},
xapi: {
domain: 'https://bat-xapi.devx.msap.io'
},
worker: {
domain: 'https://bat-worker.devx.msap.io'
}
},
qax: {
analytics: {
domain: 'https://bat-analytics.qax.msap.io'
},
artifacts: {
domain: 'https://bat-artifacts.qax.msap.io'
},
results: {
domain: 'https://bat-results.qax.msap.io'
},
scheduler: {
domain: 'https://bat-scheduler.qax.msap.io'
},
execution: {
domain: 'https://bat-execution.qax.msap.io'
},
cliXapi: {
domain: 'https://bat-cli-xapi.qax.msap.io'
},
xapi: {
domain: 'https://bat-xapi.qax.msap.io'
},
worker: {
domain: 'https://bat-worker.qax.msap.io'
}
},
stgx: {
analytics: {
domain: 'https://bat-analytics.stgx.msap.io'
},
artifacts: {
domain: 'https://bat-artifacts.stgx.msap.io'
},
analytics: {
domain: 'https://bat-analytics.stgx.msap.io'
},
results: {
domain: 'https://bat-results.stgx.msap.io'
},
scheduler: {
domain: 'https://bat-scheduler.stgx.msap.io'
},
execution: {
domain: 'https://bat-execution.stgx.msap.io'
},
cliXapi: {
domain: 'https://bat-cli-xapi.stgx.msap.io'
},
xapi: {
domain: 'https://bat-xapi.stgx.msap.io'
},
worker: {
domain: 'https://bat-worker.stgx.msap.io'
}
}
}
}
fun array2obj(array: Array<Object>) =
array reduce (item, carry = {}) -> carry ++ item
fun findVersions(service: String) = do {
var cols = [
request('GET', `$(config.services.devx[service].domain)/v1/status`),
request('GET', `$(config.services.qax[service].domain)/v1/status`),
request('GET', `$(config.services.stgx[service].domain)/v1/status`)
] map {
td: "$($.response.body.version default 'Unknown')"
}
---
tr: {
td: "$(service)",
(cols),
(if ((cols[1] == cols[2]) and (cols[2] == cols[0]))
td: "✓"
else
td: "X"
)
}
}
fun generate() =
write(
html: {
head: {
meta @('http-equiv': "refresh", 'content': "30"): '',
style @('type': "text/css"): `
{
font-family: "Trebuchet MS", 40px Arial, Helvetica, sans-serif;
font-size: 350%;
border-collapse: collapse;
width: 100%;
}
td, th {
font-size: 350%;
border: 1px solid #ddd;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2;}
tr:hover {background-color: #ddd;}
th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
`
},
body: {
table: {
tr: {
th:
b: 'Service'
,
th:
b: 'Devx'
,
th:
b: 'Qax'
,
th:
b: 'Stgx'
,
th:
b: 'Convergence'
},
(findVersions('analytics')),
(findVersions('artifacts')),
(findVersions('results')),
(findVersions('cliXapi')),
(findVersions('execution')),
(findVersions('scheduler')),
(findVersions('worker')),
(findVersions('xapi'))
}
}
}
, 'application/xml')
{
"project": {
"name": "Untitled project",
"mainScript": "scripts/main.dwl",
"apiled": {
"deploymentId": null,
"domain": "bat-versions"
}
},
"meta": {
"projectFileVersion": "0.1.0",
"creationDate": "12/06/2017"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment