From b47e99068fa0e50bb2b840efde1b117f78a6a832 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 3 Oct 2019 17:20:18 -0400 Subject: [PATCH 1/9] feat(VisualRecognitionV4): add support for visual recognition v4 --- .../Services/VisualRecognition/V4/Model.meta | 8 + .../V4/Model/AnalyzeResponse.cs | 44 + .../V4/Model/AnalyzeResponse.cs.meta | 11 + .../V4/Model/BaseCollectionTrainingStatus.cs | 33 + .../BaseCollectionTrainingStatus.cs.meta | 11 + .../VisualRecognition/V4/Model/BaseError.cs | 72 + .../V4/Model/BaseError.cs.meta | 11 + .../VisualRecognition/V4/Model/Collection.cs | 64 + .../V4/Model/Collection.cs.meta | 11 + .../V4/Model/CollectionObjects.cs | 39 + .../V4/Model/CollectionObjects.cs.meta | 11 + .../V4/Model/CollectionsList.cs | 34 + .../V4/Model/CollectionsList.cs.meta | 11 + .../V4/Model/DetectedObjects.cs | 34 + .../V4/Model/DetectedObjects.cs.meta | 11 + .../VisualRecognition/V4/Model/Error.cs | 77 + .../VisualRecognition/V4/Model/Error.cs.meta | 11 + .../VisualRecognition/V4/Model/ErrorTarget.cs | 59 + .../V4/Model/ErrorTarget.cs.meta | 11 + .../VisualRecognition/V4/Model/Image.cs | 48 + .../VisualRecognition/V4/Model/Image.cs.meta | 11 + .../V4/Model/ImageDetails.cs | 64 + .../V4/Model/ImageDetails.cs.meta | 11 + .../V4/Model/ImageDetailsList.cs | 44 + .../V4/Model/ImageDetailsList.cs.meta | 11 + .../V4/Model/ImageDimensions.cs | 38 + .../V4/Model/ImageDimensions.cs.meta | 11 + .../VisualRecognition/V4/Model/ImageSource.cs | 70 + .../V4/Model/ImageSource.cs.meta | 11 + .../V4/Model/ImageSummary.cs | 39 + .../V4/Model/ImageSummary.cs.meta | 11 + .../V4/Model/ImageSummaryList.cs | 34 + .../V4/Model/ImageSummaryList.cs.meta | 11 + .../VisualRecognition/V4/Model/Location.cs | 48 + .../V4/Model/Location.cs.meta | 11 + .../V4/Model/ObjectDetail.cs | 44 + .../V4/Model/ObjectDetail.cs.meta | 11 + .../V4/Model/ObjectTrainingStatus.cs | 54 + .../V4/Model/ObjectTrainingStatus.cs.meta | 11 + .../V4/Model/TrainingDataObject.cs | 38 + .../V4/Model/TrainingDataObject.cs.meta | 11 + .../V4/Model/TrainingDataObjects.cs | 34 + .../V4/Model/TrainingDataObjects.cs.meta | 11 + .../V4/Model/TrainingStatus.cs | 33 + .../V4/Model/TrainingStatus.cs.meta | 11 + .../VisualRecognition/V4/Model/Warning.cs | 72 + .../V4/Model/Warning.cs.meta | 11 + .../V4/VisualRecognitionService.cs | 1238 +++++++++++++++++ .../V4/VisualRecognitionService.cs.meta | 11 + 49 files changed, 2626 insertions(+) create mode 100644 Scripts/Services/VisualRecognition/V4/Model.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseError.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Collection.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Collection.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Error.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Error.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Image.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Image.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Location.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Location.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Warning.cs create mode 100644 Scripts/Services/VisualRecognition/V4/Model/Warning.cs.meta create mode 100644 Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs create mode 100644 Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs.meta diff --git a/Scripts/Services/VisualRecognition/V4/Model.meta b/Scripts/Services/VisualRecognition/V4/Model.meta new file mode 100644 index 000000000..69ac7260f --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c303c62f8964486da67eaaf010014f8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs b/Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs new file mode 100644 index 000000000..87c8546c6 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs @@ -0,0 +1,44 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Results for all images. + /// + public class AnalyzeResponse + { + /// + /// Analyzed images. + /// + [JsonProperty("images", NullValueHandling = NullValueHandling.Ignore)] + public List Images { get; set; } + /// + /// Information about what might cause less than optimal output. + /// + [JsonProperty("warnings", NullValueHandling = NullValueHandling.Ignore)] + public List Warnings { get; set; } + /// + /// A unique identifier of the request. Included only when an error or warning is returned. + /// + [JsonProperty("trace", NullValueHandling = NullValueHandling.Ignore)] + public string Trace { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs.meta new file mode 100644 index 000000000..c28d30cad --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/AnalyzeResponse.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d0dd805cb47c9433fac0c285480a96e0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs b/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs new file mode 100644 index 000000000..53a0dcc81 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs @@ -0,0 +1,33 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Training status information for the collection. + /// + public class BaseCollectionTrainingStatus + { + /// + /// Training status for the objects in the collection. + /// + [JsonProperty("objects", NullValueHandling = NullValueHandling.Ignore)] + public ObjectTrainingStatus Objects { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta new file mode 100644 index 000000000..df8fae5fa --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: da5527a522c184d65a2976c0ea85d59a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs b/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs new file mode 100644 index 000000000..553f94618 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs @@ -0,0 +1,72 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about a problem. + /// + public class BaseError + { + /// + /// Identifier of the problem. + /// + public class CodeValue + { + /// + /// Constant INVALID_FIELD for invalid_field + /// + public const string INVALID_FIELD = "invalid_field"; + /// + /// Constant INVALID_HEADER for invalid_header + /// + public const string INVALID_HEADER = "invalid_header"; + /// + /// Constant INVALID_METHOD for invalid_method + /// + public const string INVALID_METHOD = "invalid_method"; + /// + /// Constant MISSING_FIELD for missing_field + /// + public const string MISSING_FIELD = "missing_field"; + /// + /// Constant SERVER_ERROR for server_error + /// + public const string SERVER_ERROR = "server_error"; + + } + + /// + /// Identifier of the problem. + /// Constants for possible values can be found using BaseError.CodeValue + /// + [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] + public string Code { get; set; } + /// + /// An explanation of the problem with possible solutions. + /// + [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] + public string Message { get; set; } + /// + /// A URL for more information about the solution. + /// + [JsonProperty("more_info", NullValueHandling = NullValueHandling.Ignore)] + public string MoreInfo { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta new file mode 100644 index 000000000..b0eac6cce --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ea09601c4e204605806872dc06a963b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/Collection.cs b/Scripts/Services/VisualRecognition/V4/Model/Collection.cs new file mode 100644 index 000000000..75db0427e --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Collection.cs @@ -0,0 +1,64 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; +using System; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about a collection. + /// + public class Collection + { + /// + /// The identifier of the collection. + /// + [JsonProperty("collection_id", NullValueHandling = NullValueHandling.Ignore)] + public virtual string CollectionId { get; private set; } + /// + /// The name of the collection. + /// + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + public string Name { get; set; } + /// + /// The description of the collection. + /// + [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] + public string Description { get; set; } + /// + /// Date and time in Coordinated Universal Time (UTC) that the collection was created. + /// + [JsonProperty("created", NullValueHandling = NullValueHandling.Ignore)] + public virtual DateTime? Created { get; private set; } + /// + /// Date and time in Coordinated Universal Time (UTC) that the collection was most recently updated. + /// + [JsonProperty("updated", NullValueHandling = NullValueHandling.Ignore)] + public virtual DateTime? Updated { get; private set; } + /// + /// Number of images in the collection. + /// + [JsonProperty("image_count", NullValueHandling = NullValueHandling.Ignore)] + public virtual long? ImageCount { get; private set; } + /// + /// Training status information for the collection. + /// + [JsonProperty("training_status", NullValueHandling = NullValueHandling.Ignore)] + public virtual TrainingStatus TrainingStatus { get; private set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/Collection.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/Collection.cs.meta new file mode 100644 index 000000000..a6aa5feba --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Collection.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9d472723c9b5842ac8aad273020cf81b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs b/Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs new file mode 100644 index 000000000..f5299bf6a --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs @@ -0,0 +1,39 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// The objects in a collection that are detected in an image. + /// + public class CollectionObjects + { + /// + /// The identifier of the collection. + /// + [JsonProperty("collection_id", NullValueHandling = NullValueHandling.Ignore)] + public string CollectionId { get; set; } + /// + /// The identified objects in a collection. + /// + [JsonProperty("objects", NullValueHandling = NullValueHandling.Ignore)] + public List Objects { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs.meta new file mode 100644 index 000000000..8463d7ba4 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/CollectionObjects.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 59805e22915c24058a103a1e2721e4d7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs b/Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs new file mode 100644 index 000000000..8e25a6a1e --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs @@ -0,0 +1,34 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// A container for the list of collections. + /// + public class CollectionsList + { + /// + /// The collections in this service instance. + /// + [JsonProperty("collections", NullValueHandling = NullValueHandling.Ignore)] + public List Collections { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs.meta new file mode 100644 index 000000000..4990a01db --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/CollectionsList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c21cc1fccd7744d148210633549ba786 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs b/Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs new file mode 100644 index 000000000..d17bbf38c --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs @@ -0,0 +1,34 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Container for the list of collections that have objects detected in an image. + /// + public class DetectedObjects + { + /// + /// The collections with identified objects. + /// + [JsonProperty("collections", NullValueHandling = NullValueHandling.Ignore)] + public List Collections { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs.meta new file mode 100644 index 000000000..4c20aed3e --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/DetectedObjects.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8d556e5a9f023476b9cee4e4b7f9c288 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/Error.cs b/Scripts/Services/VisualRecognition/V4/Model/Error.cs new file mode 100644 index 000000000..9d375127a --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Error.cs @@ -0,0 +1,77 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about an error. + /// + public class Error + { + /// + /// Identifier of the problem. + /// + public class CodeValue + { + /// + /// Constant INVALID_FIELD for invalid_field + /// + public const string INVALID_FIELD = "invalid_field"; + /// + /// Constant INVALID_HEADER for invalid_header + /// + public const string INVALID_HEADER = "invalid_header"; + /// + /// Constant INVALID_METHOD for invalid_method + /// + public const string INVALID_METHOD = "invalid_method"; + /// + /// Constant MISSING_FIELD for missing_field + /// + public const string MISSING_FIELD = "missing_field"; + /// + /// Constant SERVER_ERROR for server_error + /// + public const string SERVER_ERROR = "server_error"; + + } + + /// + /// Identifier of the problem. + /// Constants for possible values can be found using Error.CodeValue + /// + [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] + public string Code { get; set; } + /// + /// An explanation of the problem with possible solutions. + /// + [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] + public string Message { get; set; } + /// + /// A URL for more information about the solution. + /// + [JsonProperty("more_info", NullValueHandling = NullValueHandling.Ignore)] + public string MoreInfo { get; set; } + /// + /// Details about the specific area of the problem. + /// + [JsonProperty("target", NullValueHandling = NullValueHandling.Ignore)] + public ErrorTarget Target { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/Error.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/Error.cs.meta new file mode 100644 index 000000000..b4de75e7a --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Error.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 261d3650a0e04405c949c2e588e2f3ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs b/Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs new file mode 100644 index 000000000..8799c67be --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs @@ -0,0 +1,59 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about the specific area of the problem. + /// + public class ErrorTarget + { + /// + /// The parameter or property that is the focus of the problem. + /// + public class TypeValue + { + /// + /// Constant FIELD for field + /// + public const string FIELD = "field"; + /// + /// Constant PARAMETER for parameter + /// + public const string PARAMETER = "parameter"; + /// + /// Constant HEADER for header + /// + public const string HEADER = "header"; + + } + + /// + /// The parameter or property that is the focus of the problem. + /// Constants for possible values can be found using ErrorTarget.TypeValue + /// + [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] + public string Type { get; set; } + /// + /// The property that is identified with the problem. + /// + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + public string Name { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs.meta new file mode 100644 index 000000000..7317db9db --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ErrorTarget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 81127a959e3784f1a8ab8d4b925333ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/Image.cs b/Scripts/Services/VisualRecognition/V4/Model/Image.cs new file mode 100644 index 000000000..4134b802f --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Image.cs @@ -0,0 +1,48 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about an image. + /// + public class Image + { + /// + /// The source type of the image. + /// + [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] + public ImageSource Source { get; set; } + /// + /// Height and width of an image. + /// + [JsonProperty("dimensions", NullValueHandling = NullValueHandling.Ignore)] + public ImageDimensions Dimensions { get; set; } + /// + /// Container for the list of collections that have objects detected in an image. + /// + [JsonProperty("objects", NullValueHandling = NullValueHandling.Ignore)] + public DetectedObjects Objects { get; set; } + /// + /// Details about an error. + /// + [JsonProperty("errors", NullValueHandling = NullValueHandling.Ignore)] + public Error Errors { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/Image.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/Image.cs.meta new file mode 100644 index 000000000..eecfcae49 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Image.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7224026db8ed14b638b9c96176828c9a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs b/Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs new file mode 100644 index 000000000..50eadc445 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs @@ -0,0 +1,64 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; +using System; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about an image. + /// + public class ImageDetails + { + /// + /// The identifier of the image. + /// + [JsonProperty("image_id", NullValueHandling = NullValueHandling.Ignore)] + public string ImageId { get; set; } + /// + /// Date and time in Coordinated Universal Time (UTC) that the image was most recently updated. + /// + [JsonProperty("updated", NullValueHandling = NullValueHandling.Ignore)] + public DateTime? Updated { get; set; } + /// + /// Date and time in Coordinated Universal Time (UTC) that the image was created. + /// + [JsonProperty("created", NullValueHandling = NullValueHandling.Ignore)] + public DateTime? Created { get; set; } + /// + /// The source type of the image. + /// + [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] + public ImageSource Source { get; set; } + /// + /// Height and width of an image. + /// + [JsonProperty("dimensions", NullValueHandling = NullValueHandling.Ignore)] + public ImageDimensions Dimensions { get; set; } + /// + /// Details about an error. + /// + [JsonProperty("errors", NullValueHandling = NullValueHandling.Ignore)] + public Error Errors { get; set; } + /// + /// Training data for all objects. + /// + [JsonProperty("training_data", NullValueHandling = NullValueHandling.Ignore)] + public TrainingDataObjects TrainingData { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs.meta new file mode 100644 index 000000000..b895f03aa --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageDetails.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d81711964681b45c5ad982d24e6b615b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs b/Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs new file mode 100644 index 000000000..eaf4afd09 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs @@ -0,0 +1,44 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// List of information about the images. + /// + public class ImageDetailsList + { + /// + /// The images in the collection. + /// + [JsonProperty("images", NullValueHandling = NullValueHandling.Ignore)] + public List Images { get; set; } + /// + /// Information about what might cause less than optimal output. + /// + [JsonProperty("warnings", NullValueHandling = NullValueHandling.Ignore)] + public List Warnings { get; set; } + /// + /// A unique identifier of the request. Included only when an error or warning is returned. + /// + [JsonProperty("trace", NullValueHandling = NullValueHandling.Ignore)] + public string Trace { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs.meta new file mode 100644 index 000000000..250fcf934 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageDetailsList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c525f04f1b8114aa8a3fa75a372ea19b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs b/Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs new file mode 100644 index 000000000..ca498669a --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs @@ -0,0 +1,38 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Height and width of an image. + /// + public class ImageDimensions + { + /// + /// Height in pixels of the image. + /// + [JsonProperty("height", NullValueHandling = NullValueHandling.Ignore)] + public long? Height { get; set; } + /// + /// Width in pixels of the image. + /// + [JsonProperty("width", NullValueHandling = NullValueHandling.Ignore)] + public long? Width { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs.meta new file mode 100644 index 000000000..7464e56a2 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageDimensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bdc0da5fb04694f78b5a955e17bba56a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs b/Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs new file mode 100644 index 000000000..6325743e8 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs @@ -0,0 +1,70 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// The source type of the image. + /// + public class ImageSource + { + /// + /// The source type of the image. + /// + public class TypeValue + { + /// + /// Constant FILE for file + /// + public const string FILE = "file"; + /// + /// Constant URL for url + /// + public const string URL = "url"; + + } + + /// + /// The source type of the image. + /// Constants for possible values can be found using ImageSource.TypeValue + /// + [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] + public string Type { get; set; } + /// + /// Name of the image file if uploaded. Not returned when the image is passed by URL. + /// + [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)] + public string Filename { get; set; } + /// + /// Name of the .zip file of images if uploaded. Not returned when the image is passed directly or by URL. + /// + [JsonProperty("archive_filename", NullValueHandling = NullValueHandling.Ignore)] + public string ArchiveFilename { get; set; } + /// + /// Source of the image before any redirects. Not returned when the image is uploaded. + /// + [JsonProperty("source_url", NullValueHandling = NullValueHandling.Ignore)] + public string SourceUrl { get; set; } + /// + /// Fully resolved URL of the image after redirects are followed. Not returned when the image is uploaded. + /// + [JsonProperty("resolved_url", NullValueHandling = NullValueHandling.Ignore)] + public string ResolvedUrl { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs.meta new file mode 100644 index 000000000..038fe3d57 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db7b988a33c2f422c9f6ff262466b0a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs b/Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs new file mode 100644 index 000000000..236868405 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs @@ -0,0 +1,39 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; +using System; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Basic information about an image. + /// + public class ImageSummary + { + /// + /// The identifier of the image. + /// + [JsonProperty("image_id", NullValueHandling = NullValueHandling.Ignore)] + public string ImageId { get; set; } + /// + /// Date and time in Coordinated Universal Time (UTC) that the image was most recently updated. + /// + [JsonProperty("updated", NullValueHandling = NullValueHandling.Ignore)] + public DateTime? Updated { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs.meta new file mode 100644 index 000000000..67e6b63af --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageSummary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab5436c1f6dcc4e89a3362a8486c1df7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs b/Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs new file mode 100644 index 000000000..a33cc4544 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs @@ -0,0 +1,34 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// List of images. + /// + public class ImageSummaryList + { + /// + /// The images in the collection. + /// + [JsonProperty("images", NullValueHandling = NullValueHandling.Ignore)] + public List Images { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs.meta new file mode 100644 index 000000000..5ce208f03 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ImageSummaryList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2e1fdce12e5ff4249994bc0d78f31855 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/Location.cs b/Scripts/Services/VisualRecognition/V4/Model/Location.cs new file mode 100644 index 000000000..ce8701984 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Location.cs @@ -0,0 +1,48 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Defines the location of the bounding box around the object. + /// + public class Location + { + /// + /// Y-position of top-left pixel of the bounding box. + /// + [JsonProperty("top", NullValueHandling = NullValueHandling.Ignore)] + public long? Top { get; set; } + /// + /// X-position of top-left pixel of the bounding box. + /// + [JsonProperty("left", NullValueHandling = NullValueHandling.Ignore)] + public long? Left { get; set; } + /// + /// Width in pixels of of the bounding box. + /// + [JsonProperty("width", NullValueHandling = NullValueHandling.Ignore)] + public long? Width { get; set; } + /// + /// Height in pixels of the bounding box. + /// + [JsonProperty("height", NullValueHandling = NullValueHandling.Ignore)] + public long? Height { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/Location.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/Location.cs.meta new file mode 100644 index 000000000..f2128b9de --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Location.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd9cc9d49797c470999029e6d8de113e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs b/Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs new file mode 100644 index 000000000..c1974e9cb --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs @@ -0,0 +1,44 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about an object in the collection. + /// + public class ObjectDetail + { + /// + /// The label for the object. + /// + [JsonProperty("object", NullValueHandling = NullValueHandling.Ignore)] + public string _Object { get; set; } + /// + /// Defines the location of the bounding box around the object. + /// + [JsonProperty("location", NullValueHandling = NullValueHandling.Ignore)] + public Location Location { get; set; } + /// + /// Confidence score for the object in the range of 0 to 1. A higher score indicates greater likelihood that the + /// object is depicted at this location in the image. + /// + [JsonProperty("score", NullValueHandling = NullValueHandling.Ignore)] + public float? Score { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs.meta new file mode 100644 index 000000000..a25b6006e --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ObjectDetail.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: de067b2d9c60c40039d1772c6c76fcaf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs b/Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs new file mode 100644 index 000000000..53755c563 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs @@ -0,0 +1,54 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Training status for the objects in the collection. + /// + public class ObjectTrainingStatus + { + /// + /// Whether you can analyze images in the collection with the **objects** feature. + /// + [JsonProperty("ready", NullValueHandling = NullValueHandling.Ignore)] + public bool? Ready { get; set; } + /// + /// Whether training is in progress. + /// + [JsonProperty("in_progress", NullValueHandling = NullValueHandling.Ignore)] + public bool? InProgress { get; set; } + /// + /// Whether there are changes to the training data since the most recent training. + /// + [JsonProperty("data_changed", NullValueHandling = NullValueHandling.Ignore)] + public bool? DataChanged { get; set; } + /// + /// Whether the most recent training failed. + /// + [JsonProperty("latest_failed", NullValueHandling = NullValueHandling.Ignore)] + public bool? LatestFailed { get; set; } + /// + /// Details about the training. If training is in progress, includes information about the status. If training + /// is not in progress, includes a success message or information about why training failed. + /// + [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] + public string Description { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs.meta new file mode 100644 index 000000000..203a96aa0 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/ObjectTrainingStatus.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a56739a4771c7451cab83fce02146016 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs new file mode 100644 index 000000000..9c8896180 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs @@ -0,0 +1,38 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about the training data. + /// + public class TrainingDataObject + { + /// + /// The name of the object. + /// + [JsonProperty("object", NullValueHandling = NullValueHandling.Ignore)] + public string _Object { get; set; } + /// + /// Defines the location of the bounding box around the object. + /// + [JsonProperty("location", NullValueHandling = NullValueHandling.Ignore)] + public Location Location { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs.meta new file mode 100644 index 000000000..7512c8705 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca4b62cf8c6a24bb99c9c1363e9ef287 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs new file mode 100644 index 000000000..045c62cb7 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs @@ -0,0 +1,34 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Training data for all objects. + /// + public class TrainingDataObjects + { + /// + /// Training data for specific objects. + /// + [JsonProperty("objects", NullValueHandling = NullValueHandling.Ignore)] + public List Objects { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs.meta new file mode 100644 index 000000000..1fc50cd1e --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/TrainingDataObjects.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c001910da99744443b8ae12b45bfca20 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs b/Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs new file mode 100644 index 000000000..ab2fbecb3 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs @@ -0,0 +1,33 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Training status information for the collection. + /// + public class TrainingStatus + { + /// + /// Training status for the objects in the collection. + /// + [JsonProperty("objects", NullValueHandling = NullValueHandling.Ignore)] + public ObjectTrainingStatus Objects { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs.meta new file mode 100644 index 000000000..9ef40098d --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/TrainingStatus.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ccb5d0e420a7446ad9aaab7917238bb9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/Warning.cs b/Scripts/Services/VisualRecognition/V4/Model/Warning.cs new file mode 100644 index 000000000..fb3014415 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Warning.cs @@ -0,0 +1,72 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.VisualRecognition.V4.Model +{ + /// + /// Details about a problem. + /// + public class Warning + { + /// + /// Identifier of the problem. + /// + public class CodeValue + { + /// + /// Constant INVALID_FIELD for invalid_field + /// + public const string INVALID_FIELD = "invalid_field"; + /// + /// Constant INVALID_HEADER for invalid_header + /// + public const string INVALID_HEADER = "invalid_header"; + /// + /// Constant INVALID_METHOD for invalid_method + /// + public const string INVALID_METHOD = "invalid_method"; + /// + /// Constant MISSING_FIELD for missing_field + /// + public const string MISSING_FIELD = "missing_field"; + /// + /// Constant SERVER_ERROR for server_error + /// + public const string SERVER_ERROR = "server_error"; + + } + + /// + /// Identifier of the problem. + /// Constants for possible values can be found using Warning.CodeValue + /// + [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] + public string Code { get; set; } + /// + /// An explanation of the problem with possible solutions. + /// + [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] + public string Message { get; set; } + /// + /// A URL for more information about the solution. + /// + [JsonProperty("more_info", NullValueHandling = NullValueHandling.Ignore)] + public string MoreInfo { get; set; } + } +} diff --git a/Scripts/Services/VisualRecognition/V4/Model/Warning.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/Warning.cs.meta new file mode 100644 index 000000000..8a2b710bb --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/Model/Warning.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8510c565e381e40b4aaa9d90040c5c78 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs b/Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs new file mode 100644 index 000000000..80b1b2e79 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs @@ -0,0 +1,1238 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using System.IO; +using System.Text; +using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Connection; +using IBM.Cloud.SDK.Model; +using IBM.Cloud.SDK.Utilities; +using IBM.Watson.VisualRecognition.V4.Model; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using UnityEngine.Networking; + +namespace IBM.Watson.VisualRecognition.V4 +{ + public partial class VisualRecognitionService : BaseService + { + private const string serviceId = "visual_recognition"; + private const string defaultServiceUrl = "https://gateway.watsonplatform.net/visual-recognition/api"; + + #region VersionDate + private string versionDate; + /// + /// Gets and sets the versionDate of the service. + /// + public string VersionDate + { + get { return versionDate; } + set { versionDate = value; } + } + #endregion + + #region DisableSslVerification + private bool disableSslVerification = false; + /// + /// Gets and sets the option to disable ssl verification + /// + public bool DisableSslVerification + { + get { return disableSslVerification; } + set { disableSslVerification = value; } + } + #endregion + + /// + /// VisualRecognitionService constructor. + /// + /// The service version date in `yyyy-mm-dd` format. + public VisualRecognitionService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} + + /// + /// VisualRecognitionService constructor. + /// + /// The service version date in `yyyy-mm-dd` format. + /// The service authenticator. + public VisualRecognitionService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) + { + Authenticator = authenticator; + if (string.IsNullOrEmpty(versionDate)) + { + throw new ArgumentNullException("A versionDate (format `yyyy-mm-dd`) is required to create an instance of VisualRecognitionService"); + } + else + { + VersionDate = versionDate; + } + + + if (string.IsNullOrEmpty(GetServiceUrl())) + { + SetServiceUrl(defaultServiceUrl); + } + } + + /// + /// Analyze images. + /// + /// Analyze images by URL, by file, or both against your own collection. Make sure that + /// **training_status.objects.ready** is `true` for the feature before you use a collection to analyze images. + /// + /// Encode the image and .zip file names in UTF-8 if they contain non-ASCII characters. The service assumes + /// UTF-8 encoding if it encounters non-ASCII characters. + /// + /// The callback function that is invoked when the operation completes. + /// The IDs of the collections to analyze. + /// The features to analyze. + /// An array of image files (.jpg or .png) or .zip files with images. + /// - Include a maximum of 20 images in a request. + /// - Limit the .zip file to 100 MB. + /// - Limit each image file to 10 MB. + /// + /// You can also include an image with the **image_url** parameter. (optional) + /// An array of URLs of image files (.jpg or .png). + /// - Include a maximum of 20 images in a request. + /// - Limit each image file to 10 MB. + /// - Minimum width and height is 30 pixels, but the service tends to perform better with images that are at + /// least 300 x 300 pixels. Maximum is 5400 pixels for either height or width. + /// + /// You can also include images with the **images_file** parameter. (optional) + /// The minimum score a feature must have to be returned. (optional) + /// AnalyzeResponse + public bool Analyze(Callback callback, List collectionIds, List features, List imagesFile = null, List imageUrl = null, float? threshold = null) + { + if (collectionIds == null || collectionIds.Count == 0) + { + throw new ArgumentNullException("`collectionIds` is required for `Analyze`"); + } + if (features == null || features.Count == 0) + { + throw new ArgumentNullException("`features` is required for `Analyze`"); + } + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "Analyze")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + req.Forms = new Dictionary(); + if (collectionIds != null) + { + req.Forms["collection_ids"] = new RESTConnector.Form(string.Join(",", collectionIds.ToArray())); + } + if (features != null) + { + req.Forms["features"] = new RESTConnector.Form(string.Join(",", features.ToArray())); + } + if (imagesFile != null) + { + foreach (FileWithMetadata item in imagesFile) + { + req.Forms["images_file"] = new RESTConnector.Form(item.Data, item.Filename, item.ContentType); + } + } + if (imageUrl != null) + { + foreach (string item in imageUrl) + { + req.Forms["image_url"] = new RESTConnector.Form(item); + } + } + if (threshold != null) + { + req.Forms["threshold"] = new RESTConnector.Form(threshold.ToString()); + } + + req.OnResponse = OnAnalyzeResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v4/analyze", GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnAnalyzeResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnAnalyzeResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Create a collection. + /// + /// Create a collection that can be used to store images. + /// + /// To create a collection without specifying a name and description, include an empty JSON object in the + /// request body. + /// + /// Encode the name and description in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 + /// encoding if it encounters non-ASCII characters. + /// + /// The callback function that is invoked when the operation completes. + /// The name of the collection. The name can contain alphanumeric, underscore, hyphen, and + /// dot characters. It cannot begin with the reserved prefix `sys-`. (optional) + /// The description of the collection. (optional) + /// Collection + public bool CreateCollection(Callback callback, string name = null, string description = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `CreateCollection`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "CreateCollection")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + req.Headers["Content-Type"] = "application/json"; + req.Headers["Accept"] = "application/json"; + + JObject bodyObject = new JObject(); + if (!string.IsNullOrEmpty(name)) + bodyObject["name"] = name; + if (!string.IsNullOrEmpty(description)) + bodyObject["description"] = description; + req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); + + req.OnResponse = OnCreateCollectionResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v4/collections", GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnCreateCollectionResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnCreateCollectionResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// List collections. + /// + /// Retrieves a list of collections for the service instance. + /// + /// The callback function that is invoked when the operation completes. + /// CollectionsList + public bool ListCollections(Callback callback) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `ListCollections`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbGET, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "ListCollections")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnListCollectionsResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v4/collections", GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnListCollectionsResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnListCollectionsResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Get collection details. + /// + /// Get details of one collection. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// Collection + public bool GetCollection(Callback callback, string collectionId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `GetCollection`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `GetCollection`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbGET, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "GetCollection")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnGetCollectionResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}", collectionId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnGetCollectionResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnGetCollectionResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Update a collection. + /// + /// Update the name or description of a collection. + /// + /// Encode the name and description in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 + /// encoding if it encounters non-ASCII characters. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// The name of the collection. The name can contain alphanumeric, underscore, hyphen, and + /// dot characters. It cannot begin with the reserved prefix `sys-`. (optional) + /// The description of the collection. (optional) + /// Collection + public bool UpdateCollection(Callback callback, string collectionId, string name = null, string description = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `UpdateCollection`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `UpdateCollection`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "UpdateCollection")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + req.Headers["Content-Type"] = "application/json"; + req.Headers["Accept"] = "application/json"; + + JObject bodyObject = new JObject(); + if (!string.IsNullOrEmpty(name)) + bodyObject["name"] = name; + if (!string.IsNullOrEmpty(description)) + bodyObject["description"] = description; + req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); + + req.OnResponse = OnUpdateCollectionResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}", collectionId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnUpdateCollectionResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnUpdateCollectionResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Delete a collection. + /// + /// Delete a collection from the service instance. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// object + public bool DeleteCollection(Callback callback, string collectionId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `DeleteCollection`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `DeleteCollection`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbDELETE, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "DeleteCollection")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnDeleteCollectionResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}", collectionId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnDeleteCollectionResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnDeleteCollectionResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Add images. + /// + /// Add images to a collection by URL, by file, or both. + /// + /// Encode the image and .zip file names in UTF-8 if they contain non-ASCII characters. The service assumes + /// UTF-8 encoding if it encounters non-ASCII characters. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// An array of image files (.jpg or .png) or .zip files with images. + /// - Include a maximum of 20 images in a request. + /// - Limit the .zip file to 100 MB. + /// - Limit each image file to 10 MB. + /// + /// You can also include an image with the **image_url** parameter. (optional) + /// The array of URLs of image files (.jpg or .png). + /// - Include a maximum of 20 images in a request. + /// - Limit each image file to 10 MB. + /// - Minimum width and height is 30 pixels, but the service tends to perform better with images that are at + /// least 300 x 300 pixels. Maximum is 5400 pixels for either height or width. + /// + /// You can also include images with the **images_file** parameter. (optional) + /// Training data for a single image. Include training data only if you add one image + /// with the request. + /// + /// The `object` property can contain alphanumeric, underscore, hyphen, space, and dot characters. It cannot + /// begin with the reserved prefix `sys-` and must be no longer than 32 characters. (optional) + /// ImageDetailsList + public bool AddImages(Callback callback, string collectionId, List imagesFile = null, List imageUrl = null, string trainingData = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `AddImages`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `AddImages`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "AddImages")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + req.Forms = new Dictionary(); + if (imagesFile != null) + { + foreach (FileWithMetadata item in imagesFile) + { + req.Forms["images_file"] = new RESTConnector.Form(item.Data, item.Filename, item.ContentType); + } + } + if (imageUrl != null) + { + foreach (string item in imageUrl) + { + req.Forms["image_url"] = new RESTConnector.Form(item); + } + } + if (!string.IsNullOrEmpty(trainingData)) + { + req.Forms["training_data"] = new RESTConnector.Form(trainingData); + } + + req.OnResponse = OnAddImagesResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/images", collectionId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnAddImagesResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnAddImagesResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// List images. + /// + /// Retrieves a list of images in a collection. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// ImageSummaryList + public bool ListImages(Callback callback, string collectionId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `ListImages`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `ListImages`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbGET, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "ListImages")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnListImagesResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/images", collectionId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnListImagesResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnListImagesResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Get image details. + /// + /// Get the details of an image in a collection. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// The identifier of the image. + /// ImageDetails + public bool GetImageDetails(Callback callback, string collectionId, string imageId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `GetImageDetails`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `GetImageDetails`"); + if (string.IsNullOrEmpty(imageId)) + throw new ArgumentNullException("`imageId` is required for `GetImageDetails`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbGET, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "GetImageDetails")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnGetImageDetailsResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/images/{1}", collectionId, imageId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnGetImageDetailsResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnGetImageDetailsResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Delete an image. + /// + /// Delete one image from a collection. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// The identifier of the image. + /// object + public bool DeleteImage(Callback callback, string collectionId, string imageId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `DeleteImage`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `DeleteImage`"); + if (string.IsNullOrEmpty(imageId)) + throw new ArgumentNullException("`imageId` is required for `DeleteImage`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbDELETE, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "DeleteImage")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnDeleteImageResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/images/{1}", collectionId, imageId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnDeleteImageResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnDeleteImageResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Get a JPEG file of an image. + /// + /// Download a JPEG representation of an image. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// The identifier of the image. + /// Specify the image size. (optional, default to full) + /// byte[] + public bool GetJpegImage(Callback callback, string collectionId, string imageId, string size = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `GetJpegImage`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `GetJpegImage`"); + if (string.IsNullOrEmpty(imageId)) + throw new ArgumentNullException("`imageId` is required for `GetJpegImage`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbGET, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "GetJpegImage")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + if (!string.IsNullOrEmpty(size)) + { + req.Parameters["size"] = size; + } + + req.OnResponse = OnGetJpegImageResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/images/{1}/jpeg", collectionId, imageId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnGetJpegImageResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + response.Result = resp.Data; + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Train a collection. + /// + /// Start training on images in a collection. The collection must have enough training data and untrained data + /// (the **training_status.objects.data_changed** is `true`). If training is in progress, the request queues the + /// next training job. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// Collection + public bool Train(Callback callback, string collectionId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `Train`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `Train`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "Train")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + + req.OnResponse = OnTrainResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/train", collectionId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnTrainResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnTrainResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Add training data to an image. + /// + /// Add, update, or delete training data for an image. Encode the object name in UTF-8 if it contains non-ASCII + /// characters. The service assumes UTF-8 encoding if it encounters non-ASCII characters. + /// + /// Elements in the request replace the existing elements. + /// + /// - To update the training data, provide both the unchanged and the new or changed values. + /// + /// - To delete the training data, provide an empty value for the training data. + /// + /// The callback function that is invoked when the operation completes. + /// The identifier of the collection. + /// The identifier of the image. + /// Training data for specific objects. (optional) + /// TrainingDataObjects + public bool AddImageTrainingData(Callback callback, string collectionId, string imageId, List objects = null) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `AddImageTrainingData`"); + if (string.IsNullOrEmpty(collectionId)) + throw new ArgumentNullException("`collectionId` is required for `AddImageTrainingData`"); + if (string.IsNullOrEmpty(imageId)) + throw new ArgumentNullException("`imageId` is required for `AddImageTrainingData`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbPOST, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "AddImageTrainingData")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + req.Headers["Content-Type"] = "application/json"; + req.Headers["Accept"] = "application/json"; + + JObject bodyObject = new JObject(); + if (objects != null && objects.Count > 0) + bodyObject["objects"] = JToken.FromObject(objects); + req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); + + req.OnResponse = OnAddImageTrainingDataResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v4/collections/{0}/images/{1}/training_data", collectionId, imageId), GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnAddImageTrainingDataResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnAddImageTrainingDataResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + /// + /// Delete labeled data. + /// + /// Deletes all data associated with a specified customer ID. The method has no effect if no data is associated + /// with the customer ID. + /// + /// You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes + /// data. For more information about personal data and customer IDs, see [Information + /// security](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-information-security). + /// + /// The callback function that is invoked when the operation completes. + /// The customer ID for which all data is to be deleted. + /// object + public bool DeleteUserData(Callback callback, string customerId) + { + if (callback == null) + throw new ArgumentNullException("`callback` is required for `DeleteUserData`"); + if (string.IsNullOrEmpty(customerId)) + throw new ArgumentNullException("`customerId` is required for `DeleteUserData`"); + + RequestObject req = new RequestObject + { + Callback = callback, + HttpMethod = UnityWebRequest.kHttpVerbDELETE, + DisableSslVerification = DisableSslVerification + }; + + foreach (KeyValuePair kvp in customRequestHeaders) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + ClearCustomRequestHeaders(); + + foreach (KeyValuePair kvp in Common.GetSdkHeaders("watson_vision_combined", "V4", "DeleteUserData")) + { + req.Headers.Add(kvp.Key, kvp.Value); + } + + req.Parameters["version"] = VersionDate; + if (!string.IsNullOrEmpty(customerId)) + { + req.Parameters["customer_id"] = customerId; + } + + req.OnResponse = OnDeleteUserDataResponse; + + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v4/user_data", GetServiceUrl()); + if (connector == null) + { + return false; + } + + return connector.Send(req); + } + + private void OnDeleteUserDataResponse(RESTConnector.Request req, RESTConnector.Response resp) + { + DetailedResponse response = new DetailedResponse(); + foreach (KeyValuePair kvp in resp.Headers) + { + response.Headers.Add(kvp.Key, kvp.Value); + } + response.StatusCode = resp.HttpResponseCode; + + try + { + string json = Encoding.UTF8.GetString(resp.Data); + response.Result = JsonConvert.DeserializeObject(json); + response.Response = json; + } + catch (Exception e) + { + Log.Error("VisualRecognitionService.OnDeleteUserDataResponse()", "Exception: {0}", e.ToString()); + resp.Success = false; + } + + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); + } + } +} \ No newline at end of file diff --git a/Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs.meta b/Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs.meta new file mode 100644 index 000000000..d0636fa17 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4/VisualRecognitionService.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f9f1210dce7014f06af4dd2cc5a97739 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 3df4a99c5632c2c62e6b2bec0112e55f80ba9f56 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 3 Oct 2019 17:31:19 -0400 Subject: [PATCH 2/9] test: add tests for visual recognition v4 --- Tests/VisualRecognitionV4IntegrationTests.cs | 435 ++++++++++++++++++ ...isualRecognitionV4IntegrationTests.cs.meta | 11 + 2 files changed, 446 insertions(+) create mode 100644 Tests/VisualRecognitionV4IntegrationTests.cs create mode 100644 Tests/VisualRecognitionV4IntegrationTests.cs.meta diff --git a/Tests/VisualRecognitionV4IntegrationTests.cs b/Tests/VisualRecognitionV4IntegrationTests.cs new file mode 100644 index 000000000..6b1960fc7 --- /dev/null +++ b/Tests/VisualRecognitionV4IntegrationTests.cs @@ -0,0 +1,435 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; +using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Utilities; +using IBM.Cloud.SDK.Model; +using IBM.Watson.VisualRecognition.V4; +using IBM.Watson.VisualRecognition.V4.Model; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; + +namespace IBM.Watson.Tests +{ + public class VisualRecognitionV4IntegrationTests + { + private VisualRecognitionService service; + private string versionDate = "2019-02-13"; + private string negativeExamplesFilepath; + private string giraffeImageFilepath; + private string turtleImageFilepath; + private string turtleImageContentType = "image/jpeg"; + private string imageMetadataFilepath; + private string classifierName = "unity-sdk-classifier-safe-to-delete"; + private string giraffeCollectionId = "d31d6534-3458-40c4-b6de-2185a5f3cbe4"; + private string giraffeClassname = "giraffe"; + private string turtleCollectionId = "760c8625-a456-4b73-b71d-d1619a6daf84"; + private string collectionId; + private string imageId; + + [OneTimeSetUp] + public void OneTimeSetup() + { + LogSystem.InstallDefaultReactors(); + + negativeExamplesFilepath = Application.dataPath + "/Watson/Tests/TestData/VisualRecognitionV3/negative_examples.zip"; + giraffeImageFilepath = Application.dataPath + "/Watson/Tests/TestData/VisualRecognitionV3/giraffe_to_classify.jpg"; + turtleImageFilepath = Application.dataPath + "/Watson/Tests/TestData/VisualRecognitionV3/turtle_to_classify.jpg"; + imageMetadataFilepath = Application.dataPath + "/Watson/Tests/TestData/VisualRecognitionV3/imageMetadata.json"; + } + + [UnitySetUp] + public IEnumerator UnityTestSetup() + { + if (service == null) + { + service = new VisualRecognitionService(versionDate); + } + + while (!service.Authenticator.CanAuthenticate()) + yield return null; + } + + [SetUp] + public void TestSetup() + { + service.WithHeader("X-Watson-Test", "1"); + } + + #region Analyze + [UnityTest, Order(1)] + public IEnumerator TestAnalyze() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Analyze..."); + AnalyzeResponse analyzeResponse = null; + List imagesFile = new List(); + using (FileStream fs1 = File.OpenRead(giraffeImageFilepath), fs2 = File.OpenRead(turtleImageFilepath)) + { + using (MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream()) + { + fs1.CopyTo(ms1); + fs2.CopyTo(ms2); + FileWithMetadata fileWithMetadata = new FileWithMetadata() + { + Data = ms1, + ContentType = "image/jpeg", + Filename = Path.GetFileName(giraffeImageFilepath) + }; + imagesFile.Add(fileWithMetadata); + + FileWithMetadata fileWithMetadata2 = new FileWithMetadata() + { + Data = ms2, + ContentType = "image/jpeg", + Filename = Path.GetFileName(turtleImageFilepath) + }; + imagesFile.Add(fileWithMetadata2); + + service.Analyze( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Analyze result: {0}", response.Response); + analyzeResponse = response.Result; + Assert.IsNotNull(analyzeResponse); + Assert.IsNotNull(analyzeResponse.Images); + Assert.IsTrue(analyzeResponse.Images.Count > 0); + Assert.IsNotNull(analyzeResponse.Images[0].Objects.Collections); + Assert.IsTrue(analyzeResponse.Images[0].Objects.Collections.Count > 0); + Assert.IsNull(error); + }, + collectionIds: new List() { giraffeCollectionId, turtleCollectionId }, + features: new List() { "objects" }, + imagesFile: imagesFile + ); + + while (analyzeResponse == null) + yield return null; + } + } + } + #endregion + + #region Collections + [UnityTest, Order(2)] + public IEnumerator TestListCollections() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to List Collections..."); + CollectionsList collectionsList = null; + service.ListCollections( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "List Collections result: {0}", response.Response); + collectionsList = response.Result; + Assert.IsNotNull(collectionsList.Collections); + Assert.IsTrue(collectionsList.Collections.Count > 0); + Assert.IsNull(error); + } + ); + + while (collectionsList == null) + yield return null; + } + + [UnityTest, Order(3)] + public IEnumerator TestGetCollection() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Get Collection..."); + Collection collection = null; + service.GetCollection( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "GetCollection result: {0}", response.Response); + collection = response.Result; + Assert.IsNotNull(collection.CollectionId); + Assert.IsTrue(collection.CollectionId == giraffeCollectionId); + Assert.IsNull(error); + }, + collectionId: giraffeCollectionId + ); + + while (collection == null) + yield return null; + } + + [UnityTest, Order(4)] + public IEnumerator TestCreateCollection() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Create Collection..."); + Collection collection = null; + service.CreateCollection( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "CreateCollection result: {0}", response.Response); + collection = response.Result; + Assert.IsNotNull(collection.CollectionId); + Assert.IsNull(error); + collectionId = collection.CollectionId; + } + ); + + while (collection == null) + yield return null; + } + + [UnityTest, Order(5)] + public IEnumerator TestUpdateCollection() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Update Collection..."); + Collection collection = null; + string updatedTestCollectionName = "newTestCollection"; + byte[] updatedTestCollectionNameUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(updatedTestCollectionName); + service.UpdateCollection( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "UpdateCollection result: {0}", response.Response); + collection = response.Result; + Assert.IsNotNull(collection.CollectionId); + Assert.IsTrue(collection.CollectionId == collectionId); + Assert.IsNull(error); + }, + collectionId: collectionId, + name: System.Text.Encoding.UTF8.GetString(updatedTestCollectionNameUtf8Bytes) + ); + + while (collection == null) + yield return null; + } + + [UnityTest, Order(99)] + public IEnumerator TestDeleteCollection() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Delete Collection..."); + bool isComplete = false; + service.DeleteCollection( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "DeleteCollection result: {0}", response.Response); + Assert.IsNotNull(response.Result); + Assert.IsTrue(response.StatusCode == 200); + isComplete = true; + }, + collectionId: collectionId + ); + + while (isComplete == true) + yield return null; + } + #endregion + + #region Images + [UnityTest, Order(6)] + public IEnumerator TestAddImage() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Add Images..."); + ImageDetailsList imageDetailsList = null; + List imagesFile = new List(); + using (FileStream fs1 = File.OpenRead(giraffeImageFilepath), fs2 = File.OpenRead(turtleImageFilepath)) + { + using (MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream()) + { + fs1.CopyTo(ms1); + fs2.CopyTo(ms2); + FileWithMetadata fileWithMetadata = new FileWithMetadata() + { + Data = ms1, + ContentType = "image/jpeg", + Filename = Path.GetFileName(giraffeImageFilepath) + }; + imagesFile.Add(fileWithMetadata); + + FileWithMetadata fileWithMetadata2 = new FileWithMetadata() + { + Data = ms2, + ContentType = "image/jpeg", + Filename = Path.GetFileName(turtleImageFilepath) + }; + imagesFile.Add(fileWithMetadata2); + + service.AddImages( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "AddImages result: {0}", response.Response); + imageDetailsList = response.Result; + Assert.IsNotNull(imageDetailsList.Images); + Assert.IsTrue(imageDetailsList.Images.Count > 0); + Assert.IsNull(error); + imageId = imageDetailsList.Images[0].ImageId; + }, + collectionId: collectionId, + imagesFile: imagesFile + ); + + while (imageDetailsList == null) + yield return null; + } + } + } + [UnityTest, Order(7)] + public IEnumerator TestListImages() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to List Images..."); + ImageSummaryList imagesList = null; + service.ListImages( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "ListImages result: {0}", response.Response); + imagesList = response.Result; + Assert.IsNotNull(imagesList.Images); + Assert.IsTrue(imagesList.Images.Count > 0); + Assert.IsNull(error); + }, + collectionId: collectionId + ); + + while (imagesList == null) + yield return null; + } + + [UnityTest, Order(8)] + public IEnumerator TestGetImage() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Get Image..."); + ImageDetails imageDetails = null; + service.GetImageDetails( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "GetImage result: {0}", response.Response); + imageDetails = response.Result; + Assert.IsNotNull(imageDetails); + Assert.IsTrue(imageDetails.ImageId == imageId); + Assert.IsNull(error); + }, + collectionId: collectionId, + imageId: imageId + ); + + while (imageDetails == null) + yield return null; + } + + [UnityTest, Order(9)] + public IEnumerator TestGetJpegImage() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Get Image..."); + bool isComplete = false; + service.GetJpegImage( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "GetImage result: {0}", response.Response); + Assert.IsNotNull(response.Result); + isComplete = true; + }, + collectionId: collectionId, + imageId: imageId + ); + + while (isComplete == true) + yield return null; + } + + [UnityTest, Order(98)] + public IEnumerator TestDeleteImage() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Delete Image..."); + bool isComplete = false; + service.DeleteImage( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "DeleteImage result: {0}", response.Response); + Assert.IsNotNull(response.Result); + Assert.IsTrue(response.StatusCode == 200); + isComplete = true; + }, + collectionId: collectionId, + imageId: imageId + ); + + while (isComplete == true) + yield return null; + } + #endregion + + #region Training Data + [UnityTest, Order(10)] + public IEnumerator TestAddImageTrainingData() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Add Image Training Data..."); + TrainingDataObjects trainingDataObjects = null; + var objectName = giraffeClassname; + List objects = new List() + { + new TrainingDataObject() + { + _Object = objectName, + Location = new Location() + { + Left = 27, + Top = 64, + Width = 75, + Height = 78 + } + + } + }; + service.AddImageTrainingData( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "AddImageTrainingData result: {0}", response.Response); + trainingDataObjects = response.Result; + Assert.IsNotNull(trainingDataObjects); + Assert.IsTrue(trainingDataObjects.Objects.Count > 0); + Assert.IsNull(error); + }, + collectionId: collectionId, + imageId: imageId, + objects: objects + ); + + while (trainingDataObjects == null) + yield return null; + } + + [UnityTest, Order(11)] + public IEnumerator TestTrain() + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Attempting to Train..."); + Collection collection = null; + service.Train( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("VisualRecognitionServiceV4IntegrationTests", "Train result: {0}", response.Response); + collection = response.Result; + Assert.IsNotNull(collection); + Assert.IsTrue(collection.TrainingStatus.Objects.InProgress == true); + Assert.IsNull(error); + }, + collectionId: collectionId + ); + + while (collection == null) + yield return null; + } + #endregion + } +} diff --git a/Tests/VisualRecognitionV4IntegrationTests.cs.meta b/Tests/VisualRecognitionV4IntegrationTests.cs.meta new file mode 100644 index 000000000..56709d89d --- /dev/null +++ b/Tests/VisualRecognitionV4IntegrationTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1942de15e39b34bc8b5f8705c9b95a1a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 2f220b8a2183821aa32e4a1918f312257bdebeed Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 3 Oct 2019 17:32:30 -0400 Subject: [PATCH 3/9] feat(Examples): add examples for NLU, LT and Discovery --- Examples/ExampleDiscoveryV1.cs | 89 ++++++++++ Examples/ExampleDiscoveryV1.cs.meta | 11 ++ Examples/ExampleDiscoveryV1.unity | 168 ++++++++++++++++++ Examples/ExampleDiscoveryV1.unity.meta | 7 + Examples/ExampleLanguageTranslatorV3.cs | 72 ++++++++ Examples/ExampleLanguageTranslatorV3.cs.meta | 11 ++ Examples/ExampleLanguageTranslatorV3.unity | 168 ++++++++++++++++++ .../ExampleLanguageTranslatorV3.unity.meta | 7 + .../ExampleNaturalLanguageClassifierV1.cs | 85 +++++++++ ...ExampleNaturalLanguageClassifierV1.cs.meta | 11 ++ .../ExampleNaturalLanguageClassifierV1.unity | 165 +++++++++++++++++ ...mpleNaturalLanguageClassifierV1.unity.meta | 7 + .../ExampleNaturalLanguageUnderstandingV1.cs | 4 - ...xampleNaturalLanguageUnderstandingV1.unity | 20 ++- Examples/ExampleStreaming.unity | 55 ++++-- Examples/ExampleToneAnalyzerV3.unity | 22 ++- 16 files changed, 873 insertions(+), 29 deletions(-) create mode 100644 Examples/ExampleDiscoveryV1.cs create mode 100644 Examples/ExampleDiscoveryV1.cs.meta create mode 100644 Examples/ExampleDiscoveryV1.unity create mode 100644 Examples/ExampleDiscoveryV1.unity.meta create mode 100644 Examples/ExampleLanguageTranslatorV3.cs create mode 100644 Examples/ExampleLanguageTranslatorV3.cs.meta create mode 100644 Examples/ExampleLanguageTranslatorV3.unity create mode 100644 Examples/ExampleLanguageTranslatorV3.unity.meta create mode 100644 Examples/ExampleNaturalLanguageClassifierV1.cs create mode 100644 Examples/ExampleNaturalLanguageClassifierV1.cs.meta create mode 100644 Examples/ExampleNaturalLanguageClassifierV1.unity create mode 100644 Examples/ExampleNaturalLanguageClassifierV1.unity.meta diff --git a/Examples/ExampleDiscoveryV1.cs b/Examples/ExampleDiscoveryV1.cs new file mode 100644 index 000000000..cb79ef48a --- /dev/null +++ b/Examples/ExampleDiscoveryV1.cs @@ -0,0 +1,89 @@ +using IBM.Watson.Discovery.V1; +using IBM.Watson.Discovery.V1.Model; +using IBM.Cloud.SDK.Utilities; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using IBM.Cloud.SDK; + +public class ExampleDiscoveryV1 : MonoBehaviour +{ + #region PLEASE SET THESE VARIABLES IN THE INSPECTOR + [Space(10)] + [Tooltip("The IAM apikey.")] + [SerializeField] + private string iamApikey; + [Tooltip("The service URL (optional). This defaults to \"https://gateway.watsonplatform.net/discovery/api\"")] + [SerializeField] + private string serviceUrl; + [Tooltip("The version date with which you would like to use the service in the form YYYY-MM-DD.")] + [SerializeField] + private string versionDate; + #endregion + + private DiscoveryService service; + // Start is called before the first frame update + void Start() + { + LogSystem.InstallDefaultReactors(); + Runnable.Run(CreateService()); + } + + // Update is called once per frame + public IEnumerator CreateService() + { + if (string.IsNullOrEmpty(iamApikey)) + { + throw new IBMException("Plesae provide IAM ApiKey for the service."); + } + + // Create credential and instantiate service + IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); + + // Wait for tokendata + while (!authenticator.CanAuthenticate()) + yield return null; + + service = new DiscoveryService(versionDate, authenticator); + + + Runnable.Run(ExampleCreateEnvironment()); + Runnable.Run(ExampleListEnvironments()); + } + + private IEnumerator ExampleCreateEnvironment() + { + ModelEnvironment createEnvironmentResponse = null; + service.CreateEnvironment( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("DiscoveryServiceV1", "CreateEnvironment result: {0}", response.Response); + createEnvironmentResponse = response.Result; + // environmentId = createEnvironmentResponse.EnvironmentId; + }, + name: "my_environment", + description: "My environment" + ); + + while (createEnvironmentResponse == null) + yield return null; + } + + private IEnumerator ExampleListEnvironments() + { + Log.Debug("DiscoveryServiceV1", "ListEnvironments"); + ListEnvironmentsResponse listEnvironmentsResponse = null; + service.ListEnvironments( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("DiscoveryServiceV1", "ListEnvironments result: {0}", response.Response); + listEnvironmentsResponse = response.Result; + } + ); + + while (listEnvironmentsResponse == null) + yield return null; + } +} \ No newline at end of file diff --git a/Examples/ExampleDiscoveryV1.cs.meta b/Examples/ExampleDiscoveryV1.cs.meta new file mode 100644 index 000000000..b72cb2956 --- /dev/null +++ b/Examples/ExampleDiscoveryV1.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c8cc5579d4a384f8ca87dccdf800981f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/ExampleDiscoveryV1.unity b/Examples/ExampleDiscoveryV1.unity new file mode 100644 index 000000000..32f8fdb64 --- /dev/null +++ b/Examples/ExampleDiscoveryV1.unity @@ -0,0 +1,168 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &444819960 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 444819963} + - component: {fileID: 444819961} + m_Layer: 0 + m_Name: ExampleDiscoveryV1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &444819961 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 444819960} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8cc5579d4a384f8ca87dccdf800981f, type: 3} + m_Name: + m_EditorClassIdentifier: + iamApikey: S + serviceUrl: S + versionDate: 2019-09-16 +--- !u!4 &444819963 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 444819960} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Examples/ExampleDiscoveryV1.unity.meta b/Examples/ExampleDiscoveryV1.unity.meta new file mode 100644 index 000000000..13ccdc994 --- /dev/null +++ b/Examples/ExampleDiscoveryV1.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9dd94e07480dd434883ee65b9c8e50bb +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/ExampleLanguageTranslatorV3.cs b/Examples/ExampleLanguageTranslatorV3.cs new file mode 100644 index 000000000..4e1af12f6 --- /dev/null +++ b/Examples/ExampleLanguageTranslatorV3.cs @@ -0,0 +1,72 @@ +using IBM.Watson.LanguageTranslator.V3; +using IBM.Watson.LanguageTranslator.V3.Model; +using IBM.Cloud.SDK.Utilities; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using IBM.Cloud.SDK; + +public class ExampleLanguageTranslatorV3 : MonoBehaviour +{ + #region PLEASE SET THESE VARIABLES IN THE INSPECTOR + [Space(10)] + [Tooltip("The IAM apikey.")] + [SerializeField] + private string iamApikey; + [Tooltip("The service URL (optional). This defaults to \"https://gateway.watsonplatform.net/discovery/api\"")] + [SerializeField] + private string serviceUrl; + [Tooltip("The version date with which you would like to use the service in the form YYYY-MM-DD.")] + [SerializeField] + private string versionDate; + #endregion + + private LanguageTranslatorService service; + // Start is called before the first frame update + void Start() + { + LogSystem.InstallDefaultReactors(); + Runnable.Run(CreateService()); + } + + // Update is called once per frame + public IEnumerator CreateService() + { + if (string.IsNullOrEmpty(iamApikey)) + { + throw new IBMException("Plesae provide IAM ApiKey for the service."); + } + + // Create credential and instantiate service + IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); + + // Wait for tokendata + while (!authenticator.CanAuthenticate()) + yield return null; + + service = new LanguageTranslatorService(versionDate, authenticator); + service.SetServiceUrl("https://api.us-south.language-translator.test.watson.cloud.ibm.com"); + + + Log.Debug("LanguageTranslatorServiceV3", "ListModels result"); + } + + private IEnumerator ExampleListModels() + { + TranslationModels listModelsResponse = null; + service.ListModels( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("LanguageTranslatorServiceV3", "ListModels result: {0}", response.Response); + listModelsResponse = response.Result; + }, + source: "en", + target: "fr" + ); + + while (listModelsResponse == null) + yield return null; + } +} \ No newline at end of file diff --git a/Examples/ExampleLanguageTranslatorV3.cs.meta b/Examples/ExampleLanguageTranslatorV3.cs.meta new file mode 100644 index 000000000..e5e41d24f --- /dev/null +++ b/Examples/ExampleLanguageTranslatorV3.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a1e352a986b5428ea65dbad0d72f77e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/ExampleLanguageTranslatorV3.unity b/Examples/ExampleLanguageTranslatorV3.unity new file mode 100644 index 000000000..3f15c052e --- /dev/null +++ b/Examples/ExampleLanguageTranslatorV3.unity @@ -0,0 +1,168 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &250075178 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 250075181} + - component: {fileID: 250075179} + m_Layer: 0 + m_Name: ExampleLanguageTranslatorV3 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &250075179 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 250075178} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a1e352a986b5428ea65dbad0d72f77e, type: 3} + m_Name: + m_EditorClassIdentifier: + iamApikey: s + serviceUrl: s + versionDate: 2019-09-16 +--- !u!4 &250075181 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 250075178} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Examples/ExampleLanguageTranslatorV3.unity.meta b/Examples/ExampleLanguageTranslatorV3.unity.meta new file mode 100644 index 000000000..0e262e7fc --- /dev/null +++ b/Examples/ExampleLanguageTranslatorV3.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1db2a18e871684a5590b5d13afaa8096 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/ExampleNaturalLanguageClassifierV1.cs b/Examples/ExampleNaturalLanguageClassifierV1.cs new file mode 100644 index 000000000..bda5ad4f4 --- /dev/null +++ b/Examples/ExampleNaturalLanguageClassifierV1.cs @@ -0,0 +1,85 @@ +/** +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using IBM.Watson.NaturalLanguageClassifier.V1; +using IBM.Watson.NaturalLanguageClassifier.V1.Model; +using IBM.Cloud.SDK.Utilities; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using IBM.Cloud.SDK; + + +namespace IBM.Watson.Examples +{ + public class ExampleNaturalLanguageClassifierV1 : MonoBehaviour + { + #region PLEASE SET THESE VARIABLES IN THE INSPECTOR + [Space(10)] + [Tooltip("The IAM apikey.")] + [SerializeField] + private string iamApikey; + [Tooltip("The service URL (optional). This defaults to \"https://gateway.watsonplatform.net/natural-language-understanding/api\"")] + [SerializeField] + private string serviceUrl; + #endregion + + private NaturalLanguageClassifierService service; + private string nluText = "IBM is an American multinational technology company headquartered in Armonk, New York, United States with operations in over 170 countries."; + private void Start() + { + LogSystem.InstallDefaultReactors(); + Runnable.Run(CreateService()); + } + + private IEnumerator CreateService() + { + if (string.IsNullOrEmpty(iamApikey)) + { + throw new IBMException("Please add IAM ApiKey to the Iam Apikey field in the inspector."); + } + + IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); + + while (!authenticator.CanAuthenticate()) + { + yield return null; + } + + service = new NaturalLanguageClassifierService(authenticator); + + Runnable.Run(ExampleListClassifiers()); + } + + private IEnumerator ExampleListClassifiers() + { + ClassifierList listClassifiersResponse = null; + service.ListClassifiers( + callback: (DetailedResponse response, IBMError error) => + { + Log.Debug("NaturalLanguageClassifierServiceV1", "ListClassifiers result: {0}", response.Response); + listClassifiersResponse = response.Result; + } + ); + + while (listClassifiersResponse == null) + yield return null; + } + } +} diff --git a/Examples/ExampleNaturalLanguageClassifierV1.cs.meta b/Examples/ExampleNaturalLanguageClassifierV1.cs.meta new file mode 100644 index 000000000..003fde73d --- /dev/null +++ b/Examples/ExampleNaturalLanguageClassifierV1.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6b3646f01bb184a2185f421538734ff3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/ExampleNaturalLanguageClassifierV1.unity b/Examples/ExampleNaturalLanguageClassifierV1.unity new file mode 100644 index 000000000..731d478da --- /dev/null +++ b/Examples/ExampleNaturalLanguageClassifierV1.unity @@ -0,0 +1,165 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &534719662 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 534719665} + - component: {fileID: 534719663} + m_Layer: 0 + m_Name: ExampleNaturalLanguageClassiffierV1 + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &534719663 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534719662} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6b3646f01bb184a2185f421538734ff3, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &534719665 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 534719662} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Examples/ExampleNaturalLanguageClassifierV1.unity.meta b/Examples/ExampleNaturalLanguageClassifierV1.unity.meta new file mode 100644 index 000000000..8a8d630fe --- /dev/null +++ b/Examples/ExampleNaturalLanguageClassifierV1.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a25f3447ffa82495985ba0e0516f0343 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/ExampleNaturalLanguageUnderstandingV1.cs b/Examples/ExampleNaturalLanguageUnderstandingV1.cs index 3fe808dbc..614839b90 100644 --- a/Examples/ExampleNaturalLanguageUnderstandingV1.cs +++ b/Examples/ExampleNaturalLanguageUnderstandingV1.cs @@ -60,10 +60,6 @@ private IEnumerator CreateService() IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); - // Wait for tokendata - while (!authenticator.CanAuthenticate()) - yield return null; - while (!authenticator.CanAuthenticate()) { yield return null; diff --git a/Examples/ExampleNaturalLanguageUnderstandingV1.unity b/Examples/ExampleNaturalLanguageUnderstandingV1.unity index 6307b28e9..a2fb6bc21 100644 --- a/Examples/ExampleNaturalLanguageUnderstandingV1.unity +++ b/Examples/ExampleNaturalLanguageUnderstandingV1.unity @@ -54,7 +54,7 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 12 m_Resolution: 2 m_BakeResolution: 40 m_AtlasSize: 1024 @@ -62,6 +62,7 @@ LightmapSettings: m_AOMaxDistance: 1 m_CompAOExponent: 1 m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 m_Padding: 2 m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 @@ -76,10 +77,16 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 m_PVRFilterTypeDirect: 0 m_PVRFilterTypeIndirect: 0 m_PVRFilterTypeAO: 0 - m_PVRFilteringMode: 1 + m_PVREnvironmentMIS: 0 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 @@ -87,7 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -141,9 +149,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: dfdc93e9c48b5475fbceaff19b33d951, type: 3} m_Name: m_EditorClassIdentifier: - iamApikey: - serviceUrl: - versionDate: + iamApikey: 7cIHQv_i4rwRqDd_q3T92pBZ7QFCEewk7rpQU0DyR_ZW + serviceUrl: https://api.us-south.natural-language-understanding.test.watson.cloud.ibm.com + versionDate: 2019-09-16 --- !u!4 &800506887 Transform: m_ObjectHideFlags: 0 diff --git a/Examples/ExampleStreaming.unity b/Examples/ExampleStreaming.unity index 57ebaceb5..b4d5befb3 100644 --- a/Examples/ExampleStreaming.unity +++ b/Examples/ExampleStreaming.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.49641287, b: 0.5748173, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -54,7 +54,7 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 12 m_Resolution: 2 m_BakeResolution: 40 m_AtlasSize: 1024 @@ -62,6 +62,7 @@ LightmapSettings: m_AOMaxDistance: 1 m_CompAOExponent: 1 m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 m_Padding: 2 m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 @@ -76,10 +77,16 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 m_PVRFilterTypeDirect: 0 m_PVRFilterTypeIndirect: 0 m_PVRFilterTypeAO: 0 - m_PVRFilteringMode: 1 + m_PVREnvironmentMIS: 0 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 @@ -87,7 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 0 --- !u!196 &4 @@ -140,7 +148,7 @@ MonoBehaviour: m_GameObject: {fileID: 278297820} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} m_Name: m_EditorClassIdentifier: m_IgnoreReversedGraphics: 1 @@ -157,7 +165,7 @@ MonoBehaviour: m_GameObject: {fileID: 278297820} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} m_Name: m_EditorClassIdentifier: m_UiScaleMode: 0 @@ -236,12 +244,13 @@ Light: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1159842907} m_Enabled: 1 - serializedVersion: 8 + serializedVersion: 9 m_Type: 1 m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} m_Intensity: 1 m_Range: 10 m_SpotAngle: 30 + m_InnerSpotAngle: 21.802082 m_CookieSize: 10 m_Shadows: m_Type: 2 @@ -251,6 +260,24 @@ Light: m_Bias: 0.05 m_NormalBias: 0.4 m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 m_Cookie: {fileID: 0} m_DrawHalo: 0 m_Flare: {fileID: 0} @@ -258,12 +285,15 @@ Light: m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 + m_RenderingLayerMask: 1 m_Lightmapping: 4 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 6570 m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!4 &1159842909 @@ -336,9 +366,10 @@ Camera: m_ClearFlags: 2 m_BackGroundColor: {r: 0.125, g: 0.125, b: 0.125, a: 0} m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_GateFitMode: 2 m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 @@ -407,7 +438,7 @@ MonoBehaviour: m_GameObject: {fileID: 1428860024} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} m_Name: m_EditorClassIdentifier: m_HorizontalAxis: Horizontal @@ -426,7 +457,7 @@ MonoBehaviour: m_GameObject: {fileID: 1428860024} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} m_Name: m_EditorClassIdentifier: m_FirstSelected: {fileID: 0} @@ -540,7 +571,7 @@ MonoBehaviour: m_GameObject: {fileID: 1863902089} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 1741964061, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} m_Name: m_EditorClassIdentifier: m_HorizontalFit: 2 @@ -554,7 +585,7 @@ MonoBehaviour: m_GameObject: {fileID: 1863902089} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} diff --git a/Examples/ExampleToneAnalyzerV3.unity b/Examples/ExampleToneAnalyzerV3.unity index ae87fb11c..225c62e27 100644 --- a/Examples/ExampleToneAnalyzerV3.unity +++ b/Examples/ExampleToneAnalyzerV3.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} + m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074, b: 0.35872698, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -54,7 +54,7 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 12 m_Resolution: 2 m_BakeResolution: 40 m_AtlasSize: 1024 @@ -62,6 +62,7 @@ LightmapSettings: m_AOMaxDistance: 1 m_CompAOExponent: 1 m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 m_Padding: 2 m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 @@ -76,10 +77,16 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 m_PVRFilterTypeDirect: 0 m_PVRFilterTypeIndirect: 0 m_PVRFilterTypeAO: 0 - m_PVRFilteringMode: 1 + m_PVREnvironmentMIS: 0 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 @@ -87,7 +94,8 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -141,9 +149,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0565ac87492626f4f8ae7c0b00ca16bd, type: 3} m_Name: m_EditorClassIdentifier: - iamApikey: - serviceUrl: - versionDate: + iamApikey: sad + serviceUrl: dsad + versionDate: 2019-09-16 --- !u!4 &1170910667 Transform: m_ObjectHideFlags: 0 From dc402cbccf6d7cca866131d52bc39f90b1b11bd4 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 3 Oct 2019 17:33:22 -0400 Subject: [PATCH 4/9] refactor(SpeechToText): move authentication to WSConnector --- .../Services/SpeechToText/V1/SpeechToTextServiceExtension.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs b/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs index 61800e9d0..8efd8694b 100644 --- a/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs +++ b/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs @@ -447,7 +447,6 @@ private bool CreateListenConnector() } _listenSocket = WSConnector.CreateConnector(Authenticator, "/v1/recognize", "?model=" + UnityWebRequest.EscapeURL(_recognizeModel) + parsedParams, serviceUrl); - Authenticator.Authenticate(_listenSocket); Log.Debug("SpeechToText.CreateListenConnector()", "Created listen socket. Model: {0}, parsedParams: {1}", UnityWebRequest.EscapeURL(_recognizeModel), parsedParams); _listenSocket.DisableSslVerification = DisableSslVerification; if (_listenSocket == null) @@ -560,7 +559,6 @@ private void OnListenMessage(WSConnector.Message msg) if (msg is WSConnector.TextMessage) { WSConnector.TextMessage tm = (WSConnector.TextMessage)msg; - IDictionary json = Json.Deserialize(tm.Text) as IDictionary; if (json != null) { From 12194cf26251901a785c2dae50d7315e5827d2ae Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 3 Oct 2019 17:33:46 -0400 Subject: [PATCH 5/9] feat: add meta file for vis rec v4 --- Scripts/Services/VisualRecognition/V4.meta | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Scripts/Services/VisualRecognition/V4.meta diff --git a/Scripts/Services/VisualRecognition/V4.meta b/Scripts/Services/VisualRecognition/V4.meta new file mode 100644 index 000000000..6eaae9942 --- /dev/null +++ b/Scripts/Services/VisualRecognition/V4.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 97f2602322ffe41c79fc4d582ea3c20e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From affd1f95726ad8fbd41720b3c7d5c0a8c4e65b1c Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Fri, 4 Oct 2019 08:13:56 -0400 Subject: [PATCH 6/9] feat(regenerate): regenerate services using current api def --- .../Services/Assistant/V1/AssistantService.cs | 12 +- .../V1/Model/DialogRuntimeResponseGeneric.cs | 2 +- .../V2/Model/DialogRuntimeResponseGeneric.cs | 2 +- .../Services/Discovery/V1/DiscoveryService.cs | 185 ++++-------------- .../Discovery/V1/Model/Completions.cs | 34 ++++ .../Discovery/V1/Model/Completions.cs.meta | 11 ++ .../V1/Model/NluEnrichmentEntities.cs | 2 +- .../V1/Model/NluEnrichmentRelations.cs | 4 +- .../Discovery/V1/Model/QueryFilterType.cs | 2 +- .../V1/Model/QueryRelationsArgument.cs | 2 +- .../V1/Model/QueryRelationsEntity.cs | 2 +- .../V1/Model/QueryRelationsFilter.cs | 6 +- .../V1/Model/QueryRelationsRelationship.cs | 2 +- .../V1/Model/QueryRelationsResponse.cs | 2 +- .../TextToSpeech/V1/TextToSpeechService.cs | 64 ++---- 15 files changed, 126 insertions(+), 206 deletions(-) create mode 100644 Scripts/Services/Discovery/V1/Model/Completions.cs create mode 100644 Scripts/Services/Discovery/V1/Model/Completions.cs.meta diff --git a/Scripts/Services/Assistant/V1/AssistantService.cs b/Scripts/Services/Assistant/V1/AssistantService.cs index 8513cc8fb..15a2b238e 100644 --- a/Scripts/Services/Assistant/V1/AssistantService.cs +++ b/Scripts/Services/Assistant/V1/AssistantService.cs @@ -93,9 +93,9 @@ public AssistantService(string versionDate, Authenticator authenticator) : base( /// /// Send user input to a workspace and receive a response. /// - /// **Note:** For most applications, there are significant advantages to using the v2 runtime API instead. These - /// advantages include ease of deployment, automatic state management, versioning, and search capabilities. For - /// more information, see the + /// **Important:** This method has been superseded by the new v2 runtime API. The v2 API offers significant + /// advantages, including ease of deployment, automatic state management, versioning, and search capabilities. + /// For more information, see the /// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-api-overview). /// /// There is no rate limit for this operation. @@ -4139,8 +4139,7 @@ private void OnDeleteDialogNodeResponse(RESTConnector.Request req, RESTConnector /// The callback function that is invoked when the operation completes. /// Unique identifier of the workspace. /// How to sort the returned log events. You can sort by **request_timestamp**. To reverse - /// the sort order, prefix the parameter value with a minus sign (`-`). (optional, default to - /// request_timestamp) + /// the sort order, prefix the parameter value with a minus sign (`-`). (optional) /// A cacheable parameter that limits the results to those matching the specified filter. /// For more information, see the /// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference). @@ -4241,8 +4240,7 @@ private void OnListLogsResponse(RESTConnector.Request req, RESTConnector.Respons /// or `request.context.metadata.deployment`. For more information, see the /// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference). /// How to sort the returned log events. You can sort by **request_timestamp**. To reverse - /// the sort order, prefix the parameter value with a minus sign (`-`). (optional, default to - /// request_timestamp) + /// the sort order, prefix the parameter value with a minus sign (`-`). (optional) /// The number of records to return in each page of results. (optional) /// A token identifying the page of results to retrieve. (optional) /// LogCollection diff --git a/Scripts/Services/Assistant/V1/Model/DialogRuntimeResponseGeneric.cs b/Scripts/Services/Assistant/V1/Model/DialogRuntimeResponseGeneric.cs index 09d412b0c..165306607 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogRuntimeResponseGeneric.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogRuntimeResponseGeneric.cs @@ -104,7 +104,7 @@ public class PreferenceValue [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)] public long? Time { get; set; } /// - /// Whether to send a \"user is typing\" event during the pause. + /// Whether to send a "user is typing" event during the pause. /// [JsonProperty("typing", NullValueHandling = NullValueHandling.Ignore)] public bool? Typing { get; set; } diff --git a/Scripts/Services/Assistant/V2/Model/DialogRuntimeResponseGeneric.cs b/Scripts/Services/Assistant/V2/Model/DialogRuntimeResponseGeneric.cs index 47086f53b..28a39f448 100644 --- a/Scripts/Services/Assistant/V2/Model/DialogRuntimeResponseGeneric.cs +++ b/Scripts/Services/Assistant/V2/Model/DialogRuntimeResponseGeneric.cs @@ -108,7 +108,7 @@ public class PreferenceValue [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)] public long? Time { get; set; } /// - /// Whether to send a \"user is typing\" event during the pause. + /// Whether to send a "user is typing" event during the pause. /// [JsonProperty("typing", NullValueHandling = NullValueHandling.Ignore)] public bool? Typing { get; set; } diff --git a/Scripts/Services/Discovery/V1/DiscoveryService.cs b/Scripts/Services/Discovery/V1/DiscoveryService.cs index c127d7b0b..8a3a61e9d 100644 --- a/Scripts/Services/Discovery/V1/DiscoveryService.cs +++ b/Scripts/Services/Discovery/V1/DiscoveryService.cs @@ -2607,10 +2607,16 @@ private void OnDeleteDocumentResponse(RESTConnector.Request req, RESTConnector.R /// towards field values closer to the current date. When a **number** type field is specified, returned results /// are biased towards higher field values. This parameter cannot be used in the same query as the **sort** /// parameter. (optional) + /// When `true` and the **natural_language_query** parameter is used, the + /// **natural_languge_query** parameter is spell checked. The most likely correction is retunred in the + /// **suggested_query** field of the response (if one exists). + /// + /// **Important:** this parameter is only valid when using the Cloud Pak version of Discovery. (optional, + /// default to false) /// If `true`, queries are not stored in the Discovery **Logs** endpoint. /// (optional, default to false) /// QueryResponse - public bool Query(Callback callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string _return = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? xWatsonLoggingOptOut = null) + public bool Query(Callback callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string _return = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? spellingSuggestions = null, bool? xWatsonLoggingOptOut = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Query`"); @@ -2686,6 +2692,8 @@ public bool Query(Callback callback, string environmentId, string bodyObject["similar.fields"] = similarFields; if (!string.IsNullOrEmpty(bias)) bodyObject["bias"] = bias; + if (spellingSuggestions != null) + bodyObject["spelling_suggestions"] = JToken.FromObject(spellingSuggestions); req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); req.OnResponse = OnQueryResponse; @@ -2920,6 +2928,7 @@ private void OnQueryNoticesResponse(RESTConnector.Request req, RESTConnector.Res /// /// The callback function that is invoked when the operation completes. /// The ID of the environment. + /// A comma-separated list of collection IDs to be queried against. /// A cacheable query that excludes documents that don't mention the query content. Filter /// searches are better for metadata-type searches and for assessing the concepts in the data set. /// (optional) @@ -2975,7 +2984,7 @@ private void OnQueryNoticesResponse(RESTConnector.Request req, RESTConnector.Res /// If `true`, queries are not stored in the Discovery **Logs** endpoint. /// (optional, default to false) /// QueryResponse - public bool FederatedQuery(Callback callback, string environmentId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string _return = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? xWatsonLoggingOptOut = null) + public bool FederatedQuery(Callback callback, string environmentId, string collectionIds, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string _return = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? xWatsonLoggingOptOut = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `FederatedQuery`"); @@ -3011,6 +3020,8 @@ public bool FederatedQuery(Callback callback, string environmentI } JObject bodyObject = new JObject(); + if (!string.IsNullOrEmpty(collectionIds)) + bodyObject["collection_ids"] = collectionIds; if (!string.IsNullOrEmpty(filter)) bodyObject["filter"] = filter; if (!string.IsNullOrEmpty(query)) @@ -3255,38 +3266,33 @@ private void OnFederatedQueryNoticesResponse(RESTConnector.Request req, RESTConn ((RequestObject)req).Callback(response, resp.Error); } /// - /// Knowledge Graph entity query. + /// Get Autocomplete Suggestions. /// - /// See the [Knowledge Graph documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-kg#kg) - /// for more details. + /// Returns completion query suggestions for the specified prefix. /n/n **Important:** this method is only + /// valid when using the Cloud Pak version of Discovery. /// /// The callback function that is invoked when the operation completes. /// The ID of the environment. /// The ID of the collection. - /// The entity query feature to perform. Supported features are `disambiguate` and - /// `similar_entities`. (optional) - /// A text string that appears within the entity text field. (optional) - /// Entity text to provide context for the queried entity and rank based on that - /// association. For example, if you wanted to query the city of London in England your query would look for - /// `London` with the context of `England`. (optional) - /// The number of results to return. The default is `10`. The maximum is `1000`. + /// The field in the result documents that autocompletion suggestions are identified from. /// (optional) - /// The number of evidence items to return for each result. The default is `0`. The - /// maximum number of evidence items per query is 10,000. (optional) - /// QueryEntitiesResponse - public bool QueryEntities(Callback callback, string environmentId, string collectionId, string feature = null, QueryEntitiesEntity entity = null, QueryEntitiesContext context = null, long? count = null, long? evidenceCount = null) + /// The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete + /// to `Hot`, `Housing`, or `How do I upgrade`. Possible completions are. (optional) + /// The number of autocompletion suggestions to return. (optional) + /// Completions + public bool GetAutocompletion(Callback callback, string environmentId, string collectionId, string field = null, string prefix = null, long? count = null) { if (callback == null) - throw new ArgumentNullException("`callback` is required for `QueryEntities`"); + throw new ArgumentNullException("`callback` is required for `GetAutocompletion`"); if (string.IsNullOrEmpty(environmentId)) - throw new ArgumentNullException("`environmentId` is required for `QueryEntities`"); + throw new ArgumentNullException("`environmentId` is required for `GetAutocompletion`"); if (string.IsNullOrEmpty(collectionId)) - throw new ArgumentNullException("`collectionId` is required for `QueryEntities`"); + throw new ArgumentNullException("`collectionId` is required for `GetAutocompletion`"); - RequestObject req = new RequestObject + RequestObject req = new RequestObject { Callback = callback, - HttpMethod = UnityWebRequest.kHttpVerbPOST, + HttpMethod = UnityWebRequest.kHttpVerbGET, DisableSslVerification = DisableSslVerification }; @@ -3297,135 +3303,28 @@ public bool QueryEntities(Callback callback, string envir ClearCustomRequestHeaders(); - foreach (KeyValuePair kvp in Common.GetSdkHeaders("discovery", "V1", "QueryEntities")) + foreach (KeyValuePair kvp in Common.GetSdkHeaders("discovery", "V1", "GetAutocompletion")) { req.Headers.Add(kvp.Key, kvp.Value); } req.Parameters["version"] = VersionDate; - req.Headers["Content-Type"] = "application/json"; - req.Headers["Accept"] = "application/json"; - - JObject bodyObject = new JObject(); - if (!string.IsNullOrEmpty(feature)) - bodyObject["feature"] = feature; - if (entity != null) - bodyObject["entity"] = JToken.FromObject(entity); - if (context != null) - bodyObject["context"] = JToken.FromObject(context); - if (count != null) - bodyObject["count"] = JToken.FromObject(count); - if (evidenceCount != null) - bodyObject["evidence_count"] = JToken.FromObject(evidenceCount); - req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); - - req.OnResponse = OnQueryEntitiesResponse; - - RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/query_entities", environmentId, collectionId), GetServiceUrl()); - if (connector == null) + if (!string.IsNullOrEmpty(field)) { - return false; + req.Parameters["field"] = field; } - - return connector.Send(req); - } - - private void OnQueryEntitiesResponse(RESTConnector.Request req, RESTConnector.Response resp) - { - DetailedResponse response = new DetailedResponse(); - foreach (KeyValuePair kvp in resp.Headers) - { - response.Headers.Add(kvp.Key, kvp.Value); - } - response.StatusCode = resp.HttpResponseCode; - - try - { - string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); - response.Response = json; - } - catch (Exception e) - { - Log.Error("DiscoveryService.OnQueryEntitiesResponse()", "Exception: {0}", e.ToString()); - resp.Success = false; - } - - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); - } - /// - /// Knowledge Graph relationship query. - /// - /// See the [Knowledge Graph documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-kg#kg) - /// for more details. - /// - /// The callback function that is invoked when the operation completes. - /// The ID of the environment. - /// The ID of the collection. - /// An array of entities to find relationships for. (optional) - /// Entity text to provide context for the queried entity and rank based on that - /// association. For example, if you wanted to query the city of London in England your query would look for - /// `London` with the context of `England`. (optional) - /// The sorting method for the relationships, can be `score` or `frequency`. `frequency` is - /// the number of unique times each entity is identified. The default is `score`. This parameter cannot be used - /// in the same query as the **bias** parameter. (optional) - /// Object containing an array of documents to query. (optional) - /// The number of results to return. The default is `10`. The maximum is `1000`. - /// (optional) - /// The number of evidence items to return for each result. The default is `0`. The - /// maximum number of evidence items per query is 10,000. (optional) - /// QueryRelationsResponse - public bool QueryRelations(Callback callback, string environmentId, string collectionId, List entities = null, QueryEntitiesContext context = null, string sort = null, QueryRelationsFilter filter = null, long? count = null, long? evidenceCount = null) - { - if (callback == null) - throw new ArgumentNullException("`callback` is required for `QueryRelations`"); - if (string.IsNullOrEmpty(environmentId)) - throw new ArgumentNullException("`environmentId` is required for `QueryRelations`"); - if (string.IsNullOrEmpty(collectionId)) - throw new ArgumentNullException("`collectionId` is required for `QueryRelations`"); - - RequestObject req = new RequestObject - { - Callback = callback, - HttpMethod = UnityWebRequest.kHttpVerbPOST, - DisableSslVerification = DisableSslVerification - }; - - foreach (KeyValuePair kvp in customRequestHeaders) + if (!string.IsNullOrEmpty(prefix)) { - req.Headers.Add(kvp.Key, kvp.Value); + req.Parameters["prefix"] = prefix; } - - ClearCustomRequestHeaders(); - - foreach (KeyValuePair kvp in Common.GetSdkHeaders("discovery", "V1", "QueryRelations")) + if (count != null) { - req.Headers.Add(kvp.Key, kvp.Value); + req.Parameters["count"] = count; } - req.Parameters["version"] = VersionDate; - req.Headers["Content-Type"] = "application/json"; - req.Headers["Accept"] = "application/json"; - - JObject bodyObject = new JObject(); - if (entities != null && entities.Count > 0) - bodyObject["entities"] = JToken.FromObject(entities); - if (context != null) - bodyObject["context"] = JToken.FromObject(context); - if (!string.IsNullOrEmpty(sort)) - bodyObject["sort"] = sort; - if (filter != null) - bodyObject["filter"] = JToken.FromObject(filter); - if (count != null) - bodyObject["count"] = JToken.FromObject(count); - if (evidenceCount != null) - bodyObject["evidence_count"] = JToken.FromObject(evidenceCount); - req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject)); - - req.OnResponse = OnQueryRelationsResponse; + req.OnResponse = OnGetAutocompletionResponse; - RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/query_relations", environmentId, collectionId), GetServiceUrl()); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/autocompletion", environmentId, collectionId), GetServiceUrl()); if (connector == null) { return false; @@ -3434,9 +3333,9 @@ public bool QueryRelations(Callback callback, string env return connector.Send(req); } - private void OnQueryRelationsResponse(RESTConnector.Request req, RESTConnector.Response resp) + private void OnGetAutocompletionResponse(RESTConnector.Request req, RESTConnector.Response resp) { - DetailedResponse response = new DetailedResponse(); + DetailedResponse response = new DetailedResponse(); foreach (KeyValuePair kvp in resp.Headers) { response.Headers.Add(kvp.Key, kvp.Value); @@ -3446,17 +3345,17 @@ private void OnQueryRelationsResponse(RESTConnector.Request req, RESTConnector.R try { string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); + response.Result = JsonConvert.DeserializeObject(json); response.Response = json; } catch (Exception e) { - Log.Error("DiscoveryService.OnQueryRelationsResponse()", "Exception: {0}", e.ToString()); + Log.Error("DiscoveryService.OnGetAutocompletionResponse()", "Exception: {0}", e.ToString()); resp.Success = false; } - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); } /// /// List training data. diff --git a/Scripts/Services/Discovery/V1/Model/Completions.cs b/Scripts/Services/Discovery/V1/Model/Completions.cs new file mode 100644 index 000000000..da8d8984a --- /dev/null +++ b/Scripts/Services/Discovery/V1/Model/Completions.cs @@ -0,0 +1,34 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.Discovery.V1.Model +{ + /// + /// An object containing an array of autocompletion suggestions. + /// + public class Completions + { + /// + /// Array of autcomplete suggestion based on the provided prefix. + /// + [JsonProperty("completions", NullValueHandling = NullValueHandling.Ignore)] + public List _Completions { get; set; } + } +} diff --git a/Scripts/Services/Discovery/V1/Model/Completions.cs.meta b/Scripts/Services/Discovery/V1/Model/Completions.cs.meta new file mode 100644 index 000000000..299718d32 --- /dev/null +++ b/Scripts/Services/Discovery/V1/Model/Completions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8561e0d151f674d94911334321810420 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Discovery/V1/Model/NluEnrichmentEntities.cs b/Scripts/Services/Discovery/V1/Model/NluEnrichmentEntities.cs index 7d02126e6..87862317b 100644 --- a/Scripts/Services/Discovery/V1/Model/NluEnrichmentEntities.cs +++ b/Scripts/Services/Discovery/V1/Model/NluEnrichmentEntities.cs @@ -57,7 +57,7 @@ public class NluEnrichmentEntities public bool? SentenceLocations { get; set; } /// /// The enrichement model to use with entity extraction. May be a custom model provided by Watson Knowledge - /// Studio, the public model for use with Knowledge Graph `en-news`, or the default public model `alchemy`. + /// Studio, or the default public model `alchemy`. /// [JsonProperty("model", NullValueHandling = NullValueHandling.Ignore)] public string Model { get; set; } diff --git a/Scripts/Services/Discovery/V1/Model/NluEnrichmentRelations.cs b/Scripts/Services/Discovery/V1/Model/NluEnrichmentRelations.cs index 648d96cc4..50b8a2c8a 100644 --- a/Scripts/Services/Discovery/V1/Model/NluEnrichmentRelations.cs +++ b/Scripts/Services/Discovery/V1/Model/NluEnrichmentRelations.cs @@ -26,8 +26,8 @@ public class NluEnrichmentRelations { /// /// *For use with `natural_language_understanding` enrichments only.* The enrichement model to use with - /// relationship extraction. May be a custom model provided by Watson Knowledge Studio, the public model for use - /// with Knowledge Graph `en-news`, the default is`en-news`. + /// relationship extraction. May be a custom model provided by Watson Knowledge Studio, the default public model + /// is`en-news`. /// [JsonProperty("model", NullValueHandling = NullValueHandling.Ignore)] public string Model { get; set; } diff --git a/Scripts/Services/Discovery/V1/Model/QueryFilterType.cs b/Scripts/Services/Discovery/V1/Model/QueryFilterType.cs index 22f3b1d35..eb43b7924 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryFilterType.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryFilterType.cs @@ -21,7 +21,7 @@ namespace IBM.Watson.Discovery.V1.Model { /// - /// Object containing information about excluded and included types. + /// QueryFilterType. /// public class QueryFilterType { diff --git a/Scripts/Services/Discovery/V1/Model/QueryRelationsArgument.cs b/Scripts/Services/Discovery/V1/Model/QueryRelationsArgument.cs index ac5b1bf14..7c4f968a3 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryRelationsArgument.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryRelationsArgument.cs @@ -21,7 +21,7 @@ namespace IBM.Watson.Discovery.V1.Model { /// - /// Object containing an array of query entities. + /// QueryRelationsArgument. /// public class QueryRelationsArgument { diff --git a/Scripts/Services/Discovery/V1/Model/QueryRelationsEntity.cs b/Scripts/Services/Discovery/V1/Model/QueryRelationsEntity.cs index 45e9c59ca..630375afd 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryRelationsEntity.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryRelationsEntity.cs @@ -20,7 +20,7 @@ namespace IBM.Watson.Discovery.V1.Model { /// - /// Object defining a knowledge graph relationship query entity. + /// QueryRelationsEntity. /// public class QueryRelationsEntity { diff --git a/Scripts/Services/Discovery/V1/Model/QueryRelationsFilter.cs b/Scripts/Services/Discovery/V1/Model/QueryRelationsFilter.cs index 0daf694ef..55403658b 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryRelationsFilter.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryRelationsFilter.cs @@ -21,17 +21,17 @@ namespace IBM.Watson.Discovery.V1.Model { /// - /// Object containing an array of documents to query. + /// QueryRelationsFilter. /// public class QueryRelationsFilter { /// - /// Object containing information about excluded and included types. + /// Gets or Sets RelationTypes /// [JsonProperty("relation_types", NullValueHandling = NullValueHandling.Ignore)] public QueryFilterType RelationTypes { get; set; } /// - /// Object containing information about excluded and included types. + /// Gets or Sets EntityTypes /// [JsonProperty("entity_types", NullValueHandling = NullValueHandling.Ignore)] public QueryFilterType EntityTypes { get; set; } diff --git a/Scripts/Services/Discovery/V1/Model/QueryRelationsRelationship.cs b/Scripts/Services/Discovery/V1/Model/QueryRelationsRelationship.cs index 7149ebeab..5a5d2496e 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryRelationsRelationship.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryRelationsRelationship.cs @@ -21,7 +21,7 @@ namespace IBM.Watson.Discovery.V1.Model { /// - /// Object containing knowledge graph relationship details. + /// QueryRelationsRelationship. /// public class QueryRelationsRelationship { diff --git a/Scripts/Services/Discovery/V1/Model/QueryRelationsResponse.cs b/Scripts/Services/Discovery/V1/Model/QueryRelationsResponse.cs index b6cfd92b0..c1cd46334 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryRelationsResponse.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryRelationsResponse.cs @@ -21,7 +21,7 @@ namespace IBM.Watson.Discovery.V1.Model { /// - /// Object containing an array of relationship responses. + /// QueryRelationsResponse. /// public class QueryRelationsResponse { diff --git a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs index f251f0480..14f2e1a4e 100644 --- a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs +++ b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs @@ -245,55 +245,33 @@ private void OnGetVoiceResponse(RESTConnector.Request req, RESTConnector.Respons /// The service can return audio in the following formats (MIME types). /// * Where indicated, you can optionally specify the sampling rate (`rate`) of the audio. You must specify a /// sampling rate for the `audio/l16` and `audio/mulaw` formats. A specified sampling rate must lie in the range - /// of 8 kHz to 192 kHz. + /// of 8 kHz to 192 kHz. Some formats restrict the sampling rate to certain values, as noted. /// * For the `audio/l16` format, you can optionally specify the endianness (`endianness`) of the audio: /// `endianness=big-endian` or `endianness=little-endian`. /// /// Use the `Accept` header or the `accept` parameter to specify the requested format of the response audio. If /// you omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec /// (`audio/ogg;codecs=opus`). The service always returns single-channel audio. - /// * `audio/basic` - /// - /// The service returns audio with a sampling rate of 8000 Hz. - /// * `audio/flac` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - /// * `audio/l16` - /// - /// You must specify the `rate` of the audio. You can optionally specify the `endianness` of the audio. The - /// default endianness is `little-endian`. - /// * `audio/mp3` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - /// * `audio/mpeg` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - /// * `audio/mulaw` - /// - /// You must specify the `rate` of the audio. - /// * `audio/ogg` - /// - /// The service returns the audio in the `vorbis` codec. You can optionally specify the `rate` of the audio. - /// The default sampling rate is 22,050 Hz. - /// * `audio/ogg;codecs=opus` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - /// * `audio/ogg;codecs=vorbis` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - /// * `audio/wav` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. - /// * `audio/webm` - /// - /// The service returns the audio in the `opus` codec. The service returns audio with a sampling rate of - /// 48,000 Hz. - /// * `audio/webm;codecs=opus` - /// - /// The service returns audio with a sampling rate of 48,000 Hz. - /// * `audio/webm;codecs=vorbis` - /// - /// You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. + /// * `audio/basic` - The service returns audio with a sampling rate of 8000 Hz. + /// * `audio/flac` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. + /// * `audio/l16` - You must specify the `rate` of the audio. You can optionally specify the `endianness` of the + /// audio. The default endianness is `little-endian`. + /// * `audio/mp3` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. + /// * `audio/mpeg` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. + /// * `audio/mulaw` - You must specify the `rate` of the audio. + /// * `audio/ogg` - The service returns the audio in the `vorbis` codec. You can optionally specify the `rate` + /// of the audio. The default sampling rate is 22,050 Hz. + /// * `audio/ogg;codecs=opus` - You can optionally specify the `rate` of the audio. Only the following values + /// are valid sampling rates: `48000`, `24000`, `16000`, `12000`, or `8000`. If you specify a value other than + /// one of these, the service returns an error. The default sampling rate is 48,000 Hz. + /// * `audio/ogg;codecs=vorbis` - You can optionally specify the `rate` of the audio. The default sampling rate + /// is 22,050 Hz. + /// * `audio/wav` - You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz. + /// * `audio/webm` - The service returns the audio in the `opus` codec. The service returns audio with a + /// sampling rate of 48,000 Hz. + /// * `audio/webm;codecs=opus` - The service returns audio with a sampling rate of 48,000 Hz. + /// * `audio/webm;codecs=vorbis` - You can optionally specify the `rate` of the audio. The default sampling rate + /// is 22,050 Hz. /// /// For more information about specifying an audio format, including additional details about some of the /// formats, see [Audio From 3f582d1348121dd3facac678c3ebf068696ee765 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Fri, 4 Oct 2019 08:21:42 -0400 Subject: [PATCH 7/9] feat(Discovery): add suggested query to query response --- .../Services/Discovery/V1/DiscoveryService.cs | 16 +++++++++------- .../Services/Discovery/V1/Model/QueryResponse.cs | 5 +++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Scripts/Services/Discovery/V1/DiscoveryService.cs b/Scripts/Services/Discovery/V1/DiscoveryService.cs index 8a3a61e9d..ea1650165 100644 --- a/Scripts/Services/Discovery/V1/DiscoveryService.cs +++ b/Scripts/Services/Discovery/V1/DiscoveryService.cs @@ -3274,13 +3274,13 @@ private void OnFederatedQueryNoticesResponse(RESTConnector.Request req, RESTConn /// The callback function that is invoked when the operation completes. /// The ID of the environment. /// The ID of the collection. + /// The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete + /// to `Hot`, `Housing`, or `How do I upgrade`. Possible completions are. /// The field in the result documents that autocompletion suggestions are identified from. /// (optional) - /// The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete - /// to `Hot`, `Housing`, or `How do I upgrade`. Possible completions are. (optional) /// The number of autocompletion suggestions to return. (optional) /// Completions - public bool GetAutocompletion(Callback callback, string environmentId, string collectionId, string field = null, string prefix = null, long? count = null) + public bool GetAutocompletion(Callback callback, string environmentId, string collectionId, string prefix, string field = null, long? count = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `GetAutocompletion`"); @@ -3288,6 +3288,8 @@ public bool GetAutocompletion(Callback callback, string environment throw new ArgumentNullException("`environmentId` is required for `GetAutocompletion`"); if (string.IsNullOrEmpty(collectionId)) throw new ArgumentNullException("`collectionId` is required for `GetAutocompletion`"); + if (string.IsNullOrEmpty(prefix)) + throw new ArgumentNullException("`prefix` is required for `GetAutocompletion`"); RequestObject req = new RequestObject { @@ -3309,14 +3311,14 @@ public bool GetAutocompletion(Callback callback, string environment } req.Parameters["version"] = VersionDate; - if (!string.IsNullOrEmpty(field)) - { - req.Parameters["field"] = field; - } if (!string.IsNullOrEmpty(prefix)) { req.Parameters["prefix"] = prefix; } + if (!string.IsNullOrEmpty(field)) + { + req.Parameters["field"] = field; + } if (count != null) { req.Parameters["count"] = count; diff --git a/Scripts/Services/Discovery/V1/Model/QueryResponse.cs b/Scripts/Services/Discovery/V1/Model/QueryResponse.cs index c2bd63bdb..89ca7852e 100644 --- a/Scripts/Services/Discovery/V1/Model/QueryResponse.cs +++ b/Scripts/Services/Discovery/V1/Model/QueryResponse.cs @@ -63,5 +63,10 @@ public class QueryResponse /// [JsonProperty("retrieval_details", NullValueHandling = NullValueHandling.Ignore)] public RetrievalDetails RetrievalDetails { get; set; } + /// + /// The suggestions for a misspelled natural language query. + /// + [JsonProperty("suggested_query", NullValueHandling = NullValueHandling.Ignore)] + public string SuggestedQuery { get; set; } } } From 4a86839dfd4e39a0d23e8ce9613b177027ad1ff8 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Fri, 4 Oct 2019 09:58:37 -0400 Subject: [PATCH 8/9] refactor: regenerate vis rec V4 --- .../V4/Model/BaseCollectionTrainingStatus.cs | 33 --------- .../BaseCollectionTrainingStatus.cs.meta | 11 --- .../VisualRecognition/V4/Model/BaseError.cs | 72 ------------------- .../V4/Model/BaseError.cs.meta | 11 --- Tests/DiscoveryV1IntegrationTests.cs | 64 +---------------- Tests/VisualRecognitionV4IntegrationTests.cs | 2 - 6 files changed, 1 insertion(+), 192 deletions(-) delete mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs delete mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta delete mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseError.cs delete mode 100644 Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs b/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs deleted file mode 100644 index 53a0dcc81..000000000 --- a/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs +++ /dev/null @@ -1,33 +0,0 @@ -/** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -using Newtonsoft.Json; - -namespace IBM.Watson.VisualRecognition.V4.Model -{ - /// - /// Training status information for the collection. - /// - public class BaseCollectionTrainingStatus - { - /// - /// Training status for the objects in the collection. - /// - [JsonProperty("objects", NullValueHandling = NullValueHandling.Ignore)] - public ObjectTrainingStatus Objects { get; set; } - } -} diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta deleted file mode 100644 index df8fae5fa..000000000 --- a/Scripts/Services/VisualRecognition/V4/Model/BaseCollectionTrainingStatus.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: da5527a522c184d65a2976c0ea85d59a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs b/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs deleted file mode 100644 index 553f94618..000000000 --- a/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs +++ /dev/null @@ -1,72 +0,0 @@ -/** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -using Newtonsoft.Json; - -namespace IBM.Watson.VisualRecognition.V4.Model -{ - /// - /// Details about a problem. - /// - public class BaseError - { - /// - /// Identifier of the problem. - /// - public class CodeValue - { - /// - /// Constant INVALID_FIELD for invalid_field - /// - public const string INVALID_FIELD = "invalid_field"; - /// - /// Constant INVALID_HEADER for invalid_header - /// - public const string INVALID_HEADER = "invalid_header"; - /// - /// Constant INVALID_METHOD for invalid_method - /// - public const string INVALID_METHOD = "invalid_method"; - /// - /// Constant MISSING_FIELD for missing_field - /// - public const string MISSING_FIELD = "missing_field"; - /// - /// Constant SERVER_ERROR for server_error - /// - public const string SERVER_ERROR = "server_error"; - - } - - /// - /// Identifier of the problem. - /// Constants for possible values can be found using BaseError.CodeValue - /// - [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] - public string Code { get; set; } - /// - /// An explanation of the problem with possible solutions. - /// - [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] - public string Message { get; set; } - /// - /// A URL for more information about the solution. - /// - [JsonProperty("more_info", NullValueHandling = NullValueHandling.Ignore)] - public string MoreInfo { get; set; } - } -} diff --git a/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta b/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta deleted file mode 100644 index b0eac6cce..000000000 --- a/Scripts/Services/VisualRecognition/V4/Model/BaseError.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1ea09601c4e204605806872dc06a963b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Tests/DiscoveryV1IntegrationTests.cs b/Tests/DiscoveryV1IntegrationTests.cs index 8d6c9f5d2..8cc74b31d 100644 --- a/Tests/DiscoveryV1IntegrationTests.cs +++ b/Tests/DiscoveryV1IntegrationTests.cs @@ -850,6 +850,7 @@ public IEnumerator TestFederatedQuery() Assert.IsNull(error); }, environmentId: environmentId, + collectionIds: collectionId, naturalLanguageQuery: "When did Watson win Jeopardy", passages: true, count: 10, @@ -916,37 +917,6 @@ public IEnumerator TestQuery() } #endregion - #region QueryEntities - //[UnityTest, Order(28)] - public IEnumerator TestQueryEntities() - { - Log.Debug("DiscoveryServiceV1IntegrationTests", "Attempting to QueryEntities..."); - QueryEntitiesResponse queryEntitiesResponse = null; - QueryEntitiesEntity entity = new QueryEntitiesEntity() - { - Text = "Jeopardy" - }; - - service.QueryEntities( - callback: (DetailedResponse response, IBMError error) => - { - Log.Debug("DiscoveryServiceV1IntegrationTests", "QueryEntities result: {0}", response.Response); - queryEntitiesResponse = response.Result; - Assert.IsNotNull(queryEntitiesResponse); - Assert.IsNull(error); - }, - environmentId: environmentId, - collectionId: collectionId, - entity: entity, - feature: "disambiguate", - count: 10 - ); - - while (queryEntitiesResponse == null) - yield return null; - } - #endregion - #region QueryNotices [UnityTest, Order(29)] public IEnumerator TestQueryNotices() @@ -974,38 +944,6 @@ public IEnumerator TestQueryNotices() } #endregion - #region QueryRelations - //[UnityTest, Order(30)] - public IEnumerator TestQueryRelations() - { - Log.Debug("DiscoveryServiceV1IntegrationTests", "Attempting to QueryRelations..."); - QueryRelationsResponse queryRelationsResponse = null; - List entities = new List() - { - new QueryRelationsEntity() - { - Text = "Jeopardy" - } - }; - service.QueryRelations( - callback: (DetailedResponse response, IBMError error) => - { - Log.Debug("DiscoveryServiceV1IntegrationTests", "QueryRelations result: {0}", response.Response); - queryRelationsResponse = response.Result; - Assert.IsNotNull(queryRelationsResponse); - Assert.IsNull(error); - }, - environmentId: environmentId, - collectionId: collectionId, - entities: entities, - count: 10 - ); - - while (queryRelationsResponse == null) - yield return null; - } - #endregion - #region AddTrainingData [UnityTest, Order(31)] public IEnumerator TestAddTrainingData() diff --git a/Tests/VisualRecognitionV4IntegrationTests.cs b/Tests/VisualRecognitionV4IntegrationTests.cs index 6b1960fc7..a9f46f619 100644 --- a/Tests/VisualRecognitionV4IntegrationTests.cs +++ b/Tests/VisualRecognitionV4IntegrationTests.cs @@ -39,9 +39,7 @@ public class VisualRecognitionV4IntegrationTests private string negativeExamplesFilepath; private string giraffeImageFilepath; private string turtleImageFilepath; - private string turtleImageContentType = "image/jpeg"; private string imageMetadataFilepath; - private string classifierName = "unity-sdk-classifier-safe-to-delete"; private string giraffeCollectionId = "d31d6534-3458-40c4-b6de-2185a5f3cbe4"; private string giraffeClassname = "giraffe"; private string turtleCollectionId = "760c8625-a456-4b73-b71d-d1619a6daf84"; From 7c1458fc71dc2c817e1c3bc4a1b1d896312ca9d2 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Fri, 4 Oct 2019 09:59:15 -0400 Subject: [PATCH 9/9] docs: add migration guide for vis rec 4.0.0 --- MIGRATION-v4.md | 230 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 MIGRATION-v4.md diff --git a/MIGRATION-v4.md b/MIGRATION-v4.md new file mode 100644 index 000000000..709ba9528 --- /dev/null +++ b/MIGRATION-v4.md @@ -0,0 +1,230 @@ +### Unity SDK V4 Migration guide + +#### Authentication + +##### v3.x.x + +Previously different `Config` objects were used for authentication. + +```cs +void Example() +{ + TokenOptions iamTokenOptions = new TokenOptions( + Apikey: "{iam-apikey}" + ); + service = new AssistantService("{versionDate}", iamTokenOptions); + service.SetEndpoint("{service-endpoint}"); +} +``` + +Or constructors accepted `TokenOptions` or `username` and `password`. + +```cs +void Example() +{ + service = new AssistantService("{tokenOptions}", "{versionDate}"); + service2 = new DiscoveryService("{username}", "{password}", "{versionDate}"); +} +``` + +##### v4.x.x + +Now we use an `Authenticator` to authenticate the service. Available authentication schemes include `IamAuthenticator`, `BasicAuthenticator`, `CloudPakForDataAuthenticator` and `BearerTokenAuthenticator` + +###### IamAuthenticator + +```cs +void Example() +{ + IamAuthenticator authenticator = new IamAuthenticator( + apikey: "{apikey}" + ); + var service = new AssistantService("{versionDate}", authenticator); + service.SetServiceUrl("{serviceUrl}"); +} +``` + +##### BasicAuthenticator + +```cs +void Example() +{ + BasicAuthenticator authenticator = new BasicAuthenticator( + username: "{username}", + password: "{password}" + ); + var service = new AssistantService("{versionDate}", authenticator); + service.SetServiceUrl("{serviceUrl}"); +} +``` + +###### BearerTokenAuthenticator + +```cs +void Example() +{ + BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator( + bearerToken: "{bearerToken}" + ); + var service = new AssistantService("{versionDate}", authenticator); + service.SetServiceUrl("{serviceUrl}"); +} +``` + +###### CloudPakForDataAuthenticator + +```cs +void Example() +{ + CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator( + url: "https://{cp4d_cluster_host}{:port}", + username: "{username}", + password: "{password}" + ); + var service = new AssistantService("{version-date}", authenticator); + service.SetServiceUrl("{serviceUrl}"); + var results = service.Message("{workspace-id}", "{message-request}"); +} +``` + +Constructors that did not take an `Authenticator` were removed. + +#### Supplying credentials + +You can supply credentials to your service using external `ibm-credentials.env` files. + +```cs +AssistantService service = new AssistantService("{version-date}"); +var listWorkspacesResult = service.ListWorkspaces(); +``` + +##### v3.x.x + +Previously we would look for these files first in the system `home` directory, followed by the current project directory. + +##### v4.x.x +Now in order to allow developers to have different configurations for each project we look first in the current project directory, followed by the home directory. + +#### Setting the service url + +##### v3.x.x + +Previously we set the service url via SetEndpoint() method. + +```cs +void Example() +{ + TokenOptions iamTokenOptions = new TokenOptions( + apikey: "{iam-apikey}" + ); + service = new AssistantService("{versionDate}", iamTokenOptions); + service.SetEndpoint("{service-endpoint}"); +} +``` + +##### v4.x.x + +Now we set the service url via the SetServiceUrl() method. + +```cs +void Example() +{ + IamAuthenticator authenticator = new IamAuthenticator( + apikey: "{apikey}" + ); + var service = new AssistantService("{versionDate}", authenticator); + service.SetServiceUrl("{serviceUrl}"); +} +``` + +#### Service changes + +##### Assistant v1 + +* `includeCount` is no longer a parameter of the `ListWorkspaces()` method +* `includeCount` is no longer a parameter of the `ListIntents()` method +* `includeCount` is no longer a parameter of the `ListExamples()` method +* `includeCount` is no longer a parameter of the `ListCounterexamples()` method +* `includeCount` is no longer a parameter of the `ListEntities()` method +* `includeCount` is no longer a parameter of the `ListValues()` method +* `includeCount` is no longer a parameter of the `ListSynonyms()` method +* `includeCount` is no longer a parameter of the `ListDialogNodes()` method +* `valueType` was renamed to `type` in the `CreateValue()` method +* `newValueType` was renamed to `newType` in the `UpdateValue()` method +* `nodeType` was renamed to `type` in the `CreateDialogNode()` method +* `nodeType` was renamed to `type` in the `CreateDialogNode()` method +* `newNodeType` was renamed to `newType` in the `UpdateDialogNode()` method +* `ValueTypeEnumValue` was renamed to `TypeEnumValue` in the `CreateValue` model +* `ValueType` was renamed to `Type` in the `CreateValue` model +* `NodeTypeEnumValue` was renamed to `TypeEnumValue` in the `DialogNode` model +* `NodeType` was renamed to `Type` in the `DialogNode` model +* `ActionTypeEnumValue` was renamed to `TypeEnumValue` in the `DialogNodeAction` model +* `ActionType` was renamed to `Type` in the `DialogNodeAction` model +* `SEARCH_SKILL` constant was added to the `DialogNodeOutputGeneric` model +* `QueryTypeEnumValue` constants were added to the `DialogNodeOutputGeneric` model +* `QueryType` property was added to the `DialogNodeOutputGeneric` model +* `Query` property was added to the `DialogNodeOutputGeneric` model +* `Filter` property was added to the `DialogNodeOutputGeneric` model +* `DiscoveryVersion` property was added to the `DialogNodeOutputGeneric` model +* `Output` property type was converted from `Dictionary` to `DialogSuggestionOutput` in the `DialogSuggestion` model +* `LogMessage` model no longer has `additionalProperties` +* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric` +* `RuntimeEntity` model no longer has `additionalProperties` +* `RuntimeIntent` model no longer has `additionalProperties` +* `ValueTypeEnumValue` was renamed to `TypeEnumValue` in the `Value` model +* `ValueType` was renamed to `Type` in the `Value` model + +##### Assistant v2 + +* `ActionTypeEnumValue` was renamed to `TypeEnumValue` in the `DialogNodeAction` model +* `ActionType` was renamed to `Type` in the `DialogNodeAction` model +* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric` + +##### Compare Comply v1 + +* `ConvertToHtml()` method does not require a `filename` parameter + +##### Discovery v1 + +* `returnFields` was renamed to `_return` in the `Query()` method +* `loggingOptOut` was renamed to `xWatsonLoggingOptOut` in the `Query()` method +* `spellingSuggestions` was added to the `Query()` method +* `collectionIds` is no longer a parameter of the `Query()` method +* `returnFields` was renamed to `_return` in the `QueryNotices()` method +* `loggingOptOut` was renamed to `xWatsonLoggingOptOut` in the `FederatedQuery()` method +* `collectionIds` is now required in the `FederatedQuery()` method +* `collectionIds` changed position in the `FederatedQuery()` method +* `returnFields` was renamed to `_return` in the `FederatedQuery()` method +* `returnFields` was renamed to `_return` in the `FederatedQueryNotices()` method +* `EnrichmentName` was renamed to `_Enrichment` in the `Enrichment` model +* `FieldTypeEnumValue` was renamed to `TypeEnumValue` in the `Field` model +* `FieldType` was renamed to `Type` in the `Field` model +* `FieldName` was renamed to `_Field` in the `Field` model +* `TestConfigurationInEnvironment()` method was removed +* `QueryEntities()` method was removed +* `QueryRelations()` method was removed + +##### Language Translator v3 + +* `defaultModels` was renamed to `_default` in the `ListModels()` method +* `TranslationOutput` was renamed to `_Translation` in the `Translation` model + +##### Natural Language Classifier v1 + +* `metadata` was renamed to `trainingMetadata` in the `CreateClassifier()` method + +##### Speech to Text v1 + +* `strict` is no longer a parameter of the `TrainAcousticModel()` method +* `FinalResults` was renamed to `Final` in the `SpeakerLabelsResult` model +* `FinalResults` was renamed to `Final` in the `SpeechRecognitionResult` model + +##### Visual Recognition v3 + +* `DetectFaces()` method was removed +* `ClassName` was renamed to `_Class` in the `ClassResult` model +* `ClassName` was renamed to `_Class` in the `ModelClass` model + +##### Visual Recognition v4 + +* New service! \ No newline at end of file