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..c63106b7f5 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 publishedModelName = "testpublishedModelName"; +const imageUrl = { + url: "testurl" +}; +const application = "testapplication"; + +client.classifyImageUrl(projectId, publishedModelName, 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..fcf66e2fad --- /dev/null +++ b/lib/services/customVision/prediction/lib/models/customVisionError.js @@ -0,0 +1,121 @@ +/* + * 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', + * 'BadRequestProjectUnsupportedExportPlatform', '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', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', + * 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', + * 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', + * 'BadRequestInvalidEmailAddress', 'BadRequestBakingAlreadyInProgress', + * '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..eea2d6f5cd 100644 --- a/lib/services/customVision/prediction/lib/models/index.d.ts +++ b/lib/services/customVision/prediction/lib/models/index.d.ts @@ -8,28 +8,137 @@ 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', 'BadRequestProjectUnsupportedExportPlatform', + * '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', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', 'BadRequestInvalidEmailAddress', + * 'BadRequestBakingAlreadyInProgress', '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..81b2155c2c 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageUrl(projectId: string, publishedModelName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + classifyImageUrl(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. * - * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. * - * @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, publishedModelName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImage(projectId: string, publishedModelName: string, imageData: stream.Readable, callback: ServiceCallback): void; + classifyImage(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageUrlWithNoStore(projectId: string, publishedModelName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + classifyImageUrlWithNoStore(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageWithNoStore(projectId: string, publishedModelName: string, imageData: stream.Readable, callback: ServiceCallback): void; + classifyImageWithNoStore(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageUrl(projectId: string, publishedModelName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + detectImageUrl(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImage(projectId: string, publishedModelName: string, imageData: stream.Readable, callback: ServiceCallback): void; + detectImage(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. * - * @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, publishedModelName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageUrlWithNoStore(projectId: string, publishedModelName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + detectImageUrlWithNoStore(projectId: string, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageWithNoStore(projectId: string, publishedModelName: string, imageData: stream.Readable, callback: ServiceCallback): void; + detectImageWithNoStore(projectId: string, publishedModelName: 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..839ed0137f 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/url'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); 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} publishedModelName Specifies the name of the model to + * evaluate against. * - * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/image'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/url/nostore'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); 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} publishedModelName Specifies the name of the model to + * evaluate against. * - * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/image/nostore'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/url'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); + 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/image'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); + 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/url/nostore'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); + 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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 (publishedModelName === null || publishedModelName === undefined || typeof publishedModelName.valueOf() !== 'string') { + throw new Error('publishedModelName 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/{publishedModelName}/image/nostore'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedModelName}', encodeURIComponent(publishedModelName)); + 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImageUrl(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, imageUrl, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImageUrl(projectId, publishedModelName, imageUrl, options, optionalCallback); + } + } + + /** + * @summary Classify an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImage(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImage(projectId, publishedModelName, imageData, options, optionalCallback); + } + } + + /** + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImageUrlWithNoStore(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, 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, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. * - * @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, publishedModelName, 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, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImageWithNoStore(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. * * @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, publishedModelName, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImageUrl(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, 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, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImage(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._detectImage(projectId, publishedModelName, imageData, options, optionalCallback); + } + } + + /** + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, imageUrl, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._detectImageUrlWithNoStore(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImageWithNoStore(projectId, publishedModelName, 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} publishedModelName Specifies the name of the model to + * evaluate against. + * + * @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, publishedModelName, 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, publishedModelName, 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, publishedModelName, 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/boundingBox.js b/lib/services/customVision/training/lib/models/boundingBox.js index 1dd1a18c05..98c7d72515 100644 --- a/lib/services/customVision/training/lib/models/boundingBox.js +++ b/lib/services/customVision/training/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/training/lib/models/customVisionError.js b/lib/services/customVision/training/lib/models/customVisionError.js new file mode 100644 index 0000000000..fcf66e2fad --- /dev/null +++ b/lib/services/customVision/training/lib/models/customVisionError.js @@ -0,0 +1,121 @@ +/* + * 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', + * 'BadRequestProjectUnsupportedExportPlatform', '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', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', + * 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', + * 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', + * 'BadRequestInvalidEmailAddress', 'BadRequestBakingAlreadyInProgress', + * '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/training/lib/models/exportModel.js b/lib/services/customVision/training/lib/models/exportModel.js index f351ac0633..95f3025755 100644 --- a/lib/services/customVision/training/lib/models/exportModel.js +++ b/lib/services/customVision/training/lib/models/exportModel.js @@ -17,12 +17,12 @@ class ExportModel { /** * Create a ExportModel. * @property {string} [platform] Platform of the export. Possible values - * include: 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * include: 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', 'VAIDK' * @property {string} [status] Status of the export. Possible values include: * 'Exporting', 'Failed', 'Done' * @property {string} [downloadUri] URI used to download the model. * @property {string} [flavor] Flavor of the export. Possible values include: - * 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' * @property {boolean} [newerVersionAvailable] Indicates an updated version * of the export package is available and should be re-exported for the * latest changes. diff --git a/lib/services/customVision/training/lib/models/imageIdCreateEntry.js b/lib/services/customVision/training/lib/models/imageIdCreateEntry.js index 25731b8a68..1b5d9c398e 100644 --- a/lib/services/customVision/training/lib/models/imageIdCreateEntry.js +++ b/lib/services/customVision/training/lib/models/imageIdCreateEntry.js @@ -16,7 +16,7 @@ class ImageIdCreateEntry { /** * Create a ImageIdCreateEntry. - * @property {uuid} [id] + * @property {uuid} [id] Id of the image. * @property {array} [tagIds] * @property {array} [regions] */ diff --git a/lib/services/customVision/training/lib/models/imagePrediction.js b/lib/services/customVision/training/lib/models/imagePrediction.js index 682587f610..8aeb9ac3ef 100644 --- a/lib/services/customVision/training/lib/models/imagePrediction.js +++ b/lib/services/customVision/training/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/training/lib/models/imageRegion.js b/lib/services/customVision/training/lib/models/imageRegion.js index 9f0e4a6188..1ba4b16c96 100644 --- a/lib/services/customVision/training/lib/models/imageRegion.js +++ b/lib/services/customVision/training/lib/models/imageRegion.js @@ -20,10 +20,10 @@ class ImageRegion { * @property {string} [tagName] * @property {date} [created] * @property {uuid} [tagId] Id of the tag associated with this region. - * @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/training/lib/models/imageRegionCreateEntry.js b/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js index 6083b3c910..a105a56546 100644 --- a/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js +++ b/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js @@ -19,10 +19,10 @@ class ImageRegionCreateEntry { * Create a ImageRegionCreateEntry. * @property {uuid} [imageId] Id of the image. * @property {uuid} [tagId] Id of the tag associated with this region. - * @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/training/lib/models/imageRegionCreateResult.js b/lib/services/customVision/training/lib/models/imageRegionCreateResult.js index 81658389cb..82b9a0731f 100644 --- a/lib/services/customVision/training/lib/models/imageRegionCreateResult.js +++ b/lib/services/customVision/training/lib/models/imageRegionCreateResult.js @@ -21,10 +21,10 @@ class ImageRegionCreateResult { * @property {string} [tagName] * @property {date} [created] * @property {uuid} [tagId] Id of the tag associated with this region. - * @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/training/lib/models/imageUrl.js b/lib/services/customVision/training/lib/models/imageUrl.js index 31cb128ce9..5bad1fbc0d 100644 --- a/lib/services/customVision/training/lib/models/imageUrl.js +++ b/lib/services/customVision/training/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/training/lib/models/imageUrlCreateEntry.js b/lib/services/customVision/training/lib/models/imageUrlCreateEntry.js index 1b1feb004f..513f6e2ddf 100644 --- a/lib/services/customVision/training/lib/models/imageUrlCreateEntry.js +++ b/lib/services/customVision/training/lib/models/imageUrlCreateEntry.js @@ -16,7 +16,7 @@ class ImageUrlCreateEntry { /** * Create a ImageUrlCreateEntry. - * @property {string} [url] + * @property {string} [url] Url of the image. * @property {array} [tagIds] * @property {array} [regions] */ diff --git a/lib/services/customVision/training/lib/models/index.d.ts b/lib/services/customVision/training/lib/models/index.d.ts index 767b7d2bd1..a9d49c4b8b 100644 --- a/lib/services/customVision/training/lib/models/index.d.ts +++ b/lib/services/customVision/training/lib/models/index.d.ts @@ -61,9 +61,21 @@ export interface ImageRegionCreateEntry { * Id of the tag associated with this region. */ tagId?: string; + /** + * Coordinate of the left boundary. + */ left?: number; + /** + * Coordinate of the top boundary. + */ top?: number; + /** + * Width. + */ width?: number; + /** + * Height. + */ height?: number; } @@ -83,9 +95,21 @@ export interface ImageRegionCreateResult { * Id of the tag associated with this region. */ tagId?: string; + /** + * Coordinate of the left boundary. + */ left?: number; + /** + * Coordinate of the top boundary. + */ top?: number; + /** + * Width. + */ width?: number; + /** + * Height. + */ height?: number; } @@ -109,9 +133,21 @@ export interface ImageRegion { * Id of the tag associated with this region. */ tagId?: string; + /** + * Coordinate of the left boundary. + */ left?: number; + /** + * Coordinate of the top boundary. + */ top?: number; + /** + * Width. + */ width?: number; + /** + * Height. + */ height?: number; } @@ -191,9 +227,21 @@ export interface Region { * Id of the tag associated with this region. */ tagId?: string; + /** + * Coordinate of the left boundary. + */ left?: number; + /** + * Coordinate of the top boundary. + */ top?: number; + /** + * Width. + */ width?: number; + /** + * Height. + */ height?: number; } @@ -210,6 +258,9 @@ export interface ImageFileCreateBatch { } export interface ImageUrlCreateEntry { + /** + * Url of the image. + */ url?: string; tagIds?: string[]; regions?: Region[]; @@ -221,6 +272,9 @@ export interface ImageUrlCreateBatch { } export interface ImageIdCreateEntry { + /** + * Id of the image. + */ id?: string; tagIds?: string[]; regions?: Region[]; @@ -231,10 +285,25 @@ export interface ImageIdCreateBatch { tagIds?: 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; } @@ -249,22 +318,61 @@ export interface ImageRegionProposal { readonly proposals?: RegionProposal[]; } +/** + * Image url. +*/ export interface ImageUrl { + /** + * Url of the image. + */ url?: string; } +/** + * 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[]; } @@ -309,10 +417,25 @@ export interface StoredImagePrediction { * Domain used for the prediction. */ readonly domain?: string; + /** + * 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[]; } @@ -407,6 +530,10 @@ export interface ProjectSettings { * 'Multilabel' */ classificationType?: string; + /** + * A list of ExportPlatform that the trained model should be able to support. + */ + targetExportPlatforms?: string[]; } /** @@ -414,7 +541,7 @@ export interface ProjectSettings { */ export interface Project { /** - * Gets The project id. + * Gets the project id. */ readonly id?: string; /** @@ -434,13 +561,17 @@ 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; /** - * Gets the thumbnail url representing the project. + * Gets the thumbnail url representing the image. */ readonly thumbnailUri?: string; + /** + * Gets if the DR mode is on. + */ + readonly drModeEnabled?: boolean; } /** @@ -455,11 +586,6 @@ export interface Iteration { * Gets or sets the name of the iteration. */ name?: string; - /** - * Gets or sets a value indicating whether the iteration is the default iteration for the - * project. - */ - isDefault?: boolean; /** * Gets the current iteration status. */ @@ -477,13 +603,17 @@ export interface Iteration { */ readonly trainedAt?: Date; /** - * Gets The project id. of the iteration. + * Gets the project id of the iteration. */ readonly projectId?: string; /** * Whether the iteration can be exported to another format for download. */ readonly exportable?: boolean; + /** + * A set of platforms this iteration can export to. + */ + readonly exportableTo?: string[]; /** * Get or sets a guid of the domain the iteration has been trained on. */ @@ -493,11 +623,24 @@ export interface Iteration { * 'Multilabel' */ readonly classificationType?: string; + /** + * Gets the training type of the iteration. Possible values include: 'Regular', 'Advanced' + */ + readonly trainingType?: string; + /** + * Gets the reserved baking budget for the iteration. + */ + readonly reservedBudgetInHours?: number; + /** + * Name of the published model. + */ + readonly publishName?: string; } export interface ExportModel { /** - * Platform of the export. Possible values include: 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * Platform of the export. Possible values include: 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', + * 'VAIDK' */ readonly platform?: string; /** @@ -509,7 +652,7 @@ export interface ExportModel { */ readonly downloadUri?: string; /** - * Flavor of the export. Possible values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * Flavor of the export. Possible values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' */ readonly flavor?: string; /** @@ -544,3 +687,58 @@ export interface Tag { */ readonly imageCount?: number; } + +export interface CustomVisionError { + /** + * The error code. Possible values include: 'NoError', 'BadRequest', + * 'BadRequestExceededBatchSize', 'BadRequestNotSupported', 'BadRequestInvalidIds', + * 'BadRequestProjectName', 'BadRequestProjectNameNotUnique', 'BadRequestProjectDescription', + * 'BadRequestProjectUnknownDomain', 'BadRequestProjectUnknownClassification', + * 'BadRequestProjectUnsupportedDomainTypeChange', 'BadRequestProjectUnsupportedExportPlatform', + * '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', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', 'BadRequestInvalidEmailAddress', + * 'BadRequestBakingAlreadyInProgress', '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/training/lib/models/index.js b/lib/services/customVision/training/lib/models/index.js index 73bd1ce372..276a0581e4 100644 --- a/lib/services/customVision/training/lib/models/index.js +++ b/lib/services/customVision/training/lib/models/index.js @@ -52,3 +52,4 @@ exports.Project = require('./project'); exports.Iteration = require('./iteration'); exports.ExportModel = require('./exportModel'); exports.Tag = require('./tag'); +exports.CustomVisionError = require('./customVisionError'); diff --git a/lib/services/customVision/training/lib/models/iteration.js b/lib/services/customVision/training/lib/models/iteration.js index 5d6592bba0..9312958112 100644 --- a/lib/services/customVision/training/lib/models/iteration.js +++ b/lib/services/customVision/training/lib/models/iteration.js @@ -19,21 +19,26 @@ class Iteration { * Create a Iteration. * @property {uuid} [id] Gets the id of the iteration. * @property {string} [name] Gets or sets the name of the iteration. - * @property {boolean} [isDefault] Gets or sets a value indicating whether - * the iteration is the default iteration for the project. * @property {string} [status] Gets the current iteration status. * @property {date} [created] Gets the time this iteration was completed. * @property {date} [lastModified] Gets the time this iteration was last * modified. * @property {date} [trainedAt] Gets the time this iteration was last * modified. - * @property {uuid} [projectId] Gets The project id. of the iteration. + * @property {uuid} [projectId] Gets the project id of the iteration. * @property {boolean} [exportable] Whether the iteration can be exported to * another format for download. + * @property {array} [exportableTo] A set of platforms this iteration can + * export to. * @property {uuid} [domainId] Get or sets a guid of the domain the iteration * has been trained on. * @property {string} [classificationType] Gets the classification type of * the project. Possible values include: 'Multiclass', 'Multilabel' + * @property {string} [trainingType] Gets the training type of the iteration. + * Possible values include: 'Regular', 'Advanced' + * @property {number} [reservedBudgetInHours] Gets the reserved baking budget + * for the iteration. + * @property {string} [publishName] Name of the published model. */ constructor() { } @@ -69,14 +74,6 @@ class Iteration { name: 'String' } }, - isDefault: { - required: false, - nullable: false, - serializedName: 'isDefault', - type: { - name: 'Boolean' - } - }, status: { required: false, nullable: true, @@ -131,6 +128,22 @@ class Iteration { name: 'Boolean' } }, + exportableTo: { + required: false, + nullable: true, + readOnly: true, + serializedName: 'exportableTo', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, domainId: { required: false, nullable: true, @@ -148,6 +161,33 @@ class Iteration { type: { name: 'String' } + }, + trainingType: { + required: false, + nullable: false, + readOnly: true, + serializedName: 'trainingType', + type: { + name: 'String' + } + }, + reservedBudgetInHours: { + required: false, + nullable: false, + readOnly: true, + serializedName: 'reservedBudgetInHours', + type: { + name: 'Number' + } + }, + publishName: { + required: false, + nullable: true, + readOnly: true, + serializedName: 'publishName', + type: { + name: 'String' + } } } } diff --git a/lib/services/customVision/training/lib/models/prediction.js b/lib/services/customVision/training/lib/models/prediction.js index b069516a77..3b9e1851af 100644 --- a/lib/services/customVision/training/lib/models/prediction.js +++ b/lib/services/customVision/training/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/training/lib/models/project.js b/lib/services/customVision/training/lib/models/project.js index ae364fb038..ae30f36418 100644 --- a/lib/services/customVision/training/lib/models/project.js +++ b/lib/services/customVision/training/lib/models/project.js @@ -17,7 +17,7 @@ class Project { /** * Create a Project. - * @property {uuid} [id] Gets The project id. + * @property {uuid} [id] Gets the project id. * @property {string} [name] Gets or sets the name of the project. * @property {string} [description] Gets or sets the description of the * project. @@ -27,11 +27,14 @@ class Project { * @property {string} [settings.classificationType] Gets or sets the * classification type of the project. Possible values include: 'Multiclass', * 'Multilabel' + * @property {array} [settings.targetExportPlatforms] A list of + * ExportPlatform that the trained model should be able to support. * @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. + * image. + * @property {boolean} [drModeEnabled] Gets if the DR mode is on. */ constructor() { } @@ -109,6 +112,15 @@ class Project { type: { name: 'String' } + }, + drModeEnabled: { + required: false, + nullable: false, + readOnly: true, + serializedName: 'drModeEnabled', + type: { + name: 'Boolean' + } } } } diff --git a/lib/services/customVision/training/lib/models/projectSettings.js b/lib/services/customVision/training/lib/models/projectSettings.js index bb5f9c78cb..8f3d5aaae1 100644 --- a/lib/services/customVision/training/lib/models/projectSettings.js +++ b/lib/services/customVision/training/lib/models/projectSettings.js @@ -21,6 +21,8 @@ class ProjectSettings { * this project. * @property {string} [classificationType] Gets or sets the classification * type of the project. Possible values include: 'Multiclass', 'Multilabel' + * @property {array} [targetExportPlatforms] A list of ExportPlatform that + * the trained model should be able to support. */ constructor() { } @@ -54,6 +56,21 @@ class ProjectSettings { type: { name: 'String' } + }, + targetExportPlatforms: { + required: false, + nullable: true, + serializedName: 'targetExportPlatforms', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } } } } diff --git a/lib/services/customVision/training/lib/models/region.js b/lib/services/customVision/training/lib/models/region.js index 4dfbc6a615..ead320b521 100644 --- a/lib/services/customVision/training/lib/models/region.js +++ b/lib/services/customVision/training/lib/models/region.js @@ -17,10 +17,10 @@ class Region { /** * Create a Region. * @property {uuid} [tagId] Id of the tag associated with this region. - * @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/training/lib/models/regionProposal.js b/lib/services/customVision/training/lib/models/regionProposal.js index f4026b8ea0..68baac374d 100644 --- a/lib/services/customVision/training/lib/models/regionProposal.js +++ b/lib/services/customVision/training/lib/models/regionProposal.js @@ -18,10 +18,10 @@ class RegionProposal { * Create a RegionProposal. * @property {number} [confidence] * @property {object} [boundingBox] - * @property {number} [boundingBox.left] - * @property {number} [boundingBox.top] - * @property {number} [boundingBox.width] - * @property {number} [boundingBox.height] + * @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/training/lib/models/storedImagePrediction.js b/lib/services/customVision/training/lib/models/storedImagePrediction.js index b5d10902f3..cf88a25dde 100644 --- a/lib/services/customVision/training/lib/models/storedImagePrediction.js +++ b/lib/services/customVision/training/lib/models/storedImagePrediction.js @@ -24,11 +24,11 @@ class StoredImagePrediction { * @property {string} [originalImageUri] The URI to the original prediction * image. * @property {uuid} [domain] Domain used for the prediction. - * @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/training/lib/trainingAPIClient.d.ts b/lib/services/customVision/training/lib/trainingAPIClient.d.ts index 4e0159ccae..c10909d04a 100644 --- a/lib/services/customVision/training/lib/trainingAPIClient.d.ts +++ b/lib/services/customVision/training/lib/trainingAPIClient.d.ts @@ -17,9 +17,9 @@ export default class TrainingAPIClient extends ServiceClient { * Initializes a new instance of the TrainingAPIClient 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 * @@ -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] * @@ -1289,7 +1289,7 @@ export default class TrainingAPIClient extends ServiceClient { * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * @@ -1316,7 +1316,7 @@ export default class TrainingAPIClient extends ServiceClient { * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * @@ -1830,6 +1830,9 @@ export default class TrainingAPIClient extends ServiceClient { * @param {string} [options.classificationType] The type of classifier to * create for this project. Possible values include: 'Multiclass', 'Multilabel' * + * @param {array} [options.targetExportPlatforms] List of platforms the trained + * model is intending exporting to. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1839,7 +1842,7 @@ export default class TrainingAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - createProjectWithHttpOperationResponse(name: string, options?: { description? : string, domainId? : string, classificationType? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + createProjectWithHttpOperationResponse(name: string, options?: { description? : string, domainId? : string, classificationType? : string, targetExportPlatforms? : string[], customHeaders? : { [headerName: string]: string; } }): Promise>; /** * @summary Create a project. @@ -1856,6 +1859,9 @@ export default class TrainingAPIClient extends ServiceClient { * @param {string} [options.classificationType] The type of classifier to * create for this project. Possible values include: 'Multiclass', 'Multilabel' * + * @param {array} [options.targetExportPlatforms] List of platforms the trained + * model is intending exporting to. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1881,9 +1887,9 @@ export default class TrainingAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createProject(name: string, options?: { description? : string, domainId? : string, classificationType? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + createProject(name: string, options?: { description? : string, domainId? : string, classificationType? : string, targetExportPlatforms? : string[], customHeaders? : { [headerName: string]: string; } }): Promise; createProject(name: string, callback: ServiceCallback): void; - createProject(name: string, options: { description? : string, domainId? : string, classificationType? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createProject(name: string, options: { description? : string, domainId? : string, classificationType? : string, targetExportPlatforms? : string[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2016,6 +2022,9 @@ export default class TrainingAPIClient extends ServiceClient { * the classification type of the project. Possible values include: * 'Multiclass', 'Multilabel' * + * @param {array} [updatedProject.settings.targetExportPlatforms] A list of + * ExportPlatform that the trained model should be able to support. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -2050,6 +2059,9 @@ export default class TrainingAPIClient extends ServiceClient { * the classification type of the project. Possible values include: * 'Multiclass', 'Multilabel' * + * @param {array} [updatedProject.settings.targetExportPlatforms] A list of + * ExportPlatform that the trained model should be able to support. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -2265,9 +2277,6 @@ export default class TrainingAPIClient extends ServiceClient { * @param {string} [updatedIteration.name] Gets or sets the name of the * iteration. * - * @param {boolean} [updatedIteration.isDefault] Gets or sets a value - * indicating whether the iteration is the default iteration for the project. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -2293,9 +2302,6 @@ export default class TrainingAPIClient extends ServiceClient { * @param {string} [updatedIteration.name] Gets or sets the name of the * iteration. * - * @param {boolean} [updatedIteration.isDefault] Gets or sets a value - * indicating whether the iteration is the default iteration for the project. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -2335,6 +2341,19 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.trainingType] The type of training to use to train + * the project (default: Regular). Possible values include: 'Regular', + * 'Advanced' + * + * @param {number} [options.reservedBudgetInHours] The number of hours reserved + * as budget for training (if applicable). + * + * @param {boolean} [options.forceTrain] Whether to force train even if dataset + * and configuration does not change (default: false). + * + * @param {string} [options.notificationEmailAddress] The email address to send + * notification to when training finishes (default: null). + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2344,7 +2363,7 @@ export default class TrainingAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - trainProjectWithHttpOperationResponse(projectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + trainProjectWithHttpOperationResponse(projectId: string, options?: { trainingType? : string, reservedBudgetInHours? : number, forceTrain? : boolean, notificationEmailAddress? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * @summary Queues project for training. @@ -2353,6 +2372,19 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.trainingType] The type of training to use to train + * the project (default: Regular). Possible values include: 'Regular', + * 'Advanced' + * + * @param {number} [options.reservedBudgetInHours] The number of hours reserved + * as budget for training (if applicable). + * + * @param {boolean} [options.forceTrain] Whether to force train even if dataset + * and configuration does not change (default: false). + * + * @param {string} [options.notificationEmailAddress] The email address to send + * notification to when training finishes (default: null). + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2378,9 +2410,135 @@ export default class TrainingAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - trainProject(projectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + trainProject(projectId: string, options?: { trainingType? : string, reservedBudgetInHours? : number, forceTrain? : boolean, notificationEmailAddress? : string, customHeaders? : { [headerName: string]: string; } }): Promise; trainProject(projectId: string, callback: ServiceCallback): void; - trainProject(projectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + trainProject(projectId: string, options: { trainingType? : string, reservedBudgetInHours? : number, forceTrain? : boolean, notificationEmailAddress? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Publish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {string} name The updated iteration name. + * + * @param {string} predictionId The id of the prediction resource to publish + * to. + * + * @param {object} [options] Optional Parameters. + * + * @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. + */ + publishIterationWithHttpOperationResponse(projectId: string, iterationId: string, name: string, predictionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Publish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {string} name The updated iteration name. + * + * @param {string} predictionId The id of the prediction resource to publish + * to. + * + * @param {object} [options] Optional Parameters. + * + * @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 {Boolean} - 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. + * + * {Boolean} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + publishIteration(projectId: string, iterationId: string, name: string, predictionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + publishIteration(projectId: string, iterationId: string, name: string, predictionId: string, callback: ServiceCallback): void; + publishIteration(projectId: string, iterationId: string, name: string, predictionId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Unpublish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {object} [options] Optional Parameters. + * + * @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. + */ + unpublishIterationWithHttpOperationResponse(projectId: string, iterationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Unpublish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {object} [options] Optional Parameters. + * + * @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 {Boolean} - 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. + * + * {Boolean} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + unpublishIteration(projectId: string, iterationId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + unpublishIteration(projectId: string, iterationId: string, callback: ServiceCallback): void; + unpublishIteration(projectId: string, iterationId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -2454,7 +2612,7 @@ export default class TrainingAPIClient extends ServiceClient { * @param {object} [options] Optional Parameters. * * @param {string} [options.flavor] The flavor of the target platform. Possible - * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -2480,7 +2638,7 @@ export default class TrainingAPIClient extends ServiceClient { * @param {object} [options] Optional Parameters. * * @param {string} [options.flavor] The flavor of the target platform. Possible - * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' * * @param {object} [options.customHeaders] Headers that will be added to the * request diff --git a/lib/services/customVision/training/lib/trainingAPIClient.js b/lib/services/customVision/training/lib/trainingAPIClient.js index 16d486b971..1f2eee12e3 100644 --- a/lib/services/customVision/training/lib/trainingAPIClient.js +++ b/lib/services/customVision/training/lib/trainingAPIClient.js @@ -107,6 +107,10 @@ function _getDomains(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.`; @@ -246,6 +250,10 @@ function _getDomain(domainId, 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.`; @@ -401,6 +409,10 @@ function _getTaggedImageCount(projectId, 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.`; @@ -548,6 +560,10 @@ function _getUntaggedImageCount(projectId, 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.`; @@ -700,6 +716,10 @@ function _createImageTags(projectId, batch, 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.`; @@ -739,7 +759,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. @@ -851,6 +871,10 @@ function _deleteImageTags(projectId, imageIds, tagIds, 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.`; @@ -986,6 +1010,10 @@ function _createImageRegions(projectId, batch, 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.`; @@ -1125,6 +1153,10 @@ function _deleteImageRegions(projectId, regionIds, 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.`; @@ -1297,6 +1329,10 @@ function _getTaggedImages(projectId, 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.`; @@ -1483,6 +1519,10 @@ function _getUntaggedImages(projectId, 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.`; @@ -1652,6 +1692,10 @@ function _getImagesByIds(projectId, 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.`; @@ -1823,6 +1867,10 @@ function _createImagesFromData(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.`; @@ -1860,7 +1908,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. @@ -1963,6 +2011,10 @@ function _deleteImages(projectId, imageIds, 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.`; @@ -2098,6 +2150,10 @@ function _createImagesFromFiles(projectId, batch, 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.`; @@ -2250,6 +2306,10 @@ function _createImagesFromUrls(projectId, batch, 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.`; @@ -2290,8 +2350,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] * @@ -2402,6 +2462,10 @@ function _createImagesFromPredictions(projectId, batch, 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.`; @@ -2493,7 +2557,7 @@ function _getImageRegionProposals(projectId, imageId, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/images/{imageId}/regionproposals'; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'projects/{projectId}/images/{imageId}/regionproposals'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); requestUrl = requestUrl.replace('{imageId}', encodeURIComponent(imageId.toString())); @@ -2537,6 +2601,10 @@ function _getImageRegionProposals(projectId, imageId, 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.`; @@ -2677,6 +2745,10 @@ function _deletePrediction(projectId, ids, 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.`; @@ -2700,7 +2772,7 @@ function _deletePrediction(projectId, ids, options, callback) { * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * @@ -2822,6 +2894,10 @@ function _quickTestImageUrl(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.`; @@ -2972,6 +3048,10 @@ function _quickTestImage(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.`; @@ -3136,6 +3216,10 @@ function _queryPredictions(projectId, query, 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.`; @@ -3291,6 +3375,10 @@ function _getIterationPerformance(projectId, iterationId, 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.`; @@ -3477,6 +3565,10 @@ function _getImagePerformances(projectId, iterationId, 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.`; @@ -3645,6 +3737,10 @@ function _getImagePerformanceCount(projectId, iterationId, 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.`; @@ -3769,6 +3865,10 @@ function _getProjects(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.`; @@ -3830,6 +3930,9 @@ function _getProjects(options, callback) { * @param {string} [options.classificationType] The type of classifier to * create for this project. Possible values include: 'Multiclass', 'Multilabel' * + * @param {array} [options.targetExportPlatforms] List of platforms the trained + * model is intending exporting to. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3859,6 +3962,7 @@ function _createProject(name, options, callback) { let description = (options && options.description !== undefined) ? options.description : undefined; let domainId = (options && options.domainId !== undefined) ? options.domainId : undefined; let classificationType = (options && options.classificationType !== undefined) ? options.classificationType : undefined; + let targetExportPlatforms = (options && options.targetExportPlatforms !== undefined) ? options.targetExportPlatforms : undefined; // Validate try { if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { @@ -3876,6 +3980,13 @@ function _createProject(name, options, callback) { if (classificationType !== null && classificationType !== undefined && typeof classificationType.valueOf() !== 'string') { throw new Error('classificationType must be of type string.'); } + if (Array.isArray(targetExportPlatforms)) { + for (let i = 0; i < targetExportPlatforms.length; i++) { + if (targetExportPlatforms[i] !== null && targetExportPlatforms[i] !== undefined && typeof targetExportPlatforms[i].valueOf() !== 'string') { + throw new Error('targetExportPlatforms[i] 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.'); } @@ -3898,6 +4009,16 @@ function _createProject(name, options, callback) { if (classificationType !== null && classificationType !== undefined) { queryParameters.push('classificationType=' + encodeURIComponent(classificationType)); } + if (targetExportPlatforms !== null && targetExportPlatforms !== undefined) { + if (targetExportPlatforms.length == 0) { + queryParameters.push('targetExportPlatforms=' + encodeURIComponent('')); + } else { + for (let item of targetExportPlatforms) { + item = (item === null || item === undefined) ? '' : item; + queryParameters.push('targetExportPlatforms=' + encodeURIComponent('' + item)); + } + } + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -3941,6 +4062,10 @@ function _createProject(name, 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.`; @@ -4066,6 +4191,10 @@ function _getProject(projectId, 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.`; @@ -4190,6 +4319,10 @@ function _deleteProject(projectId, 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.`; @@ -4226,6 +4359,9 @@ function _deleteProject(projectId, options, callback) { * the classification type of the project. Possible values include: * 'Multiclass', 'Multilabel' * + * @param {array} [updatedProject.settings.targetExportPlatforms] A list of + * ExportPlatform that the trained model should be able to support. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -4331,6 +4467,10 @@ function _updateProject(projectId, updatedProject, 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.`; @@ -4455,6 +4595,10 @@ function _getIterations(projectId, 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.`; @@ -4600,6 +4744,10 @@ function _getIteration(projectId, iterationId, 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.`; @@ -4730,6 +4878,10 @@ function _deleteIteration(projectId, iterationId, 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.`; @@ -4757,9 +4909,6 @@ function _deleteIteration(projectId, iterationId, options, callback) { * @param {string} [updatedIteration.name] Gets or sets the name of the * iteration. * - * @param {boolean} [updatedIteration.isDefault] Gets or sets a value - * indicating whether the iteration is the default iteration for the project. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -4869,6 +5018,10 @@ function _updateIteration(projectId, iterationId, updatedIteration, options, cal 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.`; @@ -4908,6 +5061,19 @@ function _updateIteration(projectId, iterationId, updatedIteration, options, cal * * @param {object} [options] Optional Parameters. * + * @param {string} [options.trainingType] The type of training to use to train + * the project (default: Regular). Possible values include: 'Regular', + * 'Advanced' + * + * @param {number} [options.reservedBudgetInHours] The number of hours reserved + * as budget for training (if applicable). + * + * @param {boolean} [options.forceTrain] Whether to force train even if dataset + * and configuration does not change (default: false). + * + * @param {string} [options.notificationEmailAddress] The email address to send + * notification to when training finishes (default: null). + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4934,6 +5100,10 @@ function _trainProject(projectId, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let trainingType = (options && options.trainingType !== undefined) ? options.trainingType : undefined; + let reservedBudgetInHours = (options && options.reservedBudgetInHours !== undefined) ? options.reservedBudgetInHours : 0; + let forceTrain = (options && options.forceTrain !== undefined) ? options.forceTrain : false; + let notificationEmailAddress = (options && options.notificationEmailAddress !== undefined) ? options.notificationEmailAddress : undefined; // Validate try { if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { @@ -4942,6 +5112,18 @@ function _trainProject(projectId, 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 (trainingType !== null && trainingType !== undefined && typeof trainingType.valueOf() !== 'string') { + throw new Error('trainingType must be of type string.'); + } + if (reservedBudgetInHours !== null && reservedBudgetInHours !== undefined && typeof reservedBudgetInHours !== 'number') { + throw new Error('reservedBudgetInHours must be of type number.'); + } + if (forceTrain !== null && forceTrain !== undefined && typeof forceTrain !== 'boolean') { + throw new Error('forceTrain must be of type boolean.'); + } + if (notificationEmailAddress !== null && notificationEmailAddress !== undefined && typeof notificationEmailAddress.valueOf() !== 'string') { + throw new Error('notificationEmailAddress 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.'); } @@ -4954,6 +5136,22 @@ function _trainProject(projectId, options, callback) { let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'projects/{projectId}/train'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + let queryParameters = []; + if (trainingType !== null && trainingType !== undefined) { + queryParameters.push('trainingType=' + encodeURIComponent(trainingType)); + } + if (reservedBudgetInHours !== null && reservedBudgetInHours !== undefined) { + queryParameters.push('reservedBudgetInHours=' + encodeURIComponent(reservedBudgetInHours.toString())); + } + if (forceTrain !== null && forceTrain !== undefined) { + queryParameters.push('forceTrain=' + encodeURIComponent(forceTrain.toString())); + } + if (notificationEmailAddress !== null && notificationEmailAddress !== undefined) { + queryParameters.push('notificationEmailAddress=' + encodeURIComponent(notificationEmailAddress)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -4994,6 +5192,10 @@ function _trainProject(projectId, 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.`; @@ -5026,6 +5228,303 @@ function _trainProject(projectId, options, callback) { }); } +/** + * @summary Publish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {string} name The updated iteration name. + * + * @param {string} predictionId The id of the prediction resource to publish + * to. + * + * @param {object} [options] Optional Parameters. + * + * @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. + * + * {boolean} [result] - The deserialized result object if an error did not occur. + * + * {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 _publishIteration(projectId, iterationId, name, predictionId, 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.'); + } + // 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 (iterationId === null || iterationId === undefined || typeof iterationId.valueOf() !== 'string' || !msRest.isValidUuid(iterationId)) { + throw new Error('iterationId 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 (predictionId === null || predictionId === undefined || typeof predictionId.valueOf() !== 'string') { + throw new Error('predictionId cannot be null or undefined and it 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('/') ? '' : '/') + 'projects/{projectId}/iterations/{iterationId}/publish'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{iterationId}', encodeURIComponent(iterationId.toString())); + let queryParameters = []; + queryParameters.push('name=' + encodeURIComponent(name)); + queryParameters.push('predictionId=' + encodeURIComponent(predictionId)); + 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['Training-Key'] = this.apiKey; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // 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 = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Boolean' + } + }; + 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 Unpublish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {object} [options] Optional Parameters. + * + * @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. + * + * {boolean} [result] - The deserialized result object if an error did not occur. + * + * {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 _unpublishIteration(projectId, iterationId, 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.'); + } + // 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 (iterationId === null || iterationId === undefined || typeof iterationId.valueOf() !== 'string' || !msRest.isValidUuid(iterationId)) { + throw new Error('iterationId cannot be null or undefined and it must be of type string and must be a valid uuid.'); + } + 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('/') ? '' : '/') + 'projects/{projectId}/iterations/{iterationId}/publish'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{iterationId}', encodeURIComponent(iterationId.toString())); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + 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['Training-Key'] = this.apiKey; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // 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 = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Boolean' + } + }; + 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 Get the list of exports for a specific iteration. * @@ -5124,6 +5623,10 @@ function _getExports(projectId, iterationId, 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.`; @@ -5183,7 +5686,7 @@ function _getExports(projectId, iterationId, options, callback) { * @param {object} [options] Optional Parameters. * * @param {string} [options.flavor] The flavor of the target platform. Possible - * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -5290,6 +5793,10 @@ function _exportIteration(projectId, iterationId, platform, 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.`; @@ -5435,6 +5942,10 @@ function _getTag(projectId, tagId, 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.`; @@ -5565,6 +6076,10 @@ function _deleteTag(projectId, tagId, 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.`; @@ -5706,6 +6221,10 @@ function _updateTag(projectId, tagId, updatedTag, 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.`; @@ -5843,6 +6362,10 @@ function _getTags(projectId, 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.`; @@ -6011,6 +6534,10 @@ function _createTag(projectId, name, 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.`; @@ -6047,8 +6574,8 @@ function _createTag(projectId, name, options, callback) { class TrainingAPIClient extends ServiceClient { /** * Create a TrainingAPIClient. - * @param {string} apiKey - - * @param {string} endpoint - Supported Cognitive Services endpoints + * @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 @@ -6067,7 +6594,7 @@ class TrainingAPIClient extends ServiceClient { super(null, options); - this.baseUri = '{Endpoint}/customvision/v2.2/Training'; + this.baseUri = '{Endpoint}/customvision/v3.0/training'; this.apiKey = apiKey; this.endpoint = endpoint; @@ -6108,6 +6635,8 @@ class TrainingAPIClient extends ServiceClient { this._deleteIteration = _deleteIteration; this._updateIteration = _updateIteration; this._trainProject = _trainProject; + this._publishIteration = _publishIteration; + this._unpublishIteration = _unpublishIteration; this._getExports = _getExports; this._exportIteration = _exportIteration; this._getTag = _getTag; @@ -6566,7 +7095,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 +7130,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 +7807,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 +7840,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 +8101,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 +8141,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] * @@ -7855,7 +8384,7 @@ class TrainingAPIClient extends ServiceClient { * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * @@ -7894,7 +8423,7 @@ class TrainingAPIClient extends ServiceClient { * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the * url of the image to be evaluated. * - * @param {string} [imageUrl.url] + * @param {string} [imageUrl.url] Url of the image. * * @param {object} [options] Optional Parameters. * @@ -8585,6 +9114,9 @@ class TrainingAPIClient extends ServiceClient { * @param {string} [options.classificationType] The type of classifier to * create for this project. Possible values include: 'Multiclass', 'Multilabel' * + * @param {array} [options.targetExportPlatforms] List of platforms the trained + * model is intending exporting to. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -8623,6 +9155,9 @@ class TrainingAPIClient extends ServiceClient { * @param {string} [options.classificationType] The type of classifier to * create for this project. Possible values include: 'Multiclass', 'Multilabel' * + * @param {array} [options.targetExportPlatforms] List of platforms the trained + * model is intending exporting to. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -8852,6 +9387,9 @@ class TrainingAPIClient extends ServiceClient { * the classification type of the project. Possible values include: * 'Multiclass', 'Multilabel' * + * @param {array} [updatedProject.settings.targetExportPlatforms] A list of + * ExportPlatform that the trained model should be able to support. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -8898,6 +9436,9 @@ class TrainingAPIClient extends ServiceClient { * the classification type of the project. Possible values include: * 'Multiclass', 'Multilabel' * + * @param {array} [updatedProject.settings.targetExportPlatforms] A list of + * ExportPlatform that the trained model should be able to support. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -9209,9 +9750,6 @@ class TrainingAPIClient extends ServiceClient { * @param {string} [updatedIteration.name] Gets or sets the name of the * iteration. * - * @param {boolean} [updatedIteration.isDefault] Gets or sets a value - * indicating whether the iteration is the default iteration for the project. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -9249,9 +9787,6 @@ class TrainingAPIClient extends ServiceClient { * @param {string} [updatedIteration.name] Gets or sets the name of the * iteration. * - * @param {boolean} [updatedIteration.isDefault] Gets or sets a value - * indicating whether the iteration is the default iteration for the project. - * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -9306,6 +9841,19 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.trainingType] The type of training to use to train + * the project (default: Regular). Possible values include: 'Regular', + * 'Advanced' + * + * @param {number} [options.reservedBudgetInHours] The number of hours reserved + * as budget for training (if applicable). + * + * @param {boolean} [options.forceTrain] Whether to force train even if dataset + * and configuration does not change (default: false). + * + * @param {string} [options.notificationEmailAddress] The email address to send + * notification to when training finishes (default: null). + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -9336,6 +9884,19 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.trainingType] The type of training to use to train + * the project (default: Regular). Possible values include: 'Regular', + * 'Advanced' + * + * @param {number} [options.reservedBudgetInHours] The number of hours reserved + * as budget for training (if applicable). + * + * @param {boolean} [options.forceTrain] Whether to force train even if dataset + * and configuration does not change (default: false). + * + * @param {string} [options.notificationEmailAddress] The email address to send + * notification to when training finishes (default: null). + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -9381,6 +9942,186 @@ class TrainingAPIClient extends ServiceClient { } } + /** + * @summary Publish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {string} name The updated iteration name. + * + * @param {string} predictionId The id of the prediction resource to publish + * to. + * + * @param {object} [options] Optional Parameters. + * + * @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. + */ + publishIterationWithHttpOperationResponse(projectId, iterationId, name, predictionId, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._publishIteration(projectId, iterationId, name, predictionId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Publish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {string} name The updated iteration name. + * + * @param {string} predictionId The id of the prediction resource to publish + * to. + * + * @param {object} [options] Optional Parameters. + * + * @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 {Boolean} - 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. + * + * {boolean} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + publishIteration(projectId, iterationId, name, predictionId, 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._publishIteration(projectId, iterationId, name, predictionId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._publishIteration(projectId, iterationId, name, predictionId, options, optionalCallback); + } + } + + /** + * @summary Unpublish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {object} [options] Optional Parameters. + * + * @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. + */ + unpublishIterationWithHttpOperationResponse(projectId, iterationId, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._unpublishIteration(projectId, iterationId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Unpublish a specific iteration. + * + * @param {uuid} projectId The project id. + * + * @param {uuid} iterationId The iteration id. + * + * @param {object} [options] Optional Parameters. + * + * @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 {Boolean} - 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. + * + * {boolean} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + unpublishIteration(projectId, iterationId, 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._unpublishIteration(projectId, iterationId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._unpublishIteration(projectId, iterationId, options, optionalCallback); + } + } + /** * @summary Get the list of exports for a specific iteration. * @@ -9479,7 +10220,7 @@ class TrainingAPIClient extends ServiceClient { * @param {object} [options] Optional Parameters. * * @param {string} [options.flavor] The flavor of the target platform. Possible - * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -9517,7 +10258,7 @@ class TrainingAPIClient extends ServiceClient { * @param {object} [options] Optional Parameters. * * @param {string} [options.flavor] The flavor of the target platform. Possible - * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12' + * values include: 'Linux', 'Windows', 'ONNX10', 'ONNX12', 'ARM' * * @param {object} [options.customHeaders] Headers that will be added to the * request