diff --git a/lib/services/customVision/prediction/LICENSE.txt b/lib/services/customVision/prediction/LICENSE.txt index 5431ba98b9..8f3d856145 100644 --- a/lib/services/customVision/prediction/LICENSE.txt +++ b/lib/services/customVision/prediction/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Microsoft +Copyright (c) 2019 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/services/customVision/prediction/README.md b/lib/services/customVision/prediction/README.md index 3c3b032fd4..fa1e5da83a 100644 --- a/lib/services/customVision/prediction/README.md +++ b/lib/services/customVision/prediction/README.md @@ -1,50 +1,50 @@ ---- -uid: azure-cognitiveservices-customvision-prediction -summary: *content - ---- -**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** -## Microsoft Azure SDK for Node.js - PredictionAPIClient - -This project provides a Node.js package for accessing Azure. Right now it supports: -- **Node.js version 6.x.x or higher** - -### Features - - -### How to Install - -```bash -npm install azure-cognitiveservices-customvision-prediction -``` - -### How to use - -#### Authentication, client creation, and predictImageUrl as an example. - -```javascript -const msRest = require("ms-rest"); -const PredictionAPIClient = require("azure-cognitiveservices-customvision-prediction"); -const token = ""; -const creds = new msRest.TokenCredentials(token); -const subscriptionId = ""; -const client = new PredictionAPIClient(creds, subscriptionId); -const projectId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; -const imageUrl = { - url: "testurl" -}; -const iterationId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; -const application = "testapplication"; - -client.predictImageUrl(projectId, imageUrl, iterationId, application).then((result) => { - console.log("The result is:"); - console.log(result); -}).catch((err) => { - console.log('An error occurred:'); - console.dir(err, {depth: null, colors: true}); -}); -``` - -### Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) +--- +uid: azure-cognitiveservices-customvision-prediction +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** +## Microsoft Azure SDK for Node.js - PredictionAPIClient + +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-cognitiveservices-customvision-prediction +``` + +### How to use + +#### Authentication, client creation, and classifyImageUrl as an example. + +```javascript +const msRest = require("ms-rest"); +const PredictionAPIClient = require("azure-cognitiveservices-customvision-prediction"); +const token = ""; +const creds = new msRest.TokenCredentials(token); +const subscriptionId = ""; +const client = new PredictionAPIClient(creds, subscriptionId); +const projectId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a; +const name = "testname"; +const imageUrl = { + url: "testurl" +}; +const application = "testapplication"; + +client.classifyImageUrl(projectId, name, imageUrl, application).then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); +``` + +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/customVision/prediction/lib/models/boundingBox.js b/lib/services/customVision/prediction/lib/models/boundingBox.js index 1dd1a18c05..98c7d72515 100644 --- a/lib/services/customVision/prediction/lib/models/boundingBox.js +++ b/lib/services/customVision/prediction/lib/models/boundingBox.js @@ -11,15 +11,16 @@ 'use strict'; /** - * Class representing a BoundingBox. + * Bounding box that defines a region of an image. + * */ class BoundingBox { /** * Create a BoundingBox. - * @property {number} [left] - * @property {number} [top] - * @property {number} [width] - * @property {number} [height] + * @property {number} [left] Coordinate of the left boundary. + * @property {number} [top] Coordinate of the top boundary. + * @property {number} [width] Width. + * @property {number} [height] Height. */ constructor() { } diff --git a/lib/services/customVision/prediction/lib/models/customVisionError.js b/lib/services/customVision/prediction/lib/models/customVisionError.js new file mode 100644 index 0000000000..6419cea1cc --- /dev/null +++ b/lib/services/customVision/prediction/lib/models/customVisionError.js @@ -0,0 +1,117 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a CustomVisionError. + */ +class CustomVisionError { + /** + * Create a CustomVisionError. + * @property {string} code The error code. Possible values include: + * 'NoError', 'BadRequest', 'BadRequestExceededBatchSize', + * 'BadRequestNotSupported', 'BadRequestInvalidIds', 'BadRequestProjectName', + * 'BadRequestProjectNameNotUnique', 'BadRequestProjectDescription', + * 'BadRequestProjectUnknownDomain', + * 'BadRequestProjectUnknownClassification', + * 'BadRequestProjectUnsupportedDomainTypeChange', 'BadRequestIterationName', + * 'BadRequestIterationNameNotUnique', 'BadRequestIterationDescription', + * 'BadRequestIterationIsNotTrained', 'BadRequestWorkspaceCannotBeModified', + * 'BadRequestWorkspaceNotDeletable', 'BadRequestTagName', + * 'BadRequestTagNameNotUnique', 'BadRequestTagDescription', + * 'BadRequestTagType', 'BadRequestMultipleNegativeTag', + * 'BadRequestImageTags', 'BadRequestImageRegions', + * 'BadRequestNegativeAndRegularTagOnSameImage', + * 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + * 'BadRequestSubscriptionApi', 'BadRequestPublishFailed', + * 'BadRequestUnpublishFailed', 'BadRequestExceedProjectLimit', + * 'BadRequestExceedIterationPerProjectLimit', + * 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', + * 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', + * 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', + * 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', + * 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', + * 'BadRequestTrainingNotNeeded', 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', + * 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', + * 'BadRequestExportValidationFailed', 'BadRequestExportAlreadyInProgress', + * 'BadRequestPredictionIdsMissing', 'BadRequestPredictionIdsExceededCount', + * 'BadRequestPredictionTagsExceededCount', + * 'BadRequestPredictionResultsExceededCount', + * 'BadRequestPredictionInvalidApplicationName', + * 'BadRequestPredictionInvalidQueryParameters', 'BadRequestInvalid', + * 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', + * 'ForbiddenUserResource', 'ForbiddenUserSignupDisabled', + * 'ForbiddenUserSignupAllowanceExceeded', 'ForbiddenUserDoesNotExist', + * 'ForbiddenUserDisabled', 'ForbiddenUserInsufficientCapability', + * 'ForbiddenDRModeEnabled', 'ForbiddenInvalid', 'NotFound', + * 'NotFoundProject', 'NotFoundProjectDefaultIteration', 'NotFoundIteration', + * 'NotFoundIterationPerformance', 'NotFoundTag', 'NotFoundImage', + * 'NotFoundDomain', 'NotFoundApimSubscription', 'NotFoundInvalid', + * 'Conflict', 'ConflictInvalid', 'ErrorUnknown', + * 'ErrorProjectInvalidWorkspace', + * 'ErrorProjectInvalidPipelineConfiguration', 'ErrorProjectInvalidDomain', + * 'ErrorProjectTrainingRequestFailed', 'ErrorProjectExportRequestFailed', + * 'ErrorFeaturizationServiceUnavailable', 'ErrorFeaturizationQueueTimeout', + * 'ErrorFeaturizationInvalidFeaturizer', + * 'ErrorFeaturizationAugmentationUnavailable', + * 'ErrorFeaturizationUnrecognizedJob', + * 'ErrorFeaturizationAugmentationError', 'ErrorExporterInvalidPlatform', + * 'ErrorExporterInvalidFeaturizer', 'ErrorExporterInvalidClassifier', + * 'ErrorPredictionServiceUnavailable', 'ErrorPredictionModelNotFound', + * 'ErrorPredictionModelNotCached', 'ErrorPrediction', + * 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorInvalid' + * @property {string} message A message explaining the error reported by the + * service. + */ + constructor() { + } + + /** + * Defines the metadata of CustomVisionError + * + * @returns {object} metadata of CustomVisionError + * + */ + mapper() { + return { + required: false, + serializedName: 'CustomVisionError', + type: { + name: 'Composite', + className: 'CustomVisionError', + modelProperties: { + code: { + required: true, + nullable: false, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CustomVisionError; diff --git a/lib/services/customVision/prediction/lib/models/imagePrediction.js b/lib/services/customVision/prediction/lib/models/imagePrediction.js index 682587f610..8aeb9ac3ef 100644 --- a/lib/services/customVision/prediction/lib/models/imagePrediction.js +++ b/lib/services/customVision/prediction/lib/models/imagePrediction.js @@ -11,16 +11,17 @@ 'use strict'; /** - * Class representing a ImagePrediction. + * Result of an image prediction request. + * */ class ImagePrediction { /** * Create a ImagePrediction. - * @property {uuid} [id] - * @property {uuid} [project] - * @property {uuid} [iteration] - * @property {date} [created] - * @property {array} [predictions] + * @property {uuid} [id] Prediction Id. + * @property {uuid} [project] Project Id. + * @property {uuid} [iteration] Iteration Id. + * @property {date} [created] Date this prediction was created. + * @property {array} [predictions] List of predictions. */ constructor() { } diff --git a/lib/services/customVision/prediction/lib/models/imageUrl.js b/lib/services/customVision/prediction/lib/models/imageUrl.js index 31cb128ce9..5bad1fbc0d 100644 --- a/lib/services/customVision/prediction/lib/models/imageUrl.js +++ b/lib/services/customVision/prediction/lib/models/imageUrl.js @@ -11,12 +11,13 @@ 'use strict'; /** - * Class representing a ImageUrl. + * Image url. + * */ class ImageUrl { /** * Create a ImageUrl. - * @property {string} [url] + * @property {string} [url] Url of the image. */ constructor() { } diff --git a/lib/services/customVision/prediction/lib/models/index.d.ts b/lib/services/customVision/prediction/lib/models/index.d.ts index eee742031b..dc1fc5e971 100644 --- a/lib/services/customVision/prediction/lib/models/index.d.ts +++ b/lib/services/customVision/prediction/lib/models/index.d.ts @@ -8,28 +8,134 @@ import * as moment from "moment"; +/** + * Image url. + */ export interface ImageUrl { + /** + * Url of the image. + */ url?: string; } +/** + * Bounding box that defines a region of an image. + */ export interface BoundingBox { + /** + * Coordinate of the left boundary. + */ left?: number; + /** + * Coordinate of the top boundary. + */ top?: number; + /** + * Width. + */ width?: number; + /** + * Height. + */ height?: number; } +/** + * Prediction result. + */ export interface Prediction { + /** + * Probability of the tag. + */ readonly probability?: number; + /** + * Id of the predicted tag. + */ readonly tagId?: string; + /** + * Name of the predicted tag. + */ readonly tagName?: string; + /** + * Bounding box of the prediction. + */ readonly boundingBox?: BoundingBox; } +/** + * Result of an image prediction request. + */ export interface ImagePrediction { + /** + * Prediction Id. + */ readonly id?: string; + /** + * Project Id. + */ readonly project?: string; + /** + * Iteration Id. + */ readonly iteration?: string; + /** + * Date this prediction was created. + */ readonly created?: Date; + /** + * List of predictions. + */ readonly predictions?: Prediction[]; } + +export interface CustomVisionError { + /** + * The error code. Possible values include: 'NoError', 'BadRequest', + * 'BadRequestExceededBatchSize', 'BadRequestNotSupported', 'BadRequestInvalidIds', + * 'BadRequestProjectName', 'BadRequestProjectNameNotUnique', 'BadRequestProjectDescription', + * 'BadRequestProjectUnknownDomain', 'BadRequestProjectUnknownClassification', + * 'BadRequestProjectUnsupportedDomainTypeChange', 'BadRequestIterationName', + * 'BadRequestIterationNameNotUnique', 'BadRequestIterationDescription', + * 'BadRequestIterationIsNotTrained', 'BadRequestWorkspaceCannotBeModified', + * 'BadRequestWorkspaceNotDeletable', 'BadRequestTagName', 'BadRequestTagNameNotUnique', + * 'BadRequestTagDescription', 'BadRequestTagType', 'BadRequestMultipleNegativeTag', + * 'BadRequestImageTags', 'BadRequestImageRegions', 'BadRequestNegativeAndRegularTagOnSameImage', + * 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', 'BadRequestSubscriptionApi', + * 'BadRequestPublishFailed', 'BadRequestUnpublishFailed', 'BadRequestExceedProjectLimit', + * 'BadRequestExceedIterationPerProjectLimit', 'BadRequestExceedTagPerProjectLimit', + * 'BadRequestExceedTagPerImageLimit', 'BadRequestExceededQuota', + * 'BadRequestCannotMigrateProjectWithName', 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', + * 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', + * 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', + * 'BadRequestTrainingValidationFailed', 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', 'BadRequestExportValidationFailed', + * 'BadRequestExportAlreadyInProgress', 'BadRequestPredictionIdsMissing', + * 'BadRequestPredictionIdsExceededCount', 'BadRequestPredictionTagsExceededCount', + * 'BadRequestPredictionResultsExceededCount', 'BadRequestPredictionInvalidApplicationName', + * 'BadRequestPredictionInvalidQueryParameters', 'BadRequestInvalid', 'UnsupportedMediaType', + * 'Forbidden', 'ForbiddenUser', 'ForbiddenUserResource', 'ForbiddenUserSignupDisabled', + * 'ForbiddenUserSignupAllowanceExceeded', 'ForbiddenUserDoesNotExist', 'ForbiddenUserDisabled', + * 'ForbiddenUserInsufficientCapability', 'ForbiddenDRModeEnabled', 'ForbiddenInvalid', + * 'NotFound', 'NotFoundProject', 'NotFoundProjectDefaultIteration', 'NotFoundIteration', + * 'NotFoundIterationPerformance', 'NotFoundTag', 'NotFoundImage', 'NotFoundDomain', + * 'NotFoundApimSubscription', 'NotFoundInvalid', 'Conflict', 'ConflictInvalid', 'ErrorUnknown', + * 'ErrorProjectInvalidWorkspace', 'ErrorProjectInvalidPipelineConfiguration', + * 'ErrorProjectInvalidDomain', 'ErrorProjectTrainingRequestFailed', + * 'ErrorProjectExportRequestFailed', 'ErrorFeaturizationServiceUnavailable', + * 'ErrorFeaturizationQueueTimeout', 'ErrorFeaturizationInvalidFeaturizer', + * 'ErrorFeaturizationAugmentationUnavailable', 'ErrorFeaturizationUnrecognizedJob', + * 'ErrorFeaturizationAugmentationError', 'ErrorExporterInvalidPlatform', + * 'ErrorExporterInvalidFeaturizer', 'ErrorExporterInvalidClassifier', + * 'ErrorPredictionServiceUnavailable', 'ErrorPredictionModelNotFound', + * 'ErrorPredictionModelNotCached', 'ErrorPrediction', 'ErrorPredictionStorage', + * 'ErrorRegionProposal', 'ErrorInvalid' + */ + code: string; + /** + * A message explaining the error reported by the service. + */ + message: string; +} diff --git a/lib/services/customVision/prediction/lib/models/index.js b/lib/services/customVision/prediction/lib/models/index.js index 5b752d3273..aa25ef3896 100644 --- a/lib/services/customVision/prediction/lib/models/index.js +++ b/lib/services/customVision/prediction/lib/models/index.js @@ -18,3 +18,4 @@ exports.ImageUrl = require('./imageUrl'); exports.BoundingBox = require('./boundingBox'); exports.Prediction = require('./prediction'); exports.ImagePrediction = require('./imagePrediction'); +exports.CustomVisionError = require('./customVisionError'); diff --git a/lib/services/customVision/prediction/lib/models/prediction.js b/lib/services/customVision/prediction/lib/models/prediction.js index b069516a77..3b9e1851af 100644 --- a/lib/services/customVision/prediction/lib/models/prediction.js +++ b/lib/services/customVision/prediction/lib/models/prediction.js @@ -11,19 +11,20 @@ 'use strict'; /** - * Class representing a Prediction. + * Prediction result. + * */ class Prediction { /** * Create a Prediction. - * @property {number} [probability] - * @property {uuid} [tagId] - * @property {string} [tagName] - * @property {object} [boundingBox] - * @property {number} [boundingBox.left] - * @property {number} [boundingBox.top] - * @property {number} [boundingBox.width] - * @property {number} [boundingBox.height] + * @property {number} [probability] Probability of the tag. + * @property {uuid} [tagId] Id of the predicted tag. + * @property {string} [tagName] Name of the predicted tag. + * @property {object} [boundingBox] Bounding box of the prediction. + * @property {number} [boundingBox.left] Coordinate of the left boundary. + * @property {number} [boundingBox.top] Coordinate of the top boundary. + * @property {number} [boundingBox.width] Width. + * @property {number} [boundingBox.height] Height. */ constructor() { } diff --git a/lib/services/customVision/prediction/lib/predictionAPIClient.d.ts b/lib/services/customVision/prediction/lib/predictionAPIClient.d.ts index b5cf3de061..306877821e 100644 --- a/lib/services/customVision/prediction/lib/predictionAPIClient.d.ts +++ b/lib/services/customVision/prediction/lib/predictionAPIClient.d.ts @@ -17,9 +17,9 @@ export default class PredictionAPIClient extends ServiceClient { * Initializes a new instance of the PredictionAPIClient class. * @constructor * - * @param {string} apiKey - + * @param {string} apiKey - API key. * - * @param {string} endpoint - Supported Cognitive Services endpoints + * @param {string} endpoint - Supported Cognitive Services endpoints. * * @param {object} [options] - The parameter options * @@ -39,23 +39,22 @@ export default class PredictionAPIClient extends ServiceClient { /** - * @summary Predict an image url and saves the result + * @summary Classify an image url and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -66,26 +65,25 @@ export default class PredictionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - predictImageUrlWithHttpOperationResponse(projectId: string, imageUrl: models.ImageUrl, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + classifyImageUrlWithHttpOperationResponse(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image url and saves the result + * @summary Classify an image url and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -112,26 +110,25 @@ export default class PredictionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - predictImageUrl(projectId: string, imageUrl: models.ImageUrl, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - predictImageUrl(projectId: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; - predictImageUrl(projectId: string, imageUrl: models.ImageUrl, options: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + classifyImageUrl(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageUrl(projectId: string, name: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + classifyImageUrl(projectId: string, name: string, imageUrl: models.ImageUrl, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary Predict an image and saves the result + * @summary Classify an image and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -142,23 +139,22 @@ export default class PredictionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - predictImageWithHttpOperationResponse(projectId: string, imageData: stream.Readable, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + classifyImageWithHttpOperationResponse(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image and saves the result + * @summary Classify an image and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -185,29 +181,102 @@ export default class PredictionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - predictImage(projectId: string, imageData: stream.Readable, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - predictImage(projectId: string, imageData: stream.Readable, callback: ServiceCallback): void; - predictImage(projectId: string, imageData: stream.Readable, options: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + classifyImage(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImage(projectId: string, name: string, imageData: stream.Readable, callback: ServiceCallback): void; + classifyImage(projectId: string, name: string, imageData: stream.Readable, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary Predict an image url without saving the result + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + classifyImageUrlWithNoStoreWithHttpOperationResponse(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. * - * @param {uuid} projectId The project id + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ImagePrediction} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + classifyImageUrlWithNoStore(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageUrlWithNoStore(projectId: string, name: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + classifyImageUrlWithNoStore(projectId: string, name: string, imageUrl: models.ImageUrl, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Classify an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -218,26 +287,99 @@ export default class PredictionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - predictImageUrlWithNoStoreWithHttpOperationResponse(projectId: string, imageUrl: models.ImageUrl, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + classifyImageWithNoStoreWithHttpOperationResponse(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image url without saving the result + * @summary Classify an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. * - * @param {uuid} projectId The project id + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ImagePrediction} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + classifyImageWithNoStore(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageWithNoStore(projectId: string, name: string, imageData: stream.Readable, callback: ServiceCallback): void; + classifyImageWithNoStore(projectId: string, name: string, imageData: stream.Readable, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Detect objects in an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + detectImageUrlWithHttpOperationResponse(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Detect objects in an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -264,26 +406,99 @@ export default class PredictionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - predictImageUrlWithNoStore(projectId: string, imageUrl: models.ImageUrl, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - predictImageUrlWithNoStore(projectId: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; - predictImageUrlWithNoStore(projectId: string, imageUrl: models.ImageUrl, options: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + detectImageUrl(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageUrl(projectId: string, name: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + detectImageUrl(projectId: string, name: string, imageUrl: models.ImageUrl, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary Predict an image without saving the result + * @summary Detect objects in an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + detectImageWithHttpOperationResponse(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Detect objects in an image and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ImagePrediction} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + detectImage(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImage(projectId: string, name: string, imageData: stream.Readable, callback: ServiceCallback): void; + detectImage(projectId: string, name: string, imageData: stream.Readable, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -294,23 +509,96 @@ export default class PredictionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - predictImageWithNoStoreWithHttpOperationResponse(projectId: string, imageData: stream.Readable, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + detectImageUrlWithNoStoreWithHttpOperationResponse(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image without saving the result + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * - * @param {uuid} projectId The project id + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. * - * @param {object} imageData + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ImagePrediction} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + detectImageUrlWithNoStore(projectId: string, name: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageUrlWithNoStore(projectId: string, name: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + detectImageUrlWithNoStore(projectId: string, name: string, imageUrl: models.ImageUrl, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Detect objects in an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + detectImageWithNoStoreWithHttpOperationResponse(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Detect objects in an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -337,9 +625,9 @@ export default class PredictionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - predictImageWithNoStore(projectId: string, imageData: stream.Readable, options?: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - predictImageWithNoStore(projectId: string, imageData: stream.Readable, callback: ServiceCallback): void; - predictImageWithNoStore(projectId: string, imageData: stream.Readable, options: { iterationId? : string, application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + detectImageWithNoStore(projectId: string, name: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageWithNoStore(projectId: string, name: string, imageData: stream.Readable, callback: ServiceCallback): void; + detectImageWithNoStore(projectId: string, name: string, imageData: stream.Readable, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } export { PredictionAPIClient, models as PredictionAPIModels }; diff --git a/lib/services/customVision/prediction/lib/predictionAPIClient.js b/lib/services/customVision/prediction/lib/predictionAPIClient.js index 5866f85630..0f0ac79060 100644 --- a/lib/services/customVision/prediction/lib/predictionAPIClient.js +++ b/lib/services/customVision/prediction/lib/predictionAPIClient.js @@ -22,23 +22,22 @@ const models = require('./models'); /** - * @summary Predict an image url and saves the result + * @summary Classify an image url and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -56,7 +55,7 @@ const models = require('./models'); * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _predictImageUrl(projectId, imageUrl, options, callback) { +function _classifyImageUrl(projectId, name, imageUrl, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -66,7 +65,6 @@ function _predictImageUrl(projectId, imageUrl, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let iterationId = (options && options.iterationId !== undefined) ? options.iterationId : undefined; let application = (options && options.application !== undefined) ? options.application : undefined; // Validate try { @@ -76,12 +74,12 @@ function _predictImageUrl(projectId, imageUrl, options, callback) { if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } if (imageUrl === null || imageUrl === undefined) { throw new Error('imageUrl cannot be null or undefined.'); } - if (iterationId !== null && iterationId !== undefined && !(typeof iterationId.valueOf() === 'string' && msRest.isValidUuid(iterationId))) { - throw new Error('iterationId must be of type string and must be a valid uuid.'); - } if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { throw new Error('application must be of type string.'); } @@ -94,13 +92,11 @@ function _predictImageUrl(projectId, imageUrl, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/url'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/classify/models/{name}/url'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); let queryParameters = []; - if (iterationId !== null && iterationId !== undefined) { - queryParameters.push('iterationId=' + encodeURIComponent(iterationId.toString())); - } if (application !== null && application !== undefined) { queryParameters.push('application=' + encodeURIComponent(application)); } @@ -161,6 +157,10 @@ function _predictImageUrl(projectId, imageUrl, options, callback) { error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; @@ -194,20 +194,19 @@ function _predictImageUrl(projectId, imageUrl, options, callback) { } /** - * @summary Predict an image and saves the result + * @summary Classify an image and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -225,7 +224,7 @@ function _predictImageUrl(projectId, imageUrl, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _predictImage(projectId, imageData, options, callback) { +function _classifyImage(projectId, name, imageData, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -235,7 +234,6 @@ function _predictImage(projectId, imageData, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let iterationId = (options && options.iterationId !== undefined) ? options.iterationId : undefined; let application = (options && options.application !== undefined) ? options.application : undefined; // Validate try { @@ -245,8 +243,8 @@ function _predictImage(projectId, imageData, options, callback) { if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } - if (iterationId !== null && iterationId !== undefined && !(typeof iterationId.valueOf() === 'string' && msRest.isValidUuid(iterationId))) { - throw new Error('iterationId must be of type string and must be a valid uuid.'); + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); } if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { throw new Error('application must be of type string.'); @@ -263,13 +261,11 @@ function _predictImage(projectId, imageData, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/image'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/classify/models/{name}/image'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); let queryParameters = []; - if (iterationId !== null && iterationId !== undefined) { - queryParameters.push('iterationId=' + encodeURIComponent(iterationId.toString())); - } if (application !== null && application !== undefined) { queryParameters.push('application=' + encodeURIComponent(application)); } @@ -321,6 +317,10 @@ function _predictImage(projectId, imageData, options, callback) { error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; @@ -354,23 +354,22 @@ function _predictImage(projectId, imageData, options, callback) { } /** - * @summary Predict an image url without saving the result + * @summary Classify an image url without saving the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -388,7 +387,7 @@ function _predictImage(projectId, imageData, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { +function _classifyImageUrlWithNoStore(projectId, name, imageUrl, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -398,7 +397,6 @@ function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let iterationId = (options && options.iterationId !== undefined) ? options.iterationId : undefined; let application = (options && options.application !== undefined) ? options.application : undefined; // Validate try { @@ -408,12 +406,12 @@ function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } if (imageUrl === null || imageUrl === undefined) { throw new Error('imageUrl cannot be null or undefined.'); } - if (iterationId !== null && iterationId !== undefined && !(typeof iterationId.valueOf() === 'string' && msRest.isValidUuid(iterationId))) { - throw new Error('iterationId must be of type string and must be a valid uuid.'); - } if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { throw new Error('application must be of type string.'); } @@ -426,13 +424,11 @@ function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/url/nostore'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/classify/models/{name}/url/nostore'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); let queryParameters = []; - if (iterationId !== null && iterationId !== undefined) { - queryParameters.push('iterationId=' + encodeURIComponent(iterationId.toString())); - } if (application !== null && application !== undefined) { queryParameters.push('application=' + encodeURIComponent(application)); } @@ -493,6 +489,10 @@ function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; @@ -526,20 +526,19 @@ function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { } /** - * @summary Predict an image without saving the result + * @summary Classify an image without saving the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -557,7 +556,7 @@ function _predictImageUrlWithNoStore(projectId, imageUrl, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _predictImageWithNoStore(projectId, imageData, options, callback) { +function _classifyImageWithNoStore(projectId, name, imageData, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -567,7 +566,6 @@ function _predictImageWithNoStore(projectId, imageData, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let iterationId = (options && options.iterationId !== undefined) ? options.iterationId : undefined; let application = (options && options.application !== undefined) ? options.application : undefined; // Validate try { @@ -577,8 +575,8 @@ function _predictImageWithNoStore(projectId, imageData, options, callback) { if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } - if (iterationId !== null && iterationId !== undefined && !(typeof iterationId.valueOf() === 'string' && msRest.isValidUuid(iterationId))) { - throw new Error('iterationId must be of type string and must be a valid uuid.'); + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); } if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { throw new Error('application must be of type string.'); @@ -595,13 +593,11 @@ function _predictImageWithNoStore(projectId, imageData, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/image/nostore'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/classify/models/{name}/image/nostore'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); let queryParameters = []; - if (iterationId !== null && iterationId !== undefined) { - queryParameters.push('iterationId=' + encodeURIComponent(iterationId.toString())); - } if (application !== null && application !== undefined) { queryParameters.push('application=' + encodeURIComponent(application)); } @@ -653,6 +649,10 @@ function _predictImageWithNoStore(projectId, imageData, options, callback) { error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; @@ -685,204 +685,972 @@ function _predictImageWithNoStore(projectId, imageData, options, callback) { }); } -/** Class representing a PredictionAPIClient. */ -class PredictionAPIClient extends ServiceClient { - /** - * Create a PredictionAPIClient. - * @param {string} apiKey - - * @param {string} endpoint - Supported Cognitive Services endpoints - * @param {object} [options] - The parameter options - * @param {Array} [options.filters] - Filters to be added to the request pipeline - * @param {object} [options.requestOptions] - Options for the underlying request object - * {@link https://github.com/request/request#requestoptions-callback Options doc} - * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy - */ - constructor(apiKey, endpoint, options) { - if (apiKey === null || apiKey === undefined) { - throw new Error('\'apiKey\' cannot be null.'); +/** + * @summary Detect objects in an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _detectImageUrl(projectId, name, imageUrl, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let application = (options && options.application !== undefined) ? options.application : undefined; + // Validate + try { + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (endpoint === null || endpoint === undefined) { - throw new Error('\'endpoint\' cannot be null.'); + if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { + throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); } - - if (!options) options = {}; - - super(null, options); - - this.baseUri = '{Endpoint}/customvision/v2.0/Prediction'; - this.apiKey = apiKey; - this.endpoint = endpoint; - - let packageInfo = this.getPackageJsonInfo(__dirname); - this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); - this.models = models; - this._predictImageUrl = _predictImageUrl; - this._predictImage = _predictImage; - this._predictImageUrlWithNoStore = _predictImageUrlWithNoStore; - this._predictImageWithNoStore = _predictImageWithNoStore; - msRest.addSerializationMixin(this); + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (imageUrl === null || imageUrl === undefined) { + throw new Error('imageUrl cannot be null or undefined.'); + } + if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { + throw new Error('application must be of type string.'); + } + if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { + throw new Error('this.apiKey cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); } - /** - * @summary Predict an image url and saves the result - * - * @param {uuid} projectId The project id - * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated - * - * @param {string} [imageUrl.url] - * - * @param {object} [options] Optional Parameters. - * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * - * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - predictImageUrlWithHttpOperationResponse(projectId, imageUrl, options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._predictImageUrl(projectId, imageUrl, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/detect/models/{name}/url'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + if (application !== null && application !== undefined) { + queryParameters.push('application=' + encodeURIComponent(application)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); } - /** - * @summary Predict an image url and saves the result - * - * @param {uuid} projectId The project id - * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated - * - * @param {string} [imageUrl.url] - * - * @param {object} [options] Optional Parameters. - * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * - * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {ImagePrediction} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {object} [result] - The deserialized result object if an error did not occur. - * See {@link ImagePrediction} for more information. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - predictImageUrl(projectId, imageUrl, options, optionalCallback) { - let client = this; - let self = this; - if (!optionalCallback && typeof options === 'function') { - optionalCallback = options; - options = null; - } - if (!optionalCallback) { - return new Promise((resolve, reject) => { - self._predictImageUrl(projectId, imageUrl, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._predictImageUrl(projectId, imageUrl, options, optionalCallback); + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.apiKey !== undefined && this.apiKey !== null) { + httpRequest.headers['Prediction-Key'] = this.apiKey; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } } } - - /** - * @summary Predict an image and saves the result - * - * @param {uuid} projectId The project id - * - * @param {object} imageData - * - * @param {object} [options] Optional Parameters. - * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * - * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - predictImageWithHttpOperationResponse(projectId, imageData, options) { - let client = this; - let self = this; - return new Promise((resolve, reject) => { - self._predictImage(projectId, imageData, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (imageUrl !== null && imageUrl !== undefined) { + let requestModelMapper = new client.models['ImageUrl']().mapper(); + requestModel = client.serialize(requestModelMapper, imageUrl, 'imageUrl'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(imageUrl, null, 2)}.`); + return callback(serializationError); } - - /** - * @summary Predict an image and saves the result - * - * @param {uuid} projectId The project id - * - * @param {object} imageData - * - * @param {object} [options] Optional Parameters. - * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ImagePrediction']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary Detect objects in an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _detectImage(projectId, name, imageData, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let application = (options && options.application !== undefined) ? options.application : undefined; + // Validate + try { + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); + } + if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { + throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { + throw new Error('application must be of type string.'); + } + if (imageData === null || imageData === undefined) { + throw new Error('imageData cannot be null or undefined and it must be of type object.'); + } + if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { + throw new Error('this.apiKey cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/detect/models/{name}/image'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + if (application !== null && application !== undefined) { + queryParameters.push('application=' + encodeURIComponent(application)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'multipart/form-data'; + if (this.apiKey !== undefined && this.apiKey !== null) { + httpRequest.headers['Prediction-Key'] = this.apiKey; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let formData = {}; + if (imageData !== undefined && imageData !== null) { + formData['imageData'] = imageData; + } + httpRequest.formData = formData; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ImagePrediction']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _detectImageUrlWithNoStore(projectId, name, imageUrl, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let application = (options && options.application !== undefined) ? options.application : undefined; + // Validate + try { + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); + } + if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { + throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (imageUrl === null || imageUrl === undefined) { + throw new Error('imageUrl cannot be null or undefined.'); + } + if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { + throw new Error('application must be of type string.'); + } + if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { + throw new Error('this.apiKey cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/detect/models/{name}/url/nostore'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + if (application !== null && application !== undefined) { + queryParameters.push('application=' + encodeURIComponent(application)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.apiKey !== undefined && this.apiKey !== null) { + httpRequest.headers['Prediction-Key'] = this.apiKey; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (imageUrl !== null && imageUrl !== undefined) { + let requestModelMapper = new client.models['ImageUrl']().mapper(); + requestModel = client.serialize(requestModelMapper, imageUrl, 'imageUrl'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(imageUrl, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ImagePrediction']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary Detect objects in an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _detectImageWithNoStore(projectId, name, imageData, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let application = (options && options.application !== undefined) ? options.application : undefined; + // Validate + try { + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); + } + if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) { + throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') { + throw new Error('application must be of type string.'); + } + if (imageData === null || imageData === undefined) { + throw new Error('imageData cannot be null or undefined and it must be of type object.'); + } + if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { + throw new Error('this.apiKey cannot be null or undefined and it must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/detect/models/{name}/image/nostore'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + if (application !== null && application !== undefined) { + queryParameters.push('application=' + encodeURIComponent(application)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'multipart/form-data'; + if (this.apiKey !== undefined && this.apiKey !== null) { + httpRequest.headers['Prediction-Key'] = this.apiKey; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let formData = {}; + if (imageData !== undefined && imageData !== null) { + formData['imageData'] = imageData; + } + httpRequest.formData = formData; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CustomVisionError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ImagePrediction']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a PredictionAPIClient. */ +class PredictionAPIClient extends ServiceClient { + /** + * Create a PredictionAPIClient. + * @param {string} apiKey - API key. + * @param {string} endpoint - Supported Cognitive Services endpoints. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + */ + constructor(apiKey, endpoint, options) { + if (apiKey === null || apiKey === undefined) { + throw new Error('\'apiKey\' cannot be null.'); + } + if (endpoint === null || endpoint === undefined) { + throw new Error('\'endpoint\' cannot be null.'); + } + + if (!options) options = {}; + + super(null, options); + + this.baseUri = '{Endpoint}/customvision/v3.0/prediction'; + this.apiKey = apiKey; + this.endpoint = endpoint; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + this.models = models; + this._classifyImageUrl = _classifyImageUrl; + this._classifyImage = _classifyImage; + this._classifyImageUrlWithNoStore = _classifyImageUrlWithNoStore; + this._classifyImageWithNoStore = _classifyImageWithNoStore; + this._detectImageUrl = _detectImageUrl; + this._detectImage = _detectImage; + this._detectImageUrlWithNoStore = _detectImageUrlWithNoStore; + this._detectImageWithNoStore = _detectImageWithNoStore; + msRest.addSerializationMixin(this); + } + + /** + * @summary Classify an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + classifyImageUrlWithHttpOperationResponse(projectId, name, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImageUrl(projectId, name, imageUrl, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Classify an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + classifyImageUrl(projectId, name, imageUrl, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._classifyImageUrl(projectId, name, imageUrl, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImageUrl(projectId, name, imageUrl, options, optionalCallback); + } + } + + /** + * @summary Classify an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + classifyImageWithHttpOperationResponse(projectId, name, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImage(projectId, name, imageData, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Classify an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + classifyImage(projectId, name, imageData, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._classifyImage(projectId, name, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImage(projectId, name, imageData, options, optionalCallback); + } + } + + /** + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + classifyImageUrlWithNoStoreWithHttpOperationResponse(projectId, name, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImageUrlWithNoStore(projectId, name, imageUrl, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -909,7 +1677,7 @@ class PredictionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - predictImage(projectId, imageData, options, optionalCallback) { + classifyImageUrlWithNoStore(projectId, name, imageUrl, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -918,35 +1686,31 @@ class PredictionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._predictImage(projectId, imageData, options, (err, result, request, response) => { + self._classifyImageUrlWithNoStore(projectId, name, imageUrl, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._predictImage(projectId, imageData, options, optionalCallback); + return self._classifyImageUrlWithNoStore(projectId, name, imageUrl, options, optionalCallback); } } /** - * @summary Predict an image url without saving the result + * @summary Classify an image without saving the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * - * @param {string} [imageUrl.url] + * @param {object} imageData Binary image data. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified - * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -957,11 +1721,11 @@ class PredictionAPIClient extends ServiceClient { * * @reject {Error} - The error object. */ - predictImageUrlWithNoStoreWithHttpOperationResponse(projectId, imageUrl, options) { + classifyImageWithNoStoreWithHttpOperationResponse(projectId, name, imageData, options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._predictImageUrlWithNoStore(projectId, imageUrl, options, (err, result, request, response) => { + self._classifyImageWithNoStore(projectId, name, imageData, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -972,23 +1736,123 @@ class PredictionAPIClient extends ServiceClient { } /** - * @summary Predict an image url without saving the result + * @summary Classify an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + classifyImageWithNoStore(projectId, name, imageData, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._classifyImageWithNoStore(projectId, name, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImageWithNoStore(projectId, name, imageData, options, optionalCallback); + } + } + + /** + * @summary Detect objects in an image url and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. * * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + detectImageUrlWithHttpOperationResponse(projectId, name, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImageUrl(projectId, name, imageUrl, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Detect objects in an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1015,7 +1879,7 @@ class PredictionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - predictImageUrlWithNoStore(projectId, imageUrl, options, optionalCallback) { + detectImageUrl(projectId, name, imageUrl, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1024,32 +1888,132 @@ class PredictionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._predictImageUrlWithNoStore(projectId, imageUrl, options, (err, result, request, response) => { + self._detectImageUrl(projectId, name, imageUrl, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._predictImageUrlWithNoStore(projectId, imageUrl, options, optionalCallback); + return self._detectImageUrl(projectId, name, imageUrl, options, optionalCallback); } } /** - * @summary Predict an image without saving the result + * @summary Detect objects in an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + detectImageWithHttpOperationResponse(projectId, name, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImage(projectId, name, imageData, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Detect objects in an image and saves the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + detectImage(projectId, name, imageData, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._detectImage(projectId, name, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._detectImage(projectId, name, imageData, options, optionalCallback); + } + } + + /** + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1060,11 +2024,11 @@ class PredictionAPIClient extends ServiceClient { * * @reject {Error} - The error object. */ - predictImageWithNoStoreWithHttpOperationResponse(projectId, imageData, options) { + detectImageUrlWithNoStoreWithHttpOperationResponse(projectId, name, imageUrl, options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._predictImageWithNoStore(projectId, imageData, options, (err, result, request, response) => { + self._detectImageUrlWithNoStore(projectId, name, imageUrl, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1075,20 +2039,120 @@ class PredictionAPIClient extends ServiceClient { } /** - * @summary Predict an image without saving the result + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the + * url of the image to be evaluated. + * + * @param {string} [imageUrl.url] Url of the image. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ImagePrediction} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ImagePrediction} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + detectImageUrlWithNoStore(projectId, name, imageUrl, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._detectImageUrlWithNoStore(projectId, name, imageUrl, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._detectImageUrlWithNoStore(projectId, name, imageUrl, options, optionalCallback); + } + } + + /** + * @summary Detect objects in an image without saving the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. * * @param {object} [options] Optional Parameters. * - * @param {uuid} [options.iterationId] Optional. Specifies the id of a - * particular iteration to evaluate against. - * The default iteration for the project will be used when not specified + * @param {string} [options.application] Optional. Specifies the name of + * application using the endpoint. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + detectImageWithNoStoreWithHttpOperationResponse(projectId, name, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImageWithNoStore(projectId, name, imageData, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Detect objects in an image without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} name Specifies the name of the model to evaluate against. + * The default iteration for the project will be used when not specified. + * + * @param {object} imageData Binary image data. + * + * @param {object} [options] Optional Parameters. * * @param {string} [options.application] Optional. Specifies the name of - * application using the endpoint + * application using the endpoint. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1115,7 +2179,7 @@ class PredictionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - predictImageWithNoStore(projectId, imageData, options, optionalCallback) { + detectImageWithNoStore(projectId, name, imageData, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1124,14 +2188,14 @@ class PredictionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._predictImageWithNoStore(projectId, imageData, options, (err, result, request, response) => { + self._detectImageWithNoStore(projectId, name, imageData, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._predictImageWithNoStore(projectId, imageData, options, optionalCallback); + return self._detectImageWithNoStore(projectId, name, imageData, options, optionalCallback); } } diff --git a/lib/services/customVision/training/LICENSE.txt b/lib/services/customVision/training/LICENSE.txt index 5431ba98b9..8f3d856145 100644 --- a/lib/services/customVision/training/LICENSE.txt +++ b/lib/services/customVision/training/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Microsoft +Copyright (c) 2019 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/services/customVision/training/README.md b/lib/services/customVision/training/README.md index 17700bc3c6..4ca0fd9fd7 100644 --- a/lib/services/customVision/training/README.md +++ b/lib/services/customVision/training/README.md @@ -1,44 +1,44 @@ ---- -uid: azure-cognitiveservices-customvision-training -summary: *content - ---- -**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** -## Microsoft Azure SDK for Node.js - TrainingAPIClient - -This project provides a Node.js package for accessing Azure. Right now it supports: -- **Node.js version 6.x.x or higher** - -### Features - - -### How to Install - -```bash -npm install azure-cognitiveservices-customvision-training -``` - -### How to use - -#### Authentication, client creation, and getDomains as an example. - -```javascript -const msRest = require("ms-rest"); -const TrainingAPIClient = require("azure-cognitiveservices-customvision-training"); -const token = ""; -const creds = new msRest.TokenCredentials(token); -const subscriptionId = ""; -const client = new TrainingAPIClient(creds, subscriptionId); - -client.getDomains().then((result) => { - console.log("The result is:"); - console.log(result); -}).catch((err) => { - console.log('An error occurred:'); - console.dir(err, {depth: null, colors: true}); -}); -``` - -### Related projects - -- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) +--- +uid: azure-cognitiveservices-customvision-training +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** +## Microsoft Azure SDK for Node.js - TrainingAPIClient + +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-cognitiveservices-customvision-training +``` + +### How to use + +#### Authentication, client creation, and getDomains as an example. + +```javascript +const msRest = require("ms-rest"); +const TrainingAPIClient = require("azure-cognitiveservices-customvision-training"); +const token = ""; +const creds = new msRest.TokenCredentials(token); +const subscriptionId = ""; +const client = new TrainingAPIClient(creds, subscriptionId); + +client.getDomains().then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); +``` + +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/customVision/training/lib/models/index.d.ts b/lib/services/customVision/training/lib/models/index.d.ts index 767b7d2bd1..49deace9d2 100644 --- a/lib/services/customVision/training/lib/models/index.d.ts +++ b/lib/services/customVision/training/lib/models/index.d.ts @@ -434,7 +434,7 @@ export interface Project { */ readonly created?: Date; /** - * Gets the date this project was last modifed. + * Gets the date this project was last modified. */ readonly lastModified?: Date; /** diff --git a/lib/services/customVision/training/lib/models/project.js b/lib/services/customVision/training/lib/models/project.js index ae364fb038..df8a7ff4d4 100644 --- a/lib/services/customVision/training/lib/models/project.js +++ b/lib/services/customVision/training/lib/models/project.js @@ -29,7 +29,7 @@ class Project { * 'Multilabel' * @property {date} [created] Gets the date this project was created. * @property {date} [lastModified] Gets the date this project was last - * modifed. + * modified. * @property {string} [thumbnailUri] Gets the thumbnail url representing the * project. */ diff --git a/lib/services/customVision/training/lib/trainingAPIClient.d.ts b/lib/services/customVision/training/lib/trainingAPIClient.d.ts index 4e0159ccae..feea83a197 100644 --- a/lib/services/customVision/training/lib/trainingAPIClient.d.ts +++ b/lib/services/customVision/training/lib/trainingAPIClient.d.ts @@ -351,7 +351,7 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {array} imageIds Image ids. Limited to 64 images. * - * @param {array} tagIds Tags to be deleted from the specified images. Limted + * @param {array} tagIds Tags to be deleted from the specified images. Limited * to 20 tags. * * @param {object} [options] Optional Parameters. @@ -374,7 +374,7 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {array} imageIds Image ids. Limited to 64 images. * - * @param {array} tagIds Tags to be deleted from the specified images. Limted + * @param {array} tagIds Tags to be deleted from the specified images. Limited * to 20 tags. * * @param {object} [options] Optional Parameters. @@ -874,7 +874,7 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {array} imageIds Ids of the images to be deleted. Limted to 256 + * @param {array} imageIds Ids of the images to be deleted. Limited to 256 * images per batch. * * @param {object} [options] Optional Parameters. @@ -895,7 +895,7 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {array} imageIds Ids of the images to be deleted. Limted to 256 + * @param {array} imageIds Ids of the images to be deleted. Limited to 256 * images per batch. * * @param {object} [options] Optional Parameters. @@ -1087,8 +1087,8 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} batch Image and tag ids. Limted to 64 images and 20 tags per - * batch. + * @param {object} batch Image and tag ids. Limited to 64 images and 20 tags + * per batch. * * @param {array} [batch.images] * @@ -1115,8 +1115,8 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} batch Image and tag ids. Limted to 64 images and 20 tags per - * batch. + * @param {object} batch Image and tag ids. Limited to 64 images and 20 tags + * per batch. * * @param {array} [batch.images] * diff --git a/lib/services/customVision/training/lib/trainingAPIClient.js b/lib/services/customVision/training/lib/trainingAPIClient.js index 16d486b971..a7adf9de06 100644 --- a/lib/services/customVision/training/lib/trainingAPIClient.js +++ b/lib/services/customVision/training/lib/trainingAPIClient.js @@ -739,7 +739,7 @@ function _createImageTags(projectId, batch, options, callback) { * * @param {array} imageIds Image ids. Limited to 64 images. * - * @param {array} tagIds Tags to be deleted from the specified images. Limted + * @param {array} tagIds Tags to be deleted from the specified images. Limited * to 20 tags. * * @param {object} [options] Optional Parameters. @@ -1860,7 +1860,7 @@ function _createImagesFromData(projectId, imageData, options, callback) { * * @param {uuid} projectId The project id. * - * @param {array} imageIds Ids of the images to be deleted. Limted to 256 + * @param {array} imageIds Ids of the images to be deleted. Limited to 256 * images per batch. * * @param {object} [options] Optional Parameters. @@ -2290,8 +2290,8 @@ function _createImagesFromUrls(projectId, batch, options, callback) { * * @param {uuid} projectId The project id. * - * @param {object} batch Image and tag ids. Limted to 64 images and 20 tags per - * batch. + * @param {object} batch Image and tag ids. Limited to 64 images and 20 tags + * per batch. * * @param {array} [batch.images] * @@ -6566,7 +6566,7 @@ class TrainingAPIClient extends ServiceClient { * * @param {array} imageIds Image ids. Limited to 64 images. * - * @param {array} tagIds Tags to be deleted from the specified images. Limted + * @param {array} tagIds Tags to be deleted from the specified images. Limited * to 20 tags. * * @param {object} [options] Optional Parameters. @@ -6601,7 +6601,7 @@ class TrainingAPIClient extends ServiceClient { * * @param {array} imageIds Image ids. Limited to 64 images. * - * @param {array} tagIds Tags to be deleted from the specified images. Limted + * @param {array} tagIds Tags to be deleted from the specified images. Limited * to 20 tags. * * @param {object} [options] Optional Parameters. @@ -7278,7 +7278,7 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {array} imageIds Ids of the images to be deleted. Limted to 256 + * @param {array} imageIds Ids of the images to be deleted. Limited to 256 * images per batch. * * @param {object} [options] Optional Parameters. @@ -7311,7 +7311,7 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {array} imageIds Ids of the images to be deleted. Limted to 256 + * @param {array} imageIds Ids of the images to be deleted. Limited to 256 * images per batch. * * @param {object} [options] Optional Parameters. @@ -7572,8 +7572,8 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} batch Image and tag ids. Limted to 64 images and 20 tags per - * batch. + * @param {object} batch Image and tag ids. Limited to 64 images and 20 tags + * per batch. * * @param {array} [batch.images] * @@ -7612,8 +7612,8 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} batch Image and tag ids. Limted to 64 images and 20 tags per - * batch. + * @param {object} batch Image and tag ids. Limited to 64 images and 20 tags + * per batch. * * @param {array} [batch.images] *