Skip to content

Commit e1912b5

Browse files
committed
Merge branch 'rahulmukherjeedurga-watson-developer-cloud/master'
2 parents 5ee2822 + 19869f1 commit e1912b5

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

discovery/v1.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,34 @@ DiscoveryV1.prototype.createEnvironment = function(params, callback) {
9999
return requestFactory(parameters, callback);
100100
};
101101

102+
/**
103+
* Update an existing environment
104+
* @param {string} environment_id(required)
105+
* @param {string} name(required)
106+
* @param {string} description(optional)
107+
*/
108+
DiscoveryV1.prototype.updateEnvironment = function(params, callback) {
109+
params = params || {};
110+
const parameters = {
111+
options: {
112+
url: '/v1/environments/{environment_id}',
113+
method: 'PUT',
114+
path: pick(params, ['environment_id']),
115+
multipart: [
116+
{
117+
'content-type': 'application/json',
118+
body: JSON.stringify(pick(params, ['name', 'description']))
119+
}
120+
],
121+
json: true
122+
},
123+
originalParams: params,
124+
requiredParams: ['environment_id', 'name'],
125+
defaultOptions: this._options
126+
};
127+
return requestFactory(parameters, callback);
128+
};
129+
102130
/**
103131
* Get details about an environment
104132
*

test/unit/test.discovery.v1.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ describe('discovery-v1', function() {
4747
.reply(200, { environment_id: 'yes' })
4848
.get(paths.environmentinfo + '?version=' + service.version_date)
4949
.reply(200, { environment_id: 'info' })
50+
.put(paths.environmentinfo + '?version=' + service.version_date)
51+
.reply(200, { environment_id: 'yes' })
5052
.delete(paths.environmentinfo + '?version=' + service.version_date)
5153
.reply(200, { environment_id: 'info' })
5254
.get(paths.collections + '?version=' + service.version_date)
@@ -99,6 +101,18 @@ describe('discovery-v1', function() {
99101
assert.equal(req.method, 'POST');
100102
});
101103

104+
it('should update an environment', function() {
105+
const req = discovery.updateEnvironment(
106+
{
107+
environment_id: 'env-guid',
108+
name: 'my environment updated',
109+
description: 'my description updated'
110+
},
111+
noop
112+
);
113+
assert.equal(req.method, 'PUT');
114+
});
115+
102116
it('should get an environment information', function() {
103117
const req = discovery.getEnvironment({ environment_id: 'env-guid' }, noop);
104118
assert.equal(req.uri.href, service.url + paths.environmentinfo + '?version=' + service.version_date);

0 commit comments

Comments
 (0)