UNPKG

screwdriver-api

Version:

API server for the Screwdriver.cd service

37 lines (32 loc) 1.03 kB
'use strict'; const joi = require('joi'); const schema = require('screwdriver-data-schema'); const listSchema = joi.array().items(schema.models.buildCluster.get).label('List of build clusters'); module.exports = () => ({ method: 'GET', path: '/buildclusters', options: { description: 'Get build clusters', notes: 'Returns all build clusters', tags: ['api', 'buildclusters'], auth: { strategies: ['token'], scope: ['user', '!guest'] }, handler: async (request, h) => { const { buildClusterFactory } = request.server.app; const config = { sort: request.query.sort }; return buildClusterFactory .list(config) .then(buildClusters => h.response(buildClusters.map(c => c.toJson()))) .catch(err => { throw err; }); }, response: { schema: listSchema } } });