screwdriver-api 6.0.7 → 6.0.9
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/package.json
CHANGED
|
@@ -58,6 +58,18 @@ You can get a single template by providing the template name and the specific ve
|
|
|
58
58
|
* `tag` - Tag of the template (e.g. `stable`, `latest`, etc)
|
|
59
59
|
* `version` - Version of the template
|
|
60
60
|
|
|
61
|
+
##### Get a single template using templateId
|
|
62
|
+
|
|
63
|
+
You can get a single template by providing the template id.
|
|
64
|
+
|
|
65
|
+
`GET /templates/{id}`
|
|
66
|
+
|
|
67
|
+
###### Arguments
|
|
68
|
+
|
|
69
|
+
'id'
|
|
70
|
+
|
|
71
|
+
* `id` - Id of the template
|
|
72
|
+
|
|
61
73
|
##### Create a template
|
|
62
74
|
Creating a template will store the template data (`config`, `name`, `version`, `description`, `maintainer`) into the datastore.
|
|
63
75
|
|
|
@@ -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.template.get;
|
|
7
|
+
const idSchema = schema.models.template.base.extract('id');
|
|
8
|
+
|
|
9
|
+
module.exports = () => ({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/template/{id}',
|
|
12
|
+
options: {
|
|
13
|
+
description: 'Get a single template',
|
|
14
|
+
notes: 'Returns a template record',
|
|
15
|
+
tags: ['api', 'templates'],
|
|
16
|
+
auth: {
|
|
17
|
+
strategies: ['token'],
|
|
18
|
+
scope: ['user', 'build']
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
handler: async (request, h) => {
|
|
22
|
+
const { templateFactory } = request.server.app;
|
|
23
|
+
|
|
24
|
+
return templateFactory
|
|
25
|
+
.get({ id: request.params.id })
|
|
26
|
+
.then(async template => {
|
|
27
|
+
if (!template) {
|
|
28
|
+
throw boom.notFound('Template does not exist');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return h.response(template);
|
|
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
|
+
});
|
|
@@ -11,6 +11,7 @@ const listVersionsWithMetricsRouter = require('./listVersionsWithMetric');
|
|
|
11
11
|
const removeRoute = require('./remove');
|
|
12
12
|
const removeTagRoute = require('./removeTag');
|
|
13
13
|
const updateTrustedRoute = require('./updateTrusted');
|
|
14
|
+
const getTemplateByIdRoute = require('./getTemplateById');
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Template API Plugin
|
|
@@ -83,7 +84,8 @@ const templatesPlugin = {
|
|
|
83
84
|
listVersionsWithMetricsRouter(),
|
|
84
85
|
removeRoute(),
|
|
85
86
|
removeTagRoute(),
|
|
86
|
-
updateTrustedRoute()
|
|
87
|
+
updateTrustedRoute(),
|
|
88
|
+
getTemplateByIdRoute()
|
|
87
89
|
]);
|
|
88
90
|
}
|
|
89
91
|
};
|