How to use the screwdriver-data-schema.models function in screwdriver-data-schema

To help you get started, we’ve selected a few screwdriver-data-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github screwdriver-cd / screwdriver / plugins / templates / removeTag.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const baseSchema = schema.models.templateTag.base;

/* Currently, only build scope is allowed to tag template due to security reasons.
 * The same pipeline that publishes the template has the permission to tag it.
 */
module.exports = () => ({
    method: 'DELETE',
    path: '/templates/{templateName}/tags/{tagName}',
    config: {
        description: 'Delete a template tag',
        notes: 'Delete a specific template',
        tags: ['api', 'templates'],
        auth: {
            strategies: ['token'],
            scope: ['build']
        },
        plugins: {
github screwdriver-cd / screwdriver / plugins / tokens / create.js View on Github external
})
                .then((token) => {
                    const location = urlLib.format({
                        host: request.headers.host,
                        port: request.headers.port,
                        protocol: request.server.info.protocol,
                        pathname: `${request.path}/${token.id}`
                    });

                    return reply(token.toJson()).header('Location', location).code(201);
                })
                // something broke, respond with error
                .catch(err => reply(boom.boomify(err)));
        },
        validate: {
            payload: schema.models.token.create
        }
    }
});
github screwdriver-cd / screwdriver / plugins / pipelines / jobBadge.js View on Github external
'use strict';

const joi = require('joi');
const schema = require('screwdriver-data-schema');
const tinytim = require('tinytim');
const idSchema = joi.reach(schema.models.pipeline.base, 'id');

/**
 * Generate Badge URL
 * @method getUrl
 * @param  {String} badgeService            Badge service url
 * @param  {Object} statusColor             Mapping for status and color
 * @param  {Function} encodeBadgeSubject    Function to encode subject
 * @param  {Array}  [builds=[]]             An array of builds
 * @param  {String} [subject='job']         Subject of the badge
 * @return {String}
 */
function getUrl({ badgeService, statusColor, encodeBadgeSubject, builds = [], subject = 'job' }) {
    let color = 'lightgrey';
    let status = 'unknown';

    if (builds.length > 0) {
github screwdriver-cd / screwdriver / plugins / pipelines / tokens / list.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const getSchema = joi.array().items(schema.models.token.get);
const pipelineIdSchema = joi.reach(schema.models.pipeline.base, 'id');

module.exports = () => ({
    method: 'GET',
    path: '/pipelines/{id}/tokens',
    config: {
        description: 'List tokens for pipeline',
        notes: 'List tokens for a specific pipeline',
        tags: ['api', 'tokens'],
        auth: {
            strategies: ['token'],
            scope: ['user', '!guest']
        },
        plugins: {
            'hapi-swagger': {
                security: [{ token: [] }]
github screwdriver-cd / screwdriver / plugins / jobs / listBuilds.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const jobIdSchema = joi.reach(schema.models.job.base, 'id');
const buildListSchema = joi.array().items(schema.models.build.get).label('List of builds');

module.exports = () => ({
    method: 'GET',
    path: '/jobs/{id}/builds',
    config: {
        description: 'Get builds for a given job',
        notes: 'Returns builds for a given job',
        tags: ['api', 'jobs', 'builds'],
        auth: {
            strategies: ['token'],
            scope: ['user', 'pipeline']
        },
        plugins: {
            'hapi-swagger': {
                security: [{ token: [] }]
            }
github screwdriver-cd / screwdriver / plugins / tokens / remove.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const idSchema = joi.reach(schema.models.token.base, 'id');

module.exports = () => ({
    method: 'DELETE',
    path: '/tokens/{id}',
    config: {
        description: 'Remove a single token',
        notes: 'Returns null if successful',
        tags: ['api', 'tokens'],
        auth: {
            strategies: ['token'],
            scope: ['user', '!guest']
        },
        plugins: {
            'hapi-swagger': {
                security: [{ token: [] }]
            }
github screwdriver-cd / screwdriver / plugins / jobs / get.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const getSchema = schema.models.job.get;
const idSchema = joi.reach(schema.models.job.base, 'id');

module.exports = () => ({
    method: 'GET',
    path: '/jobs/{id}',
    config: {
        description: 'Get a single job',
        notes: 'Returns a job record',
        tags: ['api', 'jobs'],
        auth: {
            strategies: ['token'],
            scope: ['user', 'build', 'pipeline']
        },
        plugins: {
            'hapi-swagger': {
                security: [{ token: [] }]
            }
github screwdriver-cd / screwdriver / plugins / collections / update.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const idSchema = joi.reach(schema.models.collection.base, 'id');

module.exports = () => ({
    method: 'PUT',
    path: '/collections/{id}',
    config: {
        description: 'Update a collection',
        notes: 'Update a specific collection',
        tags: ['api', 'collection'],
        auth: {
            strategies: ['token'],
            scope: ['user', '!guest']
        },
        plugins: {
            'hapi-swagger': {
                security: [{ token: [] }]
            }
github screwdriver-cd / screwdriver / plugins / commands / list.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const listSchema = joi.array().items(schema.models.command.get).label('List of commands');
const distinctSchema = joi.string()
    .valid(Object.keys(schema.models.command.base.describe().children))
    .label('Field to return unique results by');
const compactSchema = joi.string()
    .valid(['', 'false', 'true'])
    .label('Flag to return compact data');
const namespaceSchema = joi.reach(schema.models.command.base, 'namespace');
const namespacesSchema = joi.array().items(joi.object().keys({ namespace: namespaceSchema }));

module.exports = () => ({
    method: 'GET',
    path: '/commands',
    config: {
        description: 'Get commands with pagination',
        notes: 'Returns all command records',
        tags: ['api', 'commands'],
github screwdriver-cd / screwdriver / plugins / secrets / get.js View on Github external
'use strict';

const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const getSchema = schema.models.secret.get;
const idSchema = joi.reach(schema.models.secret.base, 'id');

module.exports = () => ({
    method: 'GET',
    path: '/secrets/{id}',
    config: {
        description: 'Get a single secret',
        notes: 'Returns a secret record',
        tags: ['api', 'secrets'],
        auth: {
            strategies: ['token'],
            scope: ['user', 'build', '!guest']
        },
        plugins: {
            'hapi-swagger': {
                security: [{ token: [] }]

screwdriver-data-schema

Internal Data Schema of Screwdriver

BSD-3-Clause
Latest version published 2 days ago

Package Health Score

81 / 100
Full package analysis