screwdriver-api 7.0.120 → 7.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@ For more information about Screwdriver, check out our [homepage](http://screwdri
24
24
 
25
25
  ### Plugins
26
26
 
27
- This API comes preloaded with 16 (sixteen) resources:
27
+ This API comes preloaded with 18 (eighteen) resources:
28
28
 
29
29
  - [auth](plugins/auth/README.md)
30
30
  - [banners](plugins/banners/README.md)
@@ -37,6 +37,8 @@ This API comes preloaded with 16 (sixteen) resources:
37
37
  - [jobs](plugins/jobs/README.md)
38
38
  - [pipelines](plugins/pipelines/README.md)
39
39
  - [secrets](plugins/secrets/README.md)
40
+ - [stages](plugins/stages/README.md)
41
+ - [stageBuilds](plugins/stageBuilds/README.md)
40
42
  - [templates](plugins/templates/README.md)
41
43
  - [tokens](plugins/tokens/README.md)
42
44
  - [webhooks](plugins/webhooks/README.md)
@@ -54,6 +54,7 @@ async function registerResourcePlugins(server, config) {
54
54
  'templates',
55
55
  'tokens',
56
56
  'secrets',
57
+ 'stages',
57
58
  'users',
58
59
  'webhooks',
59
60
  'stats',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.120",
3
+ "version": "7.0.122",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -139,7 +139,9 @@ Arguments:
139
139
 
140
140
  #### Get all stages for a single pipeline
141
141
 
142
- `GET /pipelines/{id}/stages`
142
+ `page`, `count`, `sort`, `sortBy`, and `name` optional
143
+
144
+ `GET /pipelines/{id}/stages?page={pageNumber}&count={countNumber}&sort={sort}&name={stageName}`
143
145
 
144
146
  #### Get all pipeline secrets
145
147
 
@@ -4,7 +4,8 @@ const boom = require('@hapi/boom');
4
4
  const joi = require('joi');
5
5
  const schema = require('screwdriver-data-schema');
6
6
  const pipelineIdSchema = schema.models.pipeline.base.extract('id');
7
- const stageListSchema = joi.array().items(schema.models.stage.base).label('List of stages');
7
+ const nameSchema = schema.models.stage.base.extract('name');
8
+ const stageListSchema = schema.models.stage.list;
8
9
 
9
10
  module.exports = () => ({
10
11
  method: 'GET',
@@ -20,6 +21,7 @@ module.exports = () => ({
20
21
 
21
22
  handler: async (request, h) => {
22
23
  const { pipelineFactory, stageFactory } = request.server.app;
24
+ const { name, sort, sortBy, page, count } = request.query;
23
25
  const pipelineId = request.params.id;
24
26
 
25
27
  return pipelineFactory
@@ -30,9 +32,31 @@ module.exports = () => ({
30
32
  }
31
33
 
32
34
  const config = {
33
- params: { pipelineId }
35
+ params: { pipelineId },
36
+ sort
34
37
  };
35
38
 
39
+ if (name) {
40
+ config.params = {
41
+ ...config.params,
42
+ name
43
+ };
44
+ }
45
+
46
+ if (sortBy) {
47
+ config.sortBy = sortBy;
48
+ }
49
+
50
+ if (page) {
51
+ config.paginate = config.paginate || {};
52
+ config.paginate.page = page;
53
+ }
54
+
55
+ if (count) {
56
+ config.paginate = config.paginate || {};
57
+ config.paginate.count = count;
58
+ }
59
+
36
60
  return stageFactory.list(config);
37
61
  })
38
62
  .then(stages => h.response(stages.map(s => s.toJson())))
@@ -49,6 +73,7 @@ module.exports = () => ({
49
73
  }),
50
74
  query: schema.api.pagination.concat(
51
75
  joi.object({
76
+ name: nameSchema,
52
77
  search: joi.forbidden() // we don't support search for Pipeline list stages
53
78
  })
54
79
  )
@@ -27,6 +27,11 @@ server.register({
27
27
 
28
28
  ### Routes
29
29
 
30
+ #### Get single stage
31
+
32
+ `GET /stages/{id}`
33
+
30
34
  #### Get a listing of all stage builds for a stage
31
35
 
32
36
  `GET /stages/{id}/stageBuilds`
37
+ `GET /stages/{id}/stageBuilds?eventId={eventId}`
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const boom = require('@hapi/boom');
4
+ const joi = require('joi');
5
+ const schema = require('screwdriver-data-schema');
6
+ const getSchema = schema.models.stage.get;
7
+ const idSchema = schema.models.stage.base.extract('id');
8
+
9
+ module.exports = () => ({
10
+ method: 'GET',
11
+ path: '/stages/{id}',
12
+ options: {
13
+ description: 'Get a single stage',
14
+ notes: 'Returns a stage record',
15
+ tags: ['api', 'stages'],
16
+ auth: {
17
+ strategies: ['token'],
18
+ scope: ['user', 'build', 'pipeline']
19
+ },
20
+
21
+ handler: async (request, h) => {
22
+ const { stageFactory } = request.server.app;
23
+
24
+ return stageFactory
25
+ .get(request.params.id)
26
+ .then(model => {
27
+ if (!model) {
28
+ throw boom.notFound(`Stage ${request.params.id} does not exist`);
29
+ }
30
+
31
+ return h.response(model.toJson());
32
+ })
33
+ .catch(err => {
34
+ throw err;
35
+ });
36
+ },
37
+ response: {
38
+ schema: getSchema
39
+ },
40
+ validate: {
41
+ params: joi.object({
42
+ id: idSchema
43
+ })
44
+ }
45
+ }
46
+ });
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const getStageBuildsRoute = require('./stageBuilds/list');
4
+ const getRoute = require('./get');
4
5
 
5
6
  /**
6
7
  * Stage API Plugin
@@ -12,7 +13,7 @@ const getStageBuildsRoute = require('./stageBuilds/list');
12
13
  const stagesPlugin = {
13
14
  name: 'stages',
14
15
  async register(server) {
15
- server.route([getStageBuildsRoute()]);
16
+ server.route([getStageBuildsRoute(), getRoute()]);
16
17
  }
17
18
  };
18
19
 
@@ -29,9 +29,9 @@ module.exports = () => ({
29
29
  }
30
30
  };
31
31
 
32
- return stageFactory.get(config.params.stageId).then(async stage => {
32
+ return stageFactory.get(request.params.id).then(async stage => {
33
33
  if (!stage) {
34
- throw boom.notFound(`Stage ${config.params.stageId} does not exist`);
34
+ throw boom.notFound(`Stage ${request.params.id} does not exist`);
35
35
  }
36
36
 
37
37
  if (page || count) {
@@ -60,7 +60,9 @@ module.exports = () => ({
60
60
  }),
61
61
  query: schema.api.pagination.concat(
62
62
  joi.object({
63
- eventId: eventIdSchema
63
+ eventId: eventIdSchema,
64
+ search: joi.forbidden(), // we don't support search for Stage list stageBuilds
65
+ getCount: joi.forbidden()
64
66
  })
65
67
  )
66
68
  }