diff --git a/provisioning/service/devdoc/provisioningserviceclient.md b/provisioning/service/devdoc/provisioningserviceclient.md index 35819647c..eea8a1a04 100644 --- a/provisioning/service/devdoc/provisioningserviceclient.md +++ b/provisioning/service/devdoc/provisioningserviceclient.md @@ -208,19 +208,19 @@ GET /registrations/?api-version= HTTP/1.1 Authorization: ``` **]** -### runBulkOperation(bulkOperation, bulkOperationCallback) -The `runBulkOperation` can perform CRUD operations on IndividualEnrollment objects in bulk. +### runBulkEnrollmentOperation(bulkEnrollmentOperation, bulkEnrollmentOperationCallback) +The `runBulkEnrollmentOperation` can perform CRUD operations on IndividualEnrollment objects in bulk. -**SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_038: [** The `runBulkOperation` method shall throw `ReferenceError` if the `bulkOperation` argument is falsy. **]** +**SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_038: [** The `runBulkEnrollmentOperation` method shall throw `ReferenceError` if the `bulkEnrollmentOperation` argument is falsy. **]** -**SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_039: [** The `runBulkOperation` method shall construct an HTTP request using information supplied by the caller as follows: +**SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_039: [** The `runBulkEnrollmentOperation` method shall construct an HTTP request using information supplied by the caller as follows: ``` POST /enrollments?api-version= HTTP/1.1 Authorization: Accept: application/json Content-Type: application/json; charset=utf-8 - + ``` **]** ### Generic HTTP Requirements diff --git a/provisioning/service/samples/run_bulk_operation.js b/provisioning/service/samples/run_bulk_operation.js index dd77123db..334dc91b5 100644 --- a/provisioning/service/samples/run_bulk_operation.js +++ b/provisioning/service/samples/run_bulk_operation.js @@ -46,26 +46,26 @@ badCreateBulkOperation.enrollments.push(enrollment2); badCreateBulkOperation.enrollments.push(enrollment2); // -// runBulkOperation has two different ways that errors can be indicated to the +// runBulkEnrollmentOperation has two different ways that errors can be indicated to the // caller. The err parameter on the callback or through the result parameter // on the callback. // -// This first runBulkOperation will fail. The reason it fails is because we have -// a duplicate entry in the bulk array. This will NOT produce a BulkOperationResult. +// This first runBulkEnrollmentOperation will fail. The reason it fails is because we have +// a duplicate entry in the bulk array. This will NOT produce a BulkEnrollmentOperationResult. // -serviceClient.runBulkOperation(badCreateBulkOperation, function(err, result) { +serviceClient.runBulkEnrollmentOperation(badCreateBulkOperation, function(err, result) { if (err) { console.log('The bulk operation result is: ' + err); } console.log('The value of the result operation should be undefined: ',JSON.stringify(result, null, 2)); // // Get rid of the duplicate entry and put in an entry without an actual attestation. - // Some of the bulk create will work but we should get a BulkOperationResult + // Some of the bulk create will work but we should get a BulkEnrollmentOperationResult // that indicates the third one failed. // badCreateBulkOperation.enrollments.splice(2,1); badCreateBulkOperation.enrollments.push(enrollment3); - serviceClient.runBulkOperation(badCreateBulkOperation, function(err, result) { + serviceClient.runBulkEnrollmentOperation(badCreateBulkOperation, function(err, result) { console.log('The err parameter should be null for this second bulkOperation call, err: ' + err); console.log('The value of the result operation should indicate the third enrollment was bad: ' + JSON.stringify(result, null, 2)); serviceClient.getIndividualEnrollment(enrollment1.registrationId, function(err, completeEnrollment1) { @@ -84,8 +84,8 @@ serviceClient.runBulkOperation(badCreateBulkOperation, function(err, result) { }; deleteBulkOperation.enrollments.push(completeEnrollment1); deleteBulkOperation.enrollments.push(completeEnrollment2); - serviceClient.runBulkOperation(deleteBulkOperation, function(err, result) { - console.log('The err parameter should be null for this delete runBulkOperation call, err: ' + err); + serviceClient.runBulkEnrollmentOperation(deleteBulkOperation, function(err, result) { + console.log('The err parameter should be null for this delete runBulkEnrollmentOperation call, err: ' + err); console.log('The value of the result operation should indicate success and no errors: ' + JSON.stringify(result, null, 2)); }); } diff --git a/provisioning/service/src/interfaces.ts b/provisioning/service/src/interfaces.ts index 8ba5cd7bd..aaa5b13a1 100644 --- a/provisioning/service/src/interfaces.ts +++ b/provisioning/service/src/interfaces.ts @@ -65,6 +65,11 @@ export interface X509Attestation { * suitable for signing other certificates. */ signingCertificates: X509Certificates; + /** + * Primary and secondary CA reference. These will be names rather than + * actual certificates. + */ + caReferences: X509CAReferences; } /** @@ -145,10 +150,21 @@ export interface X509Certificates { secondary: X509CertificateWithInfo; } +export interface X509CAReferences { + /** + * The name of the primary CA certificate. + */ + primary: string; + /** + * The name of the secondary CA certificate. + */ + secondary: string; +} + /** * Bulk operation */ -export interface BulkOperation { +export interface BulkEnrollmentOperation { /** * The mode property specifies the operation that will be performed upon all * of the IndividualEnrollment elements in the enrollments property. @@ -171,7 +187,7 @@ export type BulkOperationMode = 'create' | 'update' | 'updateIfMatchEtag' | 'del /** * Bulk operation result */ -export interface BulkOperationResult { +export interface BulkEnrollmentOperationResult { /** * If isSuccessful is true then all CRUD operations for a bulkOperation * were successful. Otherwise there will be at least one element in the @@ -180,7 +196,7 @@ export interface BulkOperationResult { isSuccessful: boolean; /** * Will provide information as to why particular CRUD operations failed for - * a runBulkOperation invocation. The array will be zero length if + * a runBulkEnrollmentOperation invocation. The array will be zero length if * isSuccessful is true. */ errors: Array; @@ -191,7 +207,7 @@ export interface BulkOperationResult { */ export interface DeviceRegistrationOperationError { /** - * The id of the the IndividualEnrollment object that was in error during a runBulkOperation invocation. + * The id of the the IndividualEnrollment object that was in error during a runBulkEnrollmentOperation invocation. */ registrationId: string; /** @@ -284,7 +300,7 @@ export interface IndividualEnrollment { /** * The initial twin document that will be created for this device upon its provisioning. */ - initialTwinState: TwinState; + initialTwin: InitialTwin; /** * An opaque value suitable to uniquely identify a particular generation * of this object for use during a CRUD operation. @@ -332,7 +348,7 @@ export interface EnrollmentGroup { /** * The initial twin document that will be created for devices upon their provisioning. */ - initialTwinState: TwinState; + initialTwin: InitialTwin; /** * An opaque value suitable to uniquely identify a particular generation * of this object for use during a CRUD operation. @@ -372,7 +388,7 @@ export interface TwinCollection { /** * Device twin state. */ -export interface TwinState { +export interface InitialTwin { tags: TwinCollection; properties: { desired: TwinCollection; diff --git a/provisioning/service/src/provisioningserviceclient.ts b/provisioning/service/src/provisioningserviceclient.ts index 3e89b883b..3cfe7ce2e 100644 --- a/provisioning/service/src/provisioningserviceclient.ts +++ b/provisioning/service/src/provisioningserviceclient.ts @@ -6,7 +6,7 @@ import { errors, SharedAccessSignature, ConnectionString } from 'azure-iot-common'; import { RestApiClient } from 'azure-iot-http-base'; import { QuerySpecification, Query, QueryCallback } from './query'; -import { IndividualEnrollment, EnrollmentGroup, DeviceRegistrationState, BulkOperation, BulkOperationResult } from './interfaces'; +import { IndividualEnrollment, EnrollmentGroup, DeviceRegistrationState, BulkEnrollmentOperation, BulkEnrollmentOperationResult } from './interfaces'; // tslint:disable-next-line:no-var-requires const packageJson = require('../package.json'); @@ -147,15 +147,15 @@ export class ProvisioningServiceClient { } /** - * @method module:azure-iot-provisioning-service.ProvisioningServiceClient#runBulkOperation + * @method module:azure-iot-provisioning-service.ProvisioningServiceClient#runBulkEnrollmentOperation * @description Runs a number CRUD operations on an array of enrollment records. - * @param {object} bulkOperation An object that specifies the single kind of CRUD operations on the array of IndividualEnrollment objects that are also part of the object. + * @param {object} bulkEnrollmentOperation An object that specifies the single kind of CRUD operations on the array of IndividualEnrollment objects that are also part of the object. * @param {function} callback Invoked upon completion of the operation. */ - public runBulkOperation(bulkOperation: BulkOperation, callback?: (err: Error, bulkOperationResult?: BulkOperationResult, response?: any) => void): void { - /*Codes_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_038: [The `runBulkOperation` method shall throw `ReferenceError` if the `bulkOperation` argument is falsy.] */ - if (!bulkOperation) { - throw new ReferenceError('Required runBulkOperation property was null or undefined when calling bulkOperation.'); + public runBulkEnrollmentOperation(bulkEnrollmentOperation: BulkEnrollmentOperation, callback?: (err: Error, bulkEnrollmentOperationResult?: BulkEnrollmentOperationResult, response?: any) => void): void { + /*Codes_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_038: [The `runBulkEnrollmentOperation` method shall throw `ReferenceError` if the `bulkEnrollmentOperation` argument is falsy.] */ + if (!bulkEnrollmentOperation) { + throw new ReferenceError('Required bulkEnrollmentOperation parameter was falsy when calling runBulkEnrollmentOperation.'); } const path = this._enrollmentsPrefix + this._versionQueryString(); @@ -165,20 +165,20 @@ export class ProvisioningServiceClient { 'Content-Type': 'application/json; charset=utf-8' }; - /*Codes_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_039: [** The `runBulkOperation` method shall construct an HTTP request using information supplied by the caller as follows: + /*Codes_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_039: [** The `runBulkEnrollmentOperation` method shall construct an HTTP request using information supplied by the caller as follows: POST /enrollments?api-version= HTTP/1.1 Authorization: Accept: application/json Content-Type: application/json; charset=utf-8 - + ] */ - this._restApiClient.executeApiCall('POST', path, httpHeaders, bulkOperation, (err, bulkOperationResult, httpResponse) => { + this._restApiClient.executeApiCall('POST', path, httpHeaders, bulkEnrollmentOperation, (err, bulkEnrollmentOperationResult, httpResponse) => { if (callback) { if (err) { callback(err); } else { - callback(null, bulkOperationResult, httpResponse); + callback(null, bulkEnrollmentOperationResult, httpResponse); } } }); diff --git a/provisioning/service/src/query.ts b/provisioning/service/src/query.ts index 31f1dd982..543dbccc6 100644 --- a/provisioning/service/src/query.ts +++ b/provisioning/service/src/query.ts @@ -64,7 +64,7 @@ export class Query { if (err) { actualCallback(err); } else { - this.continuationToken = response.headers['x-ms-continuation']; + this.continuationToken = response.headers['x-ms-continuation'] as string; this.hasMoreResults = this.continuationToken !== undefined; /*Codes_SRS_NODE_SERVICE_QUERY_16_007: [The `next` method shall call the `done` callback with a `null` error object, the results of the query and the response of the underlying transport if the request was successful.]*/ diff --git a/provisioning/service/test/_provisioningserviceclient_test.js b/provisioning/service/test/_provisioningserviceclient_test.js index f914f887d..f2c06c0a0 100644 --- a/provisioning/service/test/_provisioningserviceclient_test.js +++ b/provisioning/service/test/_provisioningserviceclient_test.js @@ -474,24 +474,24 @@ describe('ProvisioningServiceClient', function() { testGetAPI('getDeviceRegistrationState', '/registrations/'); - describe('#runBulkOperation', function() { - /*Tests_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_038: [The `runBulkOperation` method shall throw `ReferenceError` if the `bulkOperation` argument is falsy.] */ + describe('#runBulkEnrollmentOperation', function() { + /*Tests_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_038: [The `runBulkEnrollmentOperation` method shall throw `ReferenceError` if the `bulkEnrollmentOperation` argument is falsy.] */ [undefined, null].forEach(function(bo) { - testFalsyArg('runBulkOperation', 'bulkOperation', bo, ReferenceError); + testFalsyArg('runBulkEnrollmentOperation', 'bulkEnrollmentOperation', bo, ReferenceError); }); var fakeBo = {mode: 'update', enrollments: [fakeEnrollment]}; - testErrorCallback('runBulkOperation', fakeBo); + testErrorCallback('runBulkEnrollmentOperation', fakeBo); - /*Tests_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_039: [** The `runBulkOperation` method shall construct an HTTP request using information supplied by the caller as follows: + /*Tests_SRS_NODE_PROVISIONING_SERVICE_CLIENT_06_039: [** The `runBulkEnrollmentOperation` method shall construct an HTTP request using information supplied by the caller as follows: POST /enrollments?api-version= HTTP/1.1 Authorization: Accept: application/json Content-Type: application/json; charset=utf-8 - + ] */ - it('Constructs a valid HTTP request for bulkOperation parameter', function(testCallback) { + it('Constructs a valid HTTP request for bulkEnrollmentOperation parameter', function(testCallback) { var fakeHttpHelper = { executeApiCall: function (method, path, httpHeaders, body, done) { assert.equal(method, 'POST'); @@ -505,7 +505,7 @@ describe('ProvisioningServiceClient', function() { }; var de = new ProvisioningServiceClient({ host: 'host', sharedAccessSignature: 'sas' }, fakeHttpHelper); - de.runBulkOperation(fakeBo, testCallback); + de.runBulkEnrollmentOperation(fakeBo, testCallback); }); }); }); \ No newline at end of file