29.19.0 • Published 7 days ago

screwdriver-models v29.19.0

Weekly downloads
152
License
BSD-3-Clause
Repository
github
Last release
7 days ago

Screwdriver Models

Version Downloads Build Status Open Issues License

Screwdriver models

Usage

Asynchronous methods return promises.

npm install screwdriver-models

Pipeline Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.PipelineFactory.getInstance({
    datastore,
    scm
});
const config = {
    params: {
        scmUri: 'github.com:12345:banana'
    },
    paginate {
        page: 2,
        count: 3
    },
    sort: 'ascending',
    sortBy: 'scmRepo.name'
}

factory.list(config).then(pipelines => {
    // Do stuff with list of pipelines
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectFields to search on
config.rawBooleanWhether to return raw data or not
config.searchObjectSearch parameters
config.search.fieldString or ArraySearch field(s) (e.g.: jobName)
config.search.keywordStringSearch keyword (e.g.: %PR-%)
config.sortStringOrder to sort by (ascending or descending)
config.sortByStringKey to sort by (default id)

Create

factory.create(config).then(model => {
    // do stuff with pipeline model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.adminsObjectYesAdmins for this pipeline, e.g { batman: true }
config.scmUriStringYesSource Code URI for the application
config.scmContextStringYesScm context to which user belongs

Get

Get a pipeline based on id. Can pass the generatedId for the pipeline, or the unique keys for the model, and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with pipeline model
});

factory.get({ scmUri }).then(model => {
    // do stuff with pipeline model
});
ParameterTypeDescription
idNumberThe unique ID for the pipeline
config.scmUriStringSource Code URI for the application

Pipeline Model

Update

Update a specific pipeline model

model.update()

Example:

'use strict';
const Model = require('screwdriver-models');
const factory = Model.PipelineFactory.getInstance({
    datastore,
    scm
});
const scmUri = 'github.com:12345:master';
factory.get({ scmUri }).then(model => {
    model.scmUri = 'github.com:12345:foo';
    return model.update();
})

Add Screwdriver webhook

Attach Screwdriver webhook to the pipeline's repository

model.addWebhook(webhookUrl)
ParameterTypeDescription
webhookUrlStringThe webhook url to be added

Sync

Sync the pipeline. Look up the configuration in the repo to create and delete jobs if necessary.

model.sync()

Get Configuration

Get the screwdriver configuration for the pipeline at the given ref

model.getConfiguration(config)
ParameterTypeRequiredDescription
refStringNoReference to the branch or PR

Get Jobs

Return a list of jobs that belong to this pipeline

model.getJobs(config)
ParameterTypeRequiredDefaultDescription
configObjectNoConfiguration Object
config.paramsObjectNoFields to search on
config.paginate.pageNumberNoThe page for pagination
config.paginate.countNumberNoThe count for pagination

Get Events

Return a list of events that belong to this pipeline

model.getEvents(config)
ParameterTypeRequiredDefaultDescription
configObjectNoConfig Object
config.typeNumberNopipelineType of event: pipeline or pr
config.sortStringNodescendingOrder to sort by (ascending or descending)

Tokens

Get the pipeline's access tokens

model.tokens
    .then((tokens) => {
        // do stuff with tokens
    });

Get Event Metrics

Get all the event durations for this pipeline within time range

model.getMetrics()
    .then((metrics) => {
        // do stuff with metrics
    });

Job Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.JobFactory.getInstance({
    datastore
});
const config = {
    params: {
        pipelineId: 1
    },
    paginate {
        page: 2,
        count: 3
    }
}

factory.list(config).then(jobs => {
    // Do stuff with list of jobs
});
ParameterTypeDescription
configObjectConfiguration Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on

Create

factory.create(config).then(model => {
    // do stuff with job model
});
ParameterTypeDescription
configObjectConfiguration Object
config.pipelineIdNumberThe pipelineId that the job belongs to
config.nameStringThe name of the job

Get

Get a job based on id. Can pass the generatedId for the job, or the unique keys for the model, and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with job model
});

factory.get({ pipelineId, name }).then(model => {
    // do stuff with job model
});
ParameterTypeDescription
idNumberThe unique ID for the job
config.pipelineIdNumberId of the pipeline the job is associated with
config.nameStringName of the job

Job Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.JobFactory.getInstance({
    datastore
});

factory.get(id).then(model => {
    model.name = 'hello';
    return model.update();
});

Update

Update a job

model.update()

Get builds

Return builds that belong to this job

model.getBuilds(config)
ParameterTypeRequiredDefaultDescription
configObjectNoConfiguration Object
config.sortStringNodescendingascending or descending

Get running builds

Return all running builds that belong to this jobId

model.getRunningBuilds()

Get Build Metrics

Get all the build durations for this job within time range

model.getMetrics()
    .then((metrics) => {
        // do stuff with metrics
    });

Build Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.BuildFactory.getInstance({  
    datastore,
    scm,
    executor,
    uiUri
});
const config = {
    params: {
        jobId: 4
    },
    paginate {
        page: 2,
        count: 3
    }
}

factory.list(config).then(builds => {
    // Do stuff with list of builds
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on

Create

factory.create(config).then(model => {
    // do stuff with build model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.apiUriStringYesURI back to the API
config.tokenGenFunctionYesGenerator for building tokens
config.usernameStringYesUser who made the change to kick off the build
config.scmContextStringYesScm context to which user belongs
config.containerStringNoContainer for the build to run in
config.shaStringNoSHA used to kick off the build
config.prRefStringNoPR branch or reference; required for PR jobs
config.eventIdNumberNoId of the event this build belongs to

Get

Get a build based on id. Can pass the generatedId for the build, or the unique keys for the model, and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with build model
});

factory.get({ jobId, number }).then(model => {
    // do stuff with build model
});
ParameterTypeDescription
idNumberThe unique ID for the build
config.jobIdNumberThe unique ID for a job
config.numberNumberbuild number

Get Build Statuses

Get the statuses of the newest builds of jobs based on job ids (in ascending order). Can specify the number of build statuses desired per job id, this defaults to 1. Can specify the number of build statuses to skip per job id, this defaults to 0.

factory.getBuildStatuses(config).then(statuses => {
    // do stuff with the statuses
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.jobIdsArrayYesIds of the jobs to get build statuses for
config.numBuildsNumberNoNumber of build statuses to return per job
config.offsetNumberNoNumber of build statuses to skip per job

Get Latest Builds

Get the latest builds for each job in corresponding groupEventId.

factory.getLatestBuilds(config).then(latestBuilds => {
    // do stuff with the latest builds
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.groupEventIdNumberYesGroup event ID to get latest builds for

Build Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.BuildFactory.getInstance({  
    datastore,
    scm,
    executor,
    uiUri
});

factory.get(id).then(model => {
    model.state = 'FAILURE';
    model.update();
});

Update

Update a specific build

model.update()

Stream

Stream the log of a build

model.stream()

Update commit status

Update a commit status

model.updateCommitStatus(pipeline)
ParameterTypeDescription
pipelinePipelineThe pipeline that this build belongs to

Start a build

Start the build and update commit status as pending

model.start()

Stop a build

model.stop()

Check if a build is done

model.isDone()

User Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.UserFactory.getInstance({
    datastore,
    scm,
    password            // Password to seal/unseal user's token
});
const config = {
    params: {
        username: 'batman',
        scmContext: 'github:github.com'
    },
    paginate {
        page: 2,
        count: 3
    }
}

factory.list(config).then(users => {
    // Do stuff with list of users
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on

Create

factory.create(config).then(model => {
    // do stuff with user model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.usernameStringYesUser who made the change to kick off the build
config.tokenStringYesunsealed token
config.scmContextStringYesScm context to which user belongs
config.passwordStringYesUser's password used to seal/unseal token, not saved in datastore

Get

Get a user based on id. Can pass the generatedId for the user, or the username, and the id will be determined automatically. Can also pass a Screwdriver access token, and will get the user associated with that token.

factory.get(id).then(model => {
    // do stuff with user model
});

factory.get({ username }).then(model => {
    // do stuff with user model
});

factory.get({ token }).then(model => {
    // do stuff with user model
});
ParameterTypeDescription
idNumberThe unique ID for the build
config.usernameStringUser name
config.scmContextStringScm context to which user belongs
config.accessTokenStringA user access token value

User Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.UserFactory.getInstance({
    datastore,
    scm,
    password                    // Password to seal/unseal user's token
});
const config = {
    username: 'myself',
    token: 'eyJksd3',            // User's github token
    scmContext: 'github:github.com',          // Scm context to which user belongs
    password
}

factory.create(config)
    .then(user => user.getPermissions(scmUri))
    .then(permissions => {
        // do stuff here
    });

Update

Update a specific user

model.update()

Seal Token

Seal a token

model.sealToken(token)
ParameterTypeDescription
tokenStringThe token to seal

Unseal Token

Unseal the user's token

model.unsealToken()

Get User's Permissions For a Repo

Get user's permissions for a specific repo

model.getPermissions(scmUri)
ParameterTypeDescription
scmUriStringThe scmUri of the repo

Tokens

Get the user's access tokens

model.tokens
    .then((tokens) => {
        // do stuff with tokens
    });

Secret Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.SecretFactory.getInstance({
    datastore,
    password            // Password for encryption operations
});
const config = {
    params: {
        pipelineId: 1
    },
    paginate {
        page: 2,
        count: 3
    }
}

factory.list(config).then(secrets => {
    // Do stuff with list of secrets
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on

Create

factory.create(config).then(model => {
    // do stuff with secret model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.pipelineIdNumberYesPipeline that this secret belongs to
config.nameStringYesSecret name
config.valueStringYesSecret value
config.allowInPRStringYesFlag to denote if this secret can be shown in PR builds

Get

Get a secret based on id. Can pass the generatedId for the secret, or the combination of pipelineId and secret name, and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with secret model
});

factory.get({ pipelineId, name }).then(model => {
    // do stuff with secret model
});
ParameterTypeDescription
idNumberThe unique ID for the build
config.pipelineIdNumberPipeline that the secret belongs to
config.nameStringSecret name

Secret Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.SecretFactory.getInstance({
    datastore,
    password            // Password for encryption operations
});
const config = {
    pipelineId: 1,
    name: 'NPM_TOKEN',
    value: banana,
    allowInPR: false
}

factory.create(config)
    .then(model => // do something
    });

Update

Update a specific secret

model.update()

Stage Factory

Create

factory.create(config).then(model => {
    // do stuff with stage model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.pipelineIdNumberYesPipeline that this stage belongs to
config.nameStringYesStage name
config.jobIdsArrayNoJobs IDs that belong to this stage. Default [].
config.groupEventIdNumberYesGroup event ID that this stage belongs to
config.descriptionStringNoDescription for stage

Get

Get stage based on ID.

factory.get(id).then(model => {
    // do stuff with stage model
});
ParameterTypeDescription
idNumberThe unique ID for the stage

List

List stages that have pipelineId as 12345 and groupEventId as 555

factory.list({
    params: {
        pipelineId: 12345,
        groupEventId: 555
    }
}).then(recs =>
    // do things with the records
);

Event Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.EventFactory.getInstance({
    datastore,
    scm
});
const config = {
    params: {
        pipelineId: 1
    }
}

factory.list(config).then(events => {
    // Do stuff with list of events
});
ParameterTypeDescription
configObjectConfig Object
config.paramsObjectfields to search on

Create

factory.create(config).then(model => {
    // do stuff with event model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.typeStringNoEvent type: pipeline or pr
config.pipelineIdNumberYesUnique identifier of pipeline
config.shaStringYesCommit sha that the event was based on
config.workflowGraphObjectNoWorkflow graph of the pipeline, with edges and nodes
config.usernameStringYesUsername of the user that creates this event
config.causeMessageStringNoMessage that describes why the event was created

Get

Get an event based on id. Can pass the generatedId for the event, or { pipelineId, sha } and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with event model
});

factory.get({ pipelineId, sha }).then(model => {
    // do stuff with event model
});
ParameterTypeDescription
idNumberThe unique ID for the build
config.pipelineIdNumberUnique identifier of pipeline
config.shaStringCommit sha that the event was based on

Event Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.EventFactory.getInstance({
    datastore,
    scm
});
const config = {
    pipelineId: 1,
    sha: 'ccc49349d3cffbd12ea9e3d41521480b4aa5de5f',
    workflowGraph: {
        nodes: [
            { name: '~pr' },
            { name: '~commit' },
            { name: 'main' },
            { name: 'publish' }
        ],
        edges: [
            { src: '~pr', dest: 'main' },
            { src: '~commit', dest: 'main' },
            { src: 'main', dest: 'publish' }
        ]
    },    
    username: 'stjohn',
    causeMessage: 'Merge pull request #26 from screwdriver-cd/models'
}

factory.create(config)
    .then(model => {    // do something
    });

Example event model that got created:

{
    "type": "pipeline",
    "pipelineId": "1",
    "sha": "ccc49349d3cffbd12ea9e3d41521480b4aa5de5f",
    "createTime": "2038-01-19T03:14:08.131Z",
    "commit": {
        "url": "https://link.to/commitDiff",
        "message": "some commit message that is here",
        "author": {
            "avatar": "https://avatars.githubusercontent.com/u/1234567?v=3",
            "name": "Batman",
            "url": "https://internal-ghe.mycompany.com/imbatman",
            "username": "imbatman"
        }
    },
    "workflowGraph": {
        "nodes": [
            { "name": "~pr" },
            { "name": "~commit" },
            { "name": "main" },
            { "name": "publish" }
        ],
        "edges": [
            { "src": "~pr", "dest": "main" },
            { "src": "~commit", "dest": "main" },
            { "src": "main", "dest": "publish" }
        ]
    },
    "causeMessage": "Merge pull request #26 from screwdriver-cd/models",
    "creator": {
        "avatar": "https://avatars.githubusercontent.com/u/2042?v=3",
        "name": "St John",
        "url": "https://github.com/stjohn",
        "username": "stjohn"
    }
}

Update

Update a specific event

model.update()

Get builds

Get builds that belong to this event

model.getBuilds()

Get Build Metrics

Get all the build durations for this event within time range

model.getMetrics()
    .then((metrics) => {
        // do stuff with metrics
    });

Template Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TemplateFactory.getInstance({
    datastore
});
const config = {
    name: 'testTemplate',
    namespace: 'templateNamespace',   // optional
    version: '1.3',
    description: 'I am a test template',    
    maintainer: 'foo@bar.com',
    scmUri: 'github:123:master',
    config: { image: 'node:6'},
    labels: ['beta', 'stable']
}

factory.create(config)
    .then(model => {    // do something
    });

Update

Update a specific template

model.update()

Template Factory

Create

factory.create(config).then(model => {
    // do stuff with template model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.nameStringYesThe template name
config.namespaceStringNoThe template namespace
config.versionStringYesVersion of the template
config.descriptionStringYesDescription of the template
config.maintainerArrayYesMaintainer's email
config.configObjectYesConfig of the screwdriver-template.yaml
config.pipelineIdNumberYespipelineId of the template
config.labelsArrayNoLabels attached to the template

Get

Get a template based on id or other params.

factory.get(id).then(model => {
    // do stuff with template model
});

factory.get({ namespace, name }).then(model => {
    // do stuff with template model
});
ParameterTypeDescription
idNumberThe unique ID for the Template
config.namespaceStringTemplate namespace
config.nameStringTemplate name (can include namespace)
config.versionStringTemplate version

Get Template

Get the latest template by name or get a specific template using name and version or name and tag. The version can be in any valid version format: either major, major.minor, or major.minor.patch. If no version is specified, the function will resolve with the latest version published. If no match is found, the function will resolve null.

factory.getTemplate(fullTemplateName).then(model => {
    // do stuff with template model
});
ParameterTypeRequiredDescription
fullTemplateNameStringYesName of the template and the version or tag (e.g. chef/publish@1.2.3 or chef/publish@latest). Can also be just name of the template (e.g. chef/publish)

Search Template

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TemplateFactory.getInstance({
    datastore
});
const config = {
    params: {
        name: 'chef/publish'
    },
    paginate {
        page: 1,
        count: 3
    },
    getCount: true
}

factory.list(config).then(templates => {
    // Do stuff with list of templates
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on
config.getCountBooleanTotal count of record matching search param

Template Tag Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TemplateTagFactory.getInstance({
    datastore
});
const config = {
    name: 'testTemplate',
    namespace: 'templateNamespace', // optional
    tag: 'stable',
    version: '1.3'
}

factory.create(config)
    .then(model => {    // do something
    });

Update

Update a specific template tag

// update template version value
model.version = '2.4';

model.update();

Template Tag Factory

Create

factory.create(config).then(model => {
    // do stuff with template tag model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.nameStringYesThe template name
config.namespaceStringNoThe template namespace
config.tagStringYesThe template tag (e.g. stable, latest, etc)
config.versionStringYesVersion of the template

Get

Get a template tag based on id.

factory.get(id).then(model => {
    // do stuff with template model
});

factory.get({ namespace, name }).then(model => {
    // do stuff with template model
});
ParameterTypeDescription
idNumberThe unique ID for the Template tag
config.namespaceStringTemplate namespace
config.nameStringTemplate name (can include namespace)

Search Template Tags

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TemplateTagFactory.getInstance({
    datastore
});
const config = {
    params: {
        name: 'chef/publish'
    },
    paginate {
        page: 1,
        count: 3
    }
}

factory.list(config).then(templateTags => {
    // Do stuff with list of templateTags
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on

Trigger Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TriggerFactory.getInstance({
    datastore
});
const config = {
    dest: '~sd@123:component',
    src: '~sd@456:main'
}

factory.create(config)
    .then(model => {    // do something
});

Trigger Factory

Create

factory.create(config).then(model => {
    // do stuff with trigger model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.srcStringYesThe job that initiates the trigger (ex: ~sd@123:component)
config.destStringYesThe job that is triggered (ex: ~sd@456:main)

Get

Get trigger based on id.

factory.get(id).then(model => {
    // do stuff with trigger model
});
ParameterTypeDescription
idNumberThe unique ID for the trigger

List

List triggers that have dest as ~sd@456:main

// update template version value
factory.list({
    params: {
        dest: '~sd@456:main'
    }
}).then(recs =>
    // do things with the records
);

Get destination(s) from source

Get destinations based on source trigger.

// update template version value
factory.getDestFromSrc('~sd@456:main').then(dests =>
    console.log(dests);
    // [destA, destB]
);
ParameterTypeDescription
srcStringThe job that initiates the trigger (ex: ~sd@123:component)

Get Triggers

Get triggers based on pipeline ID.

factory.getTriggers({ pipelineId, type }).then(result => {
    console.log(result);
    // [{
    //     jobName1,
    //     triggers: [destA, destB]
    // }, {
    //     jobName2,
    //     triggers: [destC, destD]
    // }]
});
ParameterTypeDescription
configObjectConfig object
config.pipelineIdNumberThe unique ID for the pipeline
config.typeStringType of jobs to get (pr or pipeline; default pipeline)

Token Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TokenFactory.getInstance({
    datastore
});
const config = {
    params: {
        userId: 12345
    },
    paginate {
        page: 1,
        count: 3
    }
}

factory.list(config).then(tokens => {
    // Do stuff with list of tokens
});
ParameterTypeDescription
configObjectConfig Object
config.paginate.pageNumberThe page for pagination
config.paginate.countNumberThe count for pagination
config.paramsObjectfields to search on

Create

factory.create(config).then(model => {
    // do stuff with token model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.userIdNumberYesUser that this token belongs to
config.nameStringYesToken name
config.descriptionStringNoDescription of the token

Get

Get a token based on id. Can pass the generatedId for the token, or the token value, and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with token model
});

factory.get({ value }).then(model => {
    // do stuff with token model
});
ParameterTypeDescription
idNumberThe unique ID for the token
config.valueStringThe value of the token

Token Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.TokenFactory.getInstance({
    datastore,
});
const config = {
    userId: 12345,
    name: 'NPM_TOKEN',
    description: 'A token for use by npm'
}

factory.create(config)
    .then(model => // do something
    });

Update

Update a specific token

model.update()

Refresh

Refresh a token's value while preserving its other metadata. Attaches a temporary "value" field to the model

token.refresh()
    .then(model => // do something with the new model.value
    });

Collection Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.CollectionFactory.getInstance({
    datastore
});
const config = {
    params: {
        userId: 12345
    }
};

factory.list(config).then(collections => {
    // Do stuff with list of collections
});
ParameterTypeDescription
configObjectConfig object
config.paramsObjectFields to search on

Create

factory.create(config).then(model => {
    // do stuff with collection model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.userIdNumberYesUser that this collection belongs to
config.nameStringYesCollection name
config.descriptionStringNoCollection description
config.pipelineIdsArrayNoList of ids of pipelines associated with this collection

Get

Get a collection based on unique id of collection. Can also pass in a combination of userId and collection name, and the id will be determined automatically.

factory.get(id).then(model => {
    // do stuff with collection model
});

factory.get({ userId, name }).then(model => {
    // do stuff with collection model
})
ParameterTypeDescription
idNumberThe unique id for the collection

Collection Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.CollectionFactory.getInstance({
    datastore
});
const config = {
    userId: 12345,
    name: 'Screwdriver',
    description: 'Collection of screwdriver pipelines'
};

factory.create(config)
    .then(model => {
        // do something with model
    });

Update

Update a specific collection

model.update()

Remove

Remove a specific collection

model.remove()

Command Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.CommandFactory.getInstance({
    datastore
});
const config = {
    namespace: 'testCommandNS',
    name: 'testCommand',
    version: '1.3',
    description: 'This is a test command',
    maintainer: 'foo@bar.com',
    format: 'habitat',
    habitat: {
        mode: 'remote',
        package: 'core/git/2.14.1',
        command: 'git'
    }
}

factory.create(config)
    .then(model => {    // do something
    });

Command Factory

Create

factory.create(config).then(model => {
    // do stuff with command model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.namespaceStringYesThe command namespace
config.nameStringYesThe command name
config.versionStringYesVersion of the command
config.descriptionStringYesDescription of the command
config.usageStringNoCommand usage and arguments (e.g.: 'sd-cmd exec foo/bar@1 -d -h ')
config.maintainerStringYesMaintainer's email
config.formatStringYesFormat of the command, habitat or docker or binary
config.habitatObjectYes (any one of habitat, docker, binary)Configuration Object for Habitat command
config.dockerObjectYes (any one of habitat, docker, binary)Configuration Object for Docker command
config.binaryObjectYes (any one of habitat, docker, binary)Configuration Object for Binary command

Get

Get a command based on id.

factory.get(id).then(model => {
    // do stuff with command model
});
ParameterTypeDescription
idNumberThe unique ID for the Command

Get Command

Get the latest command by name or get a specific command using namespace, command name and version or tag. The version can be in any valid version format: either major, major.minor, or major.minor.patch. If no version is specified, the function will resolve with the latest version published. If no match is found, the function will resolve null.

factory.getCommand(fullCommandName).then(model => {
    // do stuff with command model
});
ParameterTypeRequiredDescription
fullCommandNameStringYesNamespace and name of the command and the version or tag (e.g. chefdk/knife@1.2.3 or chefdk/knife@latest). Can also be just namespace and name of the command (e.g. chefdk/knife)

Command Tag Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.CommandTagFactory.getInstance({
    datastore
});
const config = {
    namespace: 'testCommandNS',
    name: 'testCommand',
    tag: 'stable',
    version: '1.3.5'
}

factory.create(config)
    .then(model => {    // do something
    });

Update

Update a specific command tag

// update command version value
model.version = '2.4.8';

model.update()

Command Tag Factory

Create

factory.create(config).then(model => {
    // do stuff with command tag model
});
ParameterTypeRequiredDescription
configObjectYesConfiguration Object
config.namespaceStringYesThe command namespace
config.nameStringYesThe command name
config.tagStringYesThe command tag (e.g. stable, latest, etc)
config.versionStringYesExact version of the command

Get

Get a command tag based on id.

factory.get(id).then(model => {
    // do stuff with command model
});
ParameterTypeDescription
idNumberThe unique ID for the Command Tag

Banner Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.BannerFactory.getInstance({
    datastore
});
const config = {
    params: {
        isActive: true
    }
};

factory.list(config).then(banners => {
    // Do stuff with list of banners
});
ParameterTypeDescription
configObjectConfig object
config.paramsObjectFields to search on

Create

factory.create(config).then(model => {
    // do stuff with banner model
});
ParameterTypeRequiredDefaultDescription
configObjectYesConfiguration Object
config.messageStringYesText of banner to be displayed
config.isActiveBooleanNofalseFlag for whether banner should display
config.typeStringNoinfoType/Severity of banner message. Options: info,warn
config.createdByStringYesUsername of the user creating the banner

Get

Get a banner based on unique id of banner.

factory.get(id).then(model => {
    // do stuff with banner model
});
ParameterTypeDescription
idNumberThe unique id for the banner

Banner Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.BannerFactory.getInstance({
    datastore
});
const config = {
    message: 'There will be a brief outage between 9:00am and 9:15am tomorrow morning',
    isActive: true,
    type: 'info'
};

factory.create(config)
    .then(model => {
        // do something with model
    });

Update

Update a specific banner

model.update()

Remove

Remove a specific banner

model.remove()

BuildCluster Factory

Search

'use strict';
const Model = require('screwdriver-models');
const factory = Model.BuildClusterFactory.getInstance({
    datastore
});
const config = {
    params: {
        isActive: true
    }
};

factory.list(config).then(buildclusters => {
    // Do stuff with list of buildclusters
});
ParameterTypeDescription
configObjectConfig object
config.paramsObjectFields to search on

Create

factory.create(config).then(model => {
    // do stuff with buildCluster model
});
ParameterTypeRequiredDefaultDescription
configObjectYesConfiguration Object
config.nameStringYesName of the build cluster (unique constraint)
config.descriptionStringNoDescription of the build cluster
config.scmContextStringYesSCM context
config.scmOrganizationsArrayYesSCM organizations that can use the build cluster
config.isActiveBooleanNofalseFlag for whether banner should display
config.managedByScrewdriverBooleanYesFlag for whether the cluster managed by Screwdriver
config.maintainerStringYesEmail of the maintainer
config.weightageStringNo100Weight percentage for build cluster (from 1 to 100)

Get

Get a buildcluster based on unique id of buildcluster.

factory.get(id).then(model => {
    // do stuff with buildcluster model
});
ParameterTypeDescription
idNumberThe unique id for the buildcluster

BuildCluster Model

'use strict';
const Model = require('screwdriver-models');
const factory = Model.BuildClusterFactory.getInstance({
    datastore
});
const config = {
    name: 'sd',
    scmContext: 'github:github.com',
    scmOrganizations: [],
    isActive: true,
    managedByScrewdriver: true,
    maintainer: 'foo@bar.com'
};

factory.create(config)
    .then(model => {
        // do something with model
    });

Update

Update a specific BuildCluster

model.update()

Remove

Remove a specific BuildCluster

model.remove()

Testing

npm test

License

Code licensed under the BSD 3-Clause license. See LICENSE file for terms.

29.19.0

7 days ago

29.18.5

1 month ago

29.18.4

1 month ago

29.18.3

1 month ago

29.18.2

2 months ago

29.18.1

2 months ago

29.18.0

2 months ago

29.17.7

3 months ago

29.17.5

3 months ago

29.17.6

3 months ago

29.17.4

3 months ago

29.17.3

3 months ago

29.17.2

3 months ago

29.17.1

3 months ago

29.17.0

3 months ago

29.15.1

3 months ago

29.16.0

3 months ago

29.15.0

3 months ago

29.14.1

4 months ago

29.14.0

5 months ago

29.13.0

5 months ago

29.11.0

6 months ago

29.10.0

6 months ago

29.9.2

6 months ago

29.9.3

6 months ago

29.12.0

5 months ago

29.9.1

7 months ago

29.8.0

8 months ago

29.9.0

8 months ago

29.6.3

9 months ago

29.6.0

11 months ago

29.6.1

10 months ago

29.6.2

10 months ago

29.7.0

9 months ago

29.5.0

11 months ago

29.2.0

1 year ago

29.2.1

1 year ago

29.3.0

1 year ago

29.3.1

12 months ago

29.0.1

1 year ago

29.1.0

1 year ago

29.4.0

12 months ago

28.19.3

2 years ago

29.0.0

1 year ago

28.20.0

2 years ago

28.18.4

2 years ago

28.19.1

2 years ago

28.19.0

2 years ago

28.19.2

2 years ago

28.18.0

2 years ago

28.18.2

2 years ago

28.18.1

2 years ago

28.18.3

2 years ago

28.15.9

2 years ago

28.16.1

2 years ago

28.16.0

2 years ago

28.17.9

2 years ago

28.17.8

2 years ago

28.17.1

2 years ago

28.17.0

2 years ago

28.17.3

2 years ago

28.17.2

2 years ago

28.17.5

2 years ago

28.17.4

2 years ago

28.17.7

2 years ago

28.17.6

2 years ago

28.15.13

2 years ago

28.15.14

2 years ago

28.15.11

2 years ago

28.15.12

2 years ago

28.15.10

2 years ago

28.17.10

2 years ago

28.15.5

2 years ago

28.15.7

2 years ago

28.15.6

2 years ago

28.15.8

2 years ago

28.15.3

2 years ago

28.15.2

2 years ago

28.15.4

2 years ago

28.15.1

2 years ago

28.15.0

2 years ago

28.14.0

2 years ago

28.11.3

2 years ago

28.11.2

2 years ago

28.11.4

2 years ago

28.12.0

2 years ago

28.13.0

2 years ago

28.11.1

2 years ago

28.11.0

2 years ago

28.10.0

3 years ago

28.10.1

3 years ago

28.9.0

3 years ago

28.8.9

3 years ago

28.8.8

3 years ago

28.8.7

3 years ago

28.8.6

3 years ago

28.8.5

3 years ago

28.8.4

3 years ago

28.8.3

3 years ago

28.8.2

3 years ago

28.8.1

3 years ago

28.8.0

3 years ago

28.7.1

3 years ago

28.7.2

3 years ago

28.7.0

3 years ago

28.7.3

3 years ago

28.7.4

3 years ago

28.6.6

3 years ago

28.6.7

3 years ago

28.6.8

3 years ago

28.6.5

3 years ago

28.6.4

3 years ago

28.6.2

3 years ago

28.6.3

3 years ago

28.6.1

3 years ago

28.6.0

3 years ago

28.5.8

3 years ago

28.5.7

3 years ago

28.5.6

3 years ago

28.5.5

3 years ago

28.5.4

3 years ago

28.5.3

3 years ago

28.5.2

3 years ago

28.5.1

3 years ago

28.5.0

4 years ago

28.4.0

4 years ago

28.3.0

4 years ago

28.2.1

4 years ago

28.2.0

4 years ago

28.1.1

4 years ago

28.1.0

4 years ago

28.0.0

4 years ago

27.52.0

4 years ago

27.51.2

4 years ago

27.51.1

4 years ago

27.51.0

4 years ago

27.50.8

4 years ago

27.50.7

4 years ago

27.50.6

4 years ago

27.50.5

4 years ago

27.50.4

4 years ago

27.50.3

4 years ago

27.50.2

4 years ago

27.50.1

4 years ago

27.50.0

4 years ago

27.49.1

4 years ago

27.49.2

4 years ago

27.49.0

4 years ago

27.48.2

4 years ago

27.48.1

4 years ago

27.48.0

4 years ago

27.47.1

4 years ago

27.47.0

4 years ago

27.46.1

4 years ago

27.45.5

4 years ago

27.46.0

4 years ago

27.45.4

4 years ago

27.45.3

4 years ago

27.45.2

4 years ago

27.45.1

4 years ago

27.45.0

4 years ago

27.44.0

4 years ago

27.43.4

4 years ago

27.43.3

4 years ago

27.43.2

4 years ago

27.43.1

4 years ago

27.43.0

4 years ago

27.42.7

4 years ago

27.42.6

4 years ago

27.42.5

4 years ago

27.42.4

4 years ago

27.42.3

4 years ago

27.42.2

4 years ago

27.42.1

4 years ago

27.42.0

4 years ago

27.41.0

4 years ago

27.40.0

4 years ago

27.39.7

4 years ago

27.39.6

4 years ago

27.39.5

4 years ago

27.39.4

4 years ago

27.39.3

4 years ago

27.39.2

4 years ago

27.39.1

4 years ago

27.39.0

4 years ago

27.38.0

4 years ago

27.37.1

5 years ago

27.37.0

5 years ago

27.36.10

5 years ago

27.36.9

5 years ago

27.36.8

5 years ago

27.36.7

5 years ago

27.36.6

5 years ago

27.36.5

5 years ago

27.36.4

5 years ago

27.36.3

5 years ago

27.36.2

5 years ago

27.36.1

5 years ago

27.36.0

5 years ago

27.35.0

5 years ago

27.34.11

5 years ago

27.34.10

5 years ago

27.34.9

5 years ago

27.34.8

5 years ago

27.34.7

5 years ago

27.34.6

5 years ago

27.34.5

5 years ago

27.34.4

5 years ago

27.34.3

5 years ago

27.34.2

5 years ago

27.34.1

5 years ago

27.34.0

5 years ago

27.33.3

5 years ago

27.33.2

5 years ago

27.33.1

5 years ago

27.33.0

5 years ago

27.32.3

5 years ago

27.32.2

5 years ago

27.32.1

5 years ago

27.32.0

5 years ago

27.31.18

5 years ago

27.31.17

5 years ago

27.31.16

5 years ago

27.31.15

5 years ago

27.31.14

5 years ago

27.31.13

5 years ago

27.31.12

5 years ago

27.31.11

5 years ago

27.31.10

5 years ago

27.31.9

5 years ago

27.31.8

5 years ago

27.31.7

5 years ago

27.31.6

5 years ago

27.31.5

5 years ago

27.31.4

5 years ago

27.31.3

5 years ago

27.31.2

5 years ago

27.31.1

5 years ago

27.31.0

5 years ago

27.30.2

5 years ago

27.30.1

5 years ago

27.30.0

5 years ago

27.29.0

5 years ago

27.28.1

5 years ago

27.28.0

5 years ago

27.27.6

5 years ago

27.27.5

5 years ago

27.27.4

5 years ago

27.27.3

5 years ago

27.27.2

5 years ago

27.27.1

5 years ago

27.27.0

5 years ago

27.26.5

5 years ago

27.26.4

5 years ago

27.26.3

5 years ago

27.26.2

5 years ago

27.26.1

5 years ago

27.26.0

5 years ago

27.25.1

5 years ago

27.25.0

5 years ago

27.24.2

5 years ago

27.24.1

5 years ago

27.24.0

5 years ago

27.23.1

5 years ago

27.23.0

5 years ago

27.22.0

5 years ago

27.21.2

5 years ago

27.21.1

5 years ago

27.21.0

5 years ago

27.20.2

5 years ago

27.20.1

5 years ago

27.20.0

5 years ago

27.19.2

5 years ago

27.19.1

5 years ago

27.19.0

5 years ago

27.18.2

5 years ago

27.18.1

5 years ago

27.18.0

5 years ago

27.17.2

5 years ago

27.17.1

5 years ago

27.17.0

5 years ago

27.16.0

5 years ago

27.15.8

5 years ago

27.15.7

5 years ago

27.15.6

6 years ago

27.15.5

6 years ago

27.15.4

6 years ago

27.15.3

6 years ago

27.15.2

6 years ago

27.15.1

6 years ago

27.15.0

6 years ago

27.14.3

6 years ago

27.14.2

6 years ago

27.14.1

6 years ago

27.14.0

6 years ago

27.13.3

6 years ago

27.13.2

6 years ago

27.13.1

6 years ago

27.13.0

6 years ago

27.12.2

6 years ago

27.12.1

6 years ago

27.12.0

6 years ago

27.11.0

6 years ago

27.10.3

6 years ago

27.10.2

6 years ago

27.10.1

6 years ago

27.10.0

6 years ago

27.9.7

6 years ago

27.9.6

6 years ago

27.9.5

6 years ago

27.9.4

6 years ago

27.9.3

6 years ago

27.9.2

6 years ago

27.9.1

6 years ago

27.9.0

6 years ago

27.8.0

6 years ago

27.7.3

6 years ago

27.7.2

6 years ago

27.7.1

6 years ago

27.7.0

6 years ago

27.6.1

6 years ago

27.6.0

6 years ago

27.5.0

6 years ago

27.4.6

6 years ago

27.4.5

6 years ago

27.4.4

6 years ago

27.4.3

6 years ago

27.4.2

6 years ago

27.4.1

6 years ago

27.4.0

6 years ago

27.3.0

6 years ago

27.2.3

6 years ago

27.2.2

6 years ago

27.2.1

6 years ago

27.2.0

6 years ago

27.1.1

6 years ago

27.1.0

6 years ago

27.0.0

6 years ago

26.9.6

6 years ago

26.9.5

6 years ago

26.9.4

6 years ago

26.9.3

6 years ago

26.9.2

6 years ago

26.9.1

6 years ago

26.9.0

6 years ago

26.8.6

6 years ago

26.8.5

6 years ago

26.8.4

6 years ago

26.8.3

6 years ago

26.8.2

6 years ago

26.8.1

6 years ago

26.8.0

6 years ago

26.7.8

6 years ago

26.7.7

6 years ago

26.7.6

6 years ago

26.7.5

6 years ago

26.7.4

6 years ago

26.7.3

6 years ago

26.7.2

6 years ago

26.7.1

6 years ago

26.7.0

6 years ago

26.6.1

6 years ago

26.6.0

6 years ago

26.5.1

6 years ago

26.5.0

6 years ago

26.4.3

6 years ago

26.4.2

7 years ago

26.4.1

7 years ago

26.4.0

7 years ago

26.3.4

7 years ago

26.3.3

7 years ago

26.3.2

7 years ago

26.3.1

7 years ago

26.3.0

7 years ago

26.2.1

7 years ago

26.2.0

7 years ago

26.1.0

7 years ago

26.0.2

7 years ago

26.0.1

7 years ago

26.0.0

7 years ago

25.1.0

7 years ago

25.0.0

7 years ago

24.1.0

7 years ago

24.0.2

7 years ago

24.0.1

7 years ago

24.0.0

7 years ago

23.0.1

7 years ago

23.0.0

7 years ago

22.6.0

7 years ago

22.5.1

7 years ago

22.5.0

7 years ago

22.4.0

7 years ago

22.3.0

7 years ago

22.2.5

7 years ago

22.2.4

7 years ago

22.2.3

7 years ago

22.2.2

7 years ago

22.2.1

7 years ago

22.2.0

7 years ago

22.1.3

7 years ago

22.1.2

7 years ago

22.1.1

7 years ago

22.1.0

7 years ago

22.0.0

7 years ago

21.6.1

7 years ago

21.6.0

7 years ago

21.5.4

7 years ago

21.5.3

7 years ago

21.5.2

7 years ago

21.5.1

7 years ago

21.5.0

7 years ago

21.4.0

7 years ago

21.3.1

7 years ago

21.3.0

7 years ago

21.2.0

7 years ago

21.1.1

7 years ago

21.1.0

7 years ago

21.0.1

7 years ago

21.0.0

7 years ago

20.0.0

7 years ago

19.1.0

7 years ago

19.0.8

7 years ago

19.0.7

7 years ago

19.0.6

7 years ago

19.0.5

7 years ago

19.0.4

7 years ago

19.0.3

7 years ago

19.0.2

7 years ago

19.0.1

7 years ago

19.0.0

7 years ago

18.0.0

7 years ago

17.1.0

7 years ago

17.0.2

8 years ago

17.0.1

8 years ago

17.0.0

8 years ago

16.0.8

8 years ago

16.0.7

8 years ago

16.0.6

8 years ago

16.0.5

8 years ago

16.0.4

8 years ago

16.0.3

8 years ago

16.0.2

8 years ago

16.0.1

8 years ago

16.0.0

8 years ago

15.0.2

8 years ago

15.0.1

8 years ago

15.0.0

8 years ago

14.0.2

8 years ago

14.0.1

8 years ago

14.0.0

8 years ago

13.0.4

8 years ago

13.0.3

8 years ago

13.0.2

8 years ago

13.0.1

8 years ago

13.0.0

8 years ago

12.0.0

8 years ago

11.0.0

8 years ago

10.4.3

8 years ago

10.4.2

8 years ago

10.4.1

8 years ago

10.4.0

8 years ago

10.3.1

8 years ago

10.3.0

8 years ago

10.2.3

8 years ago

10.2.2

8 years ago

10.2.0

8 years ago

10.1.6

8 years ago

10.1.5

8 years ago

10.1.4

8 years ago

10.1.3

8 years ago

10.1.2

8 years ago

10.1.1

8 years ago

10.1.0

8 years ago

10.0.0

8 years ago

9.0.9

8 years ago

9.0.8

8 years ago

9.0.7

8 years ago

9.0.6

8 years ago

9.0.5

8 years ago

9.0.4

8 years ago

9.0.3

8 years ago

9.0.2

8 years ago

9.0.1

8 years ago

9.0.0

8 years ago

8.0.0

8 years ago

7.0.12

8 years ago

7.0.11

8 years ago

7.0.10

8 years ago

7.0.9

8 years ago

7.0.8

8 years ago

7.0.7

8 years ago

7.0.6

8 years ago

7.0.5

8 years ago

7.0.4

8 years ago

7.0.3

8 years ago

7.0.2

8 years ago

7.0.1

8 years ago

7.0.0

8 years ago

6.0.3

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

6.0.0

8 years ago

5.1.2

8 years ago

5.1.1

8 years ago

5.1.0

8 years ago

5.0.4

8 years ago

5.0.3

8 years ago

5.0.2

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.0.4

8 years ago

4.0.3

8 years ago

4.0.2

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago