Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #457 Collection Name Parameter for create collection #460

Merged
merged 3 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions discovery/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ DiscoveryV1.prototype.deleteEnvironment = function(params, callback) {

/**
* Create a new configuration
*
*
* @param {String} params.environment_id - the ID of your environment
* @param {Object} params.file - Input a JSON object that enables you to customize how your content is ingested and what enrichments are added to your data.
* @param {Object} params.file - Input a JSON object that enables you to customize how your content is ingested and what enrichments are added to your data.
*/
DiscoveryV1.prototype.createConfiguration = function(params, callback) {
params = params || {};
Expand All @@ -206,9 +206,9 @@ DiscoveryV1.prototype.createConfiguration = function(params, callback) {

/**
* Update an existing configuration for a given environment
*
*
* @param {String} params.environment_id - the ID of your environment
* @param {String} params.configuration_id - the ID of your configuration
* @param {String} params.configuration_id - the ID of your configuration
* @param {Object} params.file - Input a JSON object that enables you to update and customize how your data is ingested and what enrichments are added to your data.
*/

Expand Down Expand Up @@ -329,7 +329,7 @@ DiscoveryV1.prototype.getCollection = function(params, callback) {
*
* @param {Object} params
* @param {String} params.environment_id environment guid for the collection
* @param {string} params.collection_name
* @param {string} params.name
* @param {string} params.description
* @param {string} params.configuration_id configuration to create the collection in
* @param {string} params.language_code currently, only `en_us` is supported
Expand All @@ -347,13 +347,13 @@ DiscoveryV1.prototype.createCollection = function(params, callback) {
multipart: [
{
'content-type': 'application/json',
body: JSON.stringify(pick(params, ['collection_name', 'description', 'configuration_id', 'language_code']))
body: JSON.stringify(pick(params, ['name', 'description', 'configuration_id', 'language_code']))
}
],
json: true
},
originalParams: params,
requiredParams: ['environment_id', 'configuration_id', 'collection_name'],
requiredParams: ['environment_id', 'configuration_id', 'name'],
defaultOptions: this._options
};
return requestFactory(parameters, callback);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test.discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe.skip('discovery_integration', function() {
discovery.createCollection(
{
environment_id: environment_id,
collection_name: 'node-sdk-test-' + Date.now(),
name: 'node-sdk-test-' + Date.now(),
description: 'Test collection created by the Node.js SDK integration tests on ' + new Date() + '. Should be deleted shortly',
configuration_id: configuration_id,
language_code: 'en_us'
Expand Down
14 changes: 14 additions & 0 deletions test/unit/test.discovery.v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ describe('discovery-v1', function() {
assert.equal(req.method, 'DELETE');
});

it('should create a collection in an environment', function() {
const req = discovery.createCollection(
{
environment_id: 'env-guid',
configuration_id: 'config-guid',
name: 'new collection',
description: 'my description'
},
noop
);
assert.equal(req.uri.href, service.url + paths.collections + '?version=' + service.version_date);
assert.equal(req.method, 'POST');
});

it('should get collections from an environment', function() {
const req = discovery.getCollections({ environment_id: 'env-guid' }, noop);
assert.equal(req.uri.href, service.url + paths.collections + '?version=' + service.version_date);
Expand Down