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 ba63478712..e0d5b25aca 100644 --- a/lib/services/customVision/prediction/README.md +++ b/lib/services/customVision/prediction/README.md @@ -1,53 +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) - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-node%2Flib%2Fservices%2FcustomVision%2Fprediction%2FREADME.png) +--- +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 publishedName = "testpublishedName"; +const imageUrl = { + url: "testurl" +}; +const application = "testapplication"; + +client.classifyImageUrl(projectId, publishedName, 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..4e39973731 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() { } @@ -39,7 +40,7 @@ class BoundingBox { className: 'BoundingBox', modelProperties: { left: { - required: false, + required: true, nullable: false, serializedName: 'left', type: { @@ -47,7 +48,7 @@ class BoundingBox { } }, top: { - required: false, + required: true, nullable: false, serializedName: 'top', type: { @@ -55,7 +56,7 @@ class BoundingBox { } }, width: { - required: false, + required: true, nullable: false, serializedName: 'width', type: { @@ -63,7 +64,7 @@ class BoundingBox { } }, height: { - required: false, + required: true, nullable: false, serializedName: 'height', type: { 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..e2916bed9f --- /dev/null +++ b/lib/services/customVision/prediction/lib/models/customVisionError.js @@ -0,0 +1,124 @@ +/* + * 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', + * 'BadRequestRequiredParamIsNull', 'BadRequestIterationIsPublished', + * 'BadRequestInvalidPublishName', 'BadRequestInvalidPublishTarget', + * 'BadRequestUnpublishFailed', 'BadRequestSubscriptionApi', + * 'BadRequestExceedProjectLimit', + * 'BadRequestExceedIterationPerProjectLimit', + * 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', + * 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', + * 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', + * 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', + * 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', + * 'BadRequestTrainingNotNeeded', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', + * 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', + * 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', + * 'BadRequestInvalidEmailAddress', + * 'BadRequestDomainNotSupportedForAdvancedTraining', + * 'BadRequestExportPlatformNotSupportedForAdvancedTraining', + * 'BadRequestReservedBudgetInHoursNotEnoughForAdvancedTraining', + * '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, + 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..ba8ea27782 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() { } @@ -77,7 +78,6 @@ class ImagePrediction { }, predictions: { required: false, - nullable: true, readOnly: true, serializedName: 'predictions', type: { diff --git a/lib/services/customVision/prediction/lib/models/imageUrl.js b/lib/services/customVision/prediction/lib/models/imageUrl.js index 31cb128ce9..cb309129b0 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() { } @@ -36,8 +37,8 @@ class ImageUrl { className: 'ImageUrl', modelProperties: { url: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'url', type: { name: 'String' diff --git a/lib/services/customVision/prediction/lib/models/index.d.ts b/lib/services/customVision/prediction/lib/models/index.d.ts index eee742031b..aa991929a3 100644 --- a/lib/services/customVision/prediction/lib/models/index.d.ts +++ b/lib/services/customVision/prediction/lib/models/index.d.ts @@ -8,28 +8,141 @@ import * as moment from "moment"; +/** + * Image url. + */ export interface ImageUrl { - url?: string; + /** + * Url of the image. + */ + url: string; } +/** + * Bounding box that defines a region of an image. + */ export interface BoundingBox { - left?: number; - top?: number; - width?: number; - height?: number; + /** + * 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', 'BadRequestRequiredParamIsNull', + * 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + * 'BadRequestInvalidPublishTarget', 'BadRequestUnpublishFailed', 'BadRequestSubscriptionApi', + * 'BadRequestExceedProjectLimit', 'BadRequestExceedIterationPerProjectLimit', + * 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', + * 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', + * 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', 'BadRequestImageStream', + * 'BadRequestImageUrl', 'BadRequestImageFormat', 'BadRequestImageSizeBytes', + * 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', 'BadRequestInvalidEmailAddress', + * 'BadRequestDomainNotSupportedForAdvancedTraining', + * 'BadRequestExportPlatformNotSupportedForAdvancedTraining', + * 'BadRequestReservedBudgetInHoursNotEnoughForAdvancedTraining', + * '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..481f26078c 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() { } @@ -71,6 +72,7 @@ class Prediction { }, boundingBox: { required: false, + nullable: true, readOnly: true, serializedName: 'boundingBox', type: { diff --git a/lib/services/customVision/prediction/lib/predictionAPIClient.d.ts b/lib/services/customVision/prediction/lib/predictionAPIClient.d.ts index b5cf3de061..63c30cfe06 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,97 @@ 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 {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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. * - * @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. + */ + classifyImageUrlWithHttpOperationResponse(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Classify an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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 + * + * @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. + */ + classifyImageUrl(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageUrl(projectId: string, publishedName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + classifyImageUrl(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Classify an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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 @@ -66,26 +140,100 @@ 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>; + classifyImageWithHttpOperationResponse(projectId: string, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image url and saves the result + * @summary Classify an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. * - * @param {uuid} projectId The project id + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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. + * + * @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. + */ + classifyImage(projectId: string, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImage(projectId: string, publishedName: string, imageData: stream.Readable, callback: ServiceCallback): void; + classifyImage(projectId: string, publishedName: string, imageData: stream.Readable, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName 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. + */ + classifyImageUrlWithNoStoreWithHttpOperationResponse(projectId: string, publishedName: 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 {string} publishedName 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 @@ -112,26 +260,101 @@ 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; + classifyImageUrlWithNoStore(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageUrlWithNoStore(projectId: string, publishedName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + classifyImageUrlWithNoStore(projectId: string, publishedName: 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 without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. + * + * @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. + */ + classifyImageWithNoStoreWithHttpOperationResponse(projectId: string, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Classify an image without saving the result. + * + * @param {uuid} projectId The project id. * - * @param {uuid} projectId The project id + * @param {string} publishedName Specifies the name of the model to evaluate + * against. * - * @param {object} imageData + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. * * @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. + */ + classifyImageWithNoStore(projectId: string, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + classifyImageWithNoStore(projectId: string, publishedName: string, imageData: stream.Readable, callback: ServiceCallback): void; + classifyImageWithNoStore(projectId: string, publishedName: 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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 @@ -142,23 +365,98 @@ 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>; + detectImageUrlWithHttpOperationResponse(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image and saves the result + * @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} publishedName Specifies the name of the model to evaluate + * against. * - * @param {object} imageData + * @param {object} imageUrl An 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 {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. + */ + detectImageUrl(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageUrl(projectId: string, publishedName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + detectImageUrl(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * @summary Detect objects in an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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 + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + detectImageWithHttpOperationResponse(projectId: string, publishedName: 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 {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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 @@ -185,29 +483,28 @@ 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; + detectImage(projectId: string, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImage(projectId: string, publishedName: string, imageData: stream.Readable, callback: ServiceCallback): void; + detectImage(projectId: string, publishedName: string, imageData: stream.Readable, options: { application? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * @summary Predict an image url without saving the result + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. * - * @param {uuid} projectId The project id + * @param {string} publishedName 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 @@ -218,26 +515,25 @@ 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>; + detectImageUrlWithNoStoreWithHttpOperationResponse(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image url without saving the result + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. * - * @param {uuid} projectId The project id + * @param {string} publishedName 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 @@ -264,26 +560,26 @@ 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; + detectImageUrlWithNoStore(projectId: string, publishedName: string, imageUrl: models.ImageUrl, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageUrlWithNoStore(projectId: string, publishedName: string, imageUrl: models.ImageUrl, callback: ServiceCallback): void; + detectImageUrlWithNoStore(projectId: string, publishedName: 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 without saving the result. * - * @param {uuid} projectId The project id + * @param {uuid} projectId The project id. * - * @param {object} imageData + * @param {string} publishedName Specifies the name of the model to evaluate + * against. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. * - * @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 @@ -294,23 +590,23 @@ 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>; + detectImageWithNoStoreWithHttpOperationResponse(projectId: string, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Predict an image without saving the result + * @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} publishedName Specifies the name of the model to evaluate + * against. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. * - * @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 @@ -337,9 +633,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, publishedName: string, imageData: stream.Readable, options?: { application? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + detectImageWithNoStore(projectId: string, publishedName: string, imageData: stream.Readable, callback: ServiceCallback): void; + detectImageWithNoStore(projectId: string, publishedName: 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..61f4a3423d 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 {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated + * @param {string} publishedName Specifies the name of the model to evaluate + * against. * - * @param {string} [imageUrl.url] + * @param {object} imageUrl An ImageUrl that contains the url of the image to + * be evaluated. * - * @param {object} [options] Optional Parameters. + * @param {string} imageUrl.url Url of the image. * - * @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 @@ -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, publishedName, 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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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/iterations/{publishedName}/url'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); 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,20 @@ 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} publishedName Specifies the name of the model to evaluate + * against. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. * - * @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 +225,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, publishedName, imageData, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -235,7 +235,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 +244,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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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 +262,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/iterations/{publishedName}/image'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); 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 +318,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 +355,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} publishedName 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 +388,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, publishedName, imageUrl, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -398,7 +398,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 +407,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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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 +425,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/iterations/{publishedName}/url/nostore'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); 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 +490,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 +527,20 @@ 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} publishedName Specifies the name of the model to evaluate + * against. * - * @param {object} [options] Optional Parameters. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. * - * @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 +558,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, publishedName, imageData, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -567,7 +568,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 +577,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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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 +595,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/iterations/{publishedName}/image/nostore'; requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); 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 +651,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 +687,976 @@ 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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, publishedName, 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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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/iterations/{publishedName}/url'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); + 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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, publishedName, 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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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/iterations/{publishedName}/image'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); + 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} publishedName 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, publishedName, 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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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/iterations/{publishedName}/url/nostore'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); + 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. + * + * @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, publishedName, 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 (publishedName === null || publishedName === undefined || typeof publishedName.valueOf() !== 'string') { + throw new Error('publishedName 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/iterations/{publishedName}/image/nostore'; + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + requestUrl = requestUrl.replace('{projectId}', encodeURIComponent(projectId.toString())); + requestUrl = requestUrl.replace('{publishedName}', encodeURIComponent(publishedName)); + 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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, publishedName, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImageUrl(projectId, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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, publishedName, 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, publishedName, imageUrl, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImageUrl(projectId, publishedName, imageUrl, options, optionalCallback); + } + } + + /** + * @summary Classify an image and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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, publishedName, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImage(projectId, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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, publishedName, 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, publishedName, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImage(projectId, publishedName, imageData, options, optionalCallback); + } + } + + /** + * @summary Classify an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName 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, publishedName, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._classifyImageUrlWithNoStore(projectId, publishedName, 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} publishedName 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 +1683,7 @@ class PredictionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - predictImage(projectId, imageData, options, optionalCallback) { + classifyImageUrlWithNoStore(projectId, publishedName, imageUrl, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -918,35 +1692,32 @@ class PredictionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._predictImage(projectId, imageData, options, (err, result, request, response) => { + self._classifyImageUrlWithNoStore(projectId, publishedName, 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, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. * - * @param {string} [imageUrl.url] + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. * * @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 +1728,11 @@ class PredictionAPIClient extends ServiceClient { * * @reject {Error} - The error object. */ - predictImageUrlWithNoStoreWithHttpOperationResponse(projectId, imageUrl, options) { + classifyImageWithNoStoreWithHttpOperationResponse(projectId, publishedName, 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, publishedName, imageData, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -972,23 +1743,124 @@ 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 {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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. + * + * @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, publishedName, 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, publishedName, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._classifyImageWithNoStore(projectId, publishedName, imageData, options, optionalCallback); + } + } + + /** + * @summary Detect objects in an image url and saves the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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. * - * @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, publishedName, imageUrl, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImageUrl(projectId, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageUrl An 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 +1887,7 @@ class PredictionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - predictImageUrlWithNoStore(projectId, imageUrl, options, optionalCallback) { + detectImageUrl(projectId, publishedName, imageUrl, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1024,32 +1896,134 @@ class PredictionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._predictImageUrlWithNoStore(projectId, imageUrl, options, (err, result, request, response) => { + self._detectImageUrl(projectId, publishedName, 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, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. + * + * @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, publishedName, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImage(projectId, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 4MB. * * @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, publishedName, 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, publishedName, imageData, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._detectImage(projectId, publishedName, imageData, options, optionalCallback); + } + } + + /** + * @summary Detect objects in an image url without saving the result. + * + * @param {uuid} projectId The project id. + * + * @param {string} publishedName 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 +2034,11 @@ class PredictionAPIClient extends ServiceClient { * * @reject {Error} - The error object. */ - predictImageWithNoStoreWithHttpOperationResponse(projectId, imageData, options) { + detectImageUrlWithNoStoreWithHttpOperationResponse(projectId, publishedName, 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, publishedName, imageUrl, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -1075,20 +2049,122 @@ 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} publishedName 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, publishedName, 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, publishedName, imageUrl, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._detectImageUrlWithNoStore(projectId, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. * * @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, publishedName, imageData, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._detectImageWithNoStore(projectId, publishedName, 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} publishedName Specifies the name of the model to evaluate + * against. + * + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 0MB. + * + * @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 +2191,7 @@ class PredictionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - predictImageWithNoStore(projectId, imageData, options, optionalCallback) { + detectImageWithNoStore(projectId, publishedName, imageData, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -1124,14 +2200,14 @@ class PredictionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._predictImageWithNoStore(projectId, imageData, options, (err, result, request, response) => { + self._detectImageWithNoStore(projectId, publishedName, 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, publishedName, 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 221b74291e..4ca0fd9fd7 100644 --- a/lib/services/customVision/training/README.md +++ b/lib/services/customVision/training/README.md @@ -1,47 +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) - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-node%2Flib%2Fservices%2FcustomVision%2Ftraining%2FREADME.png) +--- +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..4e39973731 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() { } @@ -39,7 +40,7 @@ class BoundingBox { className: 'BoundingBox', modelProperties: { left: { - required: false, + required: true, nullable: false, serializedName: 'left', type: { @@ -47,7 +48,7 @@ class BoundingBox { } }, top: { - required: false, + required: true, nullable: false, serializedName: 'top', type: { @@ -55,7 +56,7 @@ class BoundingBox { } }, width: { - required: false, + required: true, nullable: false, serializedName: 'width', type: { @@ -63,7 +64,7 @@ class BoundingBox { } }, height: { - required: false, + required: true, nullable: false, serializedName: 'height', type: { 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..e43bbd1747 --- /dev/null +++ b/lib/services/customVision/training/lib/models/customVisionError.js @@ -0,0 +1,124 @@ +/* + * 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', + * 'BadRequestRequiredParamIsNull', 'BadRequestIterationIsPublished', + * 'BadRequestInvalidPublishName', 'BadRequestInvalidPublishTarget', + * 'BadRequestUnpublishFailed', 'BadRequestIterationNotPublished', + * 'BadRequestSubscriptionApi', 'BadRequestExceedProjectLimit', + * 'BadRequestExceedIterationPerProjectLimit', + * 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', + * 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', + * 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', + * 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', + * 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', + * 'BadRequestTrainingNotNeeded', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', + * 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', + * 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', + * 'BadRequestInvalidEmailAddress', + * 'BadRequestDomainNotSupportedForAdvancedTraining', + * 'BadRequestExportPlatformNotSupportedForAdvancedTraining', + * 'BadRequestReservedBudgetInHoursNotEnoughForAdvancedTraining', + * '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, + 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/domain.js b/lib/services/customVision/training/lib/models/domain.js index 5627f7c5cd..72f308e223 100644 --- a/lib/services/customVision/training/lib/models/domain.js +++ b/lib/services/customVision/training/lib/models/domain.js @@ -51,7 +51,7 @@ class Domain { }, name: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'name', type: { diff --git a/lib/services/customVision/training/lib/models/exportModel.js b/lib/services/customVision/training/lib/models/exportModel.js index f351ac0633..8bbf192e85 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. @@ -64,7 +64,7 @@ class ExportModel { }, downloadUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'downloadUri', type: { diff --git a/lib/services/customVision/training/lib/models/image.js b/lib/services/customVision/training/lib/models/image.js index f554873d48..e76b331b86 100644 --- a/lib/services/customVision/training/lib/models/image.js +++ b/lib/services/customVision/training/lib/models/image.js @@ -85,7 +85,7 @@ class Image { }, resizedImageUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'resizedImageUri', type: { @@ -94,7 +94,7 @@ class Image { }, thumbnailUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'thumbnailUri', type: { @@ -103,7 +103,7 @@ class Image { }, originalImageUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'originalImageUri', type: { diff --git a/lib/services/customVision/training/lib/models/imageCreateResult.js b/lib/services/customVision/training/lib/models/imageCreateResult.js index bc1f0559e4..38f3ca7851 100644 --- a/lib/services/customVision/training/lib/models/imageCreateResult.js +++ b/lib/services/customVision/training/lib/models/imageCreateResult.js @@ -55,7 +55,7 @@ class ImageCreateResult { modelProperties: { sourceUrl: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'sourceUrl', type: { @@ -73,6 +73,7 @@ class ImageCreateResult { }, image: { required: false, + nullable: false, readOnly: true, serializedName: 'image', type: { diff --git a/lib/services/customVision/training/lib/models/imageCreateSummary.js b/lib/services/customVision/training/lib/models/imageCreateSummary.js index c0ef1aedb8..94455ace49 100644 --- a/lib/services/customVision/training/lib/models/imageCreateSummary.js +++ b/lib/services/customVision/training/lib/models/imageCreateSummary.js @@ -48,7 +48,6 @@ class ImageCreateSummary { }, images: { required: false, - nullable: true, readOnly: true, serializedName: 'images', type: { diff --git a/lib/services/customVision/training/lib/models/imageFileCreateBatch.js b/lib/services/customVision/training/lib/models/imageFileCreateBatch.js index 42b9c133fd..d56b140bf9 100644 --- a/lib/services/customVision/training/lib/models/imageFileCreateBatch.js +++ b/lib/services/customVision/training/lib/models/imageFileCreateBatch.js @@ -38,7 +38,6 @@ class ImageFileCreateBatch { modelProperties: { images: { required: false, - nullable: true, serializedName: 'images', type: { name: 'Sequence', @@ -54,7 +53,6 @@ class ImageFileCreateBatch { }, tagIds: { required: false, - nullable: true, serializedName: 'tagIds', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imageFileCreateEntry.js b/lib/services/customVision/training/lib/models/imageFileCreateEntry.js index c43e4c4dd1..78ba2de22d 100644 --- a/lib/services/customVision/training/lib/models/imageFileCreateEntry.js +++ b/lib/services/customVision/training/lib/models/imageFileCreateEntry.js @@ -40,7 +40,7 @@ class ImageFileCreateEntry { modelProperties: { name: { required: false, - nullable: true, + nullable: false, serializedName: 'name', type: { name: 'String' @@ -48,7 +48,7 @@ class ImageFileCreateEntry { }, contents: { required: false, - nullable: true, + nullable: false, serializedName: 'contents', type: { name: 'ByteArray' @@ -56,7 +56,6 @@ class ImageFileCreateEntry { }, tagIds: { required: false, - nullable: true, serializedName: 'tagIds', type: { name: 'Sequence', @@ -71,7 +70,6 @@ class ImageFileCreateEntry { }, regions: { required: false, - nullable: true, serializedName: 'regions', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imageIdCreateBatch.js b/lib/services/customVision/training/lib/models/imageIdCreateBatch.js index 3d3be80439..4b4b6451f9 100644 --- a/lib/services/customVision/training/lib/models/imageIdCreateBatch.js +++ b/lib/services/customVision/training/lib/models/imageIdCreateBatch.js @@ -38,7 +38,6 @@ class ImageIdCreateBatch { modelProperties: { images: { required: false, - nullable: true, serializedName: 'images', type: { name: 'Sequence', @@ -54,7 +53,6 @@ class ImageIdCreateBatch { }, tagIds: { required: false, - nullable: true, serializedName: 'tagIds', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imageIdCreateEntry.js b/lib/services/customVision/training/lib/models/imageIdCreateEntry.js index 25731b8a68..52218506d5 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] */ @@ -47,7 +47,6 @@ class ImageIdCreateEntry { }, tagIds: { required: false, - nullable: true, serializedName: 'tagIds', type: { name: 'Sequence', @@ -62,7 +61,6 @@ class ImageIdCreateEntry { }, regions: { required: false, - nullable: true, serializedName: 'regions', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imagePerformance.js b/lib/services/customVision/training/lib/models/imagePerformance.js index 8f1a6cb08a..a03c25d64e 100644 --- a/lib/services/customVision/training/lib/models/imagePerformance.js +++ b/lib/services/customVision/training/lib/models/imagePerformance.js @@ -99,7 +99,7 @@ class ImagePerformance { }, imageUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'imageUri', type: { @@ -108,7 +108,7 @@ class ImagePerformance { }, thumbnailUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'thumbnailUri', type: { diff --git a/lib/services/customVision/training/lib/models/imagePrediction.js b/lib/services/customVision/training/lib/models/imagePrediction.js index 682587f610..ba8ea27782 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() { } @@ -77,7 +78,6 @@ class ImagePrediction { }, predictions: { required: false, - nullable: true, readOnly: true, serializedName: 'predictions', type: { diff --git a/lib/services/customVision/training/lib/models/imageRegion.js b/lib/services/customVision/training/lib/models/imageRegion.js index 9f0e4a6188..b25e006c18 100644 --- a/lib/services/customVision/training/lib/models/imageRegion.js +++ b/lib/services/customVision/training/lib/models/imageRegion.js @@ -19,11 +19,11 @@ class ImageRegion { * @property {uuid} [regionId] * @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 {uuid} tagId Id of the tag associated with this region. + * @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() { } @@ -53,7 +53,7 @@ class ImageRegion { }, tagName: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'tagName', type: { @@ -70,7 +70,7 @@ class ImageRegion { } }, tagId: { - required: false, + required: true, nullable: false, serializedName: 'tagId', type: { @@ -78,7 +78,7 @@ class ImageRegion { } }, left: { - required: false, + required: true, nullable: false, serializedName: 'left', type: { @@ -86,7 +86,7 @@ class ImageRegion { } }, top: { - required: false, + required: true, nullable: false, serializedName: 'top', type: { @@ -94,7 +94,7 @@ class ImageRegion { } }, width: { - required: false, + required: true, nullable: false, serializedName: 'width', type: { @@ -102,7 +102,7 @@ class ImageRegion { } }, height: { - required: false, + required: true, nullable: false, serializedName: 'height', type: { diff --git a/lib/services/customVision/training/lib/models/imageRegionCreateBatch.js b/lib/services/customVision/training/lib/models/imageRegionCreateBatch.js index 1c7f01e265..03edb81e7b 100644 --- a/lib/services/customVision/training/lib/models/imageRegionCreateBatch.js +++ b/lib/services/customVision/training/lib/models/imageRegionCreateBatch.js @@ -38,7 +38,6 @@ class ImageRegionCreateBatch { modelProperties: { regions: { required: false, - nullable: true, serializedName: 'regions', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js b/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js index 6083b3c910..3afbb8e56b 100644 --- a/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js +++ b/lib/services/customVision/training/lib/models/imageRegionCreateEntry.js @@ -17,12 +17,12 @@ 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 {uuid} imageId Id of the image. + * @property {uuid} tagId Id of the tag associated with this region. + * @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() { } @@ -42,7 +42,7 @@ class ImageRegionCreateEntry { className: 'ImageRegionCreateEntry', modelProperties: { imageId: { - required: false, + required: true, nullable: false, serializedName: 'imageId', type: { @@ -50,7 +50,7 @@ class ImageRegionCreateEntry { } }, tagId: { - required: false, + required: true, nullable: false, serializedName: 'tagId', type: { @@ -58,7 +58,7 @@ class ImageRegionCreateEntry { } }, left: { - required: false, + required: true, nullable: false, serializedName: 'left', type: { @@ -66,7 +66,7 @@ class ImageRegionCreateEntry { } }, top: { - required: false, + required: true, nullable: false, serializedName: 'top', type: { @@ -74,7 +74,7 @@ class ImageRegionCreateEntry { } }, width: { - required: false, + required: true, nullable: false, serializedName: 'width', type: { @@ -82,7 +82,7 @@ class ImageRegionCreateEntry { } }, height: { - required: false, + required: true, nullable: false, serializedName: 'height', type: { diff --git a/lib/services/customVision/training/lib/models/imageRegionCreateResult.js b/lib/services/customVision/training/lib/models/imageRegionCreateResult.js index 81658389cb..09e38668bc 100644 --- a/lib/services/customVision/training/lib/models/imageRegionCreateResult.js +++ b/lib/services/customVision/training/lib/models/imageRegionCreateResult.js @@ -20,11 +20,11 @@ class ImageRegionCreateResult { * @property {uuid} [regionId] * @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 {uuid} tagId Id of the tag associated with this region. + * @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() { } @@ -63,7 +63,7 @@ class ImageRegionCreateResult { }, tagName: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'tagName', type: { @@ -80,7 +80,7 @@ class ImageRegionCreateResult { } }, tagId: { - required: false, + required: true, nullable: false, serializedName: 'tagId', type: { @@ -88,7 +88,7 @@ class ImageRegionCreateResult { } }, left: { - required: false, + required: true, nullable: false, serializedName: 'left', type: { @@ -96,7 +96,7 @@ class ImageRegionCreateResult { } }, top: { - required: false, + required: true, nullable: false, serializedName: 'top', type: { @@ -104,7 +104,7 @@ class ImageRegionCreateResult { } }, width: { - required: false, + required: true, nullable: false, serializedName: 'width', type: { @@ -112,7 +112,7 @@ class ImageRegionCreateResult { } }, height: { - required: false, + required: true, nullable: false, serializedName: 'height', type: { diff --git a/lib/services/customVision/training/lib/models/imageRegionProposal.js b/lib/services/customVision/training/lib/models/imageRegionProposal.js index 4fea5b5467..de56de3221 100644 --- a/lib/services/customVision/training/lib/models/imageRegionProposal.js +++ b/lib/services/customVision/training/lib/models/imageRegionProposal.js @@ -57,7 +57,6 @@ class ImageRegionProposal { }, proposals: { required: false, - nullable: true, readOnly: true, serializedName: 'proposals', type: { diff --git a/lib/services/customVision/training/lib/models/imageTag.js b/lib/services/customVision/training/lib/models/imageTag.js index 1017851b23..cac41ad674 100644 --- a/lib/services/customVision/training/lib/models/imageTag.js +++ b/lib/services/customVision/training/lib/models/imageTag.js @@ -48,7 +48,7 @@ class ImageTag { }, tagName: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'tagName', type: { diff --git a/lib/services/customVision/training/lib/models/imageTagCreateBatch.js b/lib/services/customVision/training/lib/models/imageTagCreateBatch.js index a2aa933237..b06999ee65 100644 --- a/lib/services/customVision/training/lib/models/imageTagCreateBatch.js +++ b/lib/services/customVision/training/lib/models/imageTagCreateBatch.js @@ -38,7 +38,6 @@ class ImageTagCreateBatch { modelProperties: { tags: { required: false, - nullable: true, serializedName: 'tags', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imageUrl.js b/lib/services/customVision/training/lib/models/imageUrl.js index 31cb128ce9..cb309129b0 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() { } @@ -36,8 +37,8 @@ class ImageUrl { className: 'ImageUrl', modelProperties: { url: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'url', type: { name: 'String' diff --git a/lib/services/customVision/training/lib/models/imageUrlCreateBatch.js b/lib/services/customVision/training/lib/models/imageUrlCreateBatch.js index add1ab85f7..7afb29b774 100644 --- a/lib/services/customVision/training/lib/models/imageUrlCreateBatch.js +++ b/lib/services/customVision/training/lib/models/imageUrlCreateBatch.js @@ -38,7 +38,6 @@ class ImageUrlCreateBatch { modelProperties: { images: { required: false, - nullable: true, serializedName: 'images', type: { name: 'Sequence', @@ -54,7 +53,6 @@ class ImageUrlCreateBatch { }, tagIds: { required: false, - nullable: true, serializedName: 'tagIds', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/imageUrlCreateEntry.js b/lib/services/customVision/training/lib/models/imageUrlCreateEntry.js index 1b1feb004f..e68626e42e 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] */ @@ -38,8 +38,8 @@ class ImageUrlCreateEntry { className: 'ImageUrlCreateEntry', modelProperties: { url: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'url', type: { name: 'String' @@ -47,7 +47,6 @@ class ImageUrlCreateEntry { }, tagIds: { required: false, - nullable: true, serializedName: 'tagIds', type: { name: 'Sequence', @@ -62,7 +61,6 @@ class ImageUrlCreateEntry { }, regions: { required: false, - nullable: true, serializedName: 'regions', type: { name: 'Sequence', diff --git a/lib/services/customVision/training/lib/models/index.d.ts b/lib/services/customVision/training/lib/models/index.d.ts index 767b7d2bd1..d16a212b8c 100644 --- a/lib/services/customVision/training/lib/models/index.d.ts +++ b/lib/services/customVision/training/lib/models/index.d.ts @@ -56,15 +56,27 @@ export interface ImageRegionCreateEntry { /** * Id of the image. */ - imageId?: string; + imageId: string; /** * Id of the tag associated with this region. */ - tagId?: string; - left?: number; - top?: number; - width?: number; - height?: number; + tagId: string; + /** + * Coordinate of the left boundary. + */ + left: number; + /** + * Coordinate of the top boundary. + */ + top: number; + /** + * Width. + */ + width: number; + /** + * Height. + */ + height: number; } /** @@ -82,11 +94,23 @@ export interface ImageRegionCreateResult { /** * Id of the tag associated with this region. */ - tagId?: string; - left?: number; - top?: number; - width?: number; - height?: number; + tagId: string; + /** + * Coordinate of the left boundary. + */ + left: number; + /** + * Coordinate of the top boundary. + */ + top: number; + /** + * Width. + */ + width: number; + /** + * Height. + */ + height: number; } export interface ImageRegionCreateSummary { @@ -108,11 +132,23 @@ export interface ImageRegion { /** * Id of the tag associated with this region. */ - tagId?: string; - left?: number; - top?: number; - width?: number; - height?: number; + tagId: string; + /** + * Coordinate of the left boundary. + */ + left: number; + /** + * Coordinate of the top boundary. + */ + top: number; + /** + * Width. + */ + width: number; + /** + * Height. + */ + height: number; } /** @@ -190,11 +226,23 @@ export interface Region { /** * Id of the tag associated with this region. */ - tagId?: string; - left?: number; - top?: number; - width?: number; - height?: number; + tagId: string; + /** + * Coordinate of the left boundary. + */ + left: number; + /** + * Coordinate of the top boundary. + */ + top: number; + /** + * Width. + */ + width: number; + /** + * Height. + */ + height: number; } export interface ImageFileCreateEntry { @@ -210,7 +258,10 @@ export interface ImageFileCreateBatch { } export interface ImageUrlCreateEntry { - url?: string; + /** + * 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,11 +285,26 @@ export interface ImageIdCreateBatch { tagIds?: string[]; } +/** + * Bounding box that defines a region of an image. +*/ export interface BoundingBox { - left?: number; - top?: number; - width?: number; - height?: number; + /** + * Coordinate of the left boundary. + */ + left: number; + /** + * Coordinate of the top boundary. + */ + top: number; + /** + * Width. + */ + width: number; + /** + * Height. + */ + height: number; } export interface RegionProposal { @@ -249,22 +318,61 @@ export interface ImageRegionProposal { readonly proposals?: RegionProposal[]; } +/** + * Image url. +*/ export interface ImageUrl { - url?: string; + /** + * 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,33 +541,37 @@ export interface ProjectSettings { */ export interface Project { /** - * Gets The project id. + * Gets the project id. */ readonly id?: string; /** * Gets or sets the name of the project. */ - name?: string; + name: string; /** * Gets or sets the description of the project. */ - description?: string; + description: string; /** * Gets or sets the project settings. */ - settings?: ProjectSettings; + settings: ProjectSettings; /** * Gets the date this project was created. */ 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; } /** @@ -454,12 +585,7 @@ 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; + name: string; /** * 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,28 @@ 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 advanced training budget for the iteration. + */ + readonly reservedBudgetInHours?: number; + /** + * Name of the published model. + */ + readonly publishName?: string; + /** + * Resource Provider Id this iteration was originally published to. + */ + readonly originalPublishResourceId?: 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 +656,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; /** @@ -530,17 +677,77 @@ export interface Tag { /** * Gets or sets the name of the tag. */ - name?: string; + name: string; /** * Gets or sets the description of the tag. */ - description?: string; + description: string; /** * Gets or sets the type of the tag. Possible values include: 'Regular', 'Negative' */ - type?: string; + type: string; /** * Gets the number of images with this 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', 'BadRequestRequiredParamIsNull', + * 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + * 'BadRequestInvalidPublishTarget', 'BadRequestUnpublishFailed', + * 'BadRequestIterationNotPublished', 'BadRequestSubscriptionApi', + * 'BadRequestExceedProjectLimit', 'BadRequestExceedIterationPerProjectLimit', + * 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', + * 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', + * 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', 'BadRequestImageStream', + * 'BadRequestImageUrl', 'BadRequestImageFormat', 'BadRequestImageSizeBytes', + * 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', + * 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', + * 'BadRequestClassificationTrainingValidationFailed', + * 'BadRequestMultiClassClassificationTrainingValidationFailed', + * 'BadRequestMultiLabelClassificationTrainingValidationFailed', + * 'BadRequestDetectionTrainingValidationFailed', 'BadRequestTrainingAlreadyInProgress', + * 'BadRequestDetectionTrainingNotAllowNegativeTag', 'BadRequestInvalidEmailAddress', + * 'BadRequestDomainNotSupportedForAdvancedTraining', + * 'BadRequestExportPlatformNotSupportedForAdvancedTraining', + * 'BadRequestReservedBudgetInHoursNotEnoughForAdvancedTraining', + * '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..a49ee90f3a 100644 --- a/lib/services/customVision/training/lib/models/iteration.js +++ b/lib/services/customVision/training/lib/models/iteration.js @@ -18,22 +18,29 @@ 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} name Gets or sets the name of the iteration. * @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 advanced + * training budget for the iteration. + * @property {string} [publishName] Name of the published model. + * @property {string} [originalPublishResourceId] Resource Provider Id this + * iteration was originally published to. */ constructor() { } @@ -62,24 +69,16 @@ class Iteration { } }, name: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'name', type: { name: 'String' } }, - isDefault: { - required: false, - nullable: false, - serializedName: 'isDefault', - type: { - name: 'Boolean' - } - }, status: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'status', type: { @@ -131,6 +130,21 @@ class Iteration { name: 'Boolean' } }, + exportableTo: { + required: false, + readOnly: true, + serializedName: 'exportableTo', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, domainId: { required: false, nullable: true, @@ -148,6 +162,42 @@ 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' + } + }, + originalPublishResourceId: { + required: false, + nullable: true, + readOnly: true, + serializedName: 'originalPublishResourceId', + type: { + name: 'String' + } } } } diff --git a/lib/services/customVision/training/lib/models/iterationPerformance.js b/lib/services/customVision/training/lib/models/iterationPerformance.js index a0349f84b1..5bfe95939d 100644 --- a/lib/services/customVision/training/lib/models/iterationPerformance.js +++ b/lib/services/customVision/training/lib/models/iterationPerformance.js @@ -47,7 +47,6 @@ class IterationPerformance { modelProperties: { perTagPerformance: { required: false, - nullable: true, readOnly: true, serializedName: 'perTagPerformance', type: { diff --git a/lib/services/customVision/training/lib/models/prediction.js b/lib/services/customVision/training/lib/models/prediction.js index b069516a77..481f26078c 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() { } @@ -71,6 +72,7 @@ class Prediction { }, boundingBox: { required: false, + nullable: true, readOnly: true, serializedName: 'boundingBox', type: { diff --git a/lib/services/customVision/training/lib/models/predictionQueryResult.js b/lib/services/customVision/training/lib/models/predictionQueryResult.js index 2d16a6d156..77fa8083b9 100644 --- a/lib/services/customVision/training/lib/models/predictionQueryResult.js +++ b/lib/services/customVision/training/lib/models/predictionQueryResult.js @@ -48,6 +48,7 @@ class PredictionQueryResult { modelProperties: { token: { required: false, + nullable: false, readOnly: true, serializedName: 'token', type: { @@ -57,7 +58,6 @@ class PredictionQueryResult { }, results: { required: false, - nullable: true, readOnly: true, serializedName: 'results', type: { diff --git a/lib/services/customVision/training/lib/models/predictionQueryToken.js b/lib/services/customVision/training/lib/models/predictionQueryToken.js index b13a32336b..9640da971d 100644 --- a/lib/services/customVision/training/lib/models/predictionQueryToken.js +++ b/lib/services/customVision/training/lib/models/predictionQueryToken.js @@ -46,7 +46,7 @@ class PredictionQueryToken { modelProperties: { session: { required: false, - nullable: true, + nullable: false, serializedName: 'session', type: { name: 'String' @@ -54,7 +54,7 @@ class PredictionQueryToken { }, continuation: { required: false, - nullable: true, + nullable: false, serializedName: 'continuation', type: { name: 'String' @@ -78,7 +78,6 @@ class PredictionQueryToken { }, tags: { required: false, - nullable: true, serializedName: 'tags', type: { name: 'Sequence', @@ -118,7 +117,7 @@ class PredictionQueryToken { }, application: { required: false, - nullable: true, + nullable: false, serializedName: 'application', type: { name: 'String' diff --git a/lib/services/customVision/training/lib/models/project.js b/lib/services/customVision/training/lib/models/project.js index ae364fb038..8dc674d1bd 100644 --- a/lib/services/customVision/training/lib/models/project.js +++ b/lib/services/customVision/training/lib/models/project.js @@ -17,21 +17,24 @@ class Project { /** * Create a Project. - * @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 + * @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. - * @property {object} [settings] Gets or sets the project settings. + * @property {object} settings Gets or sets the project settings. * @property {uuid} [settings.domainId] Gets or sets the id of the Domain to * use with this 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() { } @@ -60,23 +63,24 @@ class Project { } }, name: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'name', type: { name: 'String' } }, description: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'description', type: { name: 'String' } }, settings: { - required: false, + required: true, + nullable: false, serializedName: 'settings', type: { name: 'Composite', @@ -103,12 +107,21 @@ class Project { }, thumbnailUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'thumbnailUri', type: { name: 'String' } + }, + drModeEnabled: { + required: false, + nullable: true, + 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..b7da8560ce 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,20 @@ class ProjectSettings { type: { name: 'String' } + }, + targetExportPlatforms: { + required: false, + 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..b5dec44374 100644 --- a/lib/services/customVision/training/lib/models/region.js +++ b/lib/services/customVision/training/lib/models/region.js @@ -16,11 +16,11 @@ 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 {uuid} tagId Id of the tag associated with this region. + * @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() { } @@ -40,7 +40,7 @@ class Region { className: 'Region', modelProperties: { tagId: { - required: false, + required: true, nullable: false, serializedName: 'tagId', type: { @@ -48,7 +48,7 @@ class Region { } }, left: { - required: false, + required: true, nullable: false, serializedName: 'left', type: { @@ -56,7 +56,7 @@ class Region { } }, top: { - required: false, + required: true, nullable: false, serializedName: 'top', type: { @@ -64,7 +64,7 @@ class Region { } }, width: { - required: false, + required: true, nullable: false, serializedName: 'width', type: { @@ -72,7 +72,7 @@ class Region { } }, height: { - required: false, + required: true, nullable: false, serializedName: 'height', type: { diff --git a/lib/services/customVision/training/lib/models/regionProposal.js b/lib/services/customVision/training/lib/models/regionProposal.js index f4026b8ea0..2f6a4870b7 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() { } @@ -51,6 +51,7 @@ class RegionProposal { }, boundingBox: { required: false, + nullable: false, readOnly: true, serializedName: 'boundingBox', type: { diff --git a/lib/services/customVision/training/lib/models/storedImagePrediction.js b/lib/services/customVision/training/lib/models/storedImagePrediction.js index b5d10902f3..b817f51642 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() { } @@ -49,7 +49,7 @@ class StoredImagePrediction { modelProperties: { resizedImageUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'resizedImageUri', type: { @@ -58,7 +58,7 @@ class StoredImagePrediction { }, thumbnailUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'thumbnailUri', type: { @@ -67,7 +67,7 @@ class StoredImagePrediction { }, originalImageUri: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'originalImageUri', type: { @@ -121,7 +121,6 @@ class StoredImagePrediction { }, predictions: { required: false, - nullable: true, readOnly: true, serializedName: 'predictions', type: { diff --git a/lib/services/customVision/training/lib/models/tag.js b/lib/services/customVision/training/lib/models/tag.js index c75fd69d31..03102653a1 100644 --- a/lib/services/customVision/training/lib/models/tag.js +++ b/lib/services/customVision/training/lib/models/tag.js @@ -18,10 +18,10 @@ class Tag { /** * Create a Tag. * @property {uuid} [id] Gets the Tag ID. - * @property {string} [name] Gets or sets the name of the tag. - * @property {string} [description] Gets or sets the description of the tag. - * @property {string} [type] Gets or sets the type of the tag. Possible - * values include: 'Regular', 'Negative' + * @property {string} name Gets or sets the name of the tag. + * @property {string} description Gets or sets the description of the tag. + * @property {string} type Gets or sets the type of the tag. Possible values + * include: 'Regular', 'Negative' * @property {number} [imageCount] Gets the number of images with this tag. */ constructor() { @@ -51,23 +51,23 @@ class Tag { } }, name: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'name', type: { name: 'String' } }, description: { - required: false, - nullable: true, + required: true, + nullable: false, serializedName: 'description', type: { name: 'String' } }, type: { - required: false, + required: true, nullable: false, serializedName: 'type', type: { diff --git a/lib/services/customVision/training/lib/models/tagPerformance.js b/lib/services/customVision/training/lib/models/tagPerformance.js index 5cca7a274f..aa557606f4 100644 --- a/lib/services/customVision/training/lib/models/tagPerformance.js +++ b/lib/services/customVision/training/lib/models/tagPerformance.js @@ -56,7 +56,7 @@ class TagPerformance { }, name: { required: false, - nullable: true, + nullable: false, readOnly: true, serializedName: 'name', type: { diff --git a/lib/services/customVision/training/lib/trainingAPIClient.d.ts b/lib/services/customVision/training/lib/trainingAPIClient.d.ts index 4e0159ccae..dfe6100129 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. @@ -805,7 +805,8 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -832,7 +833,8 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -874,7 +876,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 +897,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 +1089,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 +1117,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] * @@ -1286,10 +1288,10 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project to evaluate against. * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated. + * @param {object} imageUrl An 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. * @@ -1313,10 +1315,10 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project to evaluate against. * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated. + * @param {object} imageUrl An 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. * @@ -1359,7 +1361,8 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -1383,7 +1386,8 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -1830,6 +1834,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 +1846,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 +1863,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 +1891,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; /** @@ -2002,12 +2012,12 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} updatedProject The updated project model. * - * @param {string} [updatedProject.name] Gets or sets the name of the project. + * @param {string} updatedProject.name Gets or sets the name of the project. * - * @param {string} [updatedProject.description] Gets or sets the description of + * @param {string} updatedProject.description Gets or sets the description of * the project. * - * @param {object} [updatedProject.settings] Gets or sets the project settings. + * @param {object} updatedProject.settings Gets or sets the project settings. * * @param {uuid} [updatedProject.settings.domainId] Gets or sets the id of the * Domain to use with this project. @@ -2016,6 +2026,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 @@ -2036,12 +2049,12 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} updatedProject The updated project model. * - * @param {string} [updatedProject.name] Gets or sets the name of the project. + * @param {string} updatedProject.name Gets or sets the name of the project. * - * @param {string} [updatedProject.description] Gets or sets the description of + * @param {string} updatedProject.description Gets or sets the description of * the project. * - * @param {object} [updatedProject.settings] Gets or sets the project settings. + * @param {object} updatedProject.settings Gets or sets the project settings. * * @param {uuid} [updatedProject.settings.domainId] Gets or sets the id of the * Domain to use with this project. @@ -2050,6 +2063,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 @@ -2082,6 +2098,87 @@ export default class TrainingAPIClient extends ServiceClient { updateProject(projectId: string, updatedProject: models.Project, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * @summary Queues project for training. + * + * @param {uuid} projectId The project id. + * + * @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 + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + trainProjectWithHttpOperationResponse(projectId: string, options?: { trainingType? : string, reservedBudgetInHours? : number, forceTrain? : boolean, notificationEmailAddress? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary Queues project for training. + * + * @param {uuid} projectId The project id. + * + * @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 + * + * @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 {Iteration} - 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. + * + * {Iteration} [result] - The deserialized result object if an error did not occur. + * See {@link Iteration} 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. + */ + 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: { trainingType? : string, reservedBudgetInHours? : number, forceTrain? : boolean, notificationEmailAddress? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * @summary Get iterations for the project. * @@ -2262,12 +2359,9 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} updatedIteration The updated iteration model. * - * @param {string} [updatedIteration.name] Gets or sets the name of the + * @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 @@ -2290,12 +2384,9 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} updatedIteration The updated iteration model. * - * @param {string} [updatedIteration.name] Gets or sets the name of the + * @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 @@ -2329,10 +2420,17 @@ export default class TrainingAPIClient extends ServiceClient { /** - * @summary Queues project for training. + * @summary Publish a specific iteration. * * @param {uuid} projectId The project id. * + * @param {uuid} iterationId The iteration id. + * + * @param {string} publishName The name to give the published iteration. + * + * @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 @@ -2340,17 +2438,24 @@ export default class TrainingAPIClient extends ServiceClient { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - trainProjectWithHttpOperationResponse(projectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + publishIterationWithHttpOperationResponse(projectId: string, iterationId: string, publishName: string, predictionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Queues project for training. + * @summary Publish a specific iteration. * * @param {uuid} projectId The project id. * + * @param {uuid} iterationId The iteration id. + * + * @param {string} publishName The name to give the published iteration. + * + * @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 @@ -2363,7 +2468,7 @@ export default class TrainingAPIClient extends ServiceClient { * * {Promise} A promise is returned. * - * @resolve {Iteration} - The deserialized result object. + * @resolve {Boolean} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2371,16 +2476,73 @@ export default class TrainingAPIClient extends ServiceClient { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Iteration} [result] - The deserialized result object if an error did not occur. - * See {@link Iteration} for more information. + * {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. */ - trainProject(projectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - trainProject(projectId: string, callback: ServiceCallback): void; - trainProject(projectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + publishIteration(projectId: string, iterationId: string, publishName: string, predictionId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + publishIteration(projectId: string, iterationId: string, publishName: string, predictionId: string, callback: ServiceCallback): void; + publishIteration(projectId: string, iterationId: string, publishName: 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 {null} - 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. + * + * {null} [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; /** @@ -2449,12 +2611,12 @@ export default class TrainingAPIClient extends ServiceClient { * @param {uuid} iterationId The iteration id. * * @param {string} platform The target platform. Possible values include: - * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', 'VAIDK' * * @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 @@ -2475,12 +2637,12 @@ export default class TrainingAPIClient extends ServiceClient { * @param {uuid} iterationId The iteration id. * * @param {string} platform The target platform. Possible values include: - * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', 'VAIDK' * * @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 @@ -2644,12 +2806,12 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} updatedTag The updated tag model. * - * @param {string} [updatedTag.name] Gets or sets the name of the tag. + * @param {string} updatedTag.name Gets or sets the name of the tag. * - * @param {string} [updatedTag.description] Gets or sets the description of the + * @param {string} updatedTag.description Gets or sets the description of the * tag. * - * @param {string} [updatedTag.type] Gets or sets the type of the tag. Possible + * @param {string} updatedTag.type Gets or sets the type of the tag. Possible * values include: 'Regular', 'Negative' * * @param {object} [options] Optional Parameters. @@ -2674,12 +2836,12 @@ export default class TrainingAPIClient extends ServiceClient { * * @param {object} updatedTag The updated tag model. * - * @param {string} [updatedTag.name] Gets or sets the name of the tag. + * @param {string} updatedTag.name Gets or sets the name of the tag. * - * @param {string} [updatedTag.description] Gets or sets the description of the + * @param {string} updatedTag.description Gets or sets the description of the * tag. * - * @param {string} [updatedTag.type] Gets or sets the type of the tag. Possible + * @param {string} updatedTag.type Gets or sets the type of the tag. Possible * values include: 'Regular', 'Negative' * * @param {object} [options] Optional Parameters. diff --git a/lib/services/customVision/training/lib/trainingAPIClient.js b/lib/services/customVision/training/lib/trainingAPIClient.js index 16d486b971..4b64449ac9 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.`; @@ -334,8 +342,8 @@ function _getTaggedImageCount(projectId, options, callback) { } if (Array.isArray(tagIds)) { for (let i = 0; i < tagIds.length; i++) { - if (tagIds[i] !== null && tagIds[i] !== undefined && typeof tagIds[i].valueOf() !== 'string') { - throw new Error('tagIds[i] must be of type string.'); + if (tagIds[i] !== null && tagIds[i] !== undefined && !(typeof tagIds[i].valueOf() === 'string' && msRest.isValidUuid(tagIds[i]))) { + throw new Error('tagIds[i] must be of type string and must be a valid uuid.'); } } } @@ -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. @@ -781,16 +801,36 @@ function _deleteImageTags(projectId, imageIds, tagIds, options, callback) { throw new Error('imageIds cannot be null or undefined and it must be of type array.'); } for (let i = 0; i < imageIds.length; i++) { - if (imageIds[i] !== null && imageIds[i] !== undefined && typeof imageIds[i].valueOf() !== 'string') { - throw new Error('imageIds[i] must be of type string.'); + if (imageIds[i] !== null && imageIds[i] !== undefined && !(typeof imageIds[i].valueOf() === 'string' && msRest.isValidUuid(imageIds[i]))) { + throw new Error('imageIds[i] must be of type string and must be a valid uuid.'); + } + } + if (imageIds !== null && imageIds !== undefined) { + if (imageIds.length > 64) + { + throw new Error('"imageIds" should satisfy the constraint - "MaxItems": 64'); + } + if (imageIds.length < 0) + { + throw new Error('"imageIds" should satisfy the constraint - "MinItems": 0'); } } if (!Array.isArray(tagIds)) { throw new Error('tagIds cannot be null or undefined and it must be of type array.'); } for (let i1 = 0; i1 < tagIds.length; i1++) { - if (tagIds[i1] !== null && tagIds[i1] !== undefined && typeof tagIds[i1].valueOf() !== 'string') { - throw new Error('tagIds[i1] must be of type string.'); + if (tagIds[i1] !== null && tagIds[i1] !== undefined && !(typeof tagIds[i1].valueOf() === 'string' && msRest.isValidUuid(tagIds[i1]))) { + throw new Error('tagIds[i1] must be of type string and must be a valid uuid.'); + } + } + if (tagIds !== null && tagIds !== undefined) { + if (tagIds.length > 20) + { + throw new Error('"tagIds" should satisfy the constraint - "MaxItems": 20'); + } + if (tagIds.length < 0) + { + throw new Error('"tagIds" should satisfy the constraint - "MinItems": 0'); } } if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { @@ -851,6 +891,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 +1030,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.`; @@ -1064,8 +1112,18 @@ function _deleteImageRegions(projectId, regionIds, options, callback) { throw new Error('regionIds cannot be null or undefined and it must be of type array.'); } for (let i = 0; i < regionIds.length; i++) { - if (regionIds[i] !== null && regionIds[i] !== undefined && typeof regionIds[i].valueOf() !== 'string') { - throw new Error('regionIds[i] must be of type string.'); + if (regionIds[i] !== null && regionIds[i] !== undefined && !(typeof regionIds[i].valueOf() === 'string' && msRest.isValidUuid(regionIds[i]))) { + throw new Error('regionIds[i] must be of type string and must be a valid uuid.'); + } + } + if (regionIds !== null && regionIds !== undefined) { + if (regionIds.length > 64) + { + throw new Error('"regionIds" should satisfy the constraint - "MaxItems": 64'); + } + if (regionIds.length < 0) + { + throw new Error('"regionIds" should satisfy the constraint - "MinItems": 0'); } } if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { @@ -1125,6 +1183,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.`; @@ -1212,17 +1274,37 @@ function _getTaggedImages(projectId, options, callback) { } if (Array.isArray(tagIds)) { for (let i = 0; i < tagIds.length; i++) { - if (tagIds[i] !== null && tagIds[i] !== undefined && typeof tagIds[i].valueOf() !== 'string') { - throw new Error('tagIds[i] must be of type string.'); + if (tagIds[i] !== null && tagIds[i] !== undefined && !(typeof tagIds[i].valueOf() === 'string' && msRest.isValidUuid(tagIds[i]))) { + throw new Error('tagIds[i] must be of type string and must be a valid uuid.'); } } } + if (tagIds !== null && tagIds !== undefined) { + if (tagIds.length > 20) + { + throw new Error('"tagIds" should satisfy the constraint - "MaxItems": 20'); + } + if (tagIds.length < 0) + { + throw new Error('"tagIds" should satisfy the constraint - "MinItems": 0'); + } + } if (orderBy !== null && orderBy !== undefined && typeof orderBy.valueOf() !== 'string') { throw new Error('orderBy must be of type string.'); } if (take !== null && take !== undefined && typeof take !== 'number') { throw new Error('take must be of type number.'); } + if (take !== null && take !== undefined) { + if (take > 256) + { + throw new Error('"take" should satisfy the constraint - "InclusiveMaximum": 256'); + } + if (take < 0) + { + throw new Error('"take" should satisfy the constraint - "InclusiveMinimum": 0'); + } + } if (skip !== null && skip !== undefined && typeof skip !== 'number') { throw new Error('skip must be of type number.'); } @@ -1297,6 +1379,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.`; @@ -1412,6 +1498,16 @@ function _getUntaggedImages(projectId, options, callback) { if (take !== null && take !== undefined && typeof take !== 'number') { throw new Error('take must be of type number.'); } + if (take !== null && take !== undefined) { + if (take > 256) + { + throw new Error('"take" should satisfy the constraint - "InclusiveMaximum": 256'); + } + if (take < 0) + { + throw new Error('"take" should satisfy the constraint - "InclusiveMinimum": 0'); + } + } if (skip !== null && skip !== undefined && typeof skip !== 'number') { throw new Error('skip must be of type number.'); } @@ -1483,6 +1579,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.`; @@ -1582,11 +1682,21 @@ function _getImagesByIds(projectId, options, callback) { } if (Array.isArray(imageIds)) { for (let i = 0; i < imageIds.length; i++) { - if (imageIds[i] !== null && imageIds[i] !== undefined && typeof imageIds[i].valueOf() !== 'string') { - throw new Error('imageIds[i] must be of type string.'); + if (imageIds[i] !== null && imageIds[i] !== undefined && !(typeof imageIds[i].valueOf() === 'string' && msRest.isValidUuid(imageIds[i]))) { + throw new Error('imageIds[i] must be of type string and must be a valid uuid.'); } } } + if (imageIds !== null && imageIds !== undefined) { + if (imageIds.length > 256) + { + throw new Error('"imageIds" should satisfy the constraint - "MaxItems": 256'); + } + if (imageIds.length < 0) + { + throw new Error('"imageIds" should satisfy the constraint - "MinItems": 0'); + } + } 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.'); } @@ -1652,6 +1762,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.`; @@ -1707,7 +1821,8 @@ function _getImagesByIds(projectId, options, callback) { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -1751,11 +1866,21 @@ function _createImagesFromData(projectId, imageData, options, callback) { } if (Array.isArray(tagIds)) { for (let i = 0; i < tagIds.length; i++) { - if (tagIds[i] !== null && tagIds[i] !== undefined && typeof tagIds[i].valueOf() !== 'string') { - throw new Error('tagIds[i] must be of type string.'); + if (tagIds[i] !== null && tagIds[i] !== undefined && !(typeof tagIds[i].valueOf() === 'string' && msRest.isValidUuid(tagIds[i]))) { + throw new Error('tagIds[i] must be of type string and must be a valid uuid.'); } } } + if (tagIds !== null && tagIds !== undefined) { + if (tagIds.length > 20) + { + throw new Error('"tagIds" should satisfy the constraint - "MaxItems": 20'); + } + if (tagIds.length < 0) + { + throw new Error('"tagIds" should satisfy the constraint - "MinItems": 0'); + } + } if (imageData === null || imageData === undefined) { throw new Error('imageData cannot be null or undefined and it must be of type object.'); } @@ -1823,6 +1948,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 +1989,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. @@ -1902,8 +2031,18 @@ function _deleteImages(projectId, imageIds, options, callback) { throw new Error('imageIds cannot be null or undefined and it must be of type array.'); } for (let i = 0; i < imageIds.length; i++) { - if (imageIds[i] !== null && imageIds[i] !== undefined && typeof imageIds[i].valueOf() !== 'string') { - throw new Error('imageIds[i] must be of type string.'); + if (imageIds[i] !== null && imageIds[i] !== undefined && !(typeof imageIds[i].valueOf() === 'string' && msRest.isValidUuid(imageIds[i]))) { + throw new Error('imageIds[i] must be of type string and must be a valid uuid.'); + } + } + if (imageIds !== null && imageIds !== undefined) { + if (imageIds.length > 256) + { + throw new Error('"imageIds" should satisfy the constraint - "MaxItems": 256'); + } + if (imageIds.length < 0) + { + throw new Error('"imageIds" should satisfy the constraint - "MinItems": 0'); } } if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { @@ -1963,6 +2102,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 +2241,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 +2397,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 +2441,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 +2553,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 +2648,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 +2692,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.`; @@ -2616,8 +2775,18 @@ function _deletePrediction(projectId, ids, options, callback) { throw new Error('ids cannot be null or undefined and it must be of type array.'); } for (let i = 0; i < ids.length; i++) { - if (ids[i] !== null && ids[i] !== undefined && typeof ids[i].valueOf() !== 'string') { - throw new Error('ids[i] must be of type string.'); + if (ids[i] !== null && ids[i] !== undefined && !(typeof ids[i].valueOf() === 'string' && msRest.isValidUuid(ids[i]))) { + throw new Error('ids[i] must be of type string and must be a valid uuid.'); + } + } + if (ids !== null && ids !== undefined) { + if (ids.length > 64) + { + throw new Error('"ids" should satisfy the constraint - "MaxItems": 64'); + } + if (ids.length < 0) + { + throw new Error('"ids" should satisfy the constraint - "MinItems": 0'); } } if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') { @@ -2677,6 +2846,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.`; @@ -2697,10 +2870,10 @@ function _deletePrediction(projectId, ids, options, callback) { * * @param {uuid} projectId The project to evaluate against. * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated. + * @param {object} imageUrl An 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 +2995,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.`; @@ -2859,7 +3036,8 @@ function _quickTestImageUrl(projectId, imageUrl, options, callback) { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -2972,6 +3150,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 +3318,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 +3477,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.`; @@ -3394,17 +3584,37 @@ function _getImagePerformances(projectId, iterationId, options, callback) { } if (Array.isArray(tagIds)) { for (let i = 0; i < tagIds.length; i++) { - if (tagIds[i] !== null && tagIds[i] !== undefined && typeof tagIds[i].valueOf() !== 'string') { - throw new Error('tagIds[i] must be of type string.'); + if (tagIds[i] !== null && tagIds[i] !== undefined && !(typeof tagIds[i].valueOf() === 'string' && msRest.isValidUuid(tagIds[i]))) { + throw new Error('tagIds[i] must be of type string and must be a valid uuid.'); } } } + if (tagIds !== null && tagIds !== undefined) { + if (tagIds.length > 20) + { + throw new Error('"tagIds" should satisfy the constraint - "MaxItems": 20'); + } + if (tagIds.length < 0) + { + throw new Error('"tagIds" should satisfy the constraint - "MinItems": 0'); + } + } if (orderBy !== null && orderBy !== undefined && typeof orderBy.valueOf() !== 'string') { throw new Error('orderBy must be of type string.'); } if (take !== null && take !== undefined && typeof take !== 'number') { throw new Error('take must be of type number.'); } + if (take !== null && take !== undefined) { + if (take > 256) + { + throw new Error('"take" should satisfy the constraint - "InclusiveMaximum": 256'); + } + if (take < 0) + { + throw new Error('"take" should satisfy the constraint - "InclusiveMinimum": 0'); + } + } if (skip !== null && skip !== undefined && typeof skip !== 'number') { throw new Error('skip must be of type number.'); } @@ -3477,6 +3687,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.`; @@ -3580,8 +3794,8 @@ function _getImagePerformanceCount(projectId, iterationId, options, callback) { } if (Array.isArray(tagIds)) { for (let i = 0; i < tagIds.length; i++) { - if (tagIds[i] !== null && tagIds[i] !== undefined && typeof tagIds[i].valueOf() !== 'string') { - throw new Error('tagIds[i] must be of type string.'); + if (tagIds[i] !== null && tagIds[i] !== undefined && !(typeof tagIds[i].valueOf() === 'string' && msRest.isValidUuid(tagIds[i]))) { + throw new Error('tagIds[i] must be of type string and must be a valid uuid.'); } } } @@ -3645,6 +3859,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 +3987,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 +4052,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 +4084,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 +4102,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 +4131,9 @@ function _createProject(name, options, callback) { if (classificationType !== null && classificationType !== undefined) { queryParameters.push('classificationType=' + encodeURIComponent(classificationType)); } + if (targetExportPlatforms !== null && targetExportPlatforms !== undefined) { + queryParameters.push('targetExportPlatforms=' + encodeURIComponent(targetExportPlatforms.join(','))); + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -3941,6 +4177,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 +4306,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 +4434,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.`; @@ -4212,12 +4460,12 @@ function _deleteProject(projectId, options, callback) { * * @param {object} updatedProject The updated project model. * - * @param {string} [updatedProject.name] Gets or sets the name of the project. + * @param {string} updatedProject.name Gets or sets the name of the project. * - * @param {string} [updatedProject.description] Gets or sets the description of + * @param {string} updatedProject.description Gets or sets the description of * the project. * - * @param {object} [updatedProject.settings] Gets or sets the project settings. + * @param {object} updatedProject.settings Gets or sets the project settings. * * @param {uuid} [updatedProject.settings.domainId] Gets or sets the id of the * Domain to use with this project. @@ -4226,6 +4474,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 +4582,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.`; @@ -4363,6 +4618,180 @@ function _updateProject(projectId, updatedProject, options, callback) { }); } +/** + * @summary Queues project for training. + * + * @param {uuid} projectId The project id. + * + * @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 + * + * @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 Iteration} 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 _trainProject(projectId, 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 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') { + 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 (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.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + 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(); + 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 = new client.models['Iteration']().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 Get iterations for the project. * @@ -4455,6 +4884,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 +5033,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 +5167,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.`; @@ -4754,12 +5195,9 @@ function _deleteIteration(projectId, iterationId, options, callback) { * * @param {object} updatedIteration The updated iteration model. * - * @param {string} [updatedIteration.name] Gets or sets the name of the + * @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 +5307,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.`; @@ -4902,10 +5344,17 @@ function _updateIteration(projectId, iterationId, updatedIteration, options, cal } /** - * @summary Queues project for training. + * @summary Publish a specific iteration. * * @param {uuid} projectId The project id. * + * @param {uuid} iterationId The iteration id. + * + * @param {string} publishName The name to give the published iteration. + * + * @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 @@ -4917,14 +5366,13 @@ function _updateIteration(projectId, iterationId, updatedIteration, options, cal * * {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 Iteration} for more information. + * {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 _trainProject(projectId, options, callback) { +function _publishIteration(projectId, iterationId, publishName, predictionId, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -4942,6 +5390,15 @@ 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 (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 (publishName === null || publishName === undefined || typeof publishName.valueOf() !== 'string') { + throw new Error('publishName 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.'); } @@ -4951,9 +5408,16 @@ function _trainProject(projectId, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'projects/{projectId}/train'; + 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('publishName=' + encodeURIComponent(publishName)); + queryParameters.push('predictionId=' + encodeURIComponent(predictionId)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -4994,6 +5458,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.`; @@ -5011,7 +5479,13 @@ function _trainProject(projectId, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['Iteration']().mapper(); + let resultMapper = { + required: false, + serializedName: 'parsedResponse', + type: { + name: 'Boolean' + } + }; result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -5027,7 +5501,7 @@ function _trainProject(projectId, options, callback) { } /** - * @summary Get the list of exports for a specific iteration. + * @summary Unpublish a specific iteration. * * @param {uuid} projectId The project id. * @@ -5044,13 +5518,13 @@ function _trainProject(projectId, options, callback) { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {null} [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 _getExports(projectId, iterationId, options, callback) { +function _unpublishIteration(projectId, iterationId, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -5080,14 +5554,14 @@ function _getExports(projectId, iterationId, options, callback) { // Construct URL let baseUrl = this.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'projects/{projectId}/iterations/{iterationId}/export'; + 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 = 'GET'; + httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers @@ -5109,7 +5583,7 @@ function _getExports(projectId, iterationId, options, callback) { return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 200) { + if (statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -5124,6 +5598,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.`; @@ -5134,7 +5612,124 @@ function _getExports(projectId, iterationId, options, callback) { // Create Result let result = null; if (responseBody === '') responseBody = null; - // Deserialize Response + + return callback(null, result, httpRequest, response); + }); +} + +/** + * @summary Get the list of exports for 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. + * + * {array} [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 _getExports(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}/export'; + 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 = 'GET'; + 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 { @@ -5178,12 +5773,12 @@ function _getExports(projectId, iterationId, options, callback) { * @param {uuid} iterationId The iteration id. * * @param {string} platform The target platform. Possible values include: - * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', 'VAIDK' * * @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 +5885,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 +6034,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 +6168,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.`; @@ -5589,12 +6196,12 @@ function _deleteTag(projectId, tagId, options, callback) { * * @param {object} updatedTag The updated tag model. * - * @param {string} [updatedTag.name] Gets or sets the name of the tag. + * @param {string} updatedTag.name Gets or sets the name of the tag. * - * @param {string} [updatedTag.description] Gets or sets the description of the + * @param {string} updatedTag.description Gets or sets the description of the * tag. * - * @param {string} [updatedTag.type] Gets or sets the type of the tag. Possible + * @param {string} updatedTag.type Gets or sets the type of the tag. Possible * values include: 'Regular', 'Negative' * * @param {object} [options] Optional Parameters. @@ -5706,6 +6313,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 +6454,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 +6626,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 +6666,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 +6686,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; @@ -6103,11 +6722,13 @@ class TrainingAPIClient extends ServiceClient { this._getProject = _getProject; this._deleteProject = _deleteProject; this._updateProject = _updateProject; + this._trainProject = _trainProject; this._getIterations = _getIterations; this._getIteration = _getIteration; 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 +7187,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 +7222,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. @@ -7182,7 +7803,8 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -7221,7 +7843,8 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -7278,7 +7901,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 +7934,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 +8195,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 +8235,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] * @@ -7852,10 +8475,10 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project to evaluate against. * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated. + * @param {object} imageUrl An 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. * @@ -7891,10 +8514,10 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project to evaluate against. * - * @param {object} imageUrl An {Iris.Web.Api.Models.ImageUrl} that contains the - * url of the image to be evaluated. + * @param {object} imageUrl An 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. * @@ -7952,7 +8575,8 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -7988,7 +8612,8 @@ class TrainingAPIClient extends ServiceClient { * * @param {uuid} projectId The project id. * - * @param {object} imageData Binary image data. + * @param {object} imageData Binary image data. Supported formats are JPEG, + * GIF, PNG, and BMP. Supports images up to 6MB. * * @param {object} [options] Optional Parameters. * @@ -8585,6 +9210,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 +9251,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 * @@ -8838,12 +9469,12 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} updatedProject The updated project model. * - * @param {string} [updatedProject.name] Gets or sets the name of the project. + * @param {string} updatedProject.name Gets or sets the name of the project. * - * @param {string} [updatedProject.description] Gets or sets the description of + * @param {string} updatedProject.description Gets or sets the description of * the project. * - * @param {object} [updatedProject.settings] Gets or sets the project settings. + * @param {object} updatedProject.settings Gets or sets the project settings. * * @param {uuid} [updatedProject.settings.domainId] Gets or sets the id of the * Domain to use with this project. @@ -8852,6 +9483,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 @@ -8884,12 +9518,12 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} updatedProject The updated project model. * - * @param {string} [updatedProject.name] Gets or sets the name of the project. + * @param {string} updatedProject.name Gets or sets the name of the project. * - * @param {string} [updatedProject.description] Gets or sets the description of + * @param {string} updatedProject.description Gets or sets the description of * the project. * - * @param {object} [updatedProject.settings] Gets or sets the project settings. + * @param {object} updatedProject.settings Gets or sets the project settings. * * @param {uuid} [updatedProject.settings.domainId] Gets or sets the id of the * Domain to use with this project. @@ -8898,6 +9532,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 @@ -8945,6 +9582,114 @@ class TrainingAPIClient extends ServiceClient { } } + /** + * @summary Queues project for training. + * + * @param {uuid} projectId The project id. + * + * @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 + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + trainProjectWithHttpOperationResponse(projectId, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._trainProject(projectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary Queues project for training. + * + * @param {uuid} projectId The project id. + * + * @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 + * + * @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 {Iteration} - 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 Iteration} 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. + */ + trainProject(projectId, 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._trainProject(projectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._trainProject(projectId, options, optionalCallback); + } + } + /** * @summary Get iterations for the project. * @@ -9206,12 +9951,9 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} updatedIteration The updated iteration model. * - * @param {string} [updatedIteration.name] Gets or sets the name of the + * @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 @@ -9246,12 +9988,9 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} updatedIteration The updated iteration model. * - * @param {string} [updatedIteration.name] Gets or sets the name of the + * @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 @@ -9300,10 +10039,17 @@ class TrainingAPIClient extends ServiceClient { } /** - * @summary Queues project for training. + * @summary Publish a specific iteration. * * @param {uuid} projectId The project id. * + * @param {uuid} iterationId The iteration id. + * + * @param {string} publishName The name to give the published iteration. + * + * @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 @@ -9311,15 +10057,15 @@ class TrainingAPIClient extends ServiceClient { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - trainProjectWithHttpOperationResponse(projectId, options) { + publishIterationWithHttpOperationResponse(projectId, iterationId, publishName, predictionId, options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._trainProject(projectId, options, (err, result, request, response) => { + self._publishIteration(projectId, iterationId, publishName, predictionId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -9330,10 +10076,17 @@ class TrainingAPIClient extends ServiceClient { } /** - * @summary Queues project for training. + * @summary Publish a specific iteration. * * @param {uuid} projectId The project id. * + * @param {uuid} iterationId The iteration id. + * + * @param {string} publishName The name to give the published iteration. + * + * @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 @@ -9346,7 +10099,7 @@ class TrainingAPIClient extends ServiceClient { * * {Promise} A promise is returned * - * @resolve {Iteration} - The deserialized result object. + * @resolve {Boolean} - The deserialized result object. * * @reject {Error} - The error object. * @@ -9354,14 +10107,13 @@ class TrainingAPIClient extends ServiceClient { * * {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 Iteration} for more information. + * {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. */ - trainProject(projectId, options, optionalCallback) { + publishIteration(projectId, iterationId, publishName, predictionId, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -9370,14 +10122,99 @@ class TrainingAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._trainProject(projectId, options, (err, result, request, response) => { + self._publishIteration(projectId, iterationId, publishName, predictionId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._trainProject(projectId, options, optionalCallback); + return self._publishIteration(projectId, iterationId, publishName, 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 {null} - 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. + * + * {null} [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); } } @@ -9474,12 +10311,12 @@ class TrainingAPIClient extends ServiceClient { * @param {uuid} iterationId The iteration id. * * @param {string} platform The target platform. Possible values include: - * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', 'VAIDK' * * @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 @@ -9512,12 +10349,12 @@ class TrainingAPIClient extends ServiceClient { * @param {uuid} iterationId The iteration id. * * @param {string} platform The target platform. Possible values include: - * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX' + * 'CoreML', 'TensorFlow', 'DockerFile', 'ONNX', 'VAIDK' * * @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 @@ -9750,12 +10587,12 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} updatedTag The updated tag model. * - * @param {string} [updatedTag.name] Gets or sets the name of the tag. + * @param {string} updatedTag.name Gets or sets the name of the tag. * - * @param {string} [updatedTag.description] Gets or sets the description of the + * @param {string} updatedTag.description Gets or sets the description of the * tag. * - * @param {string} [updatedTag.type] Gets or sets the type of the tag. Possible + * @param {string} updatedTag.type Gets or sets the type of the tag. Possible * values include: 'Regular', 'Negative' * * @param {object} [options] Optional Parameters. @@ -9792,12 +10629,12 @@ class TrainingAPIClient extends ServiceClient { * * @param {object} updatedTag The updated tag model. * - * @param {string} [updatedTag.name] Gets or sets the name of the tag. + * @param {string} updatedTag.name Gets or sets the name of the tag. * - * @param {string} [updatedTag.description] Gets or sets the description of the + * @param {string} updatedTag.description Gets or sets the description of the * tag. * - * @param {string} [updatedTag.type] Gets or sets the type of the tag. Possible + * @param {string} updatedTag.type Gets or sets the type of the tag. Possible * values include: 'Regular', 'Negative' * * @param {object} [options] Optional Parameters.