diff --git a/Core/src/ServiceBuilder.php b/Core/src/ServiceBuilder.php
index 9a5ac3f4f822..02293402e442 100644
--- a/Core/src/ServiceBuilder.php
+++ b/Core/src/ServiceBuilder.php
@@ -30,7 +30,8 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Trace\TraceClient;
use Google\Cloud\Translate\V2\TranslateClient;
-use Google\Cloud\Vision\VisionClient;
+use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;
+use Google\Cloud\Vision\VisionClient as DeprecatedVisionClient;
use Psr\Cache\CacheItemPoolInterface;
/**
@@ -336,23 +337,19 @@ public function trace(array $config = [])
}
/**
- * Google Cloud Vision allows you to understand the content of an image,
- * classify images into categories, detect text, objects, faces and more.
- * Find more information at the
- * [Google Cloud Vision docs](https://cloud.google.com/vision/docs/).
- *
- * Example:
- * ```
- * $vision = $cloud->vision();
- * ```
- *
- * @param array $config [optional] Configuration options. See
- * {@see \Google\Cloud\Core\ServiceBuilder::__construct()} for the available options.
- * @return VisionClient
+ * @deprecated
+ * @see ImageAnnotatorClient
+ * @throws \BadMethodCallException
*/
public function vision(array $config = [])
{
- return $this->createClient(VisionClient::class, 'vision', $config);
+ if (class_exists(DeprecatedVisionClient::class)) {
+ return $this->createClient(DeprecatedVisionClient::class, 'vision', $config);
+ }
+ throw new \BadMethodCallException(sprintf(
+ 'This method is no longer supported, create %s directly instead.',
+ ImageAnnotatorClient::class
+ ));
}
/**
diff --git a/Core/tests/Snippet/ServiceBuilderTest.php b/Core/tests/Snippet/ServiceBuilderTest.php
index d6746317c5d3..bb28fbc5363e 100644
--- a/Core/tests/Snippet/ServiceBuilderTest.php
+++ b/Core/tests/Snippet/ServiceBuilderTest.php
@@ -30,7 +30,6 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Trace\TraceClient;
use Google\Cloud\Translate\TranslateClient;
-use Google\Cloud\Vision\VisionClient;
/**
* @group root
@@ -63,7 +62,6 @@ public function serviceBuilderMethods()
['speech', SpeechClient::class, 'speech'],
['storage', StorageClient::class, 'storage'],
['trace', TraceClient::class, 'trace'],
- ['vision', VisionClient::class, 'vision'],
['translate', TranslateClient::class, 'translate']
];
}
diff --git a/Core/tests/Unit/ServiceBuilderTest.php b/Core/tests/Unit/ServiceBuilderTest.php
index 3667628bb299..e5d06ce7deb9 100644
--- a/Core/tests/Unit/ServiceBuilderTest.php
+++ b/Core/tests/Unit/ServiceBuilderTest.php
@@ -29,7 +29,6 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Core\Tests\Unit\Fixtures;
use Google\Cloud\Translate\TranslateClient;
-use Google\Cloud\Vision\VisionClient;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
@@ -190,9 +189,6 @@ public function serviceProvider()
], [
'translate',
TranslateClient::class
- ], [
- 'vision',
- VisionClient::class
]
];
}
diff --git a/Core/tests/Unit/ServicesNotFoundTest.php b/Core/tests/Unit/ServicesNotFoundTest.php
index c4201bf0f703..a54c5af8622b 100644
--- a/Core/tests/Unit/ServicesNotFoundTest.php
+++ b/Core/tests/Unit/ServicesNotFoundTest.php
@@ -76,7 +76,6 @@ private static function getApis()
"Trace",
"Translate",
"VideoIntelligence",
- "Vision",
];
}
@@ -92,7 +91,6 @@ public function serviceBuilderMethods()
['speech'],
['storage'],
['trace'],
- ['vision'],
['translate']
];
}
diff --git a/Vision/.OwlBot.yaml b/Vision/.OwlBot.yaml
index 3a3929a467d7..7cef9f87def8 100644
--- a/Vision/.OwlBot.yaml
+++ b/Vision/.OwlBot.yaml
@@ -1,4 +1,4 @@
deep-copy-regex:
- - source: /google/cloud/vision/v1/.*-php/(.*)
- dest: /owl-bot-staging/Vision/V1/$1
+ - source: /google/cloud/vision/(v1)/.*-php/(.*)
+ dest: /owl-bot-staging/Vision/$1/$2
api-name: Vision
diff --git a/Vision/owlbot.py b/Vision/owlbot.py
index 0f4d799b284b..ef3410081634 100644
--- a/Vision/owlbot.py
+++ b/Vision/owlbot.py
@@ -1,4 +1,4 @@
-# Copyright 2018 Google LLC
+# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,8 +16,9 @@
import logging
from pathlib import Path
-import synthtool as s
import subprocess
+
+import synthtool as s
from synthtool.languages import php
from synthtool import _tracked_paths
@@ -29,65 +30,27 @@
# Added so that we can pass copy_excludes in the owlbot_main() call
_tracked_paths.add(src)
-# Exclude partial veneer files.
-php.owlbot_main(
- src=src,
- dest=dest,
- copy_excludes=[
- src / "*/src/V1/ProductSearchClient.php",
- src / "*/src/V1/ImageAnnotatorClient.php",
- ]
-)
-
-# Change the wording for the deprecation warning.
-s.replace(
- 'src/*/*_*.php',
- r'will be removed in the next major release',
- 'will be removed in a future release')
-
-### [START] protect vision backwards compatibility
-
-# format generated clients
-subprocess.run([
- 'git',
- 'apply',
- '.owlbot/safesearchannotation.patch'])
-
-### [START] protoc backwards compatibility fixes
-
-# roll back to private properties.
-s.replace(
- "src/**/V*/**/*.php",
- r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$",
- r"""Generated from protobuf field \1
- */
- private $""")
-
-# Replace "Unwrapped" with "Value" for method names.
-s.replace(
- "src/**/V*/**/*.php",
- r"public function ([s|g]\w{3,})Unwrapped",
- r"public function \1Value"
-)
-
-### [END] protoc backwards compatibility fixes
+php.owlbot_main(src=src, dest=dest)
-# fix relative cloud.google.com links
+# remove class_alias code
s.replace(
- "src/**/V*/**/*.php",
- r"(.{0,})\]\((/.{0,})\)",
- r"\1](https://cloud.google.com\2)"
-)
+ "src/V*/**/*.php",
+ r"^// Adding a class alias for backwards compatibility with the previous class name.$"
+ + "\n"
+ + r"^class_alias\(.*\);$"
+ + "\n",
+ '')
# format generated clients
subprocess.run([
- 'npx',
- '-y',
- '-p',
- '@prettier/plugin-php@^0.16',
+ 'npm',
+ 'exec',
+ '--yes',
+ '--package=@prettier/plugin-php@^0.16',
+ '--',
'prettier',
- '**/Gapic/*',
+ '**/Client/*',
'--write',
'--parser=php',
'--single-quote',
- '--print-width=80'])
+ '--print-width=120'])
diff --git a/Vision/phpunit-snippets.xml.dist b/Vision/phpunit-snippets.xml.dist
deleted file mode 100644
index 319673b50fe0..000000000000
--- a/Vision/phpunit-snippets.xml.dist
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
- src
-
-
- src/V[!a-zA-Z]*
-
-
-
-
- tests/Snippet
-
-
-
diff --git a/Vision/src/Annotation.php b/Vision/src/Annotation.php
deleted file mode 100644
index 10f6aa47b1ad..000000000000
--- a/Vision/src/Annotation.php
+++ /dev/null
@@ -1,406 +0,0 @@
-image($imageResource, [
- * 'FACE_DETECTION'
- * ]);
- *
- * $annotation = $vision->annotate($image);
- * ```
- *
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Annotation
-{
- /**
- * @var array
- */
- private $info;
-
- /**
- * @var Face[]|null
- */
- private $faces;
-
- /**
- * @var Entity[]|null
- */
- private $landmarks;
-
- /**
- * @var Entity[]|null
- */
- private $logos;
-
- /**
- * @var Entity[]|null
- */
- private $labels;
-
- /**
- * @var Entity[]|null
- */
- private $text;
-
- /**
- * @var Document|null
- */
- private $fullText;
-
- /**
- * @var SafeSearch|null
- */
- private $safeSearch;
-
- /**
- * @var ImageProperties|null
- */
- private $imageProperties;
-
- /**
- * @var CropHint[]|null
- */
- private $cropHints;
-
- /**
- * @var Web|null
- */
- private $web;
-
- /**
- * @var array|null
- */
- private $error;
-
- /**
- * Create an annotation result.
- *
- * This class represents a single image annotation response from Cloud Vision. If multiple images were tested at
- * once, the result will be an array of Annotation instances.
- *
- * This class is not intended to be instantiated outside the Google Cloud Platform Client Library.
- *
- * @param array $info The annotation result
- */
- public function __construct($info)
- {
- $this->info = $info;
-
- if (isset($info['faceAnnotations'])) {
- $this->faces = [];
-
- foreach ($info['faceAnnotations'] as $face) {
- $this->faces[] = new Face($face);
- }
- }
-
- if (isset($info['landmarkAnnotations'])) {
- $this->landmarks = [];
-
- foreach ($info['landmarkAnnotations'] as $landmark) {
- $this->landmarks[] = new Entity($landmark);
- }
- }
-
- if (isset($info['logoAnnotations'])) {
- $this->logos = [];
-
- foreach ($info['logoAnnotations'] as $logo) {
- $this->logos[] = new Entity($logo);
- }
- }
-
- if (isset($info['labelAnnotations'])) {
- $this->labels = [];
-
- foreach ($info['labelAnnotations'] as $label) {
- $this->labels[] = new Entity($label);
- }
- }
-
- if (isset($info['textAnnotations'])) {
- $this->text = [];
-
- foreach ($info['textAnnotations'] as $text) {
- $this->text[] = new Entity($text);
- }
- }
-
- if (isset($info['fullTextAnnotation'])) {
- $this->fullText = new Document($info['fullTextAnnotation']);
- }
-
- if (isset($info['safeSearchAnnotation'])) {
- $this->safeSearch = new SafeSearch($info['safeSearchAnnotation']);
- }
-
- if (isset($info['imagePropertiesAnnotation'])) {
- $this->imageProperties = new ImageProperties($info['imagePropertiesAnnotation']);
- }
-
- if (isset($info['cropHintsAnnotation']) && is_array($info['cropHintsAnnotation']['cropHints'])) {
- $this->cropHints = [];
- foreach ($info['cropHintsAnnotation']['cropHints'] as $hint) {
- $this->cropHints[] = new CropHint($hint);
- }
- }
-
- if (isset($info['webDetection'])) {
- $this->web = new Web($info['webDetection']);
- }
-
- if (isset($info['error'])) {
- $this->error = $info['error'];
- }
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Return raw annotation response array
- *
- * Example:
- * ```
- * $info = $annotation->info();
- * ```
- *
- * @codingStandardsIgnoreStart
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#annotateimageresponse AnnotateImageResponse
- * @codingStandardsIgnoreEnd
- *
- * @return array|null
- */
- public function info()
- {
- return $this->info;
- }
-
- /**
- * Return an array of faces
- *
- * Example:
- * ```
- * $faces = $annotation->faces();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#FaceAnnotation FaceAnnotation
- *
- * @return Face[]|null
- */
- public function faces()
- {
- return $this->faces;
- }
-
- /**
- * Return an array of landmarks
- *
- * Example:
- * ```
- * $landmarks = $annotation->landmarks();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#EntityAnnotation EntityAnnotation
- *
- * @return Entity[]|null
- */
- public function landmarks()
- {
- return $this->landmarks;
- }
-
- /**
- * Return an array of logos
- *
- * Example:
- * ```
- * $logos = $annotation->logos();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#EntityAnnotation EntityAnnotation
- *
- * @return Entity[]|null
- */
- public function logos()
- {
- return $this->logos;
- }
-
- /**
- * Return an array of labels
- *
- * Example:
- * ```
- * $labels = $annotation->labels();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#EntityAnnotation EntityAnnotation
- *
- * @return Entity[]|null
- */
- public function labels()
- {
- return $this->labels;
- }
-
- /**
- * Return an array containing all text found in the image
- *
- * Example:
- * ```
- * $text = $annotation->text();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#EntityAnnotation EntityAnnotation
- *
- * @return Entity[]|null
- */
- public function text()
- {
- return $this->text;
- }
-
- /**
- * Return the full text annotation.
- *
- * Example:
- * ```
- * $fullText = $annotation->fullText();
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#fulltextannotation FullTextAnnotation
- *
- * @return Document|null
- */
- public function fullText()
- {
- return $this->fullText;
- }
-
- /**
- * Get the result of a safe search detection
- *
- * Example:
- * ```
- * $safeSearch = $annotation->safeSearch();
- * ```
- *
- * @codingStandardsIgnoreStart
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#SafeSearchAnnotation SafeSearchAnnotation
- * @codingStandardsIgnoreEnd
- *
- * @return SafeSearch|null
- */
- public function safeSearch()
- {
- return $this->safeSearch;
- }
-
- /**
- * Fetch image properties
- *
- * Example:
- * ```
- * $properties = $annotation->imageProperties();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#ImageProperties ImageProperties
- *
- * @return ImageProperties|null
- */
- public function imageProperties()
- {
- return $this->imageProperties;
- }
-
- /**
- * Fetch Crop Hints
- *
- * Example:
- * ```
- * $hints = $annotation->cropHints();
- * ```
- *
- * @codingStandardsIgnoreStart
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#CropHintsAnnotation CropHintsAnnotation
- * @codingStandardsIgnoreEnd
- *
- * @return CropHint[]|null
- */
- public function cropHints()
- {
- return $this->cropHints;
- }
-
- /**
- * Fetch the Web Annotatation.
- *
- * Example:
- * ```
- * $web = $annotation->web();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#WebDetection WebDetection
- *
- * @return Web|null
- */
- public function web()
- {
- return $this->web;
- }
-
- /**
- * Get error information, if present
- *
- * Example:
- * ```
- * $error = $annotation->error();
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#status Status Format
- *
- * @return array|null
- */
- public function error()
- {
- return $this->error;
- }
-}
diff --git a/Vision/src/Annotation/AbstractFeature.php b/Vision/src/Annotation/AbstractFeature.php
deleted file mode 100644
index 4e79bc63af02..000000000000
--- a/Vision/src/Annotation/AbstractFeature.php
+++ /dev/null
@@ -1,47 +0,0 @@
-info();
- * ```
- *
- * @return array
- * @access private
- */
- public function info()
- {
- return $this->info;
- }
-}
diff --git a/Vision/src/Annotation/CropHint.php b/Vision/src/Annotation/CropHint.php
deleted file mode 100644
index 161a7af1d27f..000000000000
--- a/Vision/src/Annotation/CropHint.php
+++ /dev/null
@@ -1,90 +0,0 @@
-image($imageResource, [ 'CROP_HINTS' ]);
- * $annotation = $vision->annotate($image);
- *
- * $hints = $annotation->cropHints();
- * $hint = $hints[0];
- * ```
- *
- * @method boundingPoly() {
- * The bounding polygon of the recommended crop.
- *
- * Example:
- * ```
- * $poly = $hint->boundingPoly();
- * ```
- *
- * @return array [BoundingPoly](https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#boundingpoly)
- * }
- * @method confidence() {
- * Confidence of this being a salient region. Range [0, 1].
- *
- * Example:
- * ```
- * $confidence = $hint->confidence();
- * ```
- *
- * @return float
- * }
- * @method importanceFraction() {
- * Fraction of importance of this salient region with respect to the
- * original image.
- *
- * Example:
- * ```
- * $importance = $hint->importanceFraction();
- * ```
- *
- * @return float
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#CropHint CropHint
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class CropHint extends AbstractFeature
-{
- use CallTrait;
-
- /**
- * @param array $info Crop Hint result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-}
diff --git a/Vision/src/Annotation/Document.php b/Vision/src/Annotation/Document.php
deleted file mode 100644
index 7090ab30a1ec..000000000000
--- a/Vision/src/Annotation/Document.php
+++ /dev/null
@@ -1,88 +0,0 @@
-image($imageResource, [ 'DOCUMENT_TEXT_DETECTION' ]);
- * $annotation = $vision->annotate($image);
- *
- * $document = $annotation->fullText();
- * ```
- *
- * @method pages() {
- * Get the document pages.
- *
- * Example:
- * ```
- * $pages = $document->pages();
- * ```
- *
- * @return array
- * }
- * @method text() {
- * Get the document text.
- *
- * Example:
- * ```
- * $text = $document->text();
- * ```
- *
- * @return string
- * }
- * @method info() {
- * Get the Document Text detection result.
- *
- * Example:
- * ```
- * $info = $document->info();
- * ```
- *
- * @return array
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#TextAnnotation TextAnnotation
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Document extends AbstractFeature
-{
- use CallTrait;
-
- /**
- * @param array $info Document Text Annotation response.
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-}
diff --git a/Vision/src/Annotation/Entity.php b/Vision/src/Annotation/Entity.php
deleted file mode 100644
index 879504068bd0..000000000000
--- a/Vision/src/Annotation/Entity.php
+++ /dev/null
@@ -1,204 +0,0 @@
-image($imageResource, [ 'text' ]);
- * $annotation = $vision->annotate($image);
- *
- * $text = $annotation->text()[0];
- * ```
- *
- * @method mid() {
- * Opaque entity ID.
- *
- * Some IDs might be available in Knowledge Graph(KG).
- *
- * Example:
- * ```
- * echo $text->mid();
- * ```
- *
- * @see https://developers.google.com/knowledge-graph/ Knowledge Graph
- *
- * @return string
- * }
- * @method locale() {
- * The language code for the locale in which the entity textual description
- * (next field) is expressed.
- *
- * Example:
- * ```
- * echo $text->locale();
- * ```
- *
- * @return string
- * }
- * @method description() {
- * Entity textual description, expressed in its locale language.
- *
- * Example:
- * ```
- * echo $text->description();
- * ```
- *
- * @return string
- * }
- * @method score() {
- * Overall score of the result.
- *
- * Range [0, 1].
- *
- * Example:
- * ```
- * echo $text->score();
- * ```
- *
- * @return float
- * }
- * @method confidence() {
- * The accuracy of the entity detection in an image.
- *
- * For example, for an image containing 'Eiffel Tower,' this field
- * represents the confidence that there is a tower in the query image.
- *
- * Range [0, 1].
- *
- * Example:
- * ```
- * echo $text->confidence();
- * ```
- *
- * @return float
- * }
- * @method topicality() {
- * The relevancy of the ICA (Image Content Annotation) label to the image.
- *
- * For example, the relevancy of 'tower' to an image containing
- * 'Eiffel Tower' is likely higher than an image containing a distant
- * towering building, though the confidence that there is a tower may be the
- * same.
- *
- * Range [0, 1].
- *
- * Example:
- * ```
- * echo $text->topicality();
- * ```
- *
- * @return float
- * }
- * @method boundingPoly() {
- * Image region to which this entity belongs.
- *
- * Not filled currently for LABEL_DETECTION features. For TEXT_DETECTION
- * (OCR), boundingPolys are produced for the entire text detected in an
- * image region, followed by boundingPolys for each word within the detected
- * text.
- *
- * Example:
- * ```
- * print_r($text->boundingPoly());
- * ```
- *
- * @return array
- * }
- * @method locations() {
- * The location information for the detected entity.
- *
- * Multiple LocationInfo elements can be present since one location may
- * indicate the location of the scene in the query image, and another the
- * location of the place where the query image was taken. Location
- * information is usually present for landmarks.
- *
- * Example:
- * ```
- * print_r($text->locations());
- * ```
- *
- * @return array
- * }
- * @method properties() {
- * Some entities can have additional optional Property fields. For example a
- * different kind of score or string that qualifies the entity.
- *
- * Example:
- * ```
- * print_r($text->properties());
- * ```
- *
- * @return array
- * }
- * @method info() {
- * Get the raw annotation result
- *
- * Example:
- * ```
- * $info = $text->info();
- * ```
- *
- * @return array
- * }
- *
- * @codingStandardsIgnoreStart
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#entityannotation EntityAnnotation
- * @codingStandardsIgnoreEnd
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Entity extends AbstractFeature
-{
- use CallTrait;
-
- /**
- * Create an entity annotation result.
- *
- * This class is created internally by {@see Annotation} and is used to represent various
- * annotation feature results.
- *
- * This class should not be instantiated externally.
- *
- * Entities are returned by {@see Annotation::landmarks()},
- * {@see Annotation::logos()},
- * {@see Annotation::labels()} and
- * {@see Annotation::text()}.
- *
- * @param array $info The entity annotation result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-}
diff --git a/Vision/src/Annotation/Face.php b/Vision/src/Annotation/Face.php
deleted file mode 100644
index f0008eda2f40..000000000000
--- a/Vision/src/Annotation/Face.php
+++ /dev/null
@@ -1,402 +0,0 @@
-image($imageResource, [ 'FACE_DETECTION' ]);
- * $annotation = $vision->annotate($image);
- *
- * $faces = $annotation->faces();
- * $face = $faces[0];
- * ```
- *
- * @method boundingPoly() {
- * The bounding polygon around the face.
- *
- * Example:
- * ```
- * print_r($face->boundingPoly());
- * ```
- *
- * @return array
- * }
- * @method fdBoundingPoly() {
- * Bounding polygon around the face.
- *
- * Tighter than `boundingPoly` and encloses only the skin part of the face.
- *
- * Example:
- * ```
- * print_r($face->fdBoundingPoly());
- * ```
- *
- * @return array
- * }
- * @method rollAngle() {
- * Roll angle.
- *
- * Indicates the amount of clockwise/anti-clockwise rotation of the face.
- * Range [-180,180]
- *
- * Example:
- * ```
- * print_r($face->rollAngle());
- * ```
- *
- * @return float
- * }
- * @method panAngle() {
- * Yaw angle.
- *
- * Indicates the leftward/rightward angle that the face is pointing. Range
- * [-180,180]
- *
- * Example:
- * ```
- * print_r($face->panAngle());
- * ```
- *
- * @return float
- * }
- * @method tiltAngle() {
- * Pitch angle.
- *
- * Indicates the upwards/downwards angle that the face is pointing. Range
- * [-180,180]
- *
- * Example:
- * ```
- * print_r($face->tiltAngle());
- * ```
- *
- * @return float
- * }
- * @method detectionConfidence() {
- * The detection confidence.
- *
- * Range [0,1]
- *
- * Example:
- * ```
- * print_r($face->detectionConfidence());
- * ```
- *
- * @return float
- * }
- * @method landmarkingConfidence() {
- * Face landmarking confidence.
- *
- * Range [0,1]
- *
- * Example:
- * ```
- * print_r($face->landmarkingConfidence());
- * ```
- *
- * @return float
- * }
- * @method joyLikelihood() {
- * Joy likelihood.
- *
- * Example:
- * ```
- * echo $face->joyLikelihood();
- * ```
- *
- * @return string
- * }
- * @method sorrowLikelihood() {
- * Sorrow likelihood.
- *
- * Example:
- * ```
- * echo $face->sorrowLikelihood();
- * ```
- *
- * @return string
- * }
- * @method angerLikelihood() {
- * Anger likelihood.
- *
- * Example:
- * ```
- * echo $face->angerLikelihood();
- * ```
- *
- * @return string
- * }
- * @method surpriseLikelihood() {
- * Surprise likelihood.
- *
- * Example:
- * ```
- * echo $face->surpriseLikelihood();
- * ```
- *
- * @return string
- * }
- * @method underExposedLikelihood() {
- * Under exposure likelihood.
- *
- * Example:
- * ```
- * echo $face->underExposedLikelihood();
- * ```
- *
- * @return string
- * }
- * @method blurredLikelihood() {
- * Blurred likelihood.
- *
- * Example:
- * ```
- * echo $face->blurredLikelihood();
- * ```
- *
- * @return string
- * }
- * @method headwearLikelihood() {
- * Headwear likelihood.
- *
- * Example:
- * ```
- * echo $face->headwearLikelihood();
- * ```
- *
- * @return string
- * }
- * @method info() {
- * Get the raw annotation result
- *
- * Example:
- * ```
- * $info = $face->info();
- * ```
- *
- * @return array
- * }
- *
- * @codingStandardsIgnoreStart
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#faceannotation FaceAnnotation
- * @codingStandardsIgnoreEnd
- *
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Face extends AbstractFeature
-{
- use CallTrait;
- use LikelihoodTrait;
-
- /**
- * @var Landmarks
- */
- private $landmarks;
-
- /**
- * Create an Face result.
- *
- * This class is created internally by {@see Annotation}.
- * See {@see Annotation::faces()} for full usage details.
- * This class should not be instantiated outside the externally.
- *
- * @param array $info The face annotation result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
- $this->landmarks = new Landmarks($info['landmarks']);
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Returns an object detailing facial landmarks and their location.
- *
- * Example:
- * ```
- * $leftEye = $face->landmarks()->leftEye();
- * ```
- * @return Landmarks
- */
- public function landmarks()
- {
- return $this->landmarks;
- }
-
- /**
- * Check whether the face is joyful.
- *
- * Example:
- * ```
- * if ($face->isJoyful()) {
- * echo "Face is Joyful";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isJoyful($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['joyLikelihood'], $strength);
- }
-
- /**
- * Check whether the face is sorrowful.
- *
- * Example:
- * ```
- * if ($face->isSorrowful()) {
- * echo "Face is Sorrowful";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isSorrowful($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['sorrowLikelihood'], $strength);
- }
-
- /**
- * Check whether the face is angry.
- *
- * Example:
- * ```
- * if ($face->isAngry()) {
- * echo "Face is Angry";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isAngry($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['angerLikelihood'], $strength);
- }
-
- /**
- * Check whether the face is surprised.
- *
- * Example:
- * ```
- * if ($face->isSurprised()) {
- * echo "Face is Surprised";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isSurprised($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['surpriseLikelihood'], $strength);
- }
-
- /**
- * Check whether the face is under exposed.
- *
- * Example:
- * ```
- * if ($face->isUnderExposed()) {
- * echo "Face is Under Exposed";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isUnderExposed($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['underExposedLikelihood'], $strength);
- }
-
- /**
- * Check whether the face is blurred.
- *
- * Example:
- * ```
- * if ($face->isBlurred()) {
- * echo "Face is Blurred";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isBlurred($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['blurredLikelihood'], $strength);
- }
-
- /**
- * Check whether the person is wearing headwear.
- *
- * Example:
- * ```
- * if ($face->hasHeadwear()) {
- * echo "Face has Headwear";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `Face::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function hasHeadwear($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['headwearLikelihood'], $strength);
- }
-}
diff --git a/Vision/src/Annotation/Face/Landmarks.php b/Vision/src/Annotation/Face/Landmarks.php
deleted file mode 100644
index d5e71f0d573d..000000000000
--- a/Vision/src/Annotation/Face/Landmarks.php
+++ /dev/null
@@ -1,482 +0,0 @@
-image($imageResource, ['FACE_DETECTION']);
- * $annotation = $vision->annotate($image);
- *
- * $faces = $annotation->faces();
- * $firstFace = $faces[0];
- *
- * $landmarks = $firstFace->landmarks();
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#type_1 Face Landmark Types
- *
- * @method info() {
- * Get the raw landmarks annotation result
- *
- * Example:
- * ```
- * $info = $landmarks->info();
- * ```
- *
- * @return array
- * }
- *
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Landmarks extends AbstractFeature
-{
- /**
- * Create a landmarks results object.
- *
- * This class should not be instantiated directly. It is created internally
- * by the Cloud Vision service wrapper to represent FACE_DETECTION annotation
- * results and provide helpful convenience to users.
- *
- * @param array $info The face landmark results
- */
- public function __construct(array $info)
- {
- $this->info = $info;
- }
-
- /**
- * Fetch the left eye position.
- *
- * Example:
- * ```
- * $pos = $landmarks->leftEye();
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function leftEye()
- {
- return $this->getLandmark('LEFT_EYE');
- }
-
- /**
- * Fetch the left eye pupil position.
- *
- * Example:
- * ```
- * $pos = $landmarks->leftEyePupil();
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function leftEyePupil()
- {
- return $this->getLandmark('LEFT_EYE_PUPIL');
- }
-
- /**
- * Fetch the left eye boundaries.
- *
- * This method returns an array with four keys: `left`, `right`, `top`, `bottom`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->leftEyeBoundaries();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function leftEyeBoundaries()
- {
- return [
- 'left' => $this->getLandmark('LEFT_EYE_LEFT_CORNER'),
- 'top' => $this->getLandmark('LEFT_EYE_TOP_BOUNDARY'),
- 'right' => $this->getLandmark('LEFT_EYE_RIGHT_CORNER'),
- 'bottom' => $this->getLandmark('LEFT_EYE_BOTTOM_BOUNDARY')
- ];
- }
-
- /**
- * Fetch the left eyebrow position.
- *
- * This method returns an array with three keys: `left`, `right`, `upperMidpoint`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->leftEyebrow();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function leftEyebrow()
- {
- return [
- 'left' => $this->getLandmark('LEFT_OF_LEFT_EYEBROW'),
- 'right' => $this->getLandmark('RIGHT_OF_LEFT_EYEBROW'),
- 'upperMidpoint' => $this->getLandmark('LEFT_EYEBROW_UPPER_MIDPOINT')
- ];
- }
-
- /**
- * Fetch the right eye position.
- *
- * Example:
- * ```
- * $pos = $landmarks->rightEye();
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function rightEye()
- {
- return $this->getLandmark('RIGHT_EYE');
- }
-
- /**
- * Fetch the right eye pupil position.
- *
- * Example:
- * ```
- * $pos = $landmarks->rightEyePupil();
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function rightEyePupil()
- {
- return $this->getLandmark('RIGHT_EYE_PUPIL');
- }
-
- /**
- * Fetch the right eye boundaries.
- *
- * This method returns an array with four keys: `left`, `right`, `top`, `bottom`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->rightEyeBoundaries();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function rightEyeBoundaries()
- {
- return [
- 'left' => $this->getLandmark('RIGHT_EYE_LEFT_CORNER'),
- 'top' => $this->getLandmark('RIGHT_EYE_TOP_BOUNDARY'),
- 'right' => $this->getLandmark('RIGHT_EYE_RIGHT_CORNER'),
- 'bottom' => $this->getLandmark('RIGHT_EYE_BOTTOM_BOUNDARY')
- ];
- }
-
- /**
- * Fetch the right eyebrow position.
- *
- * This method returns an array with three keys: `left`, `right`, `upperMidpoint`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->rightEyebrow();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function rightEyebrow()
- {
- return [
- 'left' => $this->getLandmark('LEFT_OF_RIGHT_EYEBROW'),
- 'right' => $this->getLandmark('RIGHT_OF_RIGHT_EYEBROW'),
- 'upperMidpoint' => $this->getLandmark('RIGHT_EYEBROW_UPPER_MIDPOINT')
- ];
- }
-
- /**
- * Get the position of the midpoint beteeen the eyes.
- *
- * Example:
- * ```
- * $pos = $landmarks->midpointBetweenEyes();
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function midpointBetweenEyes()
- {
- return $this->getLandmark('MIDPOINT_BETWEEN_EYES');
- }
-
- /**
- * Get the position of the lips.
- *
- * This method returns an array with two keys: `upper` and `lower`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->lips();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function lips()
- {
- return [
- 'upper' => $this->getLandmark('UPPER_LIP'),
- 'lower' => $this->getLandmark('LOWER_LIP')
- ];
- }
-
- /**
- * Get the position of the mouth.
- *
- * This method returns an array with three keys: `left`, `right`, `center`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->mouth();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function mouth()
- {
- return [
- 'left' => $this->getLandmark('MOUTH_LEFT'),
- 'right' => $this->getLandmark('MOUTH_RIGHT'),
- 'center' => $this->getLandmark('MOUTH_CENTER')
- ];
- }
-
- /**
- * Get the position of the nose.
- *
- * This method returns an array with four keys: `tip`, `bottomRight`, `bottomLeft`, `bottomCenter`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->nose();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function nose()
- {
- return [
- 'tip' => $this->getLandmark('NOSE_TIP'),
- 'bottomRight' => $this->getLandmark('NOSE_BOTTOM_RIGHT'),
- 'bottomLeft' => $this->getLandmark('NOSE_BOTTOM_LEFT'),
- 'bottomCenter' => $this->getLandmark('NOSE_BOTTOM_CENTER')
- ];
- }
-
- /**
- * Get the position of the ears.
- *
- * This method returns an array with two keys: `left` and `right`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->ears();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @todo should this be earTragions?
- * @return array
- */
- public function ears()
- {
- return [
- 'left' => $this->getLandmark('LEFT_EAR_TRAGION'),
- 'right' => $this->getLandmark('RIGHT_EAR_TRAGION')
- ];
- }
-
- /**
- * Get the position of the forehead glabella.
- *
- * Example:
- * ```
- * $pos = $landmarks->forehead();
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function forehead()
- {
- return $this->getLandmark('FOREHEAD_GLABELLA');
- }
-
- /**
- * Get the position of the chin.
- *
- * This method returns an array with three keys: `left`, `right`, `gnathion`.
- * The value of each of these keys is of the normal Position format described
- * in the Cloud Vision documentation.
- *
- * Example:
- * ```
- * $positions = $landmarks->chin();
- * foreach ($positions as $name => $pos) {
- * echo "Position Type: ". $name . PHP_EOL;
- * echo "x position: ". $pos['x'] . PHP_EOL;
- * echo "y position: ". $pos['y'] . PHP_EOL;
- * echo "z position: ". $pos['z'] . PHP_EOL;
- * }
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#position Position
- *
- * @return array
- */
- public function chin()
- {
- return [
- 'gnathion' => $this->getLandmark('CHIN_GNATHION'),
- 'left' => $this->getLandmark('CHIN_LEFT_GONION'),
- 'right' => $this->getLandmark('CHIN_RIGHT_GONION')
- ];
- }
-
- private function getLandmark($type)
- {
- $result = array_filter($this->info, function ($landmark) use ($type) {
- return $type === $landmark['type'];
- });
-
- return array_shift($result)['position'];
- }
-}
diff --git a/Vision/src/Annotation/FeatureInterface.php b/Vision/src/Annotation/FeatureInterface.php
deleted file mode 100644
index 8e017e06a72a..000000000000
--- a/Vision/src/Annotation/FeatureInterface.php
+++ /dev/null
@@ -1,35 +0,0 @@
-image($imageResource, [ 'imageProperties' ]);
- * $annotation = $vision->annotate($image);
- *
- * $imageProperties = $annotation->imageProperties();
- * ```
- *
- * @method info() {
- * Get the raw annotation result
- *
- * Example:
- * ```
- * $info = $imageProperties->info();
- * ```
- *
- * @return array
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#ImageProperties ImageProperties
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class ImageProperties extends AbstractFeature
-{
- /**
- * Create an ImageProperties result.
- *
- * This class is created internally by {@see Annotation}.
- * See {@see Annotation::imageProperties()} for full usage details.
- * This class should not be instantiated outside the externally.
- *
- * @param array $info The imageProperties annotation result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Get the dominant colors in the image
- *
- * Example:
- * ```
- * $colors = $imageProperties->colors();
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#colorinfo ColorInfo
- *
- * @return array
- */
- public function colors()
- {
- return $this->info['dominantColors']['colors'];
- }
-}
diff --git a/Vision/src/Annotation/LikelihoodTrait.php b/Vision/src/Annotation/LikelihoodTrait.php
deleted file mode 100644
index e2dc6adaa048..000000000000
--- a/Vision/src/Annotation/LikelihoodTrait.php
+++ /dev/null
@@ -1,65 +0,0 @@
- [
- 'VERY_LIKELY'
- ],
- FeatureInterface::STRENGTH_MEDIUM => [
- 'VERY_LIKELY',
- 'LIKELY'
- ],
- FeatureInterface::STRENGTH_LOW => [
- 'VERY_LIKELY',
- 'LIKELY',
- 'POSSIBLE'
- ]
- ];
-
- /**
- * @param string $value The value name
- * @param string $strength The strength to test with
- * @return bool
- */
- private function likelihood($value, $strength)
- {
- if (!array_key_exists($strength, $this->likelihoodLevels)) {
- throw new InvalidArgumentException(sprintf(
- 'Given strength %s is not a valid value',
- $strength
- ));
- }
-
- $levels = $this->likelihoodLevels[$strength];
-
- return in_array($value, $levels);
- }
-}
diff --git a/Vision/src/Annotation/SafeSearch.php b/Vision/src/Annotation/SafeSearch.php
deleted file mode 100644
index b24f5d6f70b8..000000000000
--- a/Vision/src/Annotation/SafeSearch.php
+++ /dev/null
@@ -1,231 +0,0 @@
-image($imageResource, [ 'safeSearch' ]);
- * $annotation = $vision->annotate($image);
- *
- * $safeSearch = $annotation->safeSearch();
- * ```
- *
- * @method adult() {
- * Represents the adult contents likelihood for the image.
- *
- * Example:
- * ```
- * echo $safeSearch->adult();
- * ```
- *
- * @return string
- * }
- * @method spoof() {
- * Spoof likelihood. The likelihood that an obvious modification was made to
- * the image's canonical version to make it appear funny or offensive.
- *
- * Example:
- * ```
- * echo $safeSearch->spoof();
- * ```
- *
- * @return string
- * }
- * @method medical() {
- * Likelihood this is a medical image.
- *
- * Example:
- * ```
- * echo $safeSearch->medical();
- * ```
- *
- * @return string
- * }
- * @method violence() {
- * Violence likelihood.
- *
- * Example:
- * ```
- * echo $safeSearch->violence();
- * ```
- *
- * @return string
- * }
- * @method racy() {
- * Racy likelihood.
- *
- * Example:
- * ```
- * echo $safeSearch->racy();
- * ```
- *
- * @return string
- * }
- * @method info() {
- * Get the raw annotation result
- *
- * Example:
- * ```
- * $info = $safeSearch->info();
- * ```
- *
- * @return array
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#SafeSearchAnnotation SafeSearchAnnotation
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class SafeSearch extends AbstractFeature
-{
- use CallTrait;
- use LikelihoodTrait;
-
- /**
- * Create a SafeSearch annotation result
- *
- * This class is instantiated internally and is used to represent the result of Cloud Vision's SafeSearch annotation
- * feature. It should not be instantiated directly. For complete usage instructions, please refer to
- * {@see \Google\Cloud\Vision\Annotation::safeSearch()}.
- *
- * @param array $info The SafeSearch annotation result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Check whether the image contains adult content.
- *
- * Example:
- * ```
- * if ($safeSearch->isAdult()) {
- * echo "Image contains adult content.";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `SafeSearch::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isAdult($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['adult'], $strength);
- }
-
- /**
- * Check whether the image was modified to make it appear funny or offensive.
- *
- * Example:
- * ```
- * if ($safeSearch->isSpoof()) {
- * echo "Image contains spoofed content.";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `SafeSearch::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isSpoof($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['spoof'], $strength);
- }
-
- /**
- * Check whether the image contains medical content
- *
- * Example:
- * ```
- * if ($safeSearch->medical()) {
- * echo "Image contains medical content.";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `SafeSearch::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isMedical($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['medical'], $strength);
- }
-
- /**
- * Check whether the image contains violent content
- *
- * Example:
- * ```
- * if ($safeSearch->isViolent()) {
- * echo "Image contains violent content.";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `SafeSearch::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isViolent($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['violence'], $strength);
- }
-
- /**
- * Check whether the image contains racy content
- *
- * Example:
- * ```
- * if ($safeSearch->isRacy()) {
- * echo "Image contains racy content.";
- * }
- * ```
- *
- * @param string $strength [optional] Value should be one of "low",
- * "medium" or "high". Recommended usage is via `SafeSearch::STRENGTH_*`
- * constants. Higher strength will result in fewer `true` results,
- * but fewer false positives. **Defaults to** `"low"`.
- * @return bool
- */
- public function isRacy($strength = self::STRENGTH_LOW)
- {
- return $this->likelihood($this->info['racy'], $strength);
- }
-}
diff --git a/Vision/src/Annotation/Web.php b/Vision/src/Annotation/Web.php
deleted file mode 100644
index 070d612f6402..000000000000
--- a/Vision/src/Annotation/Web.php
+++ /dev/null
@@ -1,177 +0,0 @@
-image($imageResource, [ 'WEB_DETECTION' ]);
- * $annotation = $vision->annotate($image);
- *
- * $web = $annotation->web();
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#WebDetection WebDetection
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Web extends AbstractFeature
-{
- /**
- * @var WebEntity[]
- */
- private $entities;
-
- /**
- * @var WebImage[]|null
- */
- private $matchingImages;
-
- /**
- * @var WebImage[]|null
- */
- private $partialMatchingImages;
-
- /**
- * @var WebPage[]|null
- */
- private $pages;
-
- /**
- * Create a Web result.
- *
- * @param array $info The annotation result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- if (isset($info['webEntities'])) {
- $this->entities = [];
-
- foreach ($info['webEntities'] as $entity) {
- $this->entities[] = new WebEntity($entity);
- }
- }
-
- if (isset($info['fullMatchingImages'])) {
- $this->matchingImages = [];
-
- foreach ($info['fullMatchingImages'] as $image) {
- $this->matchingImages[] = new WebImage($image);
- }
- }
-
- if (isset($info['partialMatchingImages'])) {
- $this->partialMatchingImages = [];
-
- foreach ($info['partialMatchingImages'] as $image) {
- $this->partialMatchingImages[] = new WebImage($image);
- }
- }
-
- if (isset($info['pagesWithMatchingImages'])) {
- $this->pages = [];
-
- foreach ($info['pagesWithMatchingImages'] as $page) {
- $this->pages[] = new WebPage($page);
- }
- }
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Entities deduced from similar images on the Internet.
- *
- * Example:
- * ```
- * $entities = $web->entities();
- * ```
- *
- * @return WebEntity[]|null
- */
- public function entities()
- {
- return $this->entities;
- }
-
- /**
- * Fully matching images from the internet.
- *
- * Images are most likely near duplicates, and most often are a copy of the
- * given query image with a size change.
- *
- * Example:
- * ```
- * $images = $web->matchingImages();
- * ```
- *
- * @return WebImage[]|null
- */
- public function matchingImages()
- {
- return $this->matchingImages;
- }
-
- /**
- * Partial matching images from the Internet.
- *
- * Those images are similar enough to share some key-point features. For
- * example an original image will likely have partial matching for its crops.
- *
- * Example:
- * ```
- * $images = $web->partialMatchingImages();
- * ```
- *
- * @return WebImage[]|null
- */
- public function partialMatchingImages()
- {
- return $this->partialMatchingImages;
- }
-
- /**
- * Web pages containing the matching images from the Internet.
- *
- * Example:
- * ```
- * $pages = $web->pages();
- * ```
- *
- * @return WebPage[]|null
- */
- public function pages()
- {
- return $this->pages;
- }
-}
diff --git a/Vision/src/Annotation/Web/WebEntity.php b/Vision/src/Annotation/Web/WebEntity.php
deleted file mode 100644
index c4cf90309fa8..000000000000
--- a/Vision/src/Annotation/Web/WebEntity.php
+++ /dev/null
@@ -1,88 +0,0 @@
-image($imageResource, ['WEB_DETECTION']);
- * $annotation = $vision->annotate($image);
- *
- * $entities = $annotation->web()->entities();
- * $firstEntity = $entities[0];
- * ```
- *
- * @method entityId() {
- * The Entity ID
- *
- * Example:
- * ```
- * $id = $entity->entityId();
- * ```
- *
- * @return string
- * }
- * @method score() {
- * Overall relevancy score for the image.
- *
- * Not normalized and not comparable across different image queries.
- *
- * Example:
- * ```
- * $score = $entity->score();
- * ```
- *
- * @return float
- * }
- * @method description() {
- * Canonical description of the entity, in English.
- *
- * Example:
- * ```
- * $description = $entity->description();
- * ```
- *
- * @return string
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#WebEntity WebEntity
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class WebEntity extends AbstractFeature
-{
- use CallTrait;
-
- /**
- * @param array $info WebEntity info
- */
- public function __construct(array $info)
- {
- $this->info = $info;
- }
-}
diff --git a/Vision/src/Annotation/Web/WebImage.php b/Vision/src/Annotation/Web/WebImage.php
deleted file mode 100644
index 92cc87b9c738..000000000000
--- a/Vision/src/Annotation/Web/WebImage.php
+++ /dev/null
@@ -1,78 +0,0 @@
-image($imageResource, ['WEB_DETECTION']);
- * $annotation = $vision->annotate($image);
- *
- * $matchingImages = $annotation->web()->matchingImages();
- * $firstImage = $matchingImages[0];
- * ```
- *
- * @method url() {
- * The result image URL
- *
- * Example:
- * ```
- * $url = $image->url();
- * ```
- *
- * @return string
- * }
- * @method score() {
- * Overall relevancy score for the image.
- *
- * Not normalized and not comparable across different image queries.
- *
- * Example:
- * ```
- * $score = $image->score();
- * ```
- *
- * @return float
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#WebImage WebImage
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class WebImage extends AbstractFeature
-{
- use CallTrait;
-
- /**
- * @param array $info The WebImage result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
- }
-}
diff --git a/Vision/src/Annotation/Web/WebPage.php b/Vision/src/Annotation/Web/WebPage.php
deleted file mode 100644
index d4f4187ead7a..000000000000
--- a/Vision/src/Annotation/Web/WebPage.php
+++ /dev/null
@@ -1,82 +0,0 @@
-image($imageResource, ['WEB_DETECTION']);
- * $annotation = $vision->annotate($image);
- *
- * $pages = $annotation->web()->pages();
- * $firstPage = $pages[0];
- * ```
- *
- * @method url() {
- * The result web page URL
- *
- * Example:
- * ```
- * $url = $image->url();
- * ```
- *
- * @return string
- * }
- * @method score() {
- * Overall relevancy score for the image.
- *
- * Not normalized and not comparable across different image queries.
- *
- * Example:
- * ```
- * $score = $image->score();
- * ```
- *
- * @return float
- * }
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#WebPage WebPage
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class WebPage extends AbstractFeature
-{
- use CallTrait;
-
- /**
- * @param array $info The WebPage result
- */
- public function __construct(array $info)
- {
- $this->info = $info;
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-}
diff --git a/Vision/src/Connection/ConnectionInterface.php b/Vision/src/Connection/ConnectionInterface.php
deleted file mode 100644
index 0faad366b232..000000000000
--- a/Vision/src/Connection/ConnectionInterface.php
+++ /dev/null
@@ -1,32 +0,0 @@
- __DIR__ . '/ServiceDefinition/vision-v1.json',
- 'componentVersion' => VisionClient::VERSION
- ];
-
- $this->setRequestWrapper(new RequestWrapper($config));
- $this->setRequestBuilder(new RequestBuilder(
- $config['serviceDefinitionPath'],
- $this->getApiEndpoint(self::BASE_URI, $config)
- ));
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * @param array $args
- */
- public function annotate(array $args)
- {
- return $this->send('images', 'annotate', $args);
- }
-}
diff --git a/Vision/src/Connection/ServiceDefinition/vision-v1.json b/Vision/src/Connection/ServiceDefinition/vision-v1.json
deleted file mode 100644
index 2bcdadacfcae..000000000000
--- a/Vision/src/Connection/ServiceDefinition/vision-v1.json
+++ /dev/null
@@ -1,968 +0,0 @@
-{
- "id": "vision:v1",
- "auth": {
- "oauth2": {
- "scopes": {
- "https://www.googleapis.com/auth/cloud-platform": {
- "description": "View and manage your data across Google Cloud Platform services"
- }
- }
- }
- },
- "description": "Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.",
- "protocol": "rest",
- "title": "Google Cloud Vision API",
- "resources": {
- "images": {
- "methods": {
- "annotate": {
- "id": "vision.images.annotate",
- "response": {
- "$ref": "BatchAnnotateImagesResponse"
- },
- "parameterOrder": [],
- "description": "Run image detection and annotation for a batch of images.",
- "request": {
- "$ref": "BatchAnnotateImagesRequest"
- },
- "flatPath": "v1/images:annotate",
- "httpMethod": "POST",
- "parameters": {},
- "path": "v1/images:annotate",
- "scopes": [
- "https://www.googleapis.com/auth/cloud-platform"
- ]
- }
- }
- }
- },
- "schemas": {
- "ImageSource": {
- "description": "External image source (Google Cloud Storage image location).",
- "type": "object",
- "properties": {
- "gcsImageUri": {
- "description": "Google Cloud Storage image URI. It must be in the following form:\n`gs://bucket_name/object_name`. For more\ndetails, please see: https://cloud.google.com/storage/docs/reference-uris.\nNOTE: Cloud Storage object versioning is not supported!",
- "type": "string"
- },
- "ImageUri": {
- "description": "Image URI which supports: 1) Google Cloud Storage image URI, which must be in the following form: `gs://bucket_name/object_name` (for details, see [Google Cloud Storage Request URIs](https://cloud.google.com/storage/docs/reference-uris)). NOTE: Cloud Storage object versioning is not supported. 2) Publicly accessible image HTTP/HTTPS URL. This is preferred over the legacy `gcs_image_uri` above. When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes precedence.",
- "type": "string"
- }
- },
- "id": "ImageSource"
- },
- "AnnotateImageRequest": {
- "description": "Request for performing Google Cloud Vision API tasks over a user-provided\nimage, with user-requested features.",
- "type": "object",
- "properties": {
- "image": {
- "description": "The image to be processed.",
- "$ref": "Image"
- },
- "imageContext": {
- "description": "Additional context that may accompany the image.",
- "$ref": "ImageContext"
- },
- "features": {
- "description": "Requested features.",
- "type": "array",
- "items": {
- "$ref": "Feature"
- }
- }
- },
- "id": "AnnotateImageRequest"
- },
- "AnnotateImageResponse": {
- "description": "Response to an image annotation request.",
- "type": "object",
- "properties": {
- "labelAnnotations": {
- "description": "If present, label detection completed successfully.",
- "type": "array",
- "items": {
- "$ref": "EntityAnnotation"
- }
- },
- "landmarkAnnotations": {
- "description": "If present, landmark detection completed successfully.",
- "type": "array",
- "items": {
- "$ref": "EntityAnnotation"
- }
- },
- "safeSearchAnnotation": {
- "description": "If present, safe-search annotation completed successfully.",
- "$ref": "SafeSearchAnnotation"
- },
- "imagePropertiesAnnotation": {
- "description": "If present, image properties were extracted successfully.",
- "$ref": "ImageProperties"
- },
- "textAnnotations": {
- "description": "If present, text (OCR) detection completed successfully.",
- "type": "array",
- "items": {
- "$ref": "EntityAnnotation"
- }
- },
- "logoAnnotations": {
- "description": "If present, logo detection completed successfully.",
- "type": "array",
- "items": {
- "$ref": "EntityAnnotation"
- }
- },
- "faceAnnotations": {
- "description": "If present, face detection completed successfully.",
- "type": "array",
- "items": {
- "$ref": "FaceAnnotation"
- }
- },
- "error": {
- "description": "If set, represents the error message for the operation.\nNote that filled-in mage annotations are guaranteed to be\ncorrect, even when \u003ccode\u003eerror\u003c/code\u003e is non-empty.",
- "$ref": "Status"
- }
- },
- "id": "AnnotateImageResponse"
- },
- "LatLongRect": {
- "description": "Rectangle determined by min and max LatLng pairs.",
- "type": "object",
- "properties": {
- "maxLatLng": {
- "description": "Max lat/long pair.",
- "$ref": "LatLng"
- },
- "minLatLng": {
- "description": "Min lat/long pair.",
- "$ref": "LatLng"
- }
- },
- "id": "LatLongRect"
- },
- "Status": {
- "description": "The `Status` type defines a logical error model that is suitable for different\nprogramming environments, including REST APIs and RPC APIs. It is used by\n[gRPC](https://github.com/grpc). The error model is designed to be:\n\n- Simple to use and understand for most users\n- Flexible enough to meet unexpected needs\n\n# Overview\n\nThe `Status` message contains three pieces of data: error code, error message,\nand error details. The error code should be an enum value of\ngoogle.rpc.Code, but it may accept additional error codes if needed. The\nerror message should be a developer-facing English message that helps\ndevelopers *understand* and *resolve* the error. If a localized user-facing\nerror message is needed, put the localized message in the error details or\nlocalize it in the client. The optional error details may contain arbitrary\ninformation about the error. There is a predefined set of error detail types\nin the package `google.rpc` which can be used for common error conditions.\n\n# Language mapping\n\nThe `Status` message is the logical representation of the error model, but it\nis not necessarily the actual wire format. When the `Status` message is\nexposed in different client libraries and different wire protocols, it can be\nmapped differently. For example, it will likely be mapped to some exceptions\nin Java, but more likely mapped to some error codes in C.\n\n# Other uses\n\nThe error model and the `Status` message can be used in a variety of\nenvironments, either with or without APIs, to provide a\nconsistent developer experience across different environments.\n\nExample uses of this error model include:\n\n- Partial errors. If a service needs to return partial errors to the client,\n it may embed the `Status` in the normal response to indicate the partial\n errors.\n\n- Workflow errors. A typical workflow has multiple steps. Each step may\n have a `Status` message for error reporting purpose.\n\n- Batch operations. If a client uses batch request and batch response, the\n `Status` message should be used directly inside batch response, one for\n each error sub-response.\n\n- Asynchronous operations. If an API call embeds asynchronous operation\n results in its response, the status of those operations should be\n represented directly using the `Status` message.\n\n- Logging. If some API errors are stored in logs, the message `Status` could\n be used directly after any stripping needed for security/privacy reasons.",
- "type": "object",
- "properties": {
- "code": {
- "description": "The status code, which should be an enum value of google.rpc.Code.",
- "type": "integer",
- "format": "int32"
- },
- "details": {
- "description": "A list of messages that carry the error details. There will be a\ncommon set of message types for APIs to use.",
- "type": "array",
- "items": {
- "additionalProperties": {
- "description": "Properties of the object. Contains field @ype with type URL.",
- "type": "any"
- },
- "type": "object"
- }
- },
- "message": {
- "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\ngoogle.rpc.Status.details field, or localized by the client.",
- "type": "string"
- }
- },
- "id": "Status"
- },
- "FaceAnnotation": {
- "description": "A face annotation object contains the results of face detection.",
- "type": "object",
- "properties": {
- "tiltAngle": {
- "description": "Pitch angle. Indicates the upwards/downwards angle that the face is\npointing\nrelative to the image's horizontal plane. Range [-180,180].",
- "type": "number",
- "format": "float"
- },
- "underExposedLikelihood": {
- "description": "Under-exposed likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "fdBoundingPoly": {
- "description": "This bounding polygon is tighter than the previous\n\u003ccode\u003eboundingPoly\u003c/code\u003e, and\nencloses only the skin part of the face. Typically, it is used to\neliminate the face from any image analysis that detects the\n\"amount of skin\" visible in an image. It is not based on the\nlandmarker results, only on the initial face detection, hence\nthe \u003ccode\u003efd\u003c/code\u003e (face detection) prefix.",
- "$ref": "BoundingPoly"
- },
- "landmarkingConfidence": {
- "description": "Face landmarking confidence. Range [0, 1].",
- "type": "number",
- "format": "float"
- },
- "joyLikelihood": {
- "description": "Joy likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "detectionConfidence": {
- "description": "Detection confidence. Range [0, 1].",
- "type": "number",
- "format": "float"
- },
- "surpriseLikelihood": {
- "description": "Surprise likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "angerLikelihood": {
- "description": "Anger likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "headwearLikelihood": {
- "description": "Headwear likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "panAngle": {
- "description": "Yaw angle. Indicates the leftward/rightward angle that the face is\npointing, relative to the vertical plane perpendicular to the image. Range\n[-180,180].",
- "type": "number",
- "format": "float"
- },
- "boundingPoly": {
- "description": "The bounding polygon around the face. The coordinates of the bounding box\nare in the original image's scale, as returned in ImageParams.\nThe bounding box is computed to \"frame\" the face in accordance with human\nexpectations. It is based on the landmarker results.\nNote that one or more x and/or y coordinates may not be generated in the\nBoundingPoly (the polygon will be unbounded) if only a partial face appears in\nthe image to be annotated.",
- "$ref": "BoundingPoly"
- },
- "landmarks": {
- "description": "Detected face landmarks.",
- "type": "array",
- "items": {
- "$ref": "Landmark"
- }
- },
- "blurredLikelihood": {
- "description": "Blurred likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "rollAngle": {
- "description": "Roll angle. Indicates the amount of clockwise/anti-clockwise rotation of\nthe\nface relative to the image vertical, about the axis perpendicular to the\nface. Range [-180,180].",
- "type": "number",
- "format": "float"
- },
- "sorrowLikelihood": {
- "description": "Sorrow likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- }
- },
- "id": "FaceAnnotation"
- },
- "Vertex": {
- "description": "A vertex represents a 2D point in the image.\nNOTE: the vertex coordinates are in the same scale as the original image.",
- "type": "object",
- "properties": {
- "y": {
- "description": "Y coordinate.",
- "type": "integer",
- "format": "int32"
- },
- "x": {
- "description": "X coordinate.",
- "type": "integer",
- "format": "int32"
- }
- },
- "id": "Vertex"
- },
- "ColorInfo": {
- "description": "Color information consists of RGB channels, score and fraction of\nimage the color occupies in the image.",
- "type": "object",
- "properties": {
- "pixelFraction": {
- "description": "Stores the fraction of pixels the color occupies in the image.\nValue in range [0, 1].",
- "type": "number",
- "format": "float"
- },
- "color": {
- "description": "RGB components of the color.",
- "$ref": "Color"
- },
- "score": {
- "description": "Image-specific score for this color. Value in range [0, 1].",
- "type": "number",
- "format": "float"
- }
- },
- "id": "ColorInfo"
- },
- "BoundingPoly": {
- "description": "A bounding polygon for the detected image annotation.",
- "type": "object",
- "properties": {
- "vertices": {
- "description": "The bounding polygon vertices.",
- "type": "array",
- "items": {
- "$ref": "Vertex"
- }
- }
- },
- "id": "BoundingPoly"
- },
- "Landmark": {
- "description": "A face-specific landmark (for example, a face feature).\nLandmark positions may fall outside the bounds of the image\nwhen the face is near one or more edges of the image.\nTherefore it is NOT guaranteed that 0 \u003c= x \u003c width or 0 \u003c= y \u003c height.",
- "type": "object",
- "properties": {
- "position": {
- "description": "Face landmark position.",
- "$ref": "Position"
- },
- "type": {
- "description": "Face landmark type.",
- "enum": [
- "UNKNOWN_LANDMARK",
- "LEFT_EYE",
- "RIGHT_EYE",
- "LEFT_OF_LEFT_EYEBROW",
- "RIGHT_OF_LEFT_EYEBROW",
- "LEFT_OF_RIGHT_EYEBROW",
- "RIGHT_OF_RIGHT_EYEBROW",
- "MIDPOINT_BETWEEN_EYES",
- "NOSE_TIP",
- "UPPER_LIP",
- "LOWER_LIP",
- "MOUTH_LEFT",
- "MOUTH_RIGHT",
- "MOUTH_CENTER",
- "NOSE_BOTTOM_RIGHT",
- "NOSE_BOTTOM_LEFT",
- "NOSE_BOTTOM_CENTER",
- "LEFT_EYE_TOP_BOUNDARY",
- "LEFT_EYE_RIGHT_CORNER",
- "LEFT_EYE_BOTTOM_BOUNDARY",
- "LEFT_EYE_LEFT_CORNER",
- "RIGHT_EYE_TOP_BOUNDARY",
- "RIGHT_EYE_RIGHT_CORNER",
- "RIGHT_EYE_BOTTOM_BOUNDARY",
- "RIGHT_EYE_LEFT_CORNER",
- "LEFT_EYEBROW_UPPER_MIDPOINT",
- "RIGHT_EYEBROW_UPPER_MIDPOINT",
- "LEFT_EAR_TRAGION",
- "RIGHT_EAR_TRAGION",
- "LEFT_EYE_PUPIL",
- "RIGHT_EYE_PUPIL",
- "FOREHEAD_GLABELLA",
- "CHIN_GNATHION",
- "CHIN_LEFT_GONION",
- "CHIN_RIGHT_GONION"
- ],
- "enumDescriptions": [
- "Unknown face landmark detected. Should not be filled.",
- "Left eye.",
- "Right eye.",
- "Left of left eyebrow.",
- "Right of left eyebrow.",
- "Left of right eyebrow.",
- "Right of right eyebrow.",
- "Midpoint between eyes.",
- "Nose tip.",
- "Upper lip.",
- "Lower lip.",
- "Mouth left.",
- "Mouth right.",
- "Mouth center.",
- "Nose, bottom right.",
- "Nose, bottom left.",
- "Nose, bottom center.",
- "Left eye, top boundary.",
- "Left eye, right corner.",
- "Left eye, bottom boundary.",
- "Left eye, left corner.",
- "Right eye, top boundary.",
- "Right eye, right corner.",
- "Right eye, bottom boundary.",
- "Right eye, left corner.",
- "Left eyebrow, upper midpoint.",
- "Right eyebrow, upper midpoint.",
- "Left ear tragion.",
- "Right ear tragion.",
- "Left eye pupil.",
- "Right eye pupil.",
- "Forehead glabella.",
- "Chin gnathion.",
- "Chin left gonion.",
- "Chin right gonion."
- ],
- "type": "string"
- }
- },
- "id": "Landmark"
- },
- "ImageContext": {
- "description": "Image context.",
- "type": "object",
- "properties": {
- "latLongRect": {
- "description": "Lat/long rectangle that specifies the location of the image.",
- "$ref": "LatLongRect"
- },
- "languageHints": {
- "description": "List of languages to use for TEXT_DETECTION. In most cases, an empty value\nyields the best results since it enables automatic language detection. For\nlanguages based on the Latin alphabet, setting `language_hints` is not\nneeded. In rare cases, when the language of the text in the image is known,\nsetting a hint will help get better results (although it will be a\nsignificant hindrance if the hint is wrong). Text detection returns an\nerror if one or more of the specified languages is not one of the\n[supported\nlanguages](/translate/v2/translate-reference#supported_languages).",
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- "id": "ImageContext"
- },
- "BatchAnnotateImagesRequest": {
- "description": "Multiple image annotation requests are batched into a single service call.",
- "type": "object",
- "properties": {
- "requests": {
- "description": "Individual image annotation requests for this batch.",
- "type": "array",
- "items": {
- "$ref": "AnnotateImageRequest"
- }
- }
- },
- "id": "BatchAnnotateImagesRequest"
- },
- "EntityAnnotation": {
- "description": "Set of detected entity features.",
- "type": "object",
- "properties": {
- "mid": {
- "description": "Opaque entity ID. Some IDs might be available in Knowledge Graph(KG).\nFor more details on KG please see:\nhttps://developers.google.com/knowledge-graph/",
- "type": "string"
- },
- "description": {
- "description": "Entity textual description, expressed in its \u003ccode\u003elocale\u003c/code\u003e language.",
- "type": "string"
- },
- "topicality": {
- "description": "The relevancy of the ICA (Image Content Annotation) label to the\nimage. For example, the relevancy of 'tower' to an image containing\n'Eiffel Tower' is likely higher than an image containing a distant towering\nbuilding, though the confidence that there is a tower may be the same.\nRange [0, 1].",
- "type": "number",
- "format": "float"
- },
- "locale": {
- "description": "The language code for the locale in which the entity textual\n\u003ccode\u003edescription\u003c/code\u003e (next field) is expressed.",
- "type": "string"
- },
- "properties": {
- "description": "Some entities can have additional optional \u003ccode\u003eProperty\u003c/code\u003e fields.\nFor example a different kind of score or string that qualifies the entity.",
- "type": "array",
- "items": {
- "$ref": "Property"
- }
- },
- "score": {
- "description": "Overall score of the result. Range [0, 1].",
- "type": "number",
- "format": "float"
- },
- "boundingPoly": {
- "description": "Image region to which this entity belongs. Not filled currently\nfor `LABEL_DETECTION` features. For `TEXT_DETECTION` (OCR), `boundingPoly`s\nare produced for the entire text detected in an image region, followed by\n`boundingPoly`s for each word within the detected text.",
- "$ref": "BoundingPoly"
- },
- "locations": {
- "description": "The location information for the detected entity. Multiple\n\u003ccode\u003eLocationInfo\u003c/code\u003e elements can be present since one location may\nindicate the location of the scene in the query image, and another the\nlocation of the place where the query image was taken. Location information\nis usually present for landmarks.",
- "type": "array",
- "items": {
- "$ref": "LocationInfo"
- }
- },
- "confidence": {
- "description": "The accuracy of the entity detection in an image.\nFor example, for an image containing 'Eiffel Tower,' this field represents\nthe confidence that there is a tower in the query image. Range [0, 1].",
- "type": "number",
- "format": "float"
- }
- },
- "id": "EntityAnnotation"
- },
- "Property": {
- "description": "Arbitrary name/value pair.",
- "type": "object",
- "properties": {
- "value": {
- "description": "Value of the property.",
- "type": "string"
- },
- "name": {
- "description": "Name of the property.",
- "type": "string"
- }
- },
- "id": "Property"
- },
- "Color": {
- "description": "Represents a color in the RGBA color space. This representation is designed\nfor simplicity of conversion to/from color representations in various\nlanguages over compactness; for example, the fields of this representation\ncan be trivially provided to the constructor of \"java.awt.Color\" in Java; it\ncan also be trivially provided to UIColor's \"+colorWithRed:green:blue:alpha\"\nmethod in iOS; and, with just a little work, it can be easily formatted into\na CSS \"rgba()\" string in JavaScript, as well. Here are some examples:\n\nExample (Java):\n\n import com.google.type.Color;\n\n // ...\n public static java.awt.Color fromProto(Color protocolor) {\n float alpha = protocolor.hasAlpha()\n ? protocolor.getAlpha().getValue()\n : 1.0;\n\n return new java.awt.Color(\n protocolor.getRed(),\n protocolor.getGreen(),\n protocolor.getBlue(),\n alpha);\n }\n\n public static Color toProto(java.awt.Color color) {\n float red = (float) color.getRed();\n float green = (float) color.getGreen();\n float blue = (float) color.getBlue();\n float denominator = 255.0;\n Color.Builder resultBuilder =\n Color\n .newBuilder()\n .setRed(red / denominator)\n .setGreen(green / denominator)\n .setBlue(blue / denominator);\n int alpha = color.getAlpha();\n if (alpha != 255) {\n result.setAlpha(\n FloatValue\n .newBuilder()\n .setValue(((float) alpha) / denominator)\n .build());\n }\n return resultBuilder.build();\n }\n // ...\n\nExample (iOS / Obj-C):\n\n // ...\n static UIColor* fromProto(Color* protocolor) {\n float red = [protocolor red];\n float green = [protocolor green];\n float blue = [protocolor blue];\n FloatValue* alpha_wrapper = [protocolor alpha];\n float alpha = 1.0;\n if (alpha_wrapper != nil) {\n alpha = [alpha_wrapper value];\n }\n return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];\n }\n\n static Color* toProto(UIColor* color) {\n CGFloat red, green, blue, alpha;\n if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {\n return nil;\n }\n Color* result = [Color alloc] init];\n [result setRed:red];\n [result setGreen:green];\n [result setBlue:blue];\n if (alpha \u003c= 0.9999) {\n [result setAlpha:floatWrapperWithValue(alpha)];\n }\n [result autorelease];\n return result;\n }\n // ...\n\n Example (JavaScript):\n\n // ...\n\n var protoToCssColor = function(rgb_color) {\n var redFrac = rgb_color.red || 0.0;\n var greenFrac = rgb_color.green || 0.0;\n var blueFrac = rgb_color.blue || 0.0;\n var red = Math.floor(redFrac * 255);\n var green = Math.floor(greenFrac * 255);\n var blue = Math.floor(blueFrac * 255);\n\n if (!('alpha' in rgb_color)) {\n return rgbToCssColor_(red, green, blue);\n }\n\n var alphaFrac = rgb_color.alpha.value || 0.0;\n var rgbParams = [red, green, blue].join(',');\n return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');\n };\n\n var rgbToCssColor_ = function(red, green, blue) {\n var rgbNumber = new Number((red \u003c\u003c 16) | (green \u003c\u003c 8) | blue);\n var hexString = rgbNumber.toString(16);\n var missingZeros = 6 - hexString.length;\n var resultBuilder = ['#'];\n for (var i = 0; i \u003c missingZeros; i++) {\n resultBuilder.push('0');\n }\n resultBuilder.push(hexString);\n return resultBuilder.join('');\n };\n\n // ...",
- "type": "object",
- "properties": {
- "green": {
- "description": "The amount of green in the color as a value in the interval [0, 1].",
- "type": "number",
- "format": "float"
- },
- "blue": {
- "description": "The amount of blue in the color as a value in the interval [0, 1].",
- "type": "number",
- "format": "float"
- },
- "red": {
- "description": "The amount of red in the color as a value in the interval [0, 1].",
- "type": "number",
- "format": "float"
- },
- "alpha": {
- "description": "The fraction of this color that should be applied to the pixel. That is,\nthe final pixel color is defined by the equation:\n\n pixel color = alpha * (this color) + (1.0 - alpha) * (background color)\n\nThis means that a value of 1.0 corresponds to a solid color, whereas\na value of 0.0 corresponds to a completely transparent color. This\nuses a wrapper message rather than a simple float scalar so that it is\npossible to distinguish between a default value and the value being unset.\nIf omitted, this color object is to be rendered as a solid color\n(as if the alpha value had been explicitly given with a value of 1.0).",
- "type": "number",
- "format": "float"
- }
- },
- "id": "Color"
- },
- "LocationInfo": {
- "description": "Detected entity location information.",
- "type": "object",
- "properties": {
- "latLng": {
- "description": "Lat - long location coordinates.",
- "$ref": "LatLng"
- }
- },
- "id": "LocationInfo"
- },
- "SafeSearchAnnotation": {
- "description": "Set of features pertaining to the image, computed by various computer vision\nmethods over safe-search verticals (for example, adult, spoof, medical,\nviolence).",
- "type": "object",
- "properties": {
- "medical": {
- "description": "Likelihood this is a medical image.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "spoof": {
- "description": "Spoof likelihood. The likelihood that an obvious modification\nwas made to the image's canonical version to make it appear\nfunny or offensive.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "violence": {
- "description": "Violence likelihood.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- },
- "adult": {
- "description": "Represents the adult contents likelihood for the image.",
- "enum": [
- "UNKNOWN",
- "VERY_UNLIKELY",
- "UNLIKELY",
- "POSSIBLE",
- "LIKELY",
- "VERY_LIKELY"
- ],
- "enumDescriptions": [
- "Unknown likelihood.",
- "The image very unlikely belongs to the vertical specified.",
- "The image unlikely belongs to the vertical specified.",
- "The image possibly belongs to the vertical specified.",
- "The image likely belongs to the vertical specified.",
- "The image very likely belongs to the vertical specified."
- ],
- "type": "string"
- }
- },
- "id": "SafeSearchAnnotation"
- },
- "Image": {
- "description": "Client image to perform Google Cloud Vision API tasks over.",
- "type": "object",
- "properties": {
- "source": {
- "description": "Google Cloud Storage image location. If both 'content' and 'source'\nare filled for an image, 'content' takes precedence and it will be\nused for performing the image annotation request.",
- "$ref": "ImageSource"
- },
- "content": {
- "description": "Image content, represented as a stream of bytes.\nNote: as with all `bytes` fields, protobuffers use a pure binary\nrepresentation, whereas JSON representations use base64.",
- "type": "string",
- "format": "byte"
- }
- },
- "id": "Image"
- },
- "DominantColorsAnnotation": {
- "description": "Set of dominant colors and their corresponding scores.",
- "type": "object",
- "properties": {
- "colors": {
- "description": "RGB color values, with their score and pixel fraction.",
- "type": "array",
- "items": {
- "$ref": "ColorInfo"
- }
- }
- },
- "id": "DominantColorsAnnotation"
- },
- "Feature": {
- "description": "The \u003cem\u003eFeature\u003c/em\u003e indicates what type of image detection task to perform.\nUsers describe the type of Google Cloud Vision API tasks to perform over\nimages by using \u003cem\u003eFeature\u003c/em\u003es. Features encode the Cloud Vision API\nvertical to operate on and the number of top-scoring results to return.",
- "type": "object",
- "properties": {
- "type": {
- "description": "The feature type.",
- "enum": [
- "TYPE_UNSPECIFIED",
- "FACE_DETECTION",
- "LANDMARK_DETECTION",
- "LOGO_DETECTION",
- "LABEL_DETECTION",
- "TEXT_DETECTION",
- "DOCUMENT_TEXT_DETECTION",
- "SAFE_SEARCH_DETECTION",
- "IMAGE_PROPERTIES",
- "CROP_HINTS",
- "WEB_DETECTION"
- ],
- "enumDescriptions": [
- "Unspecified feature type.",
- "Run face detection.",
- "Run landmark detection.",
- "Run logo detection.",
- "Run label detection.",
- "Run OCR.",
- "Run dense text document OCR. Takes precedence when both DOCUMENT_TEXT_DETECTION and TEXT_DETECTION are present.",
- "Run various computer vision models to compute image safe-search properties.",
- "Compute a set of properties about the image (such as the image's dominant colors).",
- "Run crop hints.",
- "Run web annotation."
- ],
- "type": "string"
- },
- "maxResults": {
- "description": "Maximum number of results of this type.",
- "type": "integer",
- "format": "int32"
- }
- },
- "id": "Feature"
- },
- "BatchAnnotateImagesResponse": {
- "description": "Response to a batch image annotation request.",
- "type": "object",
- "properties": {
- "responses": {
- "description": "Individual responses to image annotation requests within the batch.",
- "type": "array",
- "items": {
- "$ref": "AnnotateImageResponse"
- }
- }
- },
- "id": "BatchAnnotateImagesResponse"
- },
- "ImageProperties": {
- "description": "Stores image properties (e.g. dominant colors).",
- "type": "object",
- "properties": {
- "dominantColors": {
- "description": "If present, dominant colors completed successfully.",
- "$ref": "DominantColorsAnnotation"
- }
- },
- "id": "ImageProperties"
- },
- "LatLng": {
- "description": "An object representing a latitude/longitude pair. This is expressed as a pair\nof doubles representing degrees latitude and degrees longitude. Unless\nspecified otherwise, this must conform to the\n\u003ca href=\"http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf\"\u003eWGS84\nstandard\u003c/a\u003e. Values must be within normalized ranges.\n\nExample of normalization code in Python:\n\n def NormalizeLongitude(longitude):\n \"\"\"Wraps decimal degrees longitude to [-180.0, 180.0].\"\"\"\n q, r = divmod(longitude, 360.0)\n if r \u003e 180.0 or (r == 180.0 and q \u003c= -1.0):\n return r - 360.0\n return r\n\n def NormalizeLatLng(latitude, longitude):\n \"\"\"Wraps decimal degrees latitude and longitude to\n [-90.0, 90.0] and [-180.0, 180.0], respectively.\"\"\"\n r = latitude % 360.0\n if r \u003c= 90.0:\n return r, NormalizeLongitude(longitude)\n elif r \u003e= 270.0:\n return r - 360, NormalizeLongitude(longitude)\n else:\n return 180 - r, NormalizeLongitude(longitude + 180.0)\n\n assert 180.0 == NormalizeLongitude(180.0)\n assert -180.0 == NormalizeLongitude(-180.0)\n assert -179.0 == NormalizeLongitude(181.0)\n assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0)\n assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0)\n assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0)\n assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0)\n assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0)\n assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0)\n assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0)\n assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0)\n assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0)\n assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0)",
- "type": "object",
- "properties": {
- "latitude": {
- "description": "The latitude in degrees. It must be in the range [-90.0, +90.0].",
- "type": "number",
- "format": "double"
- },
- "longitude": {
- "description": "The longitude in degrees. It must be in the range [-180.0, +180.0].",
- "type": "number",
- "format": "double"
- }
- },
- "id": "LatLng"
- },
- "Position": {
- "description": "A 3D position in the image, used primarily for Face detection landmarks.\nA valid Position must have both x and y coordinates.\nThe position coordinates are in the same scale as the original image.",
- "type": "object",
- "properties": {
- "y": {
- "description": "Y coordinate.",
- "type": "number",
- "format": "float"
- },
- "x": {
- "description": "X coordinate.",
- "type": "number",
- "format": "float"
- },
- "z": {
- "description": "Z coordinate (or depth).",
- "type": "number",
- "format": "float"
- }
- },
- "id": "Position"
- }
- },
- "revision": "20160606",
- "basePath": "",
- "icons": {
- "x32": "http://www.google.com/images/icons/product/search-32.gif",
- "x16": "http://www.google.com/images/icons/product/search-16.gif"
- },
- "version_module": "True",
- "discoveryVersion": "v1",
- "baseUrl": "https://vision.googleapis.com/",
- "name": "vision",
- "parameters": {
- "access_token": {
- "description": "OAuth access token.",
- "type": "string",
- "location": "query"
- },
- "prettyPrint": {
- "description": "Returns response with indentations and line breaks.",
- "default": "true",
- "type": "boolean",
- "location": "query"
- },
- "key": {
- "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
- "type": "string",
- "location": "query"
- },
- "quotaUser": {
- "description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.",
- "type": "string",
- "location": "query"
- },
- "pp": {
- "description": "Pretty-print response.",
- "default": "true",
- "type": "boolean",
- "location": "query"
- },
- "fields": {
- "description": "Selector specifying which fields to include in a partial response.",
- "type": "string",
- "location": "query"
- },
- "alt": {
- "description": "Data format for response.",
- "location": "query",
- "enum": [
- "json",
- "media",
- "proto"
- ],
- "default": "json",
- "enumDescriptions": [
- "Responses with Content-Type of application/json",
- "Media download with context-dependent Content-Type",
- "Responses with Content-Type of application/x-protobuf"
- ],
- "type": "string"
- },
- "$.xgafv": {
- "description": "V1 error format.",
- "enum": [
- "1",
- "2"
- ],
- "enumDescriptions": [
- "v1 error format",
- "v2 error format"
- ],
- "type": "string",
- "location": "query"
- },
- "callback": {
- "description": "JSONP",
- "type": "string",
- "location": "query"
- },
- "oauth_token": {
- "description": "OAuth 2.0 token for the current user.",
- "type": "string",
- "location": "query"
- },
- "uploadType": {
- "description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\").",
- "type": "string",
- "location": "query"
- },
- "bearer_token": {
- "description": "OAuth bearer token.",
- "type": "string",
- "location": "query"
- },
- "upload_protocol": {
- "description": "Upload protocol for media (e.g. \"raw\", \"multipart\").",
- "type": "string",
- "location": "query"
- }
- },
- "documentationLink": "https://cloud.google.com/vision/",
- "ownerDomain": "google.com",
- "batchPath": "batch",
- "servicePath": "",
- "ownerName": "Google",
- "version": "v1",
- "rootUrl": "https://vision.googleapis.com/",
- "kind": "discovery#restDescription"
-}
diff --git a/Vision/src/Image.php b/Vision/src/Image.php
deleted file mode 100644
index f210b73ea4e8..000000000000
--- a/Vision/src/Image.php
+++ /dev/null
@@ -1,374 +0,0 @@
-image($imageResource, [
- * 'FACE_DETECTION'
- * ]);
- * ```
- *
- * ```
- * //[snippet=direct]
- * // Images can be directly instantiated.
- * use Google\Cloud\Vision\Image;
- *
- * $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- * $image = new Image($imageResource, [
- * 'FACE_DETECTION'
- * ]);
- * ```
- *
- * ```
- * //[snippet=string]
- * // Image data can be given as a string
- *
- * use Google\Cloud\Vision\Image;
- *
- * $imageData = file_get_contents(__DIR__ .'/assets/family-photo.jpg');
- * $image = new Image($imageData, [
- * 'FACE_DETECTION'
- * ]);
- * ```
- *
- * ```
- * //[snippet=gcs]
- * // Files stored in Google Cloud Storage can be used.
- * use Google\Cloud\Storage\StorageClient;
- * use Google\Cloud\Vision\Image;
- *
- * $storage = new StorageClient();
- * $file = $storage->bucket('my-test-bucket')->object('family-photo.jpg');
- * $image = new Image($file, [
- * 'FACE_DETECTION'
- * ]);
- * ```
- *
- * ```
- * //[snippet=max]
- * // This example sets a maximum results limit on one feature and provides some image context.
- *
- * use Google\Cloud\Vision\Image;
- *
- * $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- * $image = new Image($imageResource, [
- * 'FACE_DETECTION',
- * 'LOGO_DETECTION'
- * ], [
- * 'maxResults' => [
- * 'FACE_DETECTION' => 1
- * ],
- * 'imageContext' => [
- * 'latLongRect' => [
- * 'minLatLng' => [
- * 'latitude' => '-45.0',
- * 'longitude' => '-45.0'
- * ],
- * 'maxLatLng' => [
- * 'latitude' => '45.0',
- * 'longitude' => '45.0'
- * ]
- * ]
- * ]
- * ]);
- * ```
- *
- * ```
- * //[snippet=shortcut]
- * // The client library also offers shortcut names which can be used in place of the longer feature names.
- *
- * use Google\Cloud\Vision\Image;
- *
- * $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- * $image = new Image($imageResource, [
- * 'faces', // Corresponds to `FACE_DETECTION`
- * 'landmarks', // Corresponds to `LANDMARK_DETECTION`
- * 'logos', // Corresponds to `LOGO_DETECTION`
- * 'labels', // Corresponds to `LABEL_DETECTION`
- * 'text', // Corresponds to `TEXT_DETECTION`,
- * 'document', // Corresponds to `DOCUMENT_TEXT_DETECTION`
- * 'safeSearch', // Corresponds to `SAFE_SEARCH_DETECTION`
- * 'imageProperties',// Corresponds to `IMAGE_PROPERTIES`
- * 'crop', // Corresponds to `CROP_HINTS`
- * 'web' // Corresponds to `WEB_DETECTION`
- * ]);
- * ```
- *
- * @see https://cloud.google.com/vision/docs/best-practices Best Practices
- * @see https://cloud.google.com/vision/docs/pricing Pricing
- *
- * @deprecated This class is no longer supported and will be removed in a future
- * release.
- */
-class Image
-{
- const TYPE_BYTES = 'bytes';
- const TYPE_STRING = 'string';
- const TYPE_URI = 'uri';
-
- /**
- * @var mixed
- */
- private $image;
-
- /**
- * @var string
- */
- private $type;
-
- /**
- * @var array
- */
- private $features;
-
- /**
- * @var array
- */
- private $options;
-
- /**
- * A map of short names to identifiers recognized by Cloud Vision.
- *
- * @var array
- */
- private $featureShortNames = [
- 'faces' => 'FACE_DETECTION',
- 'landmarks' => 'LANDMARK_DETECTION',
- 'logos' => 'LOGO_DETECTION',
- 'labels' => 'LABEL_DETECTION',
- 'text' => 'TEXT_DETECTION',
- 'document' => 'DOCUMENT_TEXT_DETECTION',
- 'safeSearch' => 'SAFE_SEARCH_DETECTION',
- 'imageProperties' => 'IMAGE_PROPERTIES',
- 'crop' => 'CROP_HINTS',
- 'web' => 'WEB_DETECTION'
- ];
-
- /**
- * A list of allowed url schemes.
- *
- * @var array
- */
- private $urlSchemes = [
- 'http',
- 'https',
- 'gs'
- ];
-
- /**
- * Create an image with all required configuration.
- *
- * @param resource|string|StorageObject $image An image to configure with
- * the given settings. This parameter will accept a resource, a
- * string of bytes, the URI of an image in a publicly-accessible
- * web location, or an instance of {@see Google\Cloud\Storage\StorageObject}.
- * @param array $features A list of cloud vision
- * [features](https://cloud.google.com/vision/reference/rest/v1/images/annotate#type)
- * to apply to the image. Google Cloud Platform Client Library provides a set of abbreviated
- * names which can be used in the interest of brevity in place of
- * the names offered by the cloud vision service. These names are
- * `faces`, `landmarks`, `logos`, `labels`, `text`, `document`,
- * `safeSearch`, `imageProperties`, `crop`, and `web`.
- * @param array $options {
- * Configuration Options
- *
- * @type array $maxResults A list of features and the maximum number of
- * results to return. Keys should correspond to feature names
- * given in the `$features` array, and values should be of type
- * int. In all cases where `$maxResults` does not contain a value
- * for a feature, all results will be returned. In cases where
- * a `$maxResults` value is specified, the cloud vision service
- * will return results up to the `$maxResults` value, or the full
- * results, whichever is fewer.
- * @type array $imageContext See
- * [ImageContext](https://cloud.google.com/vision/reference/rest/v1/images/annotate#imagecontext)
- * for full usage details.
- * }
- * @throws InvalidArgumentException
- */
- public function __construct($image, array $features, array $options = [])
- {
- $this->options = $options + [
- 'imageContext' => [],
- 'maxResults' => []
- ];
-
- $this->features = $this->normalizeFeatures($features);
-
- $this->image = $image;
- if (is_string($image) && in_array(parse_url($image, PHP_URL_SCHEME), $this->urlSchemes)) {
- $this->type = self::TYPE_URI;
- } elseif (is_string($image)) {
- $this->type = self::TYPE_STRING;
- } elseif ($image instanceof StorageObject) {
- $this->type = self::TYPE_URI;
- $this->image = $image->gcsUri();
- } elseif (is_resource($image)) {
- $this->type = self::TYPE_BYTES;
- $this->image = Utils::streamFor($image);
- } else {
- throw new InvalidArgumentException(
- 'Given image is not valid. ' .
- 'Image must be a string of bytes, a google storage object, a valid image URI, or a resource.'
- );
- }
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Return a formatted annotate image request.
- *
- * This method is used internally by {@see VisionClient}
- * and is not generally intended for use outside of that context.
- *
- * Example:
- * ```
- * use Google\Cloud\Vision\Image;
- *
- * $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- * $image = new Image($imageResource, [
- * 'FACE_DETECTION'
- * ]);
- *
- * $requestObj = $image->requestObject();
- * ```
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#annotateimagerequest AnnotateImageRequest
- *
- * @param bool $encode [optional] If set to true, image bytes will be base64-encoded
- * (required for json/rest requests)
- * @return array
- */
- public function requestObject($encode = true)
- {
- return array_filter([
- 'image' => $this->imageObject($encode),
- 'features' => $this->features,
- 'imageContext' => $this->options['imageContext']
- ]);
- }
-
- /**
- * Create an image object.
- *
- * The structure of the returned array will vary depending on whether the
- * given image is a storage object or not.
- *
- * @see https://cloud.google.com/vision/reference/rest/v1/images/annotate#image Image
- *
- * @param bool $encode If set to true, image bytes will be base64-encoded
- * @return array [Image](https://cloud.google.com/vision/reference/rest/v1/images/annotate#image)
- */
- private function imageObject($encode)
- {
- if ($this->type === self::TYPE_BYTES) {
- $bytes = (string) $this->image;
-
- return [
- 'content' => ($encode) ? base64_encode($bytes) : $bytes
- ];
- }
-
- if ($this->type === self::TYPE_STRING) {
- $string = $this->image;
-
- return [
- 'content' => ($encode) ? base64_encode($string) : $string
- ];
- }
-
- return [
- 'source' => [
- 'imageUri' => $this->image
- ]
- ];
- }
-
- /**
- * Normalizes short feature names to identifiers compatible with the vision
- * API and adds maxResults if specified.
- *
- * @param array $features
- * @return array A list of type [Feature](https://cloud.google.com/vision/reference/rest/v1/images/annotate#feature)
- */
- private function normalizeFeatures(array $features)
- {
- $result = [];
-
- foreach ($features as $key => $feature) {
- $maxResults = $this->maxResult($feature);
-
- if (array_key_exists($feature, $this->featureShortNames)) {
- $feature = $this->featureShortNames[$feature];
- }
-
- $result[] = array_filter([
- 'type' => $feature,
- 'maxResults' => $maxResults
- ]);
- }
-
- return $result;
- }
-
- /**
- * Identify and return a maxResults value for a given feature, if maxResults
- * is specified.
- *
- * @param string $feature
- * @return mixed Int if set, null if not set.
- */
- private function maxResult($feature)
- {
- return (isset($this->options['maxResults'][$feature]))
- ? $this->options['maxResults'][$feature]
- : null;
- }
-}
diff --git a/Vision/src/V1/AddProductToProductSetRequest.php b/Vision/src/V1/AddProductToProductSetRequest.php
index b63cb1879314..576f4d539fe8 100644
--- a/Vision/src/V1/AddProductToProductSetRequest.php
+++ b/Vision/src/V1/AddProductToProductSetRequest.php
@@ -22,7 +22,7 @@ class AddProductToProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* Required. The resource name for the Product to be added to this ProductSet.
* Format is:
@@ -30,7 +30,7 @@ class AddProductToProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string product = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $product = '';
+ protected $product = '';
/**
* @param string $name Required. The resource name for the ProductSet to modify.
diff --git a/Vision/src/V1/AnnotateFileRequest.php b/Vision/src/V1/AnnotateFileRequest.php
index 55b84c3e1f67..99467c0d102c 100644
--- a/Vision/src/V1/AnnotateFileRequest.php
+++ b/Vision/src/V1/AnnotateFileRequest.php
@@ -20,7 +20,7 @@ class AnnotateFileRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.InputConfig input_config = 1;
*/
- private $input_config = null;
+ protected $input_config = null;
/**
* Required. Requested features.
*
@@ -32,7 +32,7 @@ class AnnotateFileRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.ImageContext image_context = 3;
*/
- private $image_context = null;
+ protected $image_context = null;
/**
* Pages of the file to perform image annotation.
* Pages starts from 1, we assume the first page of the file is page 1.
diff --git a/Vision/src/V1/AnnotateFileResponse.php b/Vision/src/V1/AnnotateFileResponse.php
index d6ec71da1bdb..92682231fc13 100644
--- a/Vision/src/V1/AnnotateFileResponse.php
+++ b/Vision/src/V1/AnnotateFileResponse.php
@@ -21,7 +21,7 @@ class AnnotateFileResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.InputConfig input_config = 1;
*/
- private $input_config = null;
+ protected $input_config = null;
/**
* Individual responses to images found within the file. This field will be
* empty if the `error` field is set.
@@ -34,14 +34,14 @@ class AnnotateFileResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field int32 total_pages = 3;
*/
- private $total_pages = 0;
+ protected $total_pages = 0;
/**
* If set, represents the error message for the failed request. The
* `responses` field will not be set in this case.
*
* Generated from protobuf field .google.rpc.Status error = 4;
*/
- private $error = null;
+ protected $error = null;
/**
* Constructor.
diff --git a/Vision/src/V1/AnnotateImageRequest.php b/Vision/src/V1/AnnotateImageRequest.php
index 28c0a73aef0e..87da32a59c91 100644
--- a/Vision/src/V1/AnnotateImageRequest.php
+++ b/Vision/src/V1/AnnotateImageRequest.php
@@ -21,7 +21,7 @@ class AnnotateImageRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Image image = 1;
*/
- private $image = null;
+ protected $image = null;
/**
* Requested features.
*
@@ -33,7 +33,7 @@ class AnnotateImageRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.ImageContext image_context = 3;
*/
- private $image_context = null;
+ protected $image_context = null;
/**
* Constructor.
diff --git a/Vision/src/V1/AnnotateImageResponse.php b/Vision/src/V1/AnnotateImageResponse.php
index 014f038ba3ed..5da367298068 100644
--- a/Vision/src/V1/AnnotateImageResponse.php
+++ b/Vision/src/V1/AnnotateImageResponse.php
@@ -60,37 +60,37 @@ class AnnotateImageResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.TextAnnotation full_text_annotation = 12;
*/
- private $full_text_annotation = null;
+ protected $full_text_annotation = null;
/**
* If present, safe-search annotation has completed successfully.
*
* Generated from protobuf field .google.cloud.vision.v1.SafeSearchAnnotation safe_search_annotation = 6;
*/
- private $safe_search_annotation = null;
+ protected $safe_search_annotation = null;
/**
* If present, image properties were extracted successfully.
*
* Generated from protobuf field .google.cloud.vision.v1.ImageProperties image_properties_annotation = 8;
*/
- private $image_properties_annotation = null;
+ protected $image_properties_annotation = null;
/**
* If present, crop hints have completed successfully.
*
* Generated from protobuf field .google.cloud.vision.v1.CropHintsAnnotation crop_hints_annotation = 11;
*/
- private $crop_hints_annotation = null;
+ protected $crop_hints_annotation = null;
/**
* If present, web detection has completed successfully.
*
* Generated from protobuf field .google.cloud.vision.v1.WebDetection web_detection = 13;
*/
- private $web_detection = null;
+ protected $web_detection = null;
/**
* If present, product search has completed successfully.
*
* Generated from protobuf field .google.cloud.vision.v1.ProductSearchResults product_search_results = 14;
*/
- private $product_search_results = null;
+ protected $product_search_results = null;
/**
* If set, represents the error message for the operation.
* Note that filled-in image annotations are guaranteed to be
@@ -98,14 +98,14 @@ class AnnotateImageResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.rpc.Status error = 9;
*/
- private $error = null;
+ protected $error = null;
/**
* If present, contextual information is needed to understand where this image
* comes from.
*
* Generated from protobuf field .google.cloud.vision.v1.ImageAnnotationContext context = 21;
*/
- private $context = null;
+ protected $context = null;
/**
* Constructor.
diff --git a/Vision/src/V1/AsyncAnnotateFileRequest.php b/Vision/src/V1/AsyncAnnotateFileRequest.php
index 837ca2963854..c1ebfd6cc6dc 100644
--- a/Vision/src/V1/AsyncAnnotateFileRequest.php
+++ b/Vision/src/V1/AsyncAnnotateFileRequest.php
@@ -20,7 +20,7 @@ class AsyncAnnotateFileRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.InputConfig input_config = 1;
*/
- private $input_config = null;
+ protected $input_config = null;
/**
* Required. Requested features.
*
@@ -32,13 +32,13 @@ class AsyncAnnotateFileRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.ImageContext image_context = 3;
*/
- private $image_context = null;
+ protected $image_context = null;
/**
* Required. The desired output location and metadata (e.g. format).
*
* Generated from protobuf field .google.cloud.vision.v1.OutputConfig output_config = 4;
*/
- private $output_config = null;
+ protected $output_config = null;
/**
* Constructor.
diff --git a/Vision/src/V1/AsyncAnnotateFileResponse.php b/Vision/src/V1/AsyncAnnotateFileResponse.php
index 3bb1a759cb80..1dbad5e843de 100644
--- a/Vision/src/V1/AsyncAnnotateFileResponse.php
+++ b/Vision/src/V1/AsyncAnnotateFileResponse.php
@@ -20,7 +20,7 @@ class AsyncAnnotateFileResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.OutputConfig output_config = 1;
*/
- private $output_config = null;
+ protected $output_config = null;
/**
* Constructor.
diff --git a/Vision/src/V1/AsyncBatchAnnotateFilesRequest.php b/Vision/src/V1/AsyncBatchAnnotateFilesRequest.php
index dffadc86261b..c67b7e2781f6 100644
--- a/Vision/src/V1/AsyncBatchAnnotateFilesRequest.php
+++ b/Vision/src/V1/AsyncBatchAnnotateFilesRequest.php
@@ -34,7 +34,7 @@ class AsyncBatchAnnotateFilesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 4;
*/
- private $parent = '';
+ protected $parent = '';
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
diff --git a/Vision/src/V1/AsyncBatchAnnotateImagesRequest.php b/Vision/src/V1/AsyncBatchAnnotateImagesRequest.php
index c69b10912cec..e94ee1855b9d 100644
--- a/Vision/src/V1/AsyncBatchAnnotateImagesRequest.php
+++ b/Vision/src/V1/AsyncBatchAnnotateImagesRequest.php
@@ -26,7 +26,7 @@ class AsyncBatchAnnotateImagesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.OutputConfig output_config = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $output_config = null;
+ protected $output_config = null;
/**
* Optional. Target project and location to make a call.
* Format: `projects/{project-id}/locations/{location-id}`.
@@ -39,7 +39,7 @@ class AsyncBatchAnnotateImagesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 4;
*/
- private $parent = '';
+ protected $parent = '';
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
diff --git a/Vision/src/V1/AsyncBatchAnnotateImagesResponse.php b/Vision/src/V1/AsyncBatchAnnotateImagesResponse.php
index 81b52ea726f8..6a424d1a37ce 100644
--- a/Vision/src/V1/AsyncBatchAnnotateImagesResponse.php
+++ b/Vision/src/V1/AsyncBatchAnnotateImagesResponse.php
@@ -20,7 +20,7 @@ class AsyncBatchAnnotateImagesResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.OutputConfig output_config = 1;
*/
- private $output_config = null;
+ protected $output_config = null;
/**
* Constructor.
diff --git a/Vision/src/V1/BatchAnnotateFilesRequest.php b/Vision/src/V1/BatchAnnotateFilesRequest.php
index 6f62083ef739..320d89e0dcab 100644
--- a/Vision/src/V1/BatchAnnotateFilesRequest.php
+++ b/Vision/src/V1/BatchAnnotateFilesRequest.php
@@ -34,7 +34,7 @@ class BatchAnnotateFilesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 3;
*/
- private $parent = '';
+ protected $parent = '';
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
diff --git a/Vision/src/V1/BatchAnnotateImagesRequest.php b/Vision/src/V1/BatchAnnotateImagesRequest.php
index 1b4c4113d0d4..33b0dd8968cc 100644
--- a/Vision/src/V1/BatchAnnotateImagesRequest.php
+++ b/Vision/src/V1/BatchAnnotateImagesRequest.php
@@ -33,7 +33,7 @@ class BatchAnnotateImagesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 4;
*/
- private $parent = '';
+ protected $parent = '';
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
diff --git a/Vision/src/V1/BatchOperationMetadata.php b/Vision/src/V1/BatchOperationMetadata.php
index 6174b8f7e733..e9dd818df673 100644
--- a/Vision/src/V1/BatchOperationMetadata.php
+++ b/Vision/src/V1/BatchOperationMetadata.php
@@ -22,13 +22,13 @@ class BatchOperationMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BatchOperationMetadata.State state = 1;
*/
- private $state = 0;
+ protected $state = 0;
/**
* The time when the batch request was submitted to the server.
*
* Generated from protobuf field .google.protobuf.Timestamp submit_time = 2;
*/
- private $submit_time = null;
+ protected $submit_time = null;
/**
* The time when the batch request is finished and
* [google.longrunning.Operation.done][google.longrunning.Operation.done] is
@@ -36,7 +36,7 @@ class BatchOperationMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.Timestamp end_time = 3;
*/
- private $end_time = null;
+ protected $end_time = null;
/**
* Constructor.
diff --git a/Vision/src/V1/BatchOperationMetadata/State.php b/Vision/src/V1/BatchOperationMetadata/State.php
index cba5eccd4849..13b3e197da45 100644
--- a/Vision/src/V1/BatchOperationMetadata/State.php
+++ b/Vision/src/V1/BatchOperationMetadata/State.php
@@ -76,6 +76,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(State::class, \Google\Cloud\Vision\V1\BatchOperationMetadata_State::class);
diff --git a/Vision/src/V1/BatchOperationMetadata_State.php b/Vision/src/V1/BatchOperationMetadata_State.php
deleted file mode 100644
index 39f464990c21..000000000000
--- a/Vision/src/V1/BatchOperationMetadata_State.php
+++ /dev/null
@@ -1,16 +0,0 @@
-.google.cloud.vision.v1.TextAnnotation.TextProperty property = 1;
*/
- private $property = null;
+ protected $property = null;
/**
* The bounding box for the block.
* The vertices are in the order of top-left, top-right, bottom-right,
@@ -40,7 +40,7 @@ class Block extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_box = 2;
*/
- private $bounding_box = null;
+ protected $bounding_box = null;
/**
* List of paragraphs in this block (if this blocks is of type text).
*
@@ -52,13 +52,13 @@ class Block extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Block.BlockType block_type = 4;
*/
- private $block_type = 0;
+ protected $block_type = 0;
/**
* Confidence of the OCR results on the block. Range [0, 1].
*
* Generated from protobuf field float confidence = 5;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/Block/BlockType.php b/Vision/src/V1/Block/BlockType.php
index eefde91942e3..e711cd984372 100644
--- a/Vision/src/V1/Block/BlockType.php
+++ b/Vision/src/V1/Block/BlockType.php
@@ -80,6 +80,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(BlockType::class, \Google\Cloud\Vision\V1\Block_BlockType::class);
diff --git a/Vision/src/V1/Block_BlockType.php b/Vision/src/V1/Block_BlockType.php
deleted file mode 100644
index 321ec9c02aed..000000000000
--- a/Vision/src/V1/Block_BlockType.php
+++ /dev/null
@@ -1,16 +0,0 @@
-descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : [];
+ $options = isset($this->descriptors[$methodName]['longRunning'])
+ ? $this->descriptors[$methodName]['longRunning']
+ : [];
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
$operation->reload();
return $operation;
}
+ /**
+ * Create the default operation client for the service.
+ *
+ * @param array $options ClientOptions for the client.
+ *
+ * @return OperationsClient
+ */
+ private function createOperationsClient(array $options)
+ {
+ // Unset client-specific configuration options
+ unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']);
+
+ if (isset($options['operationsClient'])) {
+ return $options['operationsClient'];
+ }
+
+ return new OperationsClient($options);
+ }
+
/**
* Formats a string containing the fully-qualified path to represent a product_set
* resource.
@@ -287,8 +308,10 @@ public function __call($method, $args)
*
* @throws ApiException Thrown if the API call fails.
*/
- public function asyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest $request, array $callOptions = []): OperationResponse
- {
+ public function asyncBatchAnnotateFiles(
+ AsyncBatchAnnotateFilesRequest $request,
+ array $callOptions = []
+ ): OperationResponse {
return $this->startApiCall('AsyncBatchAnnotateFiles', $request, $callOptions)->wait();
}
@@ -322,8 +345,10 @@ public function asyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest $request,
*
* @throws ApiException Thrown if the API call fails.
*/
- public function asyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest $request, array $callOptions = []): OperationResponse
- {
+ public function asyncBatchAnnotateImages(
+ AsyncBatchAnnotateImagesRequest $request,
+ array $callOptions = []
+ ): OperationResponse {
return $this->startApiCall('AsyncBatchAnnotateImages', $request, $callOptions)->wait();
}
@@ -354,8 +379,10 @@ public function asyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest $reques
*
* @throws ApiException Thrown if the API call fails.
*/
- public function batchAnnotateFiles(BatchAnnotateFilesRequest $request, array $callOptions = []): BatchAnnotateFilesResponse
- {
+ public function batchAnnotateFiles(
+ BatchAnnotateFilesRequest $request,
+ array $callOptions = []
+ ): BatchAnnotateFilesResponse {
return $this->startApiCall('BatchAnnotateFiles', $request, $callOptions)->wait();
}
@@ -380,8 +407,10 @@ public function batchAnnotateFiles(BatchAnnotateFilesRequest $request, array $ca
*
* @throws ApiException Thrown if the API call fails.
*/
- public function batchAnnotateImages(BatchAnnotateImagesRequest $request, array $callOptions = []): BatchAnnotateImagesResponse
- {
+ public function batchAnnotateImages(
+ BatchAnnotateImagesRequest $request,
+ array $callOptions = []
+ ): BatchAnnotateImagesResponse {
return $this->startApiCall('BatchAnnotateImages', $request, $callOptions)->wait();
}
}
diff --git a/Vision/src/V1/Client/ProductSearchClient.php b/Vision/src/V1/Client/ProductSearchClient.php
index 0a21d64767ce..f062d321ad1a 100644
--- a/Vision/src/V1/Client/ProductSearchClient.php
+++ b/Vision/src/V1/Client/ProductSearchClient.php
@@ -1,6 +1,6 @@
descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : [];
+ $options = isset($this->descriptors[$methodName]['longRunning'])
+ ? $this->descriptors[$methodName]['longRunning']
+ : [];
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
$operation->reload();
return $operation;
}
+ /**
+ * Create the default operation client for the service.
+ *
+ * @param array $options ClientOptions for the client.
+ *
+ * @return OperationsClient
+ */
+ private function createOperationsClient(array $options)
+ {
+ // Unset client-specific configuration options
+ unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']);
+
+ if (isset($options['operationsClient'])) {
+ return $options['operationsClient'];
+ }
+
+ return new OperationsClient($options);
+ }
+
/**
* Formats a string containing the fully-qualified path to represent a location
* resource.
@@ -254,8 +275,12 @@ public static function productSetName(string $project, string $location, string
*
* @return string The formatted reference_image resource.
*/
- public static function referenceImageName(string $project, string $location, string $product, string $referenceImage): string
- {
+ public static function referenceImageName(
+ string $project,
+ string $location,
+ string $product,
+ string $referenceImage
+ ): string {
return self::getPathTemplate('referenceImage')->render([
'project' => $project,
'location' => $location,
@@ -802,8 +827,10 @@ public function listProducts(ListProductsRequest $request, array $callOptions =
*
* @throws ApiException Thrown if the API call fails.
*/
- public function listProductsInProductSet(ListProductsInProductSetRequest $request, array $callOptions = []): PagedListResponse
- {
+ public function listProductsInProductSet(
+ ListProductsInProductSetRequest $request,
+ array $callOptions = []
+ ): PagedListResponse {
return $this->startApiCall('ListProductsInProductSet', $request, $callOptions);
}
@@ -908,8 +935,10 @@ public function purgeProducts(PurgeProductsRequest $request, array $callOptions
*
* @throws ApiException Thrown if the API call fails.
*/
- public function removeProductFromProductSet(RemoveProductFromProductSetRequest $request, array $callOptions = []): void
- {
+ public function removeProductFromProductSet(
+ RemoveProductFromProductSetRequest $request,
+ array $callOptions = []
+ ): void {
$this->startApiCall('RemoveProductFromProductSet', $request, $callOptions)->wait();
}
diff --git a/Vision/src/V1/ColorInfo.php b/Vision/src/V1/ColorInfo.php
index 3f8db4b93732..545a5de76ace 100644
--- a/Vision/src/V1/ColorInfo.php
+++ b/Vision/src/V1/ColorInfo.php
@@ -21,20 +21,20 @@ class ColorInfo extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.type.Color color = 1;
*/
- private $color = null;
+ protected $color = null;
/**
* Image-specific score for this color. Value in range [0, 1].
*
* Generated from protobuf field float score = 2;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* The fraction of pixels the color occupies in the image.
* Value in range [0, 1].
*
* Generated from protobuf field float pixel_fraction = 3;
*/
- private $pixel_fraction = 0.0;
+ protected $pixel_fraction = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/CreateProductRequest.php b/Vision/src/V1/CreateProductRequest.php
index e9794833dcbb..fbb905a23ca3 100644
--- a/Vision/src/V1/CreateProductRequest.php
+++ b/Vision/src/V1/CreateProductRequest.php
@@ -22,13 +22,13 @@ class CreateProductRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* Required. The product to create.
*
* Generated from protobuf field .google.cloud.vision.v1.Product product = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $product = null;
+ protected $product = null;
/**
* A user-supplied resource id for this Product. If set, the server will
* attempt to use this value as the resource id. If it is already in use, an
@@ -37,7 +37,7 @@ class CreateProductRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string product_id = 3;
*/
- private $product_id = '';
+ protected $product_id = '';
/**
* @param string $parent Required. The project in which the Product should be created.
diff --git a/Vision/src/V1/CreateProductSetRequest.php b/Vision/src/V1/CreateProductSetRequest.php
index adafbbe77f3c..06f5ef2cf0cb 100644
--- a/Vision/src/V1/CreateProductSetRequest.php
+++ b/Vision/src/V1/CreateProductSetRequest.php
@@ -21,13 +21,13 @@ class CreateProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* Required. The ProductSet to create.
*
* Generated from protobuf field .google.cloud.vision.v1.ProductSet product_set = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $product_set = null;
+ protected $product_set = null;
/**
* A user-supplied resource id for this ProductSet. If set, the server will
* attempt to use this value as the resource id. If it is already in use, an
@@ -36,7 +36,7 @@ class CreateProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string product_set_id = 3;
*/
- private $product_set_id = '';
+ protected $product_set_id = '';
/**
* @param string $parent Required. The project in which the ProductSet should be created.
diff --git a/Vision/src/V1/CreateReferenceImageRequest.php b/Vision/src/V1/CreateReferenceImageRequest.php
index 55abf6215808..ccc3b85c92ac 100644
--- a/Vision/src/V1/CreateReferenceImageRequest.php
+++ b/Vision/src/V1/CreateReferenceImageRequest.php
@@ -23,14 +23,14 @@ class CreateReferenceImageRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* Required. The reference image to create.
* If an image ID is specified, it is ignored.
*
* Generated from protobuf field .google.cloud.vision.v1.ReferenceImage reference_image = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $reference_image = null;
+ protected $reference_image = null;
/**
* A user-supplied resource id for the ReferenceImage to be added. If set,
* the server will attempt to use this value as the resource id. If it is
@@ -39,7 +39,7 @@ class CreateReferenceImageRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string reference_image_id = 3;
*/
- private $reference_image_id = '';
+ protected $reference_image_id = '';
/**
* @param string $parent Required. Resource name of the product in which to create the reference
diff --git a/Vision/src/V1/CropHint.php b/Vision/src/V1/CropHint.php
index f1e0a8d0d3e1..34593cd6e194 100644
--- a/Vision/src/V1/CropHint.php
+++ b/Vision/src/V1/CropHint.php
@@ -21,20 +21,20 @@ class CropHint extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_poly = 1;
*/
- private $bounding_poly = null;
+ protected $bounding_poly = null;
/**
* Confidence of this being a salient region. Range [0, 1].
*
* Generated from protobuf field float confidence = 2;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Fraction of importance of this salient region with respect to the original
* image.
*
* Generated from protobuf field float importance_fraction = 3;
*/
- private $importance_fraction = 0.0;
+ protected $importance_fraction = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/DeleteProductRequest.php b/Vision/src/V1/DeleteProductRequest.php
index c7f5c0686c6f..744dae5b2622 100644
--- a/Vision/src/V1/DeleteProductRequest.php
+++ b/Vision/src/V1/DeleteProductRequest.php
@@ -22,7 +22,7 @@ class DeleteProductRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. Resource name of product to delete.
diff --git a/Vision/src/V1/DeleteProductSetRequest.php b/Vision/src/V1/DeleteProductSetRequest.php
index 89ebe692cf0b..aa0ce3fb5abb 100644
--- a/Vision/src/V1/DeleteProductSetRequest.php
+++ b/Vision/src/V1/DeleteProductSetRequest.php
@@ -22,7 +22,7 @@ class DeleteProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. Resource name of the ProductSet to delete.
diff --git a/Vision/src/V1/DeleteReferenceImageRequest.php b/Vision/src/V1/DeleteReferenceImageRequest.php
index 6d82ad8850a5..f40ed15cd650 100644
--- a/Vision/src/V1/DeleteReferenceImageRequest.php
+++ b/Vision/src/V1/DeleteReferenceImageRequest.php
@@ -22,7 +22,7 @@ class DeleteReferenceImageRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. The resource name of the reference image to delete.
diff --git a/Vision/src/V1/EntityAnnotation.php b/Vision/src/V1/EntityAnnotation.php
index f957e3bd71be..4ea1b12e776c 100644
--- a/Vision/src/V1/EntityAnnotation.php
+++ b/Vision/src/V1/EntityAnnotation.php
@@ -22,26 +22,26 @@ class EntityAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string mid = 1;
*/
- private $mid = '';
+ protected $mid = '';
/**
* The language code for the locale in which the entity textual
* `description` is expressed.
*
* Generated from protobuf field string locale = 2;
*/
- private $locale = '';
+ protected $locale = '';
/**
* Entity textual description, expressed in its `locale` language.
*
* Generated from protobuf field string description = 3;
*/
- private $description = '';
+ protected $description = '';
/**
* Overall score of the result. Range [0, 1].
*
* Generated from protobuf field float score = 4;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* **Deprecated. Use `score` instead.**
* The accuracy of the entity detection in an image.
@@ -62,14 +62,14 @@ class EntityAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float topicality = 6;
*/
- private $topicality = 0.0;
+ protected $topicality = 0.0;
/**
* Image region to which this entity belongs. Not produced
* for `LABEL_DETECTION` features.
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_poly = 7;
*/
- private $bounding_poly = null;
+ protected $bounding_poly = null;
/**
* The location information for the detected entity. Multiple
* `LocationInfo` elements can be present because one location may
diff --git a/Vision/src/V1/FaceAnnotation.php b/Vision/src/V1/FaceAnnotation.php
index a2497cac1644..b9af007fead8 100644
--- a/Vision/src/V1/FaceAnnotation.php
+++ b/Vision/src/V1/FaceAnnotation.php
@@ -26,7 +26,7 @@ class FaceAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_poly = 1;
*/
- private $bounding_poly = null;
+ protected $bounding_poly = null;
/**
* The `fd_bounding_poly` bounding polygon is tighter than the
* `boundingPoly`, and encloses only the skin part of the face. Typically, it
@@ -37,7 +37,7 @@ class FaceAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly fd_bounding_poly = 2;
*/
- private $fd_bounding_poly = null;
+ protected $fd_bounding_poly = null;
/**
* Detected face landmarks.
*
@@ -51,7 +51,7 @@ class FaceAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float roll_angle = 4;
*/
- private $roll_angle = 0.0;
+ protected $roll_angle = 0.0;
/**
* Yaw angle, which indicates the leftward/rightward angle that the face is
* pointing relative to the vertical plane perpendicular to the image. Range
@@ -59,68 +59,68 @@ class FaceAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float pan_angle = 5;
*/
- private $pan_angle = 0.0;
+ protected $pan_angle = 0.0;
/**
* Pitch angle, which indicates the upwards/downwards angle that the face is
* pointing relative to the image's horizontal plane. Range [-180,180].
*
* Generated from protobuf field float tilt_angle = 6;
*/
- private $tilt_angle = 0.0;
+ protected $tilt_angle = 0.0;
/**
* Detection confidence. Range [0, 1].
*
* Generated from protobuf field float detection_confidence = 7;
*/
- private $detection_confidence = 0.0;
+ protected $detection_confidence = 0.0;
/**
* Face landmarking confidence. Range [0, 1].
*
* Generated from protobuf field float landmarking_confidence = 8;
*/
- private $landmarking_confidence = 0.0;
+ protected $landmarking_confidence = 0.0;
/**
* Joy likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood joy_likelihood = 9;
*/
- private $joy_likelihood = 0;
+ protected $joy_likelihood = 0;
/**
* Sorrow likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood sorrow_likelihood = 10;
*/
- private $sorrow_likelihood = 0;
+ protected $sorrow_likelihood = 0;
/**
* Anger likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood anger_likelihood = 11;
*/
- private $anger_likelihood = 0;
+ protected $anger_likelihood = 0;
/**
* Surprise likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood surprise_likelihood = 12;
*/
- private $surprise_likelihood = 0;
+ protected $surprise_likelihood = 0;
/**
* Under-exposed likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood under_exposed_likelihood = 13;
*/
- private $under_exposed_likelihood = 0;
+ protected $under_exposed_likelihood = 0;
/**
* Blurred likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood blurred_likelihood = 14;
*/
- private $blurred_likelihood = 0;
+ protected $blurred_likelihood = 0;
/**
* Headwear likelihood.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood headwear_likelihood = 15;
*/
- private $headwear_likelihood = 0;
+ protected $headwear_likelihood = 0;
/**
* Constructor.
diff --git a/Vision/src/V1/FaceAnnotation/Landmark.php b/Vision/src/V1/FaceAnnotation/Landmark.php
index 725a74c8dc4f..184dfa54ae39 100644
--- a/Vision/src/V1/FaceAnnotation/Landmark.php
+++ b/Vision/src/V1/FaceAnnotation/Landmark.php
@@ -20,13 +20,13 @@ class Landmark extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.FaceAnnotation.Landmark.Type type = 3;
*/
- private $type = 0;
+ protected $type = 0;
/**
* Face landmark position.
*
* Generated from protobuf field .google.cloud.vision.v1.Position position = 4;
*/
- private $position = null;
+ protected $position = null;
/**
* Constructor.
@@ -109,6 +109,4 @@ public function setPosition($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(Landmark::class, \Google\Cloud\Vision\V1\FaceAnnotation_Landmark::class);
diff --git a/Vision/src/V1/FaceAnnotation/Landmark/Type.php b/Vision/src/V1/FaceAnnotation/Landmark/Type.php
index 7aabc19d2a6d..2454ed1f7905 100644
--- a/Vision/src/V1/FaceAnnotation/Landmark/Type.php
+++ b/Vision/src/V1/FaceAnnotation/Landmark/Type.php
@@ -300,6 +300,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(Type::class, \Google\Cloud\Vision\V1\FaceAnnotation_Landmark_Type::class);
diff --git a/Vision/src/V1/FaceAnnotation_Landmark.php b/Vision/src/V1/FaceAnnotation_Landmark.php
deleted file mode 100644
index cad544c6377e..000000000000
--- a/Vision/src/V1/FaceAnnotation_Landmark.php
+++ /dev/null
@@ -1,16 +0,0 @@
-.google.cloud.vision.v1.Feature.Type type = 1;
*/
- private $type = 0;
+ protected $type = 0;
/**
* Maximum number of results of this type. Does not apply to
* `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`.
*
* Generated from protobuf field int32 max_results = 2;
*/
- private $max_results = 0;
+ protected $max_results = 0;
/**
* Model to use for the feature.
* Supported values: "builtin/stable" (the default if unset) and
@@ -38,7 +38,7 @@ class Feature extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string model = 3;
*/
- private $model = '';
+ protected $model = '';
/**
* Constructor.
diff --git a/Vision/src/V1/Feature/Type.php b/Vision/src/V1/Feature/Type.php
index d905c7320a41..55f7c8e38478 100644
--- a/Vision/src/V1/Feature/Type.php
+++ b/Vision/src/V1/Feature/Type.php
@@ -134,6 +134,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(Type::class, \Google\Cloud\Vision\V1\Feature_Type::class);
diff --git a/Vision/src/V1/Feature_Type.php b/Vision/src/V1/Feature_Type.php
deleted file mode 100644
index 771addc51720..000000000000
--- a/Vision/src/V1/Feature_Type.php
+++ /dev/null
@@ -1,16 +0,0 @@
-asyncBatchAnnotateFiles($requests);
- * $operationResponse->pollUntilComplete();
- * if ($operationResponse->operationSucceeded()) {
- * $result = $operationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $operationResponse->getError();
- * // handleError($error)
- * }
- * // Alternatively:
- * // start the operation, keep the operation name, and resume later
- * $operationResponse = $imageAnnotatorClient->asyncBatchAnnotateFiles($requests);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $imageAnnotatorClient->resumeOperation($operationName, 'asyncBatchAnnotateFiles');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $imageAnnotatorClient->close();
- * }
- * ```
- *
- * Many parameters require resource names to be formatted in a particular way. To
- * assist with these names, this class includes a format method for each type of
- * name, and additionally a parseName method to extract the individual identifiers
- * contained within formatted names that are returned by the API.
- *
- * @deprecated Please use the new service client {@see \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient}.
- */
-class ImageAnnotatorGapicClient
-{
- use GapicClientTrait;
-
- /** The name of the service. */
- const SERVICE_NAME = 'google.cloud.vision.v1.ImageAnnotator';
-
- /**
- * The default address of the service.
- *
- * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
- */
- const SERVICE_ADDRESS = 'vision.googleapis.com';
-
- /** The address template of the service. */
- private const SERVICE_ADDRESS_TEMPLATE = 'vision.UNIVERSE_DOMAIN';
-
- /** The default port of the service. */
- const DEFAULT_SERVICE_PORT = 443;
-
- /** The name of the code generator, to be included in the agent header. */
- const CODEGEN_NAME = 'gapic';
-
- /** The default scopes required by the service. */
- public static $serviceScopes = [
- 'https://www.googleapis.com/auth/cloud-platform',
- 'https://www.googleapis.com/auth/cloud-vision',
- ];
-
- private static $productSetNameTemplate;
-
- private static $pathTemplateMap;
-
- private $operationsClient;
-
- private static function getClientDefaults()
- {
- return [
- 'serviceName' => self::SERVICE_NAME,
- 'apiEndpoint' =>
- self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
- 'clientConfig' =>
- __DIR__ . '/../resources/image_annotator_client_config.json',
- 'descriptorsConfigPath' =>
- __DIR__ . '/../resources/image_annotator_descriptor_config.php',
- 'gcpApiConfigPath' =>
- __DIR__ . '/../resources/image_annotator_grpc_config.json',
- 'credentialsConfig' => [
- 'defaultScopes' => self::$serviceScopes,
- ],
- 'transportConfig' => [
- 'rest' => [
- 'restClientConfigPath' =>
- __DIR__ .
- '/../resources/image_annotator_rest_client_config.php',
- ],
- ],
- ];
- }
-
- private static function getProductSetNameTemplate()
- {
- if (self::$productSetNameTemplate == null) {
- self::$productSetNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/productSets/{product_set}'
- );
- }
-
- return self::$productSetNameTemplate;
- }
-
- private static function getPathTemplateMap()
- {
- if (self::$pathTemplateMap == null) {
- self::$pathTemplateMap = [
- 'productSet' => self::getProductSetNameTemplate(),
- ];
- }
-
- return self::$pathTemplateMap;
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a product_set
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $productSet
- *
- * @return string The formatted product_set resource.
- */
- public static function productSetName($project, $location, $productSet)
- {
- return self::getProductSetNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'product_set' => $productSet,
- ]);
- }
-
- /**
- * Parses a formatted name string and returns an associative array of the components in the name.
- * The following name formats are supported:
- * Template: Pattern
- * - productSet: projects/{project}/locations/{location}/productSets/{product_set}
- *
- * The optional $template argument can be supplied to specify a particular pattern,
- * and must match one of the templates listed above. If no $template argument is
- * provided, or if the $template argument does not match one of the templates
- * listed, then parseName will check each of the supported templates, and return
- * the first match.
- *
- * @param string $formattedName The formatted name string
- * @param string $template Optional name of template to match
- *
- * @return array An associative array from name component IDs to component values.
- *
- * @throws ValidationException If $formattedName could not be matched.
- */
- public static function parseName($formattedName, $template = null)
- {
- $templateMap = self::getPathTemplateMap();
- if ($template) {
- if (!isset($templateMap[$template])) {
- throw new ValidationException(
- "Template name $template does not exist"
- );
- }
-
- return $templateMap[$template]->match($formattedName);
- }
-
- foreach ($templateMap as $templateName => $pathTemplate) {
- try {
- return $pathTemplate->match($formattedName);
- } catch (ValidationException $ex) {
- // Swallow the exception to continue trying other path templates
- }
- }
-
- throw new ValidationException(
- "Input did not match any known format. Input: $formattedName"
- );
- }
-
- /**
- * Return an OperationsClient object with the same endpoint as $this.
- *
- * @return OperationsClient
- */
- public function getOperationsClient()
- {
- return $this->operationsClient;
- }
-
- /**
- * Resume an existing long running operation that was previously started by a long
- * running API method. If $methodName is not provided, or does not match a long
- * running API method, then the operation can still be resumed, but the
- * OperationResponse object will not deserialize the final response.
- *
- * @param string $operationName The name of the long running operation
- * @param string $methodName The name of the method used to start the operation
- *
- * @return OperationResponse
- */
- public function resumeOperation($operationName, $methodName = null)
- {
- $options = isset($this->descriptors[$methodName]['longRunning'])
- ? $this->descriptors[$methodName]['longRunning']
- : [];
- $operation = new OperationResponse(
- $operationName,
- $this->getOperationsClient(),
- $options
- );
- $operation->reload();
- return $operation;
- }
-
- /**
- * Constructor.
- *
- * @param array $options {
- * Optional. Options for configuring the service API wrapper.
- *
- * @type string $apiEndpoint
- * The address of the API remote host. May optionally include the port, formatted
- * as ":". Default 'vision.googleapis.com:443'.
- * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
- * The credentials to be used by the client to authorize API calls. This option
- * accepts either a path to a credentials file, or a decoded credentials file as a
- * PHP array.
- * *Advanced usage*: In addition, this option can also accept a pre-constructed
- * {@see \Google\Auth\FetchAuthTokenInterface} object or
- * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
- * objects are provided, any settings in $credentialsConfig will be ignored.
- * @type array $credentialsConfig
- * Options used to configure credentials, including auth token caching, for the
- * client. For a full list of supporting configuration options, see
- * {@see \Google\ApiCore\CredentialsWrapper::build()} .
- * @type bool $disableRetries
- * Determines whether or not retries defined by the client configuration should be
- * disabled. Defaults to `false`.
- * @type string|array $clientConfig
- * Client method configuration, including retry settings. This option can be either
- * a path to a JSON file, or a PHP array containing the decoded JSON data. By
- * default this settings points to the default client config file, which is
- * provided in the resources folder.
- * @type string|TransportInterface $transport
- * The transport used for executing network requests. May be either the string
- * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system.
- * *Advanced usage*: Additionally, it is possible to pass in an already
- * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note
- * that when this object is provided, any settings in $transportConfig, and any
- * $apiEndpoint setting, will be ignored.
- * @type array $transportConfig
- * Configuration options that will be used to construct the transport. Options for
- * each supported transport type should be passed in a key for that transport. For
- * example:
- * $transportConfig = [
- * 'grpc' => [...],
- * 'rest' => [...],
- * ];
- * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and
- * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the
- * supported options.
- * @type callable $clientCertSource
- * A callable which returns the client cert as a string. This can be used to
- * provide a certificate and private key to the transport layer for mTLS.
- * }
- *
- * @throws ValidationException
- */
- public function __construct(array $options = [])
- {
- $clientOptions = $this->buildClientOptions($options);
- $this->setClientOptions($clientOptions);
- $this->operationsClient = $this->createOperationsClient($clientOptions);
- }
-
- /**
- * Run asynchronous image detection and annotation for a list of generic
- * files, such as PDF files, which may contain multiple pages and multiple
- * images per page. Progress and results can be retrieved through the
- * `google.longrunning.Operations` interface.
- * `Operation.metadata` contains `OperationMetadata` (metadata).
- * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
- *
- * Sample code:
- * ```
- * $imageAnnotatorClient = new ImageAnnotatorClient();
- * try {
- * $requests = [];
- * $operationResponse = $imageAnnotatorClient->asyncBatchAnnotateFiles($requests);
- * $operationResponse->pollUntilComplete();
- * if ($operationResponse->operationSucceeded()) {
- * $result = $operationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $operationResponse->getError();
- * // handleError($error)
- * }
- * // Alternatively:
- * // start the operation, keep the operation name, and resume later
- * $operationResponse = $imageAnnotatorClient->asyncBatchAnnotateFiles($requests);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $imageAnnotatorClient->resumeOperation($operationName, 'asyncBatchAnnotateFiles');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $imageAnnotatorClient->close();
- * }
- * ```
- *
- * @param AsyncAnnotateFileRequest[] $requests Required. Individual async file annotation requests for this batch.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $parent
- * Optional. Target project and location to make a call.
- *
- * Format: `projects/{project-id}/locations/{location-id}`.
- *
- * If no parent is specified, a region will be chosen automatically.
- *
- * Supported location-ids:
- * `us`: USA country only,
- * `asia`: East asia areas, like Japan, Taiwan,
- * `eu`: The European Union.
- *
- * Example: `projects/project-A/locations/eu`.
- * @type array $labels
- * Optional. The labels with user-defined metadata for the request.
- *
- * Label keys and values can be no longer than 63 characters
- * (Unicode codepoints), can only contain lowercase letters, numeric
- * characters, underscores and dashes. International characters are allowed.
- * Label values are optional. Label keys must start with a letter.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\OperationResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function asyncBatchAnnotateFiles($requests, array $optionalArgs = [])
- {
- $request = new AsyncBatchAnnotateFilesRequest();
- $requestParamHeaders = [];
- $request->setRequests($requests);
- if (isset($optionalArgs['parent'])) {
- $request->setParent($optionalArgs['parent']);
- $requestParamHeaders['parent'] = $optionalArgs['parent'];
- }
-
- if (isset($optionalArgs['labels'])) {
- $request->setLabels($optionalArgs['labels']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'AsyncBatchAnnotateFiles',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Run asynchronous image detection and annotation for a list of images.
- *
- * Progress and results can be retrieved through the
- * `google.longrunning.Operations` interface.
- * `Operation.metadata` contains `OperationMetadata` (metadata).
- * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
- *
- * This service will write image annotation outputs to json files in customer
- * GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
- *
- * Sample code:
- * ```
- * $imageAnnotatorClient = new ImageAnnotatorClient();
- * try {
- * $requests = [];
- * $outputConfig = new OutputConfig();
- * $operationResponse = $imageAnnotatorClient->asyncBatchAnnotateImages($requests, $outputConfig);
- * $operationResponse->pollUntilComplete();
- * if ($operationResponse->operationSucceeded()) {
- * $result = $operationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $operationResponse->getError();
- * // handleError($error)
- * }
- * // Alternatively:
- * // start the operation, keep the operation name, and resume later
- * $operationResponse = $imageAnnotatorClient->asyncBatchAnnotateImages($requests, $outputConfig);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $imageAnnotatorClient->resumeOperation($operationName, 'asyncBatchAnnotateImages');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $imageAnnotatorClient->close();
- * }
- * ```
- *
- * @param AnnotateImageRequest[] $requests Required. Individual image annotation requests for this batch.
- * @param OutputConfig $outputConfig Required. The desired output location and metadata (e.g. format).
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $parent
- * Optional. Target project and location to make a call.
- *
- * Format: `projects/{project-id}/locations/{location-id}`.
- *
- * If no parent is specified, a region will be chosen automatically.
- *
- * Supported location-ids:
- * `us`: USA country only,
- * `asia`: East asia areas, like Japan, Taiwan,
- * `eu`: The European Union.
- *
- * Example: `projects/project-A/locations/eu`.
- * @type array $labels
- * Optional. The labels with user-defined metadata for the request.
- *
- * Label keys and values can be no longer than 63 characters
- * (Unicode codepoints), can only contain lowercase letters, numeric
- * characters, underscores and dashes. International characters are allowed.
- * Label values are optional. Label keys must start with a letter.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\OperationResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function asyncBatchAnnotateImages(
- $requests,
- $outputConfig,
- array $optionalArgs = []
- ) {
- $request = new AsyncBatchAnnotateImagesRequest();
- $requestParamHeaders = [];
- $request->setRequests($requests);
- $request->setOutputConfig($outputConfig);
- if (isset($optionalArgs['parent'])) {
- $request->setParent($optionalArgs['parent']);
- $requestParamHeaders['parent'] = $optionalArgs['parent'];
- }
-
- if (isset($optionalArgs['labels'])) {
- $request->setLabels($optionalArgs['labels']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'AsyncBatchAnnotateImages',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Service that performs image detection and annotation for a batch of files.
- * Now only "application/pdf", "image/tiff" and "image/gif" are supported.
- *
- * This service will extract at most 5 (customers can specify which 5 in
- * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
- * file provided and perform detection and annotation for each image
- * extracted.
- *
- * Sample code:
- * ```
- * $imageAnnotatorClient = new ImageAnnotatorClient();
- * try {
- * $requests = [];
- * $response = $imageAnnotatorClient->batchAnnotateFiles($requests);
- * } finally {
- * $imageAnnotatorClient->close();
- * }
- * ```
- *
- * @param AnnotateFileRequest[] $requests Required. The list of file annotation requests. Right now we support only
- * one AnnotateFileRequest in BatchAnnotateFilesRequest.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $parent
- * Optional. Target project and location to make a call.
- *
- * Format: `projects/{project-id}/locations/{location-id}`.
- *
- * If no parent is specified, a region will be chosen automatically.
- *
- * Supported location-ids:
- * `us`: USA country only,
- * `asia`: East asia areas, like Japan, Taiwan,
- * `eu`: The European Union.
- *
- * Example: `projects/project-A/locations/eu`.
- * @type array $labels
- * Optional. The labels with user-defined metadata for the request.
- *
- * Label keys and values can be no longer than 63 characters
- * (Unicode codepoints), can only contain lowercase letters, numeric
- * characters, underscores and dashes. International characters are allowed.
- * Label values are optional. Label keys must start with a letter.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\BatchAnnotateFilesResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function batchAnnotateFiles($requests, array $optionalArgs = [])
- {
- $request = new BatchAnnotateFilesRequest();
- $requestParamHeaders = [];
- $request->setRequests($requests);
- if (isset($optionalArgs['parent'])) {
- $request->setParent($optionalArgs['parent']);
- $requestParamHeaders['parent'] = $optionalArgs['parent'];
- }
-
- if (isset($optionalArgs['labels'])) {
- $request->setLabels($optionalArgs['labels']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'BatchAnnotateFiles',
- BatchAnnotateFilesResponse::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Run image detection and annotation for a batch of images.
- *
- * Sample code:
- * ```
- * $imageAnnotatorClient = new ImageAnnotatorClient();
- * try {
- * $requests = [];
- * $response = $imageAnnotatorClient->batchAnnotateImages($requests);
- * } finally {
- * $imageAnnotatorClient->close();
- * }
- * ```
- *
- * @param AnnotateImageRequest[] $requests Required. Individual image annotation requests for this batch.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $parent
- * Optional. Target project and location to make a call.
- *
- * Format: `projects/{project-id}/locations/{location-id}`.
- *
- * If no parent is specified, a region will be chosen automatically.
- *
- * Supported location-ids:
- * `us`: USA country only,
- * `asia`: East asia areas, like Japan, Taiwan,
- * `eu`: The European Union.
- *
- * Example: `projects/project-A/locations/eu`.
- * @type array $labels
- * Optional. The labels with user-defined metadata for the request.
- *
- * Label keys and values can be no longer than 63 characters
- * (Unicode codepoints), can only contain lowercase letters, numeric
- * characters, underscores and dashes. International characters are allowed.
- * Label values are optional. Label keys must start with a letter.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\BatchAnnotateImagesResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function batchAnnotateImages($requests, array $optionalArgs = [])
- {
- $request = new BatchAnnotateImagesRequest();
- $requestParamHeaders = [];
- $request->setRequests($requests);
- if (isset($optionalArgs['parent'])) {
- $request->setParent($optionalArgs['parent']);
- $requestParamHeaders['parent'] = $optionalArgs['parent'];
- }
-
- if (isset($optionalArgs['labels'])) {
- $request->setLabels($optionalArgs['labels']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'BatchAnnotateImages',
- BatchAnnotateImagesResponse::class,
- $optionalArgs,
- $request
- )->wait();
- }
-}
diff --git a/Vision/src/V1/Gapic/ProductSearchGapicClient.php b/Vision/src/V1/Gapic/ProductSearchGapicClient.php
deleted file mode 100644
index 03a38ad8ffd7..000000000000
--- a/Vision/src/V1/Gapic/ProductSearchGapicClient.php
+++ /dev/null
@@ -1,1821 +0,0 @@
-productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- * $formattedProduct = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * $productSearchClient->addProductToProductSet($formattedName, $formattedProduct);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * Many parameters require resource names to be formatted in a particular way. To
- * assist with these names, this class includes a format method for each type of
- * name, and additionally a parseName method to extract the individual identifiers
- * contained within formatted names that are returned by the API.
- *
- * @deprecated Please use the new service client {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient}.
- */
-class ProductSearchGapicClient
-{
- use GapicClientTrait;
-
- /** The name of the service. */
- const SERVICE_NAME = 'google.cloud.vision.v1.ProductSearch';
-
- /**
- * The default address of the service.
- *
- * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
- */
- const SERVICE_ADDRESS = 'vision.googleapis.com';
-
- /** The address template of the service. */
- private const SERVICE_ADDRESS_TEMPLATE = 'vision.UNIVERSE_DOMAIN';
-
- /** The default port of the service. */
- const DEFAULT_SERVICE_PORT = 443;
-
- /** The name of the code generator, to be included in the agent header. */
- const CODEGEN_NAME = 'gapic';
-
- /** The default scopes required by the service. */
- public static $serviceScopes = [
- 'https://www.googleapis.com/auth/cloud-platform',
- 'https://www.googleapis.com/auth/cloud-vision',
- ];
-
- private static $locationNameTemplate;
-
- private static $productNameTemplate;
-
- private static $productSetNameTemplate;
-
- private static $referenceImageNameTemplate;
-
- private static $pathTemplateMap;
-
- private $operationsClient;
-
- private static function getClientDefaults()
- {
- return [
- 'serviceName' => self::SERVICE_NAME,
- 'apiEndpoint' =>
- self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
- 'clientConfig' =>
- __DIR__ . '/../resources/product_search_client_config.json',
- 'descriptorsConfigPath' =>
- __DIR__ . '/../resources/product_search_descriptor_config.php',
- 'gcpApiConfigPath' =>
- __DIR__ . '/../resources/product_search_grpc_config.json',
- 'credentialsConfig' => [
- 'defaultScopes' => self::$serviceScopes,
- ],
- 'transportConfig' => [
- 'rest' => [
- 'restClientConfigPath' =>
- __DIR__ .
- '/../resources/product_search_rest_client_config.php',
- ],
- ],
- ];
- }
-
- private static function getLocationNameTemplate()
- {
- if (self::$locationNameTemplate == null) {
- self::$locationNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}'
- );
- }
-
- return self::$locationNameTemplate;
- }
-
- private static function getProductNameTemplate()
- {
- if (self::$productNameTemplate == null) {
- self::$productNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/products/{product}'
- );
- }
-
- return self::$productNameTemplate;
- }
-
- private static function getProductSetNameTemplate()
- {
- if (self::$productSetNameTemplate == null) {
- self::$productSetNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/productSets/{product_set}'
- );
- }
-
- return self::$productSetNameTemplate;
- }
-
- private static function getReferenceImageNameTemplate()
- {
- if (self::$referenceImageNameTemplate == null) {
- self::$referenceImageNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}'
- );
- }
-
- return self::$referenceImageNameTemplate;
- }
-
- private static function getPathTemplateMap()
- {
- if (self::$pathTemplateMap == null) {
- self::$pathTemplateMap = [
- 'location' => self::getLocationNameTemplate(),
- 'product' => self::getProductNameTemplate(),
- 'productSet' => self::getProductSetNameTemplate(),
- 'referenceImage' => self::getReferenceImageNameTemplate(),
- ];
- }
-
- return self::$pathTemplateMap;
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a location
- * resource.
- *
- * @param string $project
- * @param string $location
- *
- * @return string The formatted location resource.
- */
- public static function locationName($project, $location)
- {
- return self::getLocationNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- ]);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a product
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $product
- *
- * @return string The formatted product resource.
- */
- public static function productName($project, $location, $product)
- {
- return self::getProductNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'product' => $product,
- ]);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a product_set
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $productSet
- *
- * @return string The formatted product_set resource.
- */
- public static function productSetName($project, $location, $productSet)
- {
- return self::getProductSetNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'product_set' => $productSet,
- ]);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a
- * reference_image resource.
- *
- * @param string $project
- * @param string $location
- * @param string $product
- * @param string $referenceImage
- *
- * @return string The formatted reference_image resource.
- */
- public static function referenceImageName(
- $project,
- $location,
- $product,
- $referenceImage
- ) {
- return self::getReferenceImageNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'product' => $product,
- 'reference_image' => $referenceImage,
- ]);
- }
-
- /**
- * Parses a formatted name string and returns an associative array of the components in the name.
- * The following name formats are supported:
- * Template: Pattern
- * - location: projects/{project}/locations/{location}
- * - product: projects/{project}/locations/{location}/products/{product}
- * - productSet: projects/{project}/locations/{location}/productSets/{product_set}
- * - referenceImage: projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}
- *
- * The optional $template argument can be supplied to specify a particular pattern,
- * and must match one of the templates listed above. If no $template argument is
- * provided, or if the $template argument does not match one of the templates
- * listed, then parseName will check each of the supported templates, and return
- * the first match.
- *
- * @param string $formattedName The formatted name string
- * @param string $template Optional name of template to match
- *
- * @return array An associative array from name component IDs to component values.
- *
- * @throws ValidationException If $formattedName could not be matched.
- */
- public static function parseName($formattedName, $template = null)
- {
- $templateMap = self::getPathTemplateMap();
- if ($template) {
- if (!isset($templateMap[$template])) {
- throw new ValidationException(
- "Template name $template does not exist"
- );
- }
-
- return $templateMap[$template]->match($formattedName);
- }
-
- foreach ($templateMap as $templateName => $pathTemplate) {
- try {
- return $pathTemplate->match($formattedName);
- } catch (ValidationException $ex) {
- // Swallow the exception to continue trying other path templates
- }
- }
-
- throw new ValidationException(
- "Input did not match any known format. Input: $formattedName"
- );
- }
-
- /**
- * Return an OperationsClient object with the same endpoint as $this.
- *
- * @return OperationsClient
- */
- public function getOperationsClient()
- {
- return $this->operationsClient;
- }
-
- /**
- * Resume an existing long running operation that was previously started by a long
- * running API method. If $methodName is not provided, or does not match a long
- * running API method, then the operation can still be resumed, but the
- * OperationResponse object will not deserialize the final response.
- *
- * @param string $operationName The name of the long running operation
- * @param string $methodName The name of the method used to start the operation
- *
- * @return OperationResponse
- */
- public function resumeOperation($operationName, $methodName = null)
- {
- $options = isset($this->descriptors[$methodName]['longRunning'])
- ? $this->descriptors[$methodName]['longRunning']
- : [];
- $operation = new OperationResponse(
- $operationName,
- $this->getOperationsClient(),
- $options
- );
- $operation->reload();
- return $operation;
- }
-
- /**
- * Constructor.
- *
- * @param array $options {
- * Optional. Options for configuring the service API wrapper.
- *
- * @type string $apiEndpoint
- * The address of the API remote host. May optionally include the port, formatted
- * as ":". Default 'vision.googleapis.com:443'.
- * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
- * The credentials to be used by the client to authorize API calls. This option
- * accepts either a path to a credentials file, or a decoded credentials file as a
- * PHP array.
- * *Advanced usage*: In addition, this option can also accept a pre-constructed
- * {@see \Google\Auth\FetchAuthTokenInterface} object or
- * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
- * objects are provided, any settings in $credentialsConfig will be ignored.
- * @type array $credentialsConfig
- * Options used to configure credentials, including auth token caching, for the
- * client. For a full list of supporting configuration options, see
- * {@see \Google\ApiCore\CredentialsWrapper::build()} .
- * @type bool $disableRetries
- * Determines whether or not retries defined by the client configuration should be
- * disabled. Defaults to `false`.
- * @type string|array $clientConfig
- * Client method configuration, including retry settings. This option can be either
- * a path to a JSON file, or a PHP array containing the decoded JSON data. By
- * default this settings points to the default client config file, which is
- * provided in the resources folder.
- * @type string|TransportInterface $transport
- * The transport used for executing network requests. May be either the string
- * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system.
- * *Advanced usage*: Additionally, it is possible to pass in an already
- * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note
- * that when this object is provided, any settings in $transportConfig, and any
- * $apiEndpoint setting, will be ignored.
- * @type array $transportConfig
- * Configuration options that will be used to construct the transport. Options for
- * each supported transport type should be passed in a key for that transport. For
- * example:
- * $transportConfig = [
- * 'grpc' => [...],
- * 'rest' => [...],
- * ];
- * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and
- * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the
- * supported options.
- * @type callable $clientCertSource
- * A callable which returns the client cert as a string. This can be used to
- * provide a certificate and private key to the transport layer for mTLS.
- * }
- *
- * @throws ValidationException
- */
- public function __construct(array $options = [])
- {
- $clientOptions = $this->buildClientOptions($options);
- $this->setClientOptions($clientOptions);
- $this->operationsClient = $this->createOperationsClient($clientOptions);
- }
-
- /**
- * Adds a Product to the specified ProductSet. If the Product is already
- * present, no change is made.
- *
- * One Product can be added to at most 100 ProductSets.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- * $formattedProduct = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * $productSearchClient->addProductToProductSet($formattedName, $formattedProduct);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. The resource name for the ProductSet to modify.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
- * @param string $product Required. The resource name for the Product to be added to this ProductSet.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @throws ApiException if the remote call fails
- */
- public function addProductToProductSet(
- $name,
- $product,
- array $optionalArgs = []
- ) {
- $request = new AddProductToProductSetRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $request->setProduct($product);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'AddProductToProductSet',
- GPBEmpty::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Creates and returns a new product resource.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096
- * characters.
- * * Returns INVALID_ARGUMENT if description is longer than 4096 characters.
- * * Returns INVALID_ARGUMENT if product_category is missing or invalid.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->locationName('[PROJECT]', '[LOCATION]');
- * $product = new Product();
- * $response = $productSearchClient->createProduct($formattedParent, $product);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project in which the Product should be created.
- *
- * Format is
- * `projects/PROJECT_ID/locations/LOC_ID`.
- * @param Product $product Required. The product to create.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $productId
- * A user-supplied resource id for this Product. If set, the server will
- * attempt to use this value as the resource id. If it is already in use, an
- * error is returned with code ALREADY_EXISTS. Must be at most 128 characters
- * long. It cannot contain the character `/`.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\Product
- *
- * @throws ApiException if the remote call fails
- */
- public function createProduct($parent, $product, array $optionalArgs = [])
- {
- $request = new CreateProductRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $request->setProduct($product);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['productId'])) {
- $request->setProductId($optionalArgs['productId']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'CreateProduct',
- Product::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Creates and returns a new ProductSet resource.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than
- * 4096 characters.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->locationName('[PROJECT]', '[LOCATION]');
- * $productSet = new ProductSet();
- * $response = $productSearchClient->createProductSet($formattedParent, $productSet);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project in which the ProductSet should be created.
- *
- * Format is `projects/PROJECT_ID/locations/LOC_ID`.
- * @param ProductSet $productSet Required. The ProductSet to create.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $productSetId
- * A user-supplied resource id for this ProductSet. If set, the server will
- * attempt to use this value as the resource id. If it is already in use, an
- * error is returned with code ALREADY_EXISTS. Must be at most 128 characters
- * long. It cannot contain the character `/`.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\ProductSet
- *
- * @throws ApiException if the remote call fails
- */
- public function createProductSet(
- $parent,
- $productSet,
- array $optionalArgs = []
- ) {
- $request = new CreateProductSetRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $request->setProductSet($productSet);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['productSetId'])) {
- $request->setProductSetId($optionalArgs['productSetId']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'CreateProductSet',
- ProductSet::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Creates and returns a new ReferenceImage resource.
- *
- * The `bounding_poly` field is optional. If `bounding_poly` is not specified,
- * the system will try to detect regions of interest in the image that are
- * compatible with the product_category on the parent product. If it is
- * specified, detection is ALWAYS skipped. The system converts polygons into
- * non-rotated rectangles.
- *
- * Note that the pipeline will resize the image if the image resolution is too
- * large to process (above 50MP).
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096
- * characters.
- * * Returns INVALID_ARGUMENT if the product does not exist.
- * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing
- * compatible with the parent product's product_category is detected.
- * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * $referenceImage = new ReferenceImage();
- * $response = $productSearchClient->createReferenceImage($formattedParent, $referenceImage);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. Resource name of the product in which to create the reference
- * image.
- *
- * Format is
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
- * @param ReferenceImage $referenceImage Required. The reference image to create.
- * If an image ID is specified, it is ignored.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $referenceImageId
- * A user-supplied resource id for the ReferenceImage to be added. If set,
- * the server will attempt to use this value as the resource id. If it is
- * already in use, an error is returned with code ALREADY_EXISTS. Must be at
- * most 128 characters long. It cannot contain the character `/`.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\ReferenceImage
- *
- * @throws ApiException if the remote call fails
- */
- public function createReferenceImage(
- $parent,
- $referenceImage,
- array $optionalArgs = []
- ) {
- $request = new CreateReferenceImageRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $request->setReferenceImage($referenceImage);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['referenceImageId'])) {
- $request->setReferenceImageId($optionalArgs['referenceImageId']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'CreateReferenceImage',
- ReferenceImage::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Permanently deletes a product and its reference images.
- *
- * Metadata of the product and all its images will be deleted right away, but
- * search queries against ProductSets containing the product may still work
- * until all related caches are refreshed.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * $productSearchClient->deleteProduct($formattedName);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. Resource name of product to delete.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @throws ApiException if the remote call fails
- */
- public function deleteProduct($name, array $optionalArgs = [])
- {
- $request = new DeleteProductRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'DeleteProduct',
- GPBEmpty::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Permanently deletes a ProductSet. Products and ReferenceImages in the
- * ProductSet are not deleted.
- *
- * The actual image files are not deleted from Google Cloud Storage.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- * $productSearchClient->deleteProductSet($formattedName);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. Resource name of the ProductSet to delete.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @throws ApiException if the remote call fails
- */
- public function deleteProductSet($name, array $optionalArgs = [])
- {
- $request = new DeleteProductSetRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'DeleteProductSet',
- GPBEmpty::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Permanently deletes a reference image.
- *
- * The image metadata will be deleted right away, but search queries
- * against ProductSets containing the image may still work until all related
- * caches are refreshed.
- *
- * The actual image files are not deleted from Google Cloud Storage.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- * $productSearchClient->deleteReferenceImage($formattedName);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. The resource name of the reference image to delete.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @throws ApiException if the remote call fails
- */
- public function deleteReferenceImage($name, array $optionalArgs = [])
- {
- $request = new DeleteReferenceImageRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'DeleteReferenceImage',
- GPBEmpty::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Gets information associated with a Product.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the Product does not exist.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * $response = $productSearchClient->getProduct($formattedName);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. Resource name of the Product to get.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\Product
- *
- * @throws ApiException if the remote call fails
- */
- public function getProduct($name, array $optionalArgs = [])
- {
- $request = new GetProductRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'GetProduct',
- Product::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Gets information associated with a ProductSet.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the ProductSet does not exist.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- * $response = $productSearchClient->getProductSet($formattedName);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. Resource name of the ProductSet to get.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\ProductSet
- *
- * @throws ApiException if the remote call fails
- */
- public function getProductSet($name, array $optionalArgs = [])
- {
- $request = new GetProductSetRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'GetProductSet',
- ProductSet::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Gets information associated with a ReferenceImage.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the specified image does not exist.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- * $response = $productSearchClient->getReferenceImage($formattedName);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. The resource name of the ReferenceImage to get.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\ReferenceImage
- *
- * @throws ApiException if the remote call fails
- */
- public function getReferenceImage($name, array $optionalArgs = [])
- {
- $request = new GetReferenceImageRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'GetReferenceImage',
- ReferenceImage::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Asynchronous API that imports a list of reference images to specified
- * product sets based on a list of image information.
- *
- * The [google.longrunning.Operation][google.longrunning.Operation] API can be
- * used to keep track of the progress and results of the request.
- * `Operation.metadata` contains `BatchOperationMetadata`. (progress)
- * `Operation.response` contains `ImportProductSetsResponse`. (results)
- *
- * The input source of this method is a csv file on Google Cloud Storage.
- * For the format of the csv file please see
- * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->locationName('[PROJECT]', '[LOCATION]');
- * $inputConfig = new ImportProductSetsInputConfig();
- * $operationResponse = $productSearchClient->importProductSets($formattedParent, $inputConfig);
- * $operationResponse->pollUntilComplete();
- * if ($operationResponse->operationSucceeded()) {
- * $result = $operationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $operationResponse->getError();
- * // handleError($error)
- * }
- * // Alternatively:
- * // start the operation, keep the operation name, and resume later
- * $operationResponse = $productSearchClient->importProductSets($formattedParent, $inputConfig);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $productSearchClient->resumeOperation($operationName, 'importProductSets');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * $result = $newOperationResponse->getResult();
- * // doSomethingWith($result)
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project in which the ProductSets should be imported.
- *
- * Format is `projects/PROJECT_ID/locations/LOC_ID`.
- * @param ImportProductSetsInputConfig $inputConfig Required. The input content for the list of requests.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\OperationResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function importProductSets(
- $parent,
- $inputConfig,
- array $optionalArgs = []
- ) {
- $request = new ImportProductSetsRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $request->setInputConfig($inputConfig);
- $requestParamHeaders['parent'] = $parent;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'ImportProductSets',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Lists ProductSets in an unspecified order.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less
- * than 1.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->locationName('[PROJECT]', '[LOCATION]');
- * // Iterate over pages of elements
- * $pagedResponse = $productSearchClient->listProductSets($formattedParent);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $productSearchClient->listProductSets($formattedParent);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project from which ProductSets should be listed.
- *
- * Format is `projects/PROJECT_ID/locations/LOC_ID`.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type int $pageSize
- * The maximum number of resources contained in the underlying API
- * response. The API may return fewer values in a page, even if
- * there are additional values to be retrieved.
- * @type string $pageToken
- * A page token is used to specify a page of values to be returned.
- * If no page token is specified (the default), the first page
- * of values will be returned. Any page token used here must have
- * been generated by a previous call to the API.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\PagedListResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function listProductSets($parent, array $optionalArgs = [])
- {
- $request = new ListProductSetsRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['pageSize'])) {
- $request->setPageSize($optionalArgs['pageSize']);
- }
-
- if (isset($optionalArgs['pageToken'])) {
- $request->setPageToken($optionalArgs['pageToken']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->getPagedListResponse(
- 'ListProductSets',
- $optionalArgs,
- ListProductSetsResponse::class,
- $request
- );
- }
-
- /**
- * Lists products in an unspecified order.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->locationName('[PROJECT]', '[LOCATION]');
- * // Iterate over pages of elements
- * $pagedResponse = $productSearchClient->listProducts($formattedParent);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $productSearchClient->listProducts($formattedParent);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project OR ProductSet from which Products should be listed.
- *
- * Format:
- * `projects/PROJECT_ID/locations/LOC_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type int $pageSize
- * The maximum number of resources contained in the underlying API
- * response. The API may return fewer values in a page, even if
- * there are additional values to be retrieved.
- * @type string $pageToken
- * A page token is used to specify a page of values to be returned.
- * If no page token is specified (the default), the first page
- * of values will be returned. Any page token used here must have
- * been generated by a previous call to the API.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\PagedListResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function listProducts($parent, array $optionalArgs = [])
- {
- $request = new ListProductsRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['pageSize'])) {
- $request->setPageSize($optionalArgs['pageSize']);
- }
-
- if (isset($optionalArgs['pageToken'])) {
- $request->setPageToken($optionalArgs['pageToken']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->getPagedListResponse(
- 'ListProducts',
- $optionalArgs,
- ListProductsResponse::class,
- $request
- );
- }
-
- /**
- * Lists the Products in a ProductSet, in an unspecified order. If the
- * ProductSet does not exist, the products field of the response will be
- * empty.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- * // Iterate over pages of elements
- * $pagedResponse = $productSearchClient->listProductsInProductSet($formattedName);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $productSearchClient->listProductsInProductSet($formattedName);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. The ProductSet resource for which to retrieve Products.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type int $pageSize
- * The maximum number of resources contained in the underlying API
- * response. The API may return fewer values in a page, even if
- * there are additional values to be retrieved.
- * @type string $pageToken
- * A page token is used to specify a page of values to be returned.
- * If no page token is specified (the default), the first page
- * of values will be returned. Any page token used here must have
- * been generated by a previous call to the API.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\PagedListResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function listProductsInProductSet($name, array $optionalArgs = [])
- {
- $request = new ListProductsInProductSetRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $requestParamHeaders['name'] = $name;
- if (isset($optionalArgs['pageSize'])) {
- $request->setPageSize($optionalArgs['pageSize']);
- }
-
- if (isset($optionalArgs['pageToken'])) {
- $request->setPageToken($optionalArgs['pageToken']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->getPagedListResponse(
- 'ListProductsInProductSet',
- $optionalArgs,
- ListProductsInProductSetResponse::class,
- $request
- );
- }
-
- /**
- * Lists reference images.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the parent product does not exist.
- * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less
- * than 1.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * // Iterate over pages of elements
- * $pagedResponse = $productSearchClient->listReferenceImages($formattedParent);
- * foreach ($pagedResponse->iteratePages() as $page) {
- * foreach ($page as $element) {
- * // doSomethingWith($element);
- * }
- * }
- * // Alternatively:
- * // Iterate through all elements
- * $pagedResponse = $productSearchClient->listReferenceImages($formattedParent);
- * foreach ($pagedResponse->iterateAllElements() as $element) {
- * // doSomethingWith($element);
- * }
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. Resource name of the product containing the reference images.
- *
- * Format is
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type int $pageSize
- * The maximum number of resources contained in the underlying API
- * response. The API may return fewer values in a page, even if
- * there are additional values to be retrieved.
- * @type string $pageToken
- * A page token is used to specify a page of values to be returned.
- * If no page token is specified (the default), the first page
- * of values will be returned. Any page token used here must have
- * been generated by a previous call to the API.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\PagedListResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function listReferenceImages($parent, array $optionalArgs = [])
- {
- $request = new ListReferenceImagesRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['pageSize'])) {
- $request->setPageSize($optionalArgs['pageSize']);
- }
-
- if (isset($optionalArgs['pageToken'])) {
- $request->setPageToken($optionalArgs['pageToken']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->getPagedListResponse(
- 'ListReferenceImages',
- $optionalArgs,
- ListReferenceImagesResponse::class,
- $request
- );
- }
-
- /**
- * Asynchronous API to delete all Products in a ProductSet or all Products
- * that are in no ProductSet.
- *
- * If a Product is a member of the specified ProductSet in addition to other
- * ProductSets, the Product will still be deleted.
- *
- * It is recommended to not delete the specified ProductSet until after this
- * operation has completed. It is also recommended to not add any of the
- * Products involved in the batch delete to a new ProductSet while this
- * operation is running because those Products may still end up deleted.
- *
- * It's not possible to undo the PurgeProducts operation. Therefore, it is
- * recommended to keep the csv files used in ImportProductSets (if that was
- * how you originally built the Product Set) before starting PurgeProducts, in
- * case you need to re-import the data after deletion.
- *
- * If the plan is to purge all of the Products from a ProductSet and then
- * re-use the empty ProductSet to re-import new Products into the empty
- * ProductSet, you must wait until the PurgeProducts operation has finished
- * for that ProductSet.
- *
- * The [google.longrunning.Operation][google.longrunning.Operation] API can be
- * used to keep track of the progress and results of the request.
- * `Operation.metadata` contains `BatchOperationMetadata`. (progress)
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedParent = $productSearchClient->locationName('[PROJECT]', '[LOCATION]');
- * $operationResponse = $productSearchClient->purgeProducts($formattedParent);
- * $operationResponse->pollUntilComplete();
- * if ($operationResponse->operationSucceeded()) {
- * // operation succeeded and returns no value
- * } else {
- * $error = $operationResponse->getError();
- * // handleError($error)
- * }
- * // Alternatively:
- * // start the operation, keep the operation name, and resume later
- * $operationResponse = $productSearchClient->purgeProducts($formattedParent);
- * $operationName = $operationResponse->getName();
- * // ... do other work
- * $newOperationResponse = $productSearchClient->resumeOperation($operationName, 'purgeProducts');
- * while (!$newOperationResponse->isDone()) {
- * // ... do other work
- * $newOperationResponse->reload();
- * }
- * if ($newOperationResponse->operationSucceeded()) {
- * // operation succeeded and returns no value
- * } else {
- * $error = $newOperationResponse->getError();
- * // handleError($error)
- * }
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $parent Required. The project and location in which the Products should be deleted.
- *
- * Format is `projects/PROJECT_ID/locations/LOC_ID`.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type ProductSetPurgeConfig $productSetPurgeConfig
- * Specify which ProductSet contains the Products to be deleted.
- * @type bool $deleteOrphanProducts
- * If delete_orphan_products is true, all Products that are not in any
- * ProductSet will be deleted.
- * @type bool $force
- * The default value is false. Override this value to true to actually perform
- * the purge.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\ApiCore\OperationResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function purgeProducts($parent, array $optionalArgs = [])
- {
- $request = new PurgeProductsRequest();
- $requestParamHeaders = [];
- $request->setParent($parent);
- $requestParamHeaders['parent'] = $parent;
- if (isset($optionalArgs['productSetPurgeConfig'])) {
- $request->setProductSetPurgeConfig(
- $optionalArgs['productSetPurgeConfig']
- );
- }
-
- if (isset($optionalArgs['deleteOrphanProducts'])) {
- $request->setDeleteOrphanProducts(
- $optionalArgs['deleteOrphanProducts']
- );
- }
-
- if (isset($optionalArgs['force'])) {
- $request->setForce($optionalArgs['force']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startOperationsCall(
- 'PurgeProducts',
- $optionalArgs,
- $request,
- $this->getOperationsClient()
- )->wait();
- }
-
- /**
- * Removes a Product from the specified ProductSet.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $formattedName = $productSearchClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- * $formattedProduct = $productSearchClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- * $productSearchClient->removeProductFromProductSet($formattedName, $formattedProduct);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param string $name Required. The resource name for the ProductSet to modify.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
- * @param string $product Required. The resource name for the Product to be removed from this
- * ProductSet.
- *
- * Format is:
- * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
- * @param array $optionalArgs {
- * Optional.
- *
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @throws ApiException if the remote call fails
- */
- public function removeProductFromProductSet(
- $name,
- $product,
- array $optionalArgs = []
- ) {
- $request = new RemoveProductFromProductSetRequest();
- $requestParamHeaders = [];
- $request->setName($name);
- $request->setProduct($product);
- $requestParamHeaders['name'] = $name;
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'RemoveProductFromProductSet',
- GPBEmpty::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Makes changes to a Product resource.
- * Only the `display_name`, `description`, and `labels` fields can be updated
- * right now.
- *
- * If labels are updated, the change will not be reflected in queries until
- * the next index time.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the Product does not exist.
- * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is
- * missing from the request or longer than 4096 characters.
- * * Returns INVALID_ARGUMENT if description is present in update_mask but is
- * longer than 4096 characters.
- * * Returns INVALID_ARGUMENT if product_category is present in update_mask.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $product = new Product();
- * $response = $productSearchClient->updateProduct($product);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param Product $product Required. The Product resource which replaces the one on the server.
- * product.name is immutable.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type FieldMask $updateMask
- * The [FieldMask][google.protobuf.FieldMask] that specifies which fields
- * to update.
- * If update_mask isn't specified, all mutable fields are to be updated.
- * Valid mask paths include `product_labels`, `display_name`, and
- * `description`.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\Product
- *
- * @throws ApiException if the remote call fails
- */
- public function updateProduct($product, array $optionalArgs = [])
- {
- $request = new UpdateProductRequest();
- $requestParamHeaders = [];
- $request->setProduct($product);
- $requestParamHeaders['product.name'] = $product->getName();
- if (isset($optionalArgs['updateMask'])) {
- $request->setUpdateMask($optionalArgs['updateMask']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'UpdateProduct',
- Product::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Makes changes to a ProductSet resource.
- * Only display_name can be updated currently.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the ProductSet does not exist.
- * * Returns INVALID_ARGUMENT if display_name is present in update_mask but
- * missing from the request or longer than 4096 characters.
- *
- * Sample code:
- * ```
- * $productSearchClient = new ProductSearchClient();
- * try {
- * $productSet = new ProductSet();
- * $response = $productSearchClient->updateProductSet($productSet);
- * } finally {
- * $productSearchClient->close();
- * }
- * ```
- *
- * @param ProductSet $productSet Required. The ProductSet resource which replaces the one on the server.
- * @param array $optionalArgs {
- * Optional.
- *
- * @type FieldMask $updateMask
- * The [FieldMask][google.protobuf.FieldMask] that specifies which fields to
- * update.
- * If update_mask isn't specified, all mutable fields are to be updated.
- * Valid mask path is `display_name`.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
- * associative array of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return \Google\Cloud\Vision\V1\ProductSet
- *
- * @throws ApiException if the remote call fails
- */
- public function updateProductSet($productSet, array $optionalArgs = [])
- {
- $request = new UpdateProductSetRequest();
- $requestParamHeaders = [];
- $request->setProductSet($productSet);
- $requestParamHeaders['product_set.name'] = $productSet->getName();
- if (isset($optionalArgs['updateMask'])) {
- $request->setUpdateMask($optionalArgs['updateMask']);
- }
-
- $requestParams = new RequestParamsHeaderDescriptor(
- $requestParamHeaders
- );
- $optionalArgs['headers'] = isset($optionalArgs['headers'])
- ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
- : $requestParams->getHeader();
- return $this->startCall(
- 'UpdateProductSet',
- ProductSet::class,
- $optionalArgs,
- $request
- )->wait();
- }
-}
diff --git a/Vision/src/V1/GcsDestination.php b/Vision/src/V1/GcsDestination.php
index ea60023f3100..5e5f3f520ee1 100644
--- a/Vision/src/V1/GcsDestination.php
+++ b/Vision/src/V1/GcsDestination.php
@@ -37,7 +37,7 @@ class GcsDestination extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string uri = 1;
*/
- private $uri = '';
+ protected $uri = '';
/**
* Constructor.
diff --git a/Vision/src/V1/GcsSource.php b/Vision/src/V1/GcsSource.php
index 1eb1af8f5b64..e7c46ae00ad3 100644
--- a/Vision/src/V1/GcsSource.php
+++ b/Vision/src/V1/GcsSource.php
@@ -21,7 +21,7 @@ class GcsSource extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string uri = 1;
*/
- private $uri = '';
+ protected $uri = '';
/**
* Constructor.
diff --git a/Vision/src/V1/GetProductRequest.php b/Vision/src/V1/GetProductRequest.php
index 5f55af3f8a06..8716aa759f18 100644
--- a/Vision/src/V1/GetProductRequest.php
+++ b/Vision/src/V1/GetProductRequest.php
@@ -22,7 +22,7 @@ class GetProductRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. Resource name of the Product to get.
diff --git a/Vision/src/V1/GetProductSetRequest.php b/Vision/src/V1/GetProductSetRequest.php
index 62de33b462da..f133d964a1f9 100644
--- a/Vision/src/V1/GetProductSetRequest.php
+++ b/Vision/src/V1/GetProductSetRequest.php
@@ -22,7 +22,7 @@ class GetProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. Resource name of the ProductSet to get.
diff --git a/Vision/src/V1/GetReferenceImageRequest.php b/Vision/src/V1/GetReferenceImageRequest.php
index 6ef7a5082beb..87a13da256c2 100644
--- a/Vision/src/V1/GetReferenceImageRequest.php
+++ b/Vision/src/V1/GetReferenceImageRequest.php
@@ -22,7 +22,7 @@ class GetReferenceImageRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* @param string $name Required. The resource name of the ReferenceImage to get.
diff --git a/Vision/src/V1/Image.php b/Vision/src/V1/Image.php
index f85626a186b8..a829768dbbe8 100644
--- a/Vision/src/V1/Image.php
+++ b/Vision/src/V1/Image.php
@@ -24,7 +24,7 @@ class Image extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bytes content = 1;
*/
- private $content = '';
+ protected $content = '';
/**
* Google Cloud Storage image location, or publicly-accessible image
* URL. If both `content` and `source` are provided for an image, `content`
@@ -32,7 +32,7 @@ class Image extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.ImageSource source = 2;
*/
- private $source = null;
+ protected $source = null;
/**
* Constructor.
diff --git a/Vision/src/V1/ImageAnnotationContext.php b/Vision/src/V1/ImageAnnotationContext.php
index 4f8c24386e8b..04aba2e4a1dc 100644
--- a/Vision/src/V1/ImageAnnotationContext.php
+++ b/Vision/src/V1/ImageAnnotationContext.php
@@ -21,14 +21,14 @@ class ImageAnnotationContext extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string uri = 1;
*/
- private $uri = '';
+ protected $uri = '';
/**
* If the file was a PDF or TIFF, this field gives the page number within
* the file used to produce the image.
*
* Generated from protobuf field int32 page_number = 2;
*/
- private $page_number = 0;
+ protected $page_number = 0;
/**
* Constructor.
diff --git a/Vision/src/V1/ImageAnnotatorClient.php b/Vision/src/V1/ImageAnnotatorClient.php
deleted file mode 100644
index a8db43756c89..000000000000
--- a/Vision/src/V1/ImageAnnotatorClient.php
+++ /dev/null
@@ -1,558 +0,0 @@
-createImageObject($imageResource);
- * $response = $imageAnnotatorClient->faceDetection($image);
- * ```
- *
- * ```
- * //[snippet=data]
- * $imageData = file_get_contents('path/to/image.jpg');
- * $image = $imageAnnotatorClient->createImageObject($imageData);
- * $response = $imageAnnotatorClient->faceDetection($image);
- * ```
- *
- * ```
- * //[snippet=url]
- * $imageUri = "gs://my-bucket/image.jpg";
- * $image = $imageAnnotatorClient->createImageObject($imageUri);
- * $response = $imageAnnotatorClient->faceDetection($image);
- * ```
- *
- * @param resource|string $imageInput An image to configure with
- * the given settings. This parameter will accept a resource, a
- * string of bytes, or the URI of an image in a publicly-accessible
- * web location.
- * @return Image
- * @throws InvalidArgumentException
- */
- public function createImageObject($imageInput)
- {
- return $this->createImageHelper(Image::class, ImageSource::class, $imageInput);
- }
-
- /**
- * Run image detection and annotation for an image.
- *
- * Example:
- * ```
- * use Google\Cloud\Vision\V1\Feature;
- * use Google\Cloud\Vision\V1\Feature\Type;
- *
- * $imageResource = fopen('path/to/image.jpg', 'r');
- * $features = [Type::FACE_DETECTION];
- * $response = $imageAnnotatorClient->annotateImage($imageResource, $features);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param Feature[]|int[] $features Requested features.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function annotateImage($image, $features, $optionalArgs = [])
- {
- $image = $this->createImageObject($image);
- return $this->annotateImageHelper(
- [$this, 'batchAnnotateImages'],
- AnnotateImageRequest::class,
- $image,
- $features,
- $optionalArgs
- );
- }
-
- /**
- * Run face detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->faceDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function faceDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::FACE_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run landmark detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->landmarkDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function landmarkDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::LANDMARK_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run logo detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->logoDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function logoDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::LOGO_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run label detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->labelDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function labelDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::LABEL_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run text detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->textDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function textDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::TEXT_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run document text detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->documentTextDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function documentTextDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::DOCUMENT_TEXT_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run safe search detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->safeSearchDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function safeSearchDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::SAFE_SEARCH_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run image properties detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->imagePropertiesDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function imagePropertiesDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::IMAGE_PROPERTIES,
- $optionalArgs
- );
- }
-
- /**
- * Run crop hints detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->cropHintsDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function cropHintsDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::CROP_HINTS,
- $optionalArgs
- );
- }
-
- /**
- * Run web detection for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->webDetection($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function webDetection($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::WEB_DETECTION,
- $optionalArgs
- );
- }
-
- /**
- * Run object localization for an image.
- *
- * Example:
- * ```
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $response = $imageAnnotatorClient->objectLocalization($imageContent);
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function objectLocalization($image, $optionalArgs = [])
- {
- return $this->annotateSingleFeature(
- $image,
- Type::OBJECT_LOCALIZATION,
- $optionalArgs
- );
- }
-
- /**
- * Run product search for an image.
- *
- * Example:
- * ```
- * use Google\Cloud\Vision\V1\ProductSearchClient;
- * use Google\Cloud\Vision\V1\ProductSearchParams;
- *
- * $imageContent = file_get_contents('path/to/image.jpg');
- * $productSetName = ProductSearchClient::productSetName('PROJECT_ID', 'LOC_ID', 'PRODUCT_SET_ID');
- * $productSearchParams = (new ProductSearchParams)
- * ->setProductSet($productSetName);
- * $response = $imageAnnotatorClient->productSearch(
- * $imageContent,
- * $productSearchParams
- * );
- * ```
- *
- * @param resource|string|Image $image The image to be processed.
- * @param ProductSearchParams $productSearchParams Parameters for a product search request. Please note, this
- * value will override the {@see ProductSearchParams} in the
- * {@see ImageContext} instance if provided.
- * @param array $optionalArgs {
- * Configuration Options.
- *
- * @type ImageContext $imageContext Additional context that may accompany the image.
- * @type RetrySettings|array $retrySettings
- * Retry settings to use for this call. Can be a
- * {@see RetrySettings} object, or an associative array
- * of retry settings parameters. See the documentation on
- * {@see RetrySettings} for example usage.
- * }
- *
- * @return AnnotateImageResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function productSearch($image, ProductSearchParams $productSearchParams, $optionalArgs = [])
- {
- if (isset($optionalArgs['imageContext']) && $optionalArgs['imageContext'] instanceof ImageContext) {
- $optionalArgs['imageContext']->setProductSearchParams($productSearchParams);
- } else {
- $optionalArgs['imageContext'] = (new ImageContext)
- ->setProductSearchParams($productSearchParams);
- }
-
- return $this->annotateSingleFeature(
- $image,
- Type::PRODUCT_SEARCH,
- $optionalArgs
- );
- }
-
- /**
- * @param Image $image
- * @param Feature|int $featureType
- * @param array $optionalArgs
- * @return AnnotateImageResponse
- */
- private function annotateSingleFeature($image, $featureType, $optionalArgs)
- {
- return $this->annotateImage($image, [$featureType], $optionalArgs);
- }
-}
diff --git a/Vision/src/V1/ImageAnnotatorGrpcClient.php b/Vision/src/V1/ImageAnnotatorGrpcClient.php
deleted file mode 100644
index 02ed612778c7..000000000000
--- a/Vision/src/V1/ImageAnnotatorGrpcClient.php
+++ /dev/null
@@ -1,116 +0,0 @@
-_simpleRequest('/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages',
- $argument,
- ['\Google\Cloud\Vision\V1\BatchAnnotateImagesResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Service that performs image detection and annotation for a batch of files.
- * Now only "application/pdf", "image/tiff" and "image/gif" are supported.
- *
- * This service will extract at most 5 (customers can specify which 5 in
- * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
- * file provided and perform detection and annotation for each image
- * extracted.
- * @param \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function BatchAnnotateFiles(\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles',
- $argument,
- ['\Google\Cloud\Vision\V1\BatchAnnotateFilesResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Run asynchronous image detection and annotation for a list of images.
- *
- * Progress and results can be retrieved through the
- * `google.longrunning.Operations` interface.
- * `Operation.metadata` contains `OperationMetadata` (metadata).
- * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
- *
- * This service will write image annotation outputs to json files in customer
- * GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
- * @param \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function AsyncBatchAnnotateImages(\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Run asynchronous image detection and annotation for a list of generic
- * files, such as PDF files, which may contain multiple pages and multiple
- * images per page. Progress and results can be retrieved through the
- * `google.longrunning.Operations` interface.
- * `Operation.metadata` contains `OperationMetadata` (metadata).
- * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
- * @param \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function AsyncBatchAnnotateFiles(\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
-}
diff --git a/Vision/src/V1/ImageContext.php b/Vision/src/V1/ImageContext.php
index 9e08bcfb50d9..25a6e9b648ce 100644
--- a/Vision/src/V1/ImageContext.php
+++ b/Vision/src/V1/ImageContext.php
@@ -20,7 +20,7 @@ class ImageContext extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.LatLongRect lat_long_rect = 1;
*/
- private $lat_long_rect = null;
+ protected $lat_long_rect = null;
/**
* List of languages to use for TEXT_DETECTION. In most cases, an empty value
* yields the best results since it enables automatic language detection. For
@@ -39,25 +39,25 @@ class ImageContext extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.CropHintsParams crop_hints_params = 4;
*/
- private $crop_hints_params = null;
+ protected $crop_hints_params = null;
/**
* Parameters for product search.
*
* Generated from protobuf field .google.cloud.vision.v1.ProductSearchParams product_search_params = 5;
*/
- private $product_search_params = null;
+ protected $product_search_params = null;
/**
* Parameters for web detection.
*
* Generated from protobuf field .google.cloud.vision.v1.WebDetectionParams web_detection_params = 6;
*/
- private $web_detection_params = null;
+ protected $web_detection_params = null;
/**
* Parameters for text detection and document text detection.
*
* Generated from protobuf field .google.cloud.vision.v1.TextDetectionParams text_detection_params = 12;
*/
- private $text_detection_params = null;
+ protected $text_detection_params = null;
/**
* Constructor.
diff --git a/Vision/src/V1/ImageProperties.php b/Vision/src/V1/ImageProperties.php
index a4b5f87576aa..05d082b53f75 100644
--- a/Vision/src/V1/ImageProperties.php
+++ b/Vision/src/V1/ImageProperties.php
@@ -20,7 +20,7 @@ class ImageProperties extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.DominantColorsAnnotation dominant_colors = 1;
*/
- private $dominant_colors = null;
+ protected $dominant_colors = null;
/**
* Constructor.
diff --git a/Vision/src/V1/ImageSource.php b/Vision/src/V1/ImageSource.php
index 64a32d840027..977a6a7406c4 100644
--- a/Vision/src/V1/ImageSource.php
+++ b/Vision/src/V1/ImageSource.php
@@ -24,7 +24,7 @@ class ImageSource extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string gcs_image_uri = 1;
*/
- private $gcs_image_uri = '';
+ protected $gcs_image_uri = '';
/**
* The URI of the source image. Can be either:
* 1. A Google Cloud Storage URI of the form
@@ -43,7 +43,7 @@ class ImageSource extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string image_uri = 2;
*/
- private $image_uri = '';
+ protected $image_uri = '';
/**
* Constructor.
diff --git a/Vision/src/V1/ImportProductSetsGcsSource.php b/Vision/src/V1/ImportProductSetsGcsSource.php
index 3f7db71dd598..b6e1d5818b47 100644
--- a/Vision/src/V1/ImportProductSetsGcsSource.php
+++ b/Vision/src/V1/ImportProductSetsGcsSource.php
@@ -69,7 +69,7 @@ class ImportProductSetsGcsSource extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string csv_file_uri = 1;
*/
- private $csv_file_uri = '';
+ protected $csv_file_uri = '';
/**
* Constructor.
diff --git a/Vision/src/V1/ImportProductSetsRequest.php b/Vision/src/V1/ImportProductSetsRequest.php
index c8ec7ccbd47a..24ecfc858acb 100644
--- a/Vision/src/V1/ImportProductSetsRequest.php
+++ b/Vision/src/V1/ImportProductSetsRequest.php
@@ -21,13 +21,13 @@ class ImportProductSetsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* Required. The input content for the list of requests.
*
* Generated from protobuf field .google.cloud.vision.v1.ImportProductSetsInputConfig input_config = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $input_config = null;
+ protected $input_config = null;
/**
* @param string $parent Required. The project in which the ProductSets should be imported.
diff --git a/Vision/src/V1/InputConfig.php b/Vision/src/V1/InputConfig.php
index 0742d9ba9de2..7fc7ef2d630c 100644
--- a/Vision/src/V1/InputConfig.php
+++ b/Vision/src/V1/InputConfig.php
@@ -20,7 +20,7 @@ class InputConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.GcsSource gcs_source = 1;
*/
- private $gcs_source = null;
+ protected $gcs_source = null;
/**
* File content, represented as a stream of bytes.
* Note: As with all `bytes` fields, protobuffers use a pure binary
@@ -30,14 +30,14 @@ class InputConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bytes content = 3;
*/
- private $content = '';
+ protected $content = '';
/**
* The type of the file. Currently only "application/pdf", "image/tiff" and
* "image/gif" are supported. Wildcards are not supported.
*
* Generated from protobuf field string mime_type = 2;
*/
- private $mime_type = '';
+ protected $mime_type = '';
/**
* Constructor.
diff --git a/Vision/src/V1/LatLongRect.php b/Vision/src/V1/LatLongRect.php
index ad1fcb7bf56a..c582fe6217f4 100644
--- a/Vision/src/V1/LatLongRect.php
+++ b/Vision/src/V1/LatLongRect.php
@@ -20,13 +20,13 @@ class LatLongRect extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.type.LatLng min_lat_lng = 1;
*/
- private $min_lat_lng = null;
+ protected $min_lat_lng = null;
/**
* Max lat/long pair.
*
* Generated from protobuf field .google.type.LatLng max_lat_lng = 2;
*/
- private $max_lat_lng = null;
+ protected $max_lat_lng = null;
/**
* Constructor.
diff --git a/Vision/src/V1/ListProductSetsRequest.php b/Vision/src/V1/ListProductSetsRequest.php
index 87bb3be3bb0f..c2ca9f793d5a 100644
--- a/Vision/src/V1/ListProductSetsRequest.php
+++ b/Vision/src/V1/ListProductSetsRequest.php
@@ -21,19 +21,19 @@ class ListProductSetsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* The maximum number of items to return. Default 10, maximum 100.
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* The next_page_token returned from a previous List request, if any.
*
* Generated from protobuf field string page_token = 3;
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* @param string $parent Required. The project from which ProductSets should be listed.
diff --git a/Vision/src/V1/ListProductSetsResponse.php b/Vision/src/V1/ListProductSetsResponse.php
index c4bc3ca7d7af..6fb58f3ea6d7 100644
--- a/Vision/src/V1/ListProductSetsResponse.php
+++ b/Vision/src/V1/ListProductSetsResponse.php
@@ -27,7 +27,7 @@ class ListProductSetsResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string next_page_token = 2;
*/
- private $next_page_token = '';
+ protected $next_page_token = '';
/**
* Constructor.
diff --git a/Vision/src/V1/ListProductsInProductSetRequest.php b/Vision/src/V1/ListProductsInProductSetRequest.php
index 1694201f0a84..70a71c26a951 100644
--- a/Vision/src/V1/ListProductsInProductSetRequest.php
+++ b/Vision/src/V1/ListProductsInProductSetRequest.php
@@ -22,19 +22,19 @@ class ListProductsInProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* The maximum number of items to return. Default 10, maximum 100.
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* The next_page_token returned from a previous List request, if any.
*
* Generated from protobuf field string page_token = 3;
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* @param string $name Required. The ProductSet resource for which to retrieve Products.
diff --git a/Vision/src/V1/ListProductsInProductSetResponse.php b/Vision/src/V1/ListProductsInProductSetResponse.php
index 026b674cfac2..550e51fc19f7 100644
--- a/Vision/src/V1/ListProductsInProductSetResponse.php
+++ b/Vision/src/V1/ListProductsInProductSetResponse.php
@@ -27,7 +27,7 @@ class ListProductsInProductSetResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string next_page_token = 2;
*/
- private $next_page_token = '';
+ protected $next_page_token = '';
/**
* Constructor.
diff --git a/Vision/src/V1/ListProductsRequest.php b/Vision/src/V1/ListProductsRequest.php
index feec3e8e5c58..e6efb131265a 100644
--- a/Vision/src/V1/ListProductsRequest.php
+++ b/Vision/src/V1/ListProductsRequest.php
@@ -22,19 +22,19 @@ class ListProductsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* The maximum number of items to return. Default 10, maximum 100.
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* The next_page_token returned from a previous List request, if any.
*
* Generated from protobuf field string page_token = 3;
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* @param string $parent Required. The project OR ProductSet from which Products should be listed.
diff --git a/Vision/src/V1/ListProductsResponse.php b/Vision/src/V1/ListProductsResponse.php
index 0136626773fa..192d6f3a9a11 100644
--- a/Vision/src/V1/ListProductsResponse.php
+++ b/Vision/src/V1/ListProductsResponse.php
@@ -27,7 +27,7 @@ class ListProductsResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string next_page_token = 2;
*/
- private $next_page_token = '';
+ protected $next_page_token = '';
/**
* Constructor.
diff --git a/Vision/src/V1/ListReferenceImagesRequest.php b/Vision/src/V1/ListReferenceImagesRequest.php
index 75417445e135..fb833ada7722 100644
--- a/Vision/src/V1/ListReferenceImagesRequest.php
+++ b/Vision/src/V1/ListReferenceImagesRequest.php
@@ -22,13 +22,13 @@ class ListReferenceImagesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* The maximum number of items to return. Default 10, maximum 100.
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* A token identifying a page of results to be returned. This is the value
* of `nextPageToken` returned in a previous reference image list request.
@@ -36,7 +36,7 @@ class ListReferenceImagesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string page_token = 3;
*/
- private $page_token = '';
+ protected $page_token = '';
/**
* @param string $parent Required. Resource name of the product containing the reference images.
diff --git a/Vision/src/V1/ListReferenceImagesResponse.php b/Vision/src/V1/ListReferenceImagesResponse.php
index 1151a6e633f3..bf552bad802f 100644
--- a/Vision/src/V1/ListReferenceImagesResponse.php
+++ b/Vision/src/V1/ListReferenceImagesResponse.php
@@ -26,13 +26,13 @@ class ListReferenceImagesResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field int32 page_size = 2;
*/
- private $page_size = 0;
+ protected $page_size = 0;
/**
* The next_page_token returned from a previous List request, if any.
*
* Generated from protobuf field string next_page_token = 3;
*/
- private $next_page_token = '';
+ protected $next_page_token = '';
/**
* Constructor.
diff --git a/Vision/src/V1/LocalizedObjectAnnotation.php b/Vision/src/V1/LocalizedObjectAnnotation.php
index 35efa7f0f79b..6e85feb7fede 100644
--- a/Vision/src/V1/LocalizedObjectAnnotation.php
+++ b/Vision/src/V1/LocalizedObjectAnnotation.php
@@ -20,7 +20,7 @@ class LocalizedObjectAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string mid = 1;
*/
- private $mid = '';
+ protected $mid = '';
/**
* The BCP-47 language code, such as "en-US" or "sr-Latn". For more
* information, see
@@ -28,25 +28,25 @@ class LocalizedObjectAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string language_code = 2;
*/
- private $language_code = '';
+ protected $language_code = '';
/**
* Object name, expressed in its `language_code` language.
*
* Generated from protobuf field string name = 3;
*/
- private $name = '';
+ protected $name = '';
/**
* Score of the result. Range [0, 1].
*
* Generated from protobuf field float score = 4;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* Image region to which this object belongs. This must be populated.
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_poly = 5;
*/
- private $bounding_poly = null;
+ protected $bounding_poly = null;
/**
* Constructor.
diff --git a/Vision/src/V1/LocationInfo.php b/Vision/src/V1/LocationInfo.php
index 50ad741a1d2e..02c79371bf4d 100644
--- a/Vision/src/V1/LocationInfo.php
+++ b/Vision/src/V1/LocationInfo.php
@@ -20,7 +20,7 @@ class LocationInfo extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.type.LatLng lat_lng = 1;
*/
- private $lat_lng = null;
+ protected $lat_lng = null;
/**
* Constructor.
diff --git a/Vision/src/V1/NormalizedVertex.php b/Vision/src/V1/NormalizedVertex.php
index 16e89f6dc35f..20d663aa3bd5 100644
--- a/Vision/src/V1/NormalizedVertex.php
+++ b/Vision/src/V1/NormalizedVertex.php
@@ -22,13 +22,13 @@ class NormalizedVertex extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float x = 1;
*/
- private $x = 0.0;
+ protected $x = 0.0;
/**
* Y coordinate.
*
* Generated from protobuf field float y = 2;
*/
- private $y = 0.0;
+ protected $y = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/OperationMetadata.php b/Vision/src/V1/OperationMetadata.php
index 91aead790f4f..ae546b7644c5 100644
--- a/Vision/src/V1/OperationMetadata.php
+++ b/Vision/src/V1/OperationMetadata.php
@@ -20,19 +20,19 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.OperationMetadata.State state = 1;
*/
- private $state = 0;
+ protected $state = 0;
/**
* The time when the batch request was received.
*
* Generated from protobuf field .google.protobuf.Timestamp create_time = 5;
*/
- private $create_time = null;
+ protected $create_time = null;
/**
* The time when the operation result was last updated.
*
* Generated from protobuf field .google.protobuf.Timestamp update_time = 6;
*/
- private $update_time = null;
+ protected $update_time = null;
/**
* Constructor.
diff --git a/Vision/src/V1/OperationMetadata/State.php b/Vision/src/V1/OperationMetadata/State.php
index 345f7bb0a591..35cfdde91bc9 100644
--- a/Vision/src/V1/OperationMetadata/State.php
+++ b/Vision/src/V1/OperationMetadata/State.php
@@ -73,6 +73,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(State::class, \Google\Cloud\Vision\V1\OperationMetadata_State::class);
diff --git a/Vision/src/V1/OperationMetadata_State.php b/Vision/src/V1/OperationMetadata_State.php
deleted file mode 100644
index e4d68a92e0f6..000000000000
--- a/Vision/src/V1/OperationMetadata_State.php
+++ /dev/null
@@ -1,16 +0,0 @@
-.google.cloud.vision.v1.GcsDestination gcs_destination = 1;
*/
- private $gcs_destination = null;
+ protected $gcs_destination = null;
/**
* The max number of response protos to put into each output JSON file on
* Google Cloud Storage.
@@ -34,7 +34,7 @@ class OutputConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field int32 batch_size = 2;
*/
- private $batch_size = 0;
+ protected $batch_size = 0;
/**
* Constructor.
diff --git a/Vision/src/V1/Page.php b/Vision/src/V1/Page.php
index 2934950b4239..26020d0280b5 100644
--- a/Vision/src/V1/Page.php
+++ b/Vision/src/V1/Page.php
@@ -20,21 +20,21 @@ class Page extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.TextAnnotation.TextProperty property = 1;
*/
- private $property = null;
+ protected $property = null;
/**
* Page width. For PDFs the unit is points. For images (including
* TIFFs) the unit is pixels.
*
* Generated from protobuf field int32 width = 2;
*/
- private $width = 0;
+ protected $width = 0;
/**
* Page height. For PDFs the unit is points. For images (including
* TIFFs) the unit is pixels.
*
* Generated from protobuf field int32 height = 3;
*/
- private $height = 0;
+ protected $height = 0;
/**
* List of blocks of text, images etc on this page.
*
@@ -46,7 +46,7 @@ class Page extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float confidence = 5;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/Paragraph.php b/Vision/src/V1/Paragraph.php
index 1aab0b6ef3a0..0dbbb5b4367f 100644
--- a/Vision/src/V1/Paragraph.php
+++ b/Vision/src/V1/Paragraph.php
@@ -20,7 +20,7 @@ class Paragraph extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.TextAnnotation.TextProperty property = 1;
*/
- private $property = null;
+ protected $property = null;
/**
* The bounding box for the paragraph.
* The vertices are in the order of top-left, top-right, bottom-right,
@@ -40,7 +40,7 @@ class Paragraph extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_box = 2;
*/
- private $bounding_box = null;
+ protected $bounding_box = null;
/**
* List of all words in this paragraph.
*
@@ -52,7 +52,7 @@ class Paragraph extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float confidence = 4;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/Position.php b/Vision/src/V1/Position.php
index 75133540e94b..198ed9067d2e 100644
--- a/Vision/src/V1/Position.php
+++ b/Vision/src/V1/Position.php
@@ -22,19 +22,19 @@ class Position extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float x = 1;
*/
- private $x = 0.0;
+ protected $x = 0.0;
/**
* Y coordinate.
*
* Generated from protobuf field float y = 2;
*/
- private $y = 0.0;
+ protected $y = 0.0;
/**
* Z coordinate (or depth).
*
* Generated from protobuf field float z = 3;
*/
- private $z = 0.0;
+ protected $z = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/Product.php b/Vision/src/V1/Product.php
index a7eba102b882..56502e7cfe56 100644
--- a/Vision/src/V1/Product.php
+++ b/Vision/src/V1/Product.php
@@ -23,21 +23,21 @@ class Product extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1;
*/
- private $name = '';
+ protected $name = '';
/**
* The user-provided name for this Product. Must not be empty. Must be at most
* 4096 characters long.
*
* Generated from protobuf field string display_name = 2;
*/
- private $display_name = '';
+ protected $display_name = '';
/**
* User-provided metadata to be stored with this product. Must be at most 4096
* characters long.
*
* Generated from protobuf field string description = 3;
*/
- private $description = '';
+ protected $description = '';
/**
* Immutable. The category for the product identified by the reference image.
* This should be one of "homegoods-v2", "apparel-v2", "toys-v2",
@@ -47,7 +47,7 @@ class Product extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string product_category = 4 [(.google.api.field_behavior) = IMMUTABLE];
*/
- private $product_category = '';
+ protected $product_category = '';
/**
* Key-value pairs that can be attached to a product. At query time,
* constraints can be specified based on the product_labels.
diff --git a/Vision/src/V1/Product/KeyValue.php b/Vision/src/V1/Product/KeyValue.php
index 5a68dab618c2..f0b06524b9c8 100644
--- a/Vision/src/V1/Product/KeyValue.php
+++ b/Vision/src/V1/Product/KeyValue.php
@@ -21,14 +21,14 @@ class KeyValue extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string key = 1;
*/
- private $key = '';
+ protected $key = '';
/**
* The value of the label attached to the product. Cannot be empty and
* cannot exceed 128 bytes.
*
* Generated from protobuf field string value = 2;
*/
- private $value = '';
+ protected $value = '';
/**
* Constructor.
@@ -107,6 +107,4 @@ public function setValue($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(KeyValue::class, \Google\Cloud\Vision\V1\Product_KeyValue::class);
diff --git a/Vision/src/V1/ProductSearchClient.php b/Vision/src/V1/ProductSearchClient.php
deleted file mode 100644
index ba6ef5d6166d..000000000000
--- a/Vision/src/V1/ProductSearchClient.php
+++ /dev/null
@@ -1,36 +0,0 @@
-_simpleRequest('/google.cloud.vision.v1.ProductSearch/CreateProductSet',
- $argument,
- ['\Google\Cloud\Vision\V1\ProductSet', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Lists ProductSets in an unspecified order.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less
- * than 1.
- * @param \Google\Cloud\Vision\V1\ListProductSetsRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function ListProductSets(\Google\Cloud\Vision\V1\ListProductSetsRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/ListProductSets',
- $argument,
- ['\Google\Cloud\Vision\V1\ListProductSetsResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Gets information associated with a ProductSet.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the ProductSet does not exist.
- * @param \Google\Cloud\Vision\V1\GetProductSetRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function GetProductSet(\Google\Cloud\Vision\V1\GetProductSetRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/GetProductSet',
- $argument,
- ['\Google\Cloud\Vision\V1\ProductSet', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Makes changes to a ProductSet resource.
- * Only display_name can be updated currently.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the ProductSet does not exist.
- * * Returns INVALID_ARGUMENT if display_name is present in update_mask but
- * missing from the request or longer than 4096 characters.
- * @param \Google\Cloud\Vision\V1\UpdateProductSetRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function UpdateProductSet(\Google\Cloud\Vision\V1\UpdateProductSetRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/UpdateProductSet',
- $argument,
- ['\Google\Cloud\Vision\V1\ProductSet', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Permanently deletes a ProductSet. Products and ReferenceImages in the
- * ProductSet are not deleted.
- *
- * The actual image files are not deleted from Google Cloud Storage.
- * @param \Google\Cloud\Vision\V1\DeleteProductSetRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function DeleteProductSet(\Google\Cloud\Vision\V1\DeleteProductSetRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/DeleteProductSet',
- $argument,
- ['\Google\Protobuf\GPBEmpty', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Creates and returns a new product resource.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096
- * characters.
- * * Returns INVALID_ARGUMENT if description is longer than 4096 characters.
- * * Returns INVALID_ARGUMENT if product_category is missing or invalid.
- * @param \Google\Cloud\Vision\V1\CreateProductRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function CreateProduct(\Google\Cloud\Vision\V1\CreateProductRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/CreateProduct',
- $argument,
- ['\Google\Cloud\Vision\V1\Product', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Lists products in an unspecified order.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
- * @param \Google\Cloud\Vision\V1\ListProductsRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function ListProducts(\Google\Cloud\Vision\V1\ListProductsRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/ListProducts',
- $argument,
- ['\Google\Cloud\Vision\V1\ListProductsResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Gets information associated with a Product.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the Product does not exist.
- * @param \Google\Cloud\Vision\V1\GetProductRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function GetProduct(\Google\Cloud\Vision\V1\GetProductRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/GetProduct',
- $argument,
- ['\Google\Cloud\Vision\V1\Product', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Makes changes to a Product resource.
- * Only the `display_name`, `description`, and `labels` fields can be updated
- * right now.
- *
- * If labels are updated, the change will not be reflected in queries until
- * the next index time.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the Product does not exist.
- * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is
- * missing from the request or longer than 4096 characters.
- * * Returns INVALID_ARGUMENT if description is present in update_mask but is
- * longer than 4096 characters.
- * * Returns INVALID_ARGUMENT if product_category is present in update_mask.
- * @param \Google\Cloud\Vision\V1\UpdateProductRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function UpdateProduct(\Google\Cloud\Vision\V1\UpdateProductRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/UpdateProduct',
- $argument,
- ['\Google\Cloud\Vision\V1\Product', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Permanently deletes a product and its reference images.
- *
- * Metadata of the product and all its images will be deleted right away, but
- * search queries against ProductSets containing the product may still work
- * until all related caches are refreshed.
- * @param \Google\Cloud\Vision\V1\DeleteProductRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function DeleteProduct(\Google\Cloud\Vision\V1\DeleteProductRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/DeleteProduct',
- $argument,
- ['\Google\Protobuf\GPBEmpty', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Creates and returns a new ReferenceImage resource.
- *
- * The `bounding_poly` field is optional. If `bounding_poly` is not specified,
- * the system will try to detect regions of interest in the image that are
- * compatible with the product_category on the parent product. If it is
- * specified, detection is ALWAYS skipped. The system converts polygons into
- * non-rotated rectangles.
- *
- * Note that the pipeline will resize the image if the image resolution is too
- * large to process (above 50MP).
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096
- * characters.
- * * Returns INVALID_ARGUMENT if the product does not exist.
- * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing
- * compatible with the parent product's product_category is detected.
- * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
- * @param \Google\Cloud\Vision\V1\CreateReferenceImageRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function CreateReferenceImage(\Google\Cloud\Vision\V1\CreateReferenceImageRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/CreateReferenceImage',
- $argument,
- ['\Google\Cloud\Vision\V1\ReferenceImage', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Permanently deletes a reference image.
- *
- * The image metadata will be deleted right away, but search queries
- * against ProductSets containing the image may still work until all related
- * caches are refreshed.
- *
- * The actual image files are not deleted from Google Cloud Storage.
- * @param \Google\Cloud\Vision\V1\DeleteReferenceImageRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function DeleteReferenceImage(\Google\Cloud\Vision\V1\DeleteReferenceImageRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/DeleteReferenceImage',
- $argument,
- ['\Google\Protobuf\GPBEmpty', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Lists reference images.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the parent product does not exist.
- * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less
- * than 1.
- * @param \Google\Cloud\Vision\V1\ListReferenceImagesRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function ListReferenceImages(\Google\Cloud\Vision\V1\ListReferenceImagesRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/ListReferenceImages',
- $argument,
- ['\Google\Cloud\Vision\V1\ListReferenceImagesResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Gets information associated with a ReferenceImage.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the specified image does not exist.
- * @param \Google\Cloud\Vision\V1\GetReferenceImageRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function GetReferenceImage(\Google\Cloud\Vision\V1\GetReferenceImageRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/GetReferenceImage',
- $argument,
- ['\Google\Cloud\Vision\V1\ReferenceImage', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Adds a Product to the specified ProductSet. If the Product is already
- * present, no change is made.
- *
- * One Product can be added to at most 100 ProductSets.
- *
- * Possible errors:
- *
- * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
- * @param \Google\Cloud\Vision\V1\AddProductToProductSetRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function AddProductToProductSet(\Google\Cloud\Vision\V1\AddProductToProductSetRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/AddProductToProductSet',
- $argument,
- ['\Google\Protobuf\GPBEmpty', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Removes a Product from the specified ProductSet.
- * @param \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function RemoveProductFromProductSet(\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet',
- $argument,
- ['\Google\Protobuf\GPBEmpty', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Lists the Products in a ProductSet, in an unspecified order. If the
- * ProductSet does not exist, the products field of the response will be
- * empty.
- *
- * Possible errors:
- *
- * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
- * @param \Google\Cloud\Vision\V1\ListProductsInProductSetRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function ListProductsInProductSet(\Google\Cloud\Vision\V1\ListProductsInProductSetRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/ListProductsInProductSet',
- $argument,
- ['\Google\Cloud\Vision\V1\ListProductsInProductSetResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Asynchronous API that imports a list of reference images to specified
- * product sets based on a list of image information.
- *
- * The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the
- * progress and results of the request.
- * `Operation.metadata` contains `BatchOperationMetadata`. (progress)
- * `Operation.response` contains `ImportProductSetsResponse`. (results)
- *
- * The input source of this method is a csv file on Google Cloud Storage.
- * For the format of the csv file please see
- * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri].
- * @param \Google\Cloud\Vision\V1\ImportProductSetsRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function ImportProductSets(\Google\Cloud\Vision\V1\ImportProductSetsRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/ImportProductSets',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Asynchronous API to delete all Products in a ProductSet or all Products
- * that are in no ProductSet.
- *
- * If a Product is a member of the specified ProductSet in addition to other
- * ProductSets, the Product will still be deleted.
- *
- * It is recommended to not delete the specified ProductSet until after this
- * operation has completed. It is also recommended to not add any of the
- * Products involved in the batch delete to a new ProductSet while this
- * operation is running because those Products may still end up deleted.
- *
- * It's not possible to undo the PurgeProducts operation. Therefore, it is
- * recommended to keep the csv files used in ImportProductSets (if that was
- * how you originally built the Product Set) before starting PurgeProducts, in
- * case you need to re-import the data after deletion.
- *
- * If the plan is to purge all of the Products from a ProductSet and then
- * re-use the empty ProductSet to re-import new Products into the empty
- * ProductSet, you must wait until the PurgeProducts operation has finished
- * for that ProductSet.
- *
- * The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the
- * progress and results of the request.
- * `Operation.metadata` contains `BatchOperationMetadata`. (progress)
- * @param \Google\Cloud\Vision\V1\PurgeProductsRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function PurgeProducts(\Google\Cloud\Vision\V1\PurgeProductsRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.vision.v1.ProductSearch/PurgeProducts',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
-}
diff --git a/Vision/src/V1/ProductSearchParams.php b/Vision/src/V1/ProductSearchParams.php
index 9fa234843a97..315a68ba9bc9 100644
--- a/Vision/src/V1/ProductSearchParams.php
+++ b/Vision/src/V1/ProductSearchParams.php
@@ -21,7 +21,7 @@ class ProductSearchParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_poly = 9;
*/
- private $bounding_poly = null;
+ protected $bounding_poly = null;
/**
* The resource name of a [ProductSet][google.cloud.vision.v1.ProductSet] to
* be searched for similar images.
@@ -30,7 +30,7 @@ class ProductSearchParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string product_set = 6 [(.google.api.resource_reference) = {
*/
- private $product_set = '';
+ protected $product_set = '';
/**
* The list of product categories to search in. Currently, we only consider
* the first category, and either "homegoods-v2", "apparel-v2", "toys-v2",
@@ -54,7 +54,7 @@ class ProductSearchParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string filter = 8;
*/
- private $filter = '';
+ protected $filter = '';
/**
* Constructor.
diff --git a/Vision/src/V1/ProductSearchResults.php b/Vision/src/V1/ProductSearchResults.php
index 9711540c622a..44d025f0d729 100644
--- a/Vision/src/V1/ProductSearchResults.php
+++ b/Vision/src/V1/ProductSearchResults.php
@@ -22,7 +22,7 @@ class ProductSearchResults extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.Timestamp index_time = 2;
*/
- private $index_time = null;
+ protected $index_time = null;
/**
* List of results, one for each product match.
*
diff --git a/Vision/src/V1/ProductSearchResults/GroupedResult.php b/Vision/src/V1/ProductSearchResults/GroupedResult.php
index 06265360d727..a19ea4f4cf68 100644
--- a/Vision/src/V1/ProductSearchResults/GroupedResult.php
+++ b/Vision/src/V1/ProductSearchResults/GroupedResult.php
@@ -21,7 +21,7 @@ class GroupedResult extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_poly = 1;
*/
- private $bounding_poly = null;
+ protected $bounding_poly = null;
/**
* List of results, one for each product match.
*
@@ -144,6 +144,4 @@ public function setObjectAnnotations($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(GroupedResult::class, \Google\Cloud\Vision\V1\ProductSearchResults_GroupedResult::class);
diff --git a/Vision/src/V1/ProductSearchResults/ObjectAnnotation.php b/Vision/src/V1/ProductSearchResults/ObjectAnnotation.php
index 9ebeaa22ecde..4d2ba21ec4ef 100644
--- a/Vision/src/V1/ProductSearchResults/ObjectAnnotation.php
+++ b/Vision/src/V1/ProductSearchResults/ObjectAnnotation.php
@@ -20,7 +20,7 @@ class ObjectAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string mid = 1;
*/
- private $mid = '';
+ protected $mid = '';
/**
* The BCP-47 language code, such as "en-US" or "sr-Latn". For more
* information, see
@@ -28,19 +28,19 @@ class ObjectAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string language_code = 2;
*/
- private $language_code = '';
+ protected $language_code = '';
/**
* Object name, expressed in its `language_code` language.
*
* Generated from protobuf field string name = 3;
*/
- private $name = '';
+ protected $name = '';
/**
* Score of the result. Range [0, 1].
*
* Generated from protobuf field float score = 4;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* Constructor.
@@ -175,6 +175,4 @@ public function setScore($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(ObjectAnnotation::class, \Google\Cloud\Vision\V1\ProductSearchResults_ObjectAnnotation::class);
diff --git a/Vision/src/V1/ProductSearchResults/Result.php b/Vision/src/V1/ProductSearchResults/Result.php
index 464bd86b8ebd..b73141a653d3 100644
--- a/Vision/src/V1/ProductSearchResults/Result.php
+++ b/Vision/src/V1/ProductSearchResults/Result.php
@@ -20,21 +20,21 @@ class Result extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Product product = 1;
*/
- private $product = null;
+ protected $product = null;
/**
* A confidence level on the match, ranging from 0 (no confidence) to
* 1 (full confidence).
*
* Generated from protobuf field float score = 2;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* The resource name of the image from the product that is the closest match
* to the query.
*
* Generated from protobuf field string image = 3;
*/
- private $image = '';
+ protected $image = '';
/**
* Constructor.
@@ -151,6 +151,4 @@ public function setImage($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(Result::class, \Google\Cloud\Vision\V1\ProductSearchResults_Result::class);
diff --git a/Vision/src/V1/ProductSearchResults_GroupedResult.php b/Vision/src/V1/ProductSearchResults_GroupedResult.php
deleted file mode 100644
index 82125013a71b..000000000000
--- a/Vision/src/V1/ProductSearchResults_GroupedResult.php
+++ /dev/null
@@ -1,16 +0,0 @@
-string name = 1;
*/
- private $name = '';
+ protected $name = '';
/**
* The user-provided name for this ProductSet. Must not be empty. Must be at
* most 4096 characters long.
*
* Generated from protobuf field string display_name = 2;
*/
- private $display_name = '';
+ protected $display_name = '';
/**
* Output only. The time at which this ProductSet was last indexed. Query
* results will reflect all updates before this time. If this ProductSet has
@@ -42,7 +42,7 @@ class ProductSet extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.Timestamp index_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $index_time = null;
+ protected $index_time = null;
/**
* Output only. If there was an error with indexing the product set, the field
* is populated.
@@ -50,7 +50,7 @@ class ProductSet extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.rpc.Status index_error = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
*/
- private $index_error = null;
+ protected $index_error = null;
/**
* Constructor.
diff --git a/Vision/src/V1/ProductSetPurgeConfig.php b/Vision/src/V1/ProductSetPurgeConfig.php
index 8e14cb78f088..b433c625acb4 100644
--- a/Vision/src/V1/ProductSetPurgeConfig.php
+++ b/Vision/src/V1/ProductSetPurgeConfig.php
@@ -22,7 +22,7 @@ class ProductSetPurgeConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string product_set_id = 1;
*/
- private $product_set_id = '';
+ protected $product_set_id = '';
/**
* Constructor.
diff --git a/Vision/src/V1/Product_KeyValue.php b/Vision/src/V1/Product_KeyValue.php
deleted file mode 100644
index 694da6b21398..000000000000
--- a/Vision/src/V1/Product_KeyValue.php
+++ /dev/null
@@ -1,16 +0,0 @@
-string name = 1;
*/
- private $name = '';
+ protected $name = '';
/**
* Value of the property.
*
* Generated from protobuf field string value = 2;
*/
- private $value = '';
+ protected $value = '';
/**
* Value of numeric properties.
*
* Generated from protobuf field uint64 uint64_value = 3;
*/
- private $uint64_value = 0;
+ protected $uint64_value = 0;
/**
* Constructor.
diff --git a/Vision/src/V1/PurgeProductsRequest.php b/Vision/src/V1/PurgeProductsRequest.php
index e1e229f645ea..9633606d6678 100644
--- a/Vision/src/V1/PurgeProductsRequest.php
+++ b/Vision/src/V1/PurgeProductsRequest.php
@@ -21,14 +21,14 @@ class PurgeProductsRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $parent = '';
+ protected $parent = '';
/**
* The default value is false. Override this value to true to actually perform
* the purge.
*
* Generated from protobuf field bool force = 4;
*/
- private $force = false;
+ protected $force = false;
protected $target;
/**
diff --git a/Vision/src/V1/README.md b/Vision/src/V1/README.md
deleted file mode 100644
index 1ac45178efac..000000000000
--- a/Vision/src/V1/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Google Cloud Vision V1 generated client for PHP
-
-### Sample
-
-```php
-require 'vendor/autoload.php';
-
-use Google\Cloud\Vision\V1\ImageAnnotatorClient;
-
-$imageAnnotatorClient = new ImageAnnotatorClient();
-try {
- $requests = [];
- $response = $imageAnnotatorClient->batchAnnotateImages($requests);
-} finally {
- $imageAnnotatorClient->close();
-}
-```
diff --git a/Vision/src/V1/ReferenceImage.php b/Vision/src/V1/ReferenceImage.php
index bf12eee17ba1..a4371a4149d9 100644
--- a/Vision/src/V1/ReferenceImage.php
+++ b/Vision/src/V1/ReferenceImage.php
@@ -24,14 +24,14 @@ class ReferenceImage extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 1;
*/
- private $name = '';
+ protected $name = '';
/**
* Required. The Google Cloud Storage URI of the reference image.
* The URI must start with `gs://`.
*
* Generated from protobuf field string uri = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $uri = '';
+ protected $uri = '';
/**
* Optional. Bounding polygons around the areas of interest in the reference
* image. If this field is empty, the system will try to detect regions of
diff --git a/Vision/src/V1/RemoveProductFromProductSetRequest.php b/Vision/src/V1/RemoveProductFromProductSetRequest.php
index 24b16bf28a0f..344af637ba5f 100644
--- a/Vision/src/V1/RemoveProductFromProductSetRequest.php
+++ b/Vision/src/V1/RemoveProductFromProductSetRequest.php
@@ -22,7 +22,7 @@ class RemoveProductFromProductSetRequest extends \Google\Protobuf\Internal\Messa
*
* Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $name = '';
+ protected $name = '';
/**
* Required. The resource name for the Product to be removed from this
* ProductSet.
@@ -31,7 +31,7 @@ class RemoveProductFromProductSetRequest extends \Google\Protobuf\Internal\Messa
*
* Generated from protobuf field string product = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $product = '';
+ protected $product = '';
/**
* @param string $name Required. The resource name for the ProductSet to modify.
diff --git a/Vision/src/V1/SafeSearchAnnotation.php b/Vision/src/V1/SafeSearchAnnotation.php
index 80f7d4e033dc..58c2b95955e4 100644
--- a/Vision/src/V1/SafeSearchAnnotation.php
+++ b/Vision/src/V1/SafeSearchAnnotation.php
@@ -24,7 +24,7 @@ class SafeSearchAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood adult = 1;
*/
- private $adult = 0;
+ protected $adult = 0;
/**
* Spoof likelihood. The likelihood that an modification
* was made to the image's canonical version to make it appear
@@ -32,13 +32,13 @@ class SafeSearchAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood spoof = 2;
*/
- private $spoof = 0;
+ protected $spoof = 0;
/**
* Likelihood that this is a medical image.
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood medical = 3;
*/
- private $medical = 0;
+ protected $medical = 0;
/**
* Likelihood that this image contains violent content. Violent content may
* include death, serious harm, or injury to individuals or groups of
@@ -46,7 +46,7 @@ class SafeSearchAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood violence = 4;
*/
- private $violence = 0;
+ protected $violence = 0;
/**
* Likelihood that the request image contains racy content. Racy content may
* include (but is not limited to) skimpy or sheer clothing, strategically
@@ -55,7 +55,7 @@ class SafeSearchAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Likelihood racy = 9;
*/
- private $racy = 0;
+ protected $racy = 0;
/**
* Constructor.
@@ -237,185 +237,5 @@ public function setRacy($var)
return $this;
}
- /**
- * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float adult_confidence = 16 [deprecated = true];
- * @return float
- * @deprecated
- */
- public function getAdultConfidence()
- {
- @trigger_error('adult_confidence is deprecated.', E_USER_DEPRECATED);
- return 0.0;
- }
-
- /**
- * Confidence of adult_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float adult_confidence = 16 [deprecated = true];
- * @param float $var
- * @return $this
- * @deprecated
- */
- public function setAdultConfidence($var)
- {
- @trigger_error('adult_confidence is deprecated.', E_USER_DEPRECATED);
- GPBUtil::checkFloat($var);
- return $this;
- }
-
- /**
- * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float spoof_confidence = 18 [deprecated = true];
- * @return float
- * @deprecated
- */
- public function getSpoofConfidence()
- {
- @trigger_error('spoof_confidence is deprecated.', E_USER_DEPRECATED);
- return 0.0;
- }
-
- /**
- * Confidence of spoof_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float spoof_confidence = 18 [deprecated = true];
- * @param float $var
- * @return $this
- * @deprecated
- */
- public function setSpoofConfidence($var)
- {
- @trigger_error('spoof_confidence is deprecated.', E_USER_DEPRECATED);
- GPBUtil::checkFloat($var);
- return $this;
- }
-
- /**
- * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float medical_confidence = 20 [deprecated = true];
- * @return float
- * @deprecated
- */
- public function getMedicalConfidence()
- {
- @trigger_error('medical_confidence is deprecated.', E_USER_DEPRECATED);
- return 0.0;
- }
-
- /**
- * Confidence of medical_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float medical_confidence = 20 [deprecated = true];
- * @param float $var
- * @return $this
- * @deprecated
- */
- public function setMedicalConfidence($var)
- {
- @trigger_error('medical_confidence is deprecated.', E_USER_DEPRECATED);
- GPBUtil::checkFloat($var);
- return $this;
- }
-
- /**
- * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float violence_confidence = 22 [deprecated = true];
- * @return float
- * @deprecated
- */
- public function getViolenceConfidence()
- {
- @trigger_error('violence_confidence is deprecated.', E_USER_DEPRECATED);
- return 0.0;
- }
-
- /**
- * Confidence of violence_score. Range [0, 1]. 0 means not confident, 1 means
- * very confident.
- *
- * Generated from protobuf field float violence_confidence = 22 [deprecated = true];
- * @param float $var
- * @return $this
- * @deprecated
- */
- public function setViolenceConfidence($var)
- {
- @trigger_error('violence_confidence is deprecated.', E_USER_DEPRECATED);
- GPBUtil::checkFloat($var);
- return $this;
- }
-
- /**
- * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
- * confident.
- *
- * Generated from protobuf field float racy_confidence = 24 [deprecated = true];
- * @return float
- * @deprecated
- */
- public function getRacyConfidence()
- {
- @trigger_error('racy_confidence is deprecated.', E_USER_DEPRECATED);
- GPBUtil::checkFloat($var);
- return 0.0;
- }
-
- /**
- * Confidence of racy_score. Range [0, 1]. 0 means not confident, 1 means very
- * confident.
- *
- * Generated from protobuf field float racy_confidence = 24 [deprecated = true];
- * @param float $var
- * @return $this
- * @deprecated
- */
- public function setRacyConfidence($var)
- {
- @trigger_error('racy_confidence is deprecated.', E_USER_DEPRECATED);
- return $this;
- }
-
- /**
- * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
- * confident.
- *
- * Generated from protobuf field float nsfw_confidence = 26 [deprecated = true];
- * @return float
- * @deprecated
- */
- public function getNsfwConfidence()
- {
- @trigger_error('nsfw_confidence is deprecated.', E_USER_DEPRECATED);
- return 0.0;
- }
-
- /**
- * Confidence of nsfw_score. Range [0, 1]. 0 means not confident, 1 means very
- * confident.
- *
- * Generated from protobuf field float nsfw_confidence = 26 [deprecated = true];
- * @param float $var
- * @return $this
- * @deprecated
- */
- public function setNsfwConfidence($var)
- {
- @trigger_error('nsfw_confidence is deprecated.', E_USER_DEPRECATED);
- GPBUtil::checkFloat($var);
- return 0.0;
- }
-
}
diff --git a/Vision/src/V1/Symbol.php b/Vision/src/V1/Symbol.php
index dafb68058ad6..4fe27114775f 100644
--- a/Vision/src/V1/Symbol.php
+++ b/Vision/src/V1/Symbol.php
@@ -20,7 +20,7 @@ class Symbol extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.TextAnnotation.TextProperty property = 1;
*/
- private $property = null;
+ protected $property = null;
/**
* The bounding box for the symbol.
* The vertices are in the order of top-left, top-right, bottom-right,
@@ -40,19 +40,19 @@ class Symbol extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_box = 2;
*/
- private $bounding_box = null;
+ protected $bounding_box = null;
/**
* The actual UTF-8 representation of the symbol.
*
* Generated from protobuf field string text = 3;
*/
- private $text = '';
+ protected $text = '';
/**
* Confidence of the OCR results for the symbol. Range [0, 1].
*
* Generated from protobuf field float confidence = 4;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Constructor.
diff --git a/Vision/src/V1/TextAnnotation.php b/Vision/src/V1/TextAnnotation.php
index 7fc05aaf4534..e736837aaee1 100644
--- a/Vision/src/V1/TextAnnotation.php
+++ b/Vision/src/V1/TextAnnotation.php
@@ -33,7 +33,7 @@ class TextAnnotation extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string text = 2;
*/
- private $text = '';
+ protected $text = '';
/**
* Constructor.
diff --git a/Vision/src/V1/TextAnnotation/DetectedBreak.php b/Vision/src/V1/TextAnnotation/DetectedBreak.php
index c9104dc6a189..75d846493f3f 100644
--- a/Vision/src/V1/TextAnnotation/DetectedBreak.php
+++ b/Vision/src/V1/TextAnnotation/DetectedBreak.php
@@ -20,13 +20,13 @@ class DetectedBreak extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.TextAnnotation.DetectedBreak.BreakType type = 1;
*/
- private $type = 0;
+ protected $type = 0;
/**
* True if break prepends the element.
*
* Generated from protobuf field bool is_prefix = 2;
*/
- private $is_prefix = false;
+ protected $is_prefix = false;
/**
* Constructor.
@@ -99,6 +99,4 @@ public function setIsPrefix($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(DetectedBreak::class, \Google\Cloud\Vision\V1\TextAnnotation_DetectedBreak::class);
diff --git a/Vision/src/V1/TextAnnotation/DetectedBreak/BreakType.php b/Vision/src/V1/TextAnnotation/DetectedBreak/BreakType.php
index 455626c48545..c35254dda9a3 100644
--- a/Vision/src/V1/TextAnnotation/DetectedBreak/BreakType.php
+++ b/Vision/src/V1/TextAnnotation/DetectedBreak/BreakType.php
@@ -81,6 +81,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(BreakType::class, \Google\Cloud\Vision\V1\TextAnnotation_DetectedBreak_BreakType::class);
diff --git a/Vision/src/V1/TextAnnotation/DetectedLanguage.php b/Vision/src/V1/TextAnnotation/DetectedLanguage.php
index 0e763eae7097..5dcaa1025ccc 100644
--- a/Vision/src/V1/TextAnnotation/DetectedLanguage.php
+++ b/Vision/src/V1/TextAnnotation/DetectedLanguage.php
@@ -22,13 +22,13 @@ class DetectedLanguage extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string language_code = 1;
*/
- private $language_code = '';
+ protected $language_code = '';
/**
* Confidence of detected language. Range [0, 1].
*
* Generated from protobuf field float confidence = 2;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Constructor.
@@ -107,6 +107,4 @@ public function setConfidence($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(DetectedLanguage::class, \Google\Cloud\Vision\V1\TextAnnotation_DetectedLanguage::class);
diff --git a/Vision/src/V1/TextAnnotation/TextProperty.php b/Vision/src/V1/TextAnnotation/TextProperty.php
index ff5c593fc778..2efb890740c6 100644
--- a/Vision/src/V1/TextAnnotation/TextProperty.php
+++ b/Vision/src/V1/TextAnnotation/TextProperty.php
@@ -26,7 +26,7 @@ class TextProperty extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.TextAnnotation.DetectedBreak detected_break = 2;
*/
- private $detected_break = null;
+ protected $detected_break = null;
/**
* Constructor.
@@ -109,6 +109,4 @@ public function setDetectedBreak($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(TextProperty::class, \Google\Cloud\Vision\V1\TextAnnotation_TextProperty::class);
diff --git a/Vision/src/V1/TextAnnotation_DetectedBreak.php b/Vision/src/V1/TextAnnotation_DetectedBreak.php
deleted file mode 100644
index 4bfe2f590ba2..000000000000
--- a/Vision/src/V1/TextAnnotation_DetectedBreak.php
+++ /dev/null
@@ -1,16 +0,0 @@
-bool enable_text_detection_confidence_score = 9;
*/
- private $enable_text_detection_confidence_score = false;
+ protected $enable_text_detection_confidence_score = false;
/**
* A list of advanced OCR options to further fine-tune OCR behavior.
* Current valid values are:
diff --git a/Vision/src/V1/UpdateProductRequest.php b/Vision/src/V1/UpdateProductRequest.php
index febfeeb880da..91ab72f3f77e 100644
--- a/Vision/src/V1/UpdateProductRequest.php
+++ b/Vision/src/V1/UpdateProductRequest.php
@@ -21,7 +21,7 @@ class UpdateProductRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.Product product = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $product = null;
+ protected $product = null;
/**
* The [FieldMask][google.protobuf.FieldMask] that specifies which fields
* to update.
@@ -31,7 +31,7 @@ class UpdateProductRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.FieldMask update_mask = 2;
*/
- private $update_mask = null;
+ protected $update_mask = null;
/**
* @param \Google\Cloud\Vision\V1\Product $product Required. The Product resource which replaces the one on the server.
diff --git a/Vision/src/V1/UpdateProductSetRequest.php b/Vision/src/V1/UpdateProductSetRequest.php
index db231b5ec775..f3efd0e6405a 100644
--- a/Vision/src/V1/UpdateProductSetRequest.php
+++ b/Vision/src/V1/UpdateProductSetRequest.php
@@ -20,7 +20,7 @@ class UpdateProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.ProductSet product_set = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $product_set = null;
+ protected $product_set = null;
/**
* The [FieldMask][google.protobuf.FieldMask] that specifies which fields to
* update.
@@ -29,7 +29,7 @@ class UpdateProductSetRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.FieldMask update_mask = 2;
*/
- private $update_mask = null;
+ protected $update_mask = null;
/**
* @param \Google\Cloud\Vision\V1\ProductSet $productSet Required. The ProductSet resource which replaces the one on the server.
diff --git a/Vision/src/V1/Vertex.php b/Vision/src/V1/Vertex.php
index 8999deb41163..2944b434c7a6 100644
--- a/Vision/src/V1/Vertex.php
+++ b/Vision/src/V1/Vertex.php
@@ -21,13 +21,13 @@ class Vertex extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field int32 x = 1;
*/
- private $x = 0;
+ protected $x = 0;
/**
* Y coordinate.
*
* Generated from protobuf field int32 y = 2;
*/
- private $y = 0;
+ protected $y = 0;
/**
* Constructor.
diff --git a/Vision/src/V1/WebDetection/WebEntity.php b/Vision/src/V1/WebDetection/WebEntity.php
index 41fce53f998d..4718d8c93749 100644
--- a/Vision/src/V1/WebDetection/WebEntity.php
+++ b/Vision/src/V1/WebDetection/WebEntity.php
@@ -20,20 +20,20 @@ class WebEntity extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string entity_id = 1;
*/
- private $entity_id = '';
+ protected $entity_id = '';
/**
* Overall relevancy score for the entity.
* Not normalized and not comparable across different image queries.
*
* Generated from protobuf field float score = 2;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* Canonical description of the entity, in English.
*
* Generated from protobuf field string description = 3;
*/
- private $description = '';
+ protected $description = '';
/**
* Constructor.
@@ -137,6 +137,4 @@ public function setDescription($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(WebEntity::class, \Google\Cloud\Vision\V1\WebDetection_WebEntity::class);
diff --git a/Vision/src/V1/WebDetection/WebImage.php b/Vision/src/V1/WebDetection/WebImage.php
index 53cc9bdadcb8..b566677f58e1 100644
--- a/Vision/src/V1/WebDetection/WebImage.php
+++ b/Vision/src/V1/WebDetection/WebImage.php
@@ -20,13 +20,13 @@ class WebImage extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string url = 1;
*/
- private $url = '';
+ protected $url = '';
/**
* (Deprecated) Overall relevancy score for the image.
*
* Generated from protobuf field float score = 2;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* Constructor.
@@ -99,6 +99,4 @@ public function setScore($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(WebImage::class, \Google\Cloud\Vision\V1\WebDetection_WebImage::class);
diff --git a/Vision/src/V1/WebDetection/WebLabel.php b/Vision/src/V1/WebDetection/WebLabel.php
index 983b44382530..4a6276308937 100644
--- a/Vision/src/V1/WebDetection/WebLabel.php
+++ b/Vision/src/V1/WebDetection/WebLabel.php
@@ -20,7 +20,7 @@ class WebLabel extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string label = 1;
*/
- private $label = '';
+ protected $label = '';
/**
* The BCP-47 language code for `label`, such as "en-US" or "sr-Latn".
* For more information, see
@@ -28,7 +28,7 @@ class WebLabel extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string language_code = 2;
*/
- private $language_code = '';
+ protected $language_code = '';
/**
* Constructor.
@@ -107,6 +107,4 @@ public function setLanguageCode($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(WebLabel::class, \Google\Cloud\Vision\V1\WebDetection_WebLabel::class);
diff --git a/Vision/src/V1/WebDetection/WebPage.php b/Vision/src/V1/WebDetection/WebPage.php
index 9605ffbdff0a..aa1b2163216b 100644
--- a/Vision/src/V1/WebDetection/WebPage.php
+++ b/Vision/src/V1/WebDetection/WebPage.php
@@ -20,19 +20,19 @@ class WebPage extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string url = 1;
*/
- private $url = '';
+ protected $url = '';
/**
* (Deprecated) Overall relevancy score for the web page.
*
* Generated from protobuf field float score = 2;
*/
- private $score = 0.0;
+ protected $score = 0.0;
/**
* Title for the web page, may contain HTML markups.
*
* Generated from protobuf field string page_title = 3;
*/
- private $page_title = '';
+ protected $page_title = '';
/**
* Fully matching images on the page.
* Can include resized copies of the query image.
@@ -217,6 +217,4 @@ public function setPartialMatchingImages($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(WebPage::class, \Google\Cloud\Vision\V1\WebDetection_WebPage::class);
diff --git a/Vision/src/V1/WebDetection_WebEntity.php b/Vision/src/V1/WebDetection_WebEntity.php
deleted file mode 100644
index d5d666168500..000000000000
--- a/Vision/src/V1/WebDetection_WebEntity.php
+++ /dev/null
@@ -1,16 +0,0 @@
-.google.cloud.vision.v1.TextAnnotation.TextProperty property = 1;
*/
- private $property = null;
+ protected $property = null;
/**
* The bounding box for the word.
* The vertices are in the order of top-left, top-right, bottom-right,
@@ -40,7 +40,7 @@ class Word extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.vision.v1.BoundingPoly bounding_box = 2;
*/
- private $bounding_box = null;
+ protected $bounding_box = null;
/**
* List of symbols in the word.
* The order of the symbols follows the natural reading order.
@@ -53,7 +53,7 @@ class Word extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field float confidence = 4;
*/
- private $confidence = 0.0;
+ protected $confidence = 0.0;
/**
* Constructor.
diff --git a/Vision/src/VisionClient.php b/Vision/src/VisionClient.php
deleted file mode 100644
index cbd9439c6ace..000000000000
--- a/Vision/src/VisionClient.php
+++ /dev/null
@@ -1,300 +0,0 @@
-connection = new Rest($this->configureAuthentication($config));
-
- $class = get_class($this);
- $err = "The class {$class} is no longer supported";
- @trigger_error($err, E_USER_DEPRECATED);
- }
-
- /**
- * Create an instance of {@see \Google\Cloud\Vision\Image} with required
- * features and options.
- *
- * This method should be used to configure a single image, or when a set of
- * images requires different settings for each member of the set. If you
- * have a set of images which all will use the same settings,
- * {@see VisionClient::images()} may be quicker and
- * simpler to use.
- *
- * This method will not perform any service requests, and is meant to be
- * used to configure a request prior to calling
- * {@see VisionClient::annotate()}.
- *
- * For more information, including best practices and examples detailing
- * other usage such as `$imageContext`, see {@see Image::__construct()}.
- *
- * Example:
- * ```
- * $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- *
- * $image = $vision->image($imageResource, [
- * 'FACE_DETECTION'
- * ]);
- * ```
- *
- * ```
- * // Setting maxResults for a feature
- *
- * $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- *
- * $image = $vision->image($imageResource, [
- * 'FACE_DETECTION'
- * ], [
- * 'maxResults' => [
- * 'FACE_DETECTION' => 1
- * ]
- * ]);
- * ```
- *
- * @param resource|string|StorageObject $image An image to configure with
- * the given settings. This parameter will accept a resource, a
- * string of bytes, the URI of an image in a publicly-accessible
- * web location, or an instance of {@see \Google\Cloud\Storage\StorageObject}.
- * @param array $features A list of cloud vision
- * [features](https://cloud.google.com/vision/reference/rest/v1/images/annotate#type)
- * to apply to the image.
- * @param array $options See {@see Image::__construct()} for
- * configuration details.
- * @return Image
- * @throws InvalidArgumentException
- */
- public function image($image, array $features, array $options = [])
- {
- return new Image($image, $features, $options);
- }
-
- /**
- * Create an array of type {@see \Google\Cloud\Vision\Image} with required features and options
- * set for each member of the set.
- *
- * This method is useful for quickly configuring every member of a set of
- * images with the same features and options. Should you need to provide
- * different features or options for one or more members of the set,
- * {@see VisionClient::image()} is a better choice.
- *
- * This method will not perform any service requests, and is meant to be
- * used to configure a request prior to calling
- * {@see VisionClient::annotateBatch()}.
- *
- * For more information, including best practices and examples detailing
- * other usage such as `$imageContext`, see {@see Image::__construct()}.
- *
- * Example:
- * ```
- * // In the example below, both images will have the same settings applied.
- * // They will both run face detection and return up to 10 results.
- *
- * $familyPhotoResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- * $weddingPhotoResource = fopen(__DIR__ . '/assets/wedding-photo.jpg', 'r');
- *
- * $images = $vision->images([$familyPhotoResource, $weddingPhotoResource], [
- * 'FACE_DETECTION'
- * ], [
- * 'maxResults' => [
- * 'FACE_DETECTION' => 10
- * ]
- * ]);
- * ```
- *
- * @param resource[]|string[]|StorageObject[] $images An array of images
- * to configure with the given settings. Each member of the set can
- * be a resource, a string of bytes, the URI of an image in a
- * publicly-accessible web location, or an instance of
- * {@see \Google\Cloud\Storage\StorageObject}.
- * @param array $features A list of cloud vision features to apply to each image.
- * @param array $options See {@see Image::__construct()} for
- * configuration details.
- * @return Image[]
- * @throws InvalidArgumentException
- */
- public function images(array $images, array $features, array $options = [])
- {
- $result = [];
- foreach ($images as $image) {
- $result[] = $this->image($image, $features, $options);
- }
-
- return $result;
- }
-
- /**
- * Annotate a single image.
- *
- * Example:
- * ```
- * $familyPhotoResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- *
- * $image = $vision->image($familyPhotoResource, [
- * 'FACE_DETECTION'
- * ]);
- *
- * $result = $vision->annotate($image);
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate Annotate API documentation
- *
- * @param Image $image The image to annotate
- * @param array $options Configuration options
- * @return Annotation
- */
- public function annotate(Image $image, array $options = [])
- {
- $res = $this->annotateBatch([$image], $options);
- return $res[0];
- }
-
- /**
- * Annotate a set of images.
- *
- * Example:
- * ```
- * $images = [];
- *
- * $familyPhotoResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
- * $eiffelTowerResource = fopen(__DIR__ . '/assets/eiffel-tower.jpg', 'r');
- *
- * $images[] = $vision->image($familyPhotoResource, [
- * 'FACE_DETECTION'
- * ]);
- *
- * $images[] = $vision->image($eiffelTowerResource, [
- * 'LANDMARK_DETECTION'
- * ]);
- *
- * $result = $vision->annotateBatch($images);
- * ```
- *
- * @see https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate Annotate API documentation
- *
- * @param Image[] $images An array consisting of instances of
- * {@see Image}.
- * @param array $options Configuration Options
- * @return Annotation[]
- */
- public function annotateBatch(array $images, array $options = [])
- {
- $this->validateBatch($images, Image::class);
-
- $requests = [];
- foreach ($images as $image) {
- $requests[] = $image->requestObject();
- }
-
- $res = $this->connection->annotate([
- 'requests' => $requests
- ] + $options);
-
- $annotations = [];
- if (isset($res['responses'])) {
- foreach ($res['responses'] as $response) {
- $annotations[] = new Annotation($response);
- }
- }
-
- return $annotations;
- }
-}
diff --git a/Vision/src/VisionHelpersTrait.php b/Vision/src/VisionHelpersTrait.php
deleted file mode 100644
index 5a8ccb8388f0..000000000000
--- a/Vision/src/VisionHelpersTrait.php
+++ /dev/null
@@ -1,120 +0,0 @@
-setImage($image);
- $features = $this->buildFeatureList(Feature::class, $features);
- $request->setFeatures($features);
- $imageContext = $this->pluck('imageContext', $optionalArgs, false);
- if (!is_null($imageContext)) {
- $request->setImageContext($imageContext);
- }
- return $callback([$request], $optionalArgs)->getResponses()[0];
- }
-
- /**
- * @param string $featureClass
- * @param Feature[]|int[] $featureTypes
- * @return Feature[]|array
- */
- private function buildFeatureList($featureClass, $featureTypes)
- {
- $features = [];
- foreach ($featureTypes as $featureType) {
- if (is_int($featureType)) {
- $feature = new $featureClass();
- $feature->setType($featureType);
- } else {
- $feature = $featureType;
- }
- $features[] = $feature;
- }
- return $features;
- }
-
- /**
- * @param string $imageClass
- * @param string $imageSourceClass
- * @param string|resource|Image|mixed $imageInput
- * @return Image|mixed
- */
- private function createImageHelper($imageClass, $imageSourceClass, $imageInput)
- {
- if (is_object($imageInput) && is_a($imageInput, $imageClass)) {
- return $imageInput;
- }
- $image = new $imageClass();
- if (is_string($imageInput)) {
- if (in_array(parse_url($imageInput, PHP_URL_SCHEME), $this->urlSchemes)) {
- $imageSource = new $imageSourceClass();
- $imageSource->setImageUri($imageInput);
- $image->setSource($imageSource);
- } else {
- $image->setContent($imageInput);
- }
- } elseif (is_resource($imageInput)) {
- $image->setContent(stream_get_contents($imageInput));
- } else {
- throw new InvalidArgumentException(
- 'Given image is not valid. ' .
- 'Image must be a string of bytes, a valid image URI, or a resource.'
- );
- }
- return $image;
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/AbstractFeatureTest.php b/Vision/tests/Snippet/Annotation/AbstractFeatureTest.php
deleted file mode 100644
index 52cbe20f901b..000000000000
--- a/Vision/tests/Snippet/Annotation/AbstractFeatureTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-___setProperty('info', 'hello world');
-
- $snippet = $this->snippetFromMethod(AbstractFeature::class, 'info');
- $snippet->addLocal('imageProperties', $stub);
-
- $res = $snippet->invoke('info');
- $this->assertEquals('hello world', $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/CropHintTest.php b/Vision/tests/Snippet/Annotation/CropHintTest.php
deleted file mode 100644
index 8989c98d1430..000000000000
--- a/Vision/tests/Snippet/Annotation/CropHintTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-info = [
- 'boundingPoly' => ['foo' => 'bar'],
- 'confidence' => 0.4,
- 'importanceFraction' => 0.1
- ];
-
- $this->hint = new CropHint($this->info);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(CropHint::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'cropHintsAnnotation' => [
- 'cropHints' => [[]]
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('hint');
- $this->assertInstanceOf(CropHint::class, $res->returnVal());
- }
-
- public function testBoundingPoly()
- {
- $snippet = $this->snippetFromMagicMethod(CropHint::class, 'boundingPoly');
- $snippet->addLocal('hint', $this->hint);
-
- $res = $snippet->invoke('poly');
- $this->assertEquals($this->info['boundingPoly'], $res->returnVal());
- }
-
- public function testConfidence()
- {
- $snippet = $this->snippetFromMagicMethod(CropHint::class, 'confidence');
- $snippet->addLocal('hint', $this->hint);
-
- $res = $snippet->invoke('confidence');
- $this->assertEquals($this->info['confidence'], $res->returnVal());
- }
-
- public function testImportanceFraction()
- {
- $snippet = $this->snippetFromMagicMethod(CropHint::class, 'importanceFraction');
- $snippet->addLocal('hint', $this->hint);
-
- $res = $snippet->invoke('importance');
- $this->assertEquals($this->info['importanceFraction'], $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/DocumentTest.php b/Vision/tests/Snippet/Annotation/DocumentTest.php
deleted file mode 100644
index 69efa89958f3..000000000000
--- a/Vision/tests/Snippet/Annotation/DocumentTest.php
+++ /dev/null
@@ -1,104 +0,0 @@
-info = [
- 'pages' => [['foo' => 'bar']],
- 'text' => 'hello world'
- ];
- $this->document = new Document($this->info);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(Document::class);
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'fullTextAnnotation' => [[]]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/the-constitution.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('document');
- $this->assertInstanceOf(Document::class, $res->returnVal());
- }
-
- public function testPages()
- {
- $snippet = $this->snippetFromMagicMethod(Document::class, 'pages');
- $snippet->addLocal('document', $this->document);
-
- $res = $snippet->invoke('pages');
- $this->assertEquals($this->info['pages'], $res->returnVal());
- }
-
- public function testText()
- {
- $snippet = $this->snippetFromMagicMethod(Document::class, 'text');
- $snippet->addLocal('document', $this->document);
-
- $res = $snippet->invoke('text');
- $this->assertEquals($this->info['text'], $res->returnVal());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMagicMethod(Document::class, 'info');
- $snippet->addLocal('document', $this->document);
-
- $res = $snippet->invoke('info');
- $this->assertEquals($this->info, $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/EntityTest.php b/Vision/tests/Snippet/Annotation/EntityTest.php
deleted file mode 100644
index 15753fe97d31..000000000000
--- a/Vision/tests/Snippet/Annotation/EntityTest.php
+++ /dev/null
@@ -1,174 +0,0 @@
-entityData = [
- 'mid' => 'testMid',
- 'locale' => 'testLocale',
- 'description' => 'testDescription',
- 'score' => 'testScore',
- 'confidence' => 'testConfidence',
- 'topicality' => 'testTopicality',
- 'boundingPoly' => 'testBoundingPoly',
- 'locations' => 'testLocations',
- 'properties' => 'testProperties'
- ];
-
- $this->entity = new Entity($this->entityData);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(Entity::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'textAnnotations' => [[]]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('text');
- $this->assertInstanceOf(Entity::class, $res->returnVal());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'info');
- $snippet->addLocal('text', $this->entity);
- $this->assertEquals($this->entityData, $snippet->invoke('info')->returnVal());
- }
-
- public function testMid()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'mid');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['mid'], $res->output());
- }
-
- public function testLocale()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'locale');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['locale'], $res->output());
- }
-
- public function testDescription()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'description');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['description'], $res->output());
- }
-
- public function testScore()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'score');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['score'], $res->output());
- }
-
- public function testConfidence()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'confidence');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['confidence'], $res->output());
- }
-
- public function testTopicality()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'topicality');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['topicality'], $res->output());
- }
-
- public function testBoundingPoly()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'boundingPoly');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['boundingPoly'], $res->output());
- }
-
- public function testLocations()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'locations');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['locations'], $res->output());
- }
-
- public function testProperties()
- {
- $snippet = $this->snippetFromMagicMethod(Entity::class, 'properties');
- $snippet->addLocal('text', $this->entity);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->entityData['properties'], $res->output());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/Face/LandmarksTest.php b/Vision/tests/Snippet/Annotation/Face/LandmarksTest.php
deleted file mode 100644
index 747453ba68c0..000000000000
--- a/Vision/tests/Snippet/Annotation/Face/LandmarksTest.php
+++ /dev/null
@@ -1,346 +0,0 @@
-pos = [
- 'x' => 1,
- 'y' => 1,
- 'z' => 1
- ];
-
- $this->landmarksData = [
- $this->formatLandmark('LEFT_EYE'),
- $this->formatLandmark('LEFT_EYE_PUPIL'),
- $this->formatLandmark('LEFT_EYE_LEFT_CORNER'),
- $this->formatLandmark('LEFT_EYE_TOP_BOUNDARY'),
- $this->formatLandmark('LEFT_EYE_RIGHT_CORNER'),
- $this->formatLandmark('LEFT_EYE_BOTTOM_BOUNDARY'),
- $this->formatLandmark('LEFT_OF_LEFT_EYEBROW'),
- $this->formatLandmark('RIGHT_OF_LEFT_EYEBROW'),
- $this->formatLandmark('LEFT_EYEBROW_UPPER_MIDPOINT'),
- $this->formatLandmark('RIGHT_EYE'),
- $this->formatLandmark('RIGHT_EYE_PUPIL'),
- $this->formatLandmark('RIGHT_EYE_LEFT_CORNER'),
- $this->formatLandmark('RIGHT_EYE_TOP_BOUNDARY'),
- $this->formatLandmark('RIGHT_EYE_RIGHT_CORNER'),
- $this->formatLandmark('RIGHT_EYE_BOTTOM_BOUNDARY'),
- $this->formatLandmark('LEFT_OF_RIGHT_EYEBROW'),
- $this->formatLandmark('RIGHT_OF_RIGHT_EYEBROW'),
- $this->formatLandmark('RIGHT_EYEBROW_UPPER_MIDPOINT'),
- $this->formatLandmark('MIDPOINT_BETWEEN_EYES'),
- $this->formatLandmark('UPPER_LIP'),
- $this->formatLandmark('LOWER_LIP'),
- $this->formatLandmark('MOUTH_LEFT'),
- $this->formatLandmark('MOUTH_RIGHT'),
- $this->formatLandmark('MOUTH_CENTER'),
- $this->formatLandmark('NOSE_TIP'),
- $this->formatLandmark('NOSE_BOTTOM_RIGHT'),
- $this->formatLandmark('NOSE_BOTTOM_LEFT'),
- $this->formatLandmark('NOSE_BOTTOM_CENTER'),
- $this->formatLandmark('LEFT_EAR_TRAGION'),
- $this->formatLandmark('RIGHT_EAR_TRAGION'),
- $this->formatLandmark('FOREHEAD_GLABELLA'),
- $this->formatLandmark('CHIN_GNATHION'),
- $this->formatLandmark('CHIN_LEFT_GONION'),
- $this->formatLandmark('CHIN_RIGHT_GONION'),
- ];
-
- $this->landmarks = new Landmarks($this->landmarksData);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(Landmarks::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'faceAnnotations' => [
- [
- 'landmarks' => []
- ]
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('landmarks');
- $this->assertInstanceOf(Landmarks::class, $res->returnVal());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMagicMethod(Landmarks::class, 'info');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke('info');
- $this->assertEquals($this->landmarksData, $res->returnVal());
- }
-
- public function testLeftEye()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'leftEye');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionOutput('LEFT_EYE'), $res->output());
- }
-
- public function testLeftEyePupil()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'leftEyePupil');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionOutput('LEFT_EYE_PUPIL'), $res->output());
- }
-
- public function testLeftEyeBoundaries()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'leftEyeBoundaries');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'left' => 'LEFT_EYE_LEFT_CORNER',
- 'top' => 'LEFT_EYE_TOP_BOUNDARY',
- 'right' => 'LEFT_EYE_RIGHT_CORNER',
- 'bottom' => 'LEFT_EYE_BOTTOM_BOUNDARY'
- ]), $res->output());
- }
-
- public function testLeftEyeBrow()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'leftEyebrow');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'left' => 'LEFT_OF_LEFT_EYEBROW',
- 'right' => 'RIGHT_OF_LEFT_EYEBROW',
- 'upperMidpoint' => 'LEFT_EYEBROW_UPPER_MIDPOINT'
- ]), $res->output());
- }
-
- public function testRightEye()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'rightEye');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionOutput('RIGHT_EYE'), $res->output());
- }
-
- public function testRightEyePupil()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'rightEyePupil');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionOutput('RIGHT_EYE_PUPIL'), $res->output());
- }
-
- public function testRightEyeBoundaries()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'rightEyeBoundaries');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'left' => 'RIGHT_EYE_LEFT_CORNER',
- 'top' => 'RIGHT_EYE_TOP_BOUNDARY',
- 'right' => 'RIGHT_EYE_RIGHT_CORNER',
- 'bottom' => 'RIGHT_EYE_BOTTOM_BOUNDARY'
- ]), $res->output());
- }
-
- public function testRightEyeBrow()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'rightEyebrow');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'left' => 'LEFT_OF_RIGHT_EYEBROW',
- 'right' => 'RIGHT_OF_RIGHT_EYEBROW',
- 'upperMidpoint' => 'RIGHT_EYEBROW_UPPER_MIDPOINT'
- ]), $res->output());
- }
-
- public function testMidpointBetweenEyes()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'midpointBetweenEyes');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionOutput('MIDPOINT_BETWEEN_EYES'), $res->output());
- }
-
- public function testLips()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'lips');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'upper' => 'UPPER_LIP',
- 'lower' => 'LOWER_LIP'
- ]), $res->output());
- }
-
- public function testMouth()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'mouth');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'left' => 'MOUTH_LEFT',
- 'right' => 'MOUTH_RIGHT',
- 'center' => 'MOUTH_CENTER'
- ]), $res->output());
- }
-
- public function testNose()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'nose');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'tip' => 'NOSE_TIP',
- 'bottomRight' => 'NOSE_BOTTOM_RIGHT',
- 'bottomLeft' => 'NOSE_BOTTOM_LEFT',
- 'bottomCenter' => 'NOSE_BOTTOM_CENTER'
- ]), $res->output());
- }
-
- public function testEars()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'ears');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'left' => 'LEFT_EAR_TRAGION',
- 'right' => 'RIGHT_EAR_TRAGION'
- ]), $res->output());
- }
-
- public function testForehead()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'forehead');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionOutput('FOREHEAD_GLABELLA'), $res->output());
- }
-
- public function testChin()
- {
- $snippet = $this->snippetFromMethod(Landmarks::class, 'chin');
- $snippet->addLocal('landmarks', $this->landmarks);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->positionAggregate([
- 'gnathion' => 'CHIN_GNATHION',
- 'left' => 'CHIN_LEFT_GONION',
- 'right' => 'CHIN_RIGHT_GONION'
- ]), $res->output());
- }
-
- /****** HELPERS *****/
-
- private function positionOutput($type)
- {
- $pos = $this->getLandmark($type);
- $res = '';
- $res .= "x position: ". $pos['position']['x'] . PHP_EOL;
- $res .= "y position: ". $pos['position']['y'] . PHP_EOL;
- $res .= "z position: ". $pos['position']['z'] . PHP_EOL;
-
- return $res;
- }
-
- private function positionAggregate(array $positions)
- {
- $res = '';
- foreach ($positions as $name => $pos) {
- $res .= "Position Type: ". $name . PHP_EOL;
- $res .= $this->positionOutput($pos);
- }
-
- return $res;
- }
-
- private function getLandmark($type)
- {
- $l = array_filter($this->landmarksData, function ($landmark) use ($type) {
- return ($landmark['type'] === $type);
- });
-
- if (!empty($l)) {
- return current($l);
- }
- }
-
- private function formatLandmark($type)
- {
- return [
- 'type' => $type,
- 'position' => $this->pos
- ];
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/FaceTest.php b/Vision/tests/Snippet/Annotation/FaceTest.php
deleted file mode 100644
index c6c0c6366a5d..000000000000
--- a/Vision/tests/Snippet/Annotation/FaceTest.php
+++ /dev/null
@@ -1,272 +0,0 @@
-faceData = [
- 'landmarks' => [[]],
- 'boundingPoly' => 'testBoundingPoly',
- 'fdBoundingPoly' => 'testFdBoundingPoly',
- "rollAngle" => 'testrollAngle',
- "panAngle" => 'testpanAngle',
- "tiltAngle" => 'testtiltAngle',
- "detectionConfidence" => 'testdetectionConfidence',
- "landmarkingConfidence" => 'testlandmarkingConfidence',
- "joyLikelihood" => 'VERY_LIKELY',
- "sorrowLikelihood" => 'VERY_LIKELY',
- "angerLikelihood" => 'VERY_LIKELY',
- "surpriseLikelihood" => 'VERY_LIKELY',
- "underExposedLikelihood" => 'VERY_LIKELY',
- "blurredLikelihood" => 'VERY_LIKELY',
- "headwearLikelihood" => 'VERY_LIKELY',
- ];
-
- $this->face = new Face($this->faceData);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(Face::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'faceAnnotations' => [
- [
- 'landmarks' => [
- []
- ]
- ]
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('face');
- $this->assertInstanceOf(Face::class, $res->returnVal());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'info');
- $snippet->addLocal('face', $this->face);
- $this->assertEquals($this->faceData, $snippet->invoke('info')->returnVal());
- }
-
- public function testLandmarks()
- {
- $snippet = $this->snippetFromMethod(Face::class, 'landmarks');
- $snippet->addLocal('face', new Face([
- 'landmarks' => [
- [
- 'type' => 'LEFT_EYE',
- 'position' => 'foo'
- ]
- ]
- ]));
-
- $res = $snippet->invoke('leftEye');
- $this->assertEquals('foo', $res->returnVal());
- }
-
- public function testBoundingpoly()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'boundingPoly');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['boundingPoly'], $res->output());
- }
-
- public function testFdboundingpoly()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'fdBoundingPoly');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['fdBoundingPoly'], $res->output());
- }
-
- public function testRollangle()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'rollAngle');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['rollAngle'], $res->output());
- }
-
- public function testPanangle()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'panAngle');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['panAngle'], $res->output());
- }
-
- public function testTiltangle()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'tiltAngle');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['tiltAngle'], $res->output());
- }
-
- public function testDetectionconfidence()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'detectionConfidence');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['detectionConfidence'], $res->output());
- }
-
- public function testLandmarkingconfidence()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'landmarkingConfidence');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['landmarkingConfidence'], $res->output());
- }
-
- public function testJoylikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'joyLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['joyLikelihood'], $res->output());
- }
-
- public function testSorrowlikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'sorrowLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['sorrowLikelihood'], $res->output());
- }
-
- public function testAngerlikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'angerLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['angerLikelihood'], $res->output());
- }
-
- public function testSurpriselikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'surpriseLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['surpriseLikelihood'], $res->output());
- }
-
- public function testUnderexposedlikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'underExposedLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['underExposedLikelihood'], $res->output());
- }
-
- public function testBlurredlikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'blurredLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['blurredLikelihood'], $res->output());
- }
-
- public function testHeadwearlikelihood()
- {
- $snippet = $this->snippetFromMagicMethod(Face::class, 'headwearLikelihood');
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->faceData['headwearLikelihood'], $res->output());
- }
-
- /**
- * @dataProvider boolTests
- */
- public function testFaceBoolTests($method, $output)
- {
- $snippet = $this->snippetFromMethod(Face::class, $method);
- $snippet->addLocal('face', $this->face);
-
- $res = $snippet->invoke();
- $this->assertEquals($output, $res->output());
- }
-
- public function boolTests()
- {
- return [
- ['isJoyful', 'Face is Joyful'],
- ['isSorrowful', 'Face is Sorrowful'],
- ['isAngry', 'Face is Angry'],
- ['isSurprised', 'Face is Surprised'],
- ['isUnderExposed', 'Face is Under Exposed'],
- ['isBlurred', 'Face is Blurred'],
- ['hasHeadwear', 'Face has Headwear']
- ];
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/ImagePropertiesTest.php b/Vision/tests/Snippet/Annotation/ImagePropertiesTest.php
deleted file mode 100644
index 92f505432472..000000000000
--- a/Vision/tests/Snippet/Annotation/ImagePropertiesTest.php
+++ /dev/null
@@ -1,95 +0,0 @@
-propsData = ['dominantColors' => ['colors' => 'colorsTest']];
- $this->props = new ImageProperties($this->propsData);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(ImageProperties::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'imagePropertiesAnnotation' => [
- []
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('imageProperties');
- $this->assertInstanceOf(ImageProperties::class, $res->returnVal());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMagicMethod(ImageProperties::class, 'info');
- $snippet->addLocal('imageProperties', $this->props);
-
- $res = $snippet->invoke('info');
- $this->assertEquals($this->propsData, $res->returnVal());
- }
-
- public function testColors()
- {
- $snippet = $this->snippetFromMethod(ImageProperties::class, 'colors');
- $snippet->addLocal('imageProperties', $this->props);
-
- $res = $snippet->invoke('colors');
- $this->assertEquals($this->propsData['dominantColors']['colors'], $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/SafeSearchTest.php b/Vision/tests/Snippet/Annotation/SafeSearchTest.php
deleted file mode 100644
index 3a138f20f83b..000000000000
--- a/Vision/tests/Snippet/Annotation/SafeSearchTest.php
+++ /dev/null
@@ -1,183 +0,0 @@
-ssData = [
- 'adult' => 'VERY_LIKELY',
- 'spoof' => 'VERY_LIKELY',
- 'medical' => 'VERY_LIKELY',
- 'violence' => 'VERY_LIKELY',
- 'racy' => 'VERY_LIKELY',
- ];
- $this->ss = new SafeSearch($this->ssData);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(SafeSearch::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'safeSearchAnnotation' => [
- []
- ]
- ]
- ]
- ]);
-
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('safeSearch');
- $this->assertInstanceOf(SafeSearch::class, $res->returnVal());
- }
-
- public function testAdult()
- {
- $snippet = $this->snippetFromMagicMethod(SafeSearch::class, 'adult');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->ssData['adult'], $res->output());
- }
-
- public function testSpoof()
- {
- $snippet = $this->snippetFromMagicMethod(SafeSearch::class, 'spoof');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->ssData['spoof'], $res->output());
- }
-
- public function testMedical()
- {
- $snippet = $this->snippetFromMagicMethod(SafeSearch::class, 'medical');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->ssData['medical'], $res->output());
- }
-
- public function testViolence()
- {
- $snippet = $this->snippetFromMagicMethod(SafeSearch::class, 'violence');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->ssData['violence'], $res->output());
- }
-
- public function testRacy()
- {
- $snippet = $this->snippetFromMagicMethod(SafeSearch::class, 'racy');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals($this->ssData['racy'], $res->output());
- }
-
- public function testIsAdult()
- {
- $snippet = $this->snippetFromMethod(SafeSearch::class, 'isAdult');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals(sprintf('Image contains %s content.', 'adult'), $res->output());
- }
-
- public function testIsSpoof()
- {
- $snippet = $this->snippetFromMethod(SafeSearch::class, 'isSpoof');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals(sprintf('Image contains %s content.', 'spoofed'), $res->output());
- }
-
- public function testIsMedical()
- {
- $snippet = $this->snippetFromMethod(SafeSearch::class, 'isMedical');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals(sprintf('Image contains %s content.', 'medical'), $res->output());
- }
-
- public function testIsViolent()
- {
- $snippet = $this->snippetFromMethod(SafeSearch::class, 'isViolent');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals(sprintf('Image contains %s content.', 'violent'), $res->output());
- }
-
- public function testIsRacy()
- {
- $snippet = $this->snippetFromMethod(SafeSearch::class, 'isRacy');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke();
- $this->assertEquals(sprintf('Image contains %s content.', 'racy'), $res->output());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMagicMethod(SafeSearch::class, 'info');
- $snippet->addLocal('safeSearch', $this->ss);
-
- $res = $snippet->invoke('info');
- $this->assertEquals($this->ssData, $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/Web/WebEntityTest.php b/Vision/tests/Snippet/Annotation/Web/WebEntityTest.php
deleted file mode 100644
index 688a8ebfeb4f..000000000000
--- a/Vision/tests/Snippet/Annotation/Web/WebEntityTest.php
+++ /dev/null
@@ -1,110 +0,0 @@
-info = [
- 'entityId' => 'foo',
- 'score' => 0.1,
- 'description' => 'bar'
- ];
- $this->entity = new WebEntity($this->info);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(WebEntity::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'webDetection' => [
- 'webEntities' => [
- []
- ]
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/eiffel-tower.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('firstEntity');
- $this->assertInstanceOf(WebEntity::class, $res->returnVal());
- }
-
- public function testEntityId()
- {
- $snippet = $this->snippetFromMagicMethod(WebEntity::class, 'entityId');
- $snippet->addLocal('entity', $this->entity);
-
- $res = $snippet->invoke('id');
- $this->assertEquals($this->info['entityId'], $res->returnVal());
- }
-
- public function testScore()
- {
- $snippet = $this->snippetFromMagicMethod(WebEntity::class, 'score');
- $snippet->addLocal('entity', $this->entity);
-
- $res = $snippet->invoke('score');
- $this->assertEquals($this->info['score'], $res->returnVal());
- }
-
- public function testDescription()
- {
- $snippet = $this->snippetFromMagicMethod(WebEntity::class, 'description');
- $snippet->addLocal('entity', $this->entity);
-
- $res = $snippet->invoke('description');
- $this->assertEquals($this->info['description'], $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/Web/WebImageTest.php b/Vision/tests/Snippet/Annotation/Web/WebImageTest.php
deleted file mode 100644
index f37659eb3ca4..000000000000
--- a/Vision/tests/Snippet/Annotation/Web/WebImageTest.php
+++ /dev/null
@@ -1,100 +0,0 @@
-info = [
- 'url' => 'http://foo.bar/image.jpg',
- 'score' => 0.1,
- ];
- $this->image = new WebImage($this->info);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(WebImage::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'webDetection' => [
- 'fullMatchingImages' => [
- []
- ]
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/eiffel-tower.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('firstImage');
- $this->assertInstanceOf(WebImage::class, $res->returnVal());
- }
-
- public function testurl()
- {
- $snippet = $this->snippetFromMagicMethod(WebImage::class, 'url');
- $snippet->addLocal('image', $this->image);
-
- $res = $snippet->invoke('url');
- $this->assertEquals($this->info['url'], $this->image->url());
- }
-
- public function testscore()
- {
- $snippet = $this->snippetFromMagicMethod(WebImage::class, 'score');
- $snippet->addLocal('image', $this->image);
-
- $res = $snippet->invoke('score');
- $this->assertEquals($this->info['score'], $this->image->score());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/Web/WebPageTest.php b/Vision/tests/Snippet/Annotation/Web/WebPageTest.php
deleted file mode 100644
index 0cd25d772425..000000000000
--- a/Vision/tests/Snippet/Annotation/Web/WebPageTest.php
+++ /dev/null
@@ -1,100 +0,0 @@
-info = [
- 'url' => 'http://foo.bar/image.jpg',
- 'score' => 0.1,
- ];
- $this->image = new WebPage($this->info);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(WebPage::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'webDetection' => [
- 'pagesWithMatchingImages' => [
- []
- ]
- ]
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/eiffel-tower.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('firstPage');
- $this->assertInstanceOf(WebPage::class, $res->returnVal());
- }
-
- public function testurl()
- {
- $snippet = $this->snippetFromMagicMethod(WebPage::class, 'url');
- $snippet->addLocal('image', $this->image);
-
- $res = $snippet->invoke('url');
- $this->assertEquals($this->info['url'], $this->image->url());
- }
-
- public function testscore()
- {
- $snippet = $this->snippetFromMagicMethod(WebPage::class, 'score');
- $snippet->addLocal('image', $this->image);
-
- $res = $snippet->invoke('score');
- $this->assertEquals($this->info['score'], $this->image->score());
- }
-}
diff --git a/Vision/tests/Snippet/Annotation/WebTest.php b/Vision/tests/Snippet/Annotation/WebTest.php
deleted file mode 100644
index a4dfba59dc80..000000000000
--- a/Vision/tests/Snippet/Annotation/WebTest.php
+++ /dev/null
@@ -1,127 +0,0 @@
-info = [
- 'webEntities' => [
- []
- ],
- 'fullMatchingImages' => [
- []
- ],
- 'partialMatchingImages' => [
- []
- ],
- 'pagesWithMatchingImages' => [
- []
- ]
- ];
- $this->web = new Web($this->info);
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(Web::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [
- 'webDetection' => []
- ]
- ]
- ]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('web');
- $this->assertInstanceOf(Web::class, $res->returnVal());
- }
-
- public function testEntities()
- {
- $snippet = $this->snippetFromMethod(Web::class, 'entities');
- $snippet->addLocal('web', $this->web);
-
- $res = $snippet->invoke('entities');
- $this->assertInstanceOf(WebEntity::class, $res->returnVal()[0]);
- }
-
- public function testMatchingImages()
- {
- $snippet = $this->snippetFromMethod(Web::class, 'matchingImages');
- $snippet->addLocal('web', $this->web);
-
- $res = $snippet->invoke('images');
- $this->assertInstanceOf(WebImage::class, $res->returnVal()[0]);
- }
-
- public function testPartialMatchingImages()
- {
- $snippet = $this->snippetFromMethod(Web::class, 'partialMatchingImages');
- $snippet->addLocal('web', $this->web);
-
- $res = $snippet->invoke('images');
- $this->assertInstanceOf(WebImage::class, $res->returnVal()[0]);
- }
-
- public function testPages()
- {
- $snippet = $this->snippetFromMethod(Web::class, 'pages');
- $snippet->addLocal('web', $this->web);
-
- $res = $snippet->invoke('pages');
- $this->assertInstanceOf(WebPage::class, $res->returnVal()[0]);
- }
-}
diff --git a/Vision/tests/Snippet/AnnotationTest.php b/Vision/tests/Snippet/AnnotationTest.php
deleted file mode 100644
index 47cf747d64d4..000000000000
--- a/Vision/tests/Snippet/AnnotationTest.php
+++ /dev/null
@@ -1,210 +0,0 @@
-snippetFromClass(Annotation::class);
-
- $connection = $this->prophesize(ConnectionInterface::class);
- $connection->annotate(Argument::any())
- ->willReturn(['responses' => [[]]]);
-
- $vision = TestHelpers::stub(VisionClient::class);
- $vision->___setProperty('connection', $connection->reveal());
-
- $snippet->addLocal('vision', $vision);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
- $snippet->replace(
- '$vision = new VisionClient();',
- ''
- );
-
- $res = $snippet->invoke('annotation');
- $this->assertInstanceOf(Annotation::class, $res->returnVal());
- }
-
- public function testInfo()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'info');
- $snippet->addLocal('annotation', new Annotation('foo'));
-
- $res = $snippet->invoke('info');
- $this->assertEquals('foo', $res->returnVal());
- }
-
- public function testFaces()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'faces');
- $snippet->addLocal('annotation', new Annotation([
- 'faceAnnotations' => [
- ['landmarks' => []]
- ]
- ]));
-
- $res = $snippet->invoke('faces');
- $this->assertInstanceOf(Face::class, $res->returnVal()[0]);
- }
-
- public function testLandmarks()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'landmarks');
- $snippet->addLocal('annotation', new Annotation([
- 'landmarkAnnotations' => [
- []
- ]
- ]));
-
- $res = $snippet->invoke('landmarks');
- $this->assertInstanceOf(Entity::class, $res->returnVal()[0]);
- }
-
- public function testLogos()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'logos');
- $snippet->addLocal('annotation', new Annotation([
- 'logoAnnotations' => [
- []
- ]
- ]));
-
- $res = $snippet->invoke('logos');
- $this->assertInstanceOf(Entity::class, $res->returnVal()[0]);
- }
-
- public function testLabels()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'labels');
- $snippet->addLocal('annotation', new Annotation([
- 'labelAnnotations' => [
- []
- ]
- ]));
-
- $res = $snippet->invoke('labels');
- $this->assertInstanceOf(Entity::class, $res->returnVal()[0]);
- }
-
- public function testText()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'text');
- $snippet->addLocal('annotation', new Annotation([
- 'textAnnotations' => [
- []
- ]
- ]));
-
- $res = $snippet->invoke('text');
- $this->assertInstanceOf(Entity::class, $res->returnVal()[0]);
- }
-
- public function testSafeSearch()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'safeSearch');
- $snippet->addLocal('annotation', new Annotation([
- 'safeSearchAnnotation' => []
- ]));
-
- $res = $snippet->invoke('safeSearch');
- $this->assertInstanceOf(SafeSearch::class, $res->returnVal());
- }
-
- public function testImageProperties()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'imageProperties');
- $snippet->addLocal('annotation', new Annotation([
- 'imagePropertiesAnnotation' => []
- ]));
-
- $res = $snippet->invoke('properties');
- $this->assertInstanceOf(ImageProperties::class, $res->returnVal());
- }
-
- public function testFullText()
- {
- $ft = ['foo' => 'bar'];
- $snippet = $this->snippetFromMethod(Annotation::class, 'fullText');
- $snippet->addLocal('annotation', new Annotation([
- 'fullTextAnnotation' => $ft
- ]));
-
- $res = $snippet->invoke('fullText');
- $this->assertInstanceOf(Document::class, $res->returnVal());
- }
-
- public function testCropHints()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'cropHints');
- $snippet->addLocal('annotation', new Annotation([
- 'cropHintsAnnotation' => [
- 'cropHints' => [[]]
- ]
- ]));
-
- $res = $snippet->invoke('hints');
- $this->assertInstanceOf(CropHint::class, $res->returnVal()[0]);
- }
-
- public function testWeb()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'web');
- $snippet->addLocal('annotation', new Annotation([
- 'webDetection' => []
- ]));
-
- $res = $snippet->invoke('web');
- $this->assertInstanceOf(Web::class, $res->returnVal());
- }
-
- public function testError()
- {
- $snippet = $this->snippetFromMethod(Annotation::class, 'error');
- $snippet->addLocal('annotation', new Annotation([
- 'error' => []
- ]));
-
- $res = $snippet->invoke('error');
- $this->assertIsArray($res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/ImageTest.php b/Vision/tests/Snippet/ImageTest.php
deleted file mode 100644
index 262b21c036c7..000000000000
--- a/Vision/tests/Snippet/ImageTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
-snippetFromClass(Image::class, 'default');
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('image');
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testDirectInstantiation()
- {
- $snippet = $this->snippetFromClass(Image::class, 'direct');
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('image');
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testImageString()
- {
- $snippet = $this->snippetFromClass(Image::class, 'string');
- $snippet->setLine(5, '$imageData = \'foo\';');
-
- $res = $snippet->invoke('image');
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testGcsImage()
- {
- $cloud = new ServiceBuilder;
- $snippet = $this->snippetFromClass(Image::class, 'gcs');
- $snippet->addLocal('cloud', $cloud);
-
- $res = $snippet->invoke('image');
- $res = $snippet->invoke('image');
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testMaxResults()
- {
- $snippet = $this->snippetFromClass(Image::class, 'max');
- $snippet->setLine(5, '$imageResource = fopen(\'php://temp\', \'r\');');
-
- $res = $snippet->invoke('image');
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testFeatureShortcuts()
- {
- $snippet = $this->snippetFromClass(Image::class, 'shortcut');
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('image');
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testRequestObject()
- {
- $snippet = $this->snippetFromMethod(Image::class, 'requestObject');
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('requestObj');
- $this->assertArrayHasKey('image', $res->returnVal());
- $this->assertArrayHasKey('features', $res->returnVal());
- }
-}
diff --git a/Vision/tests/Snippet/V1/ImageAnnotatorClientTest.php b/Vision/tests/Snippet/V1/ImageAnnotatorClientTest.php
deleted file mode 100644
index 53dbabad8ba7..000000000000
--- a/Vision/tests/Snippet/V1/ImageAnnotatorClientTest.php
+++ /dev/null
@@ -1,153 +0,0 @@
-transport = $this->prophesize(TransportInterface::class);
- $this->client = new ImageAnnotatorClient([
- 'transport' => $this->transport->reveal(),
- ]);
- }
-
- /**
- * @dataProvider createImageObjectSnippetsDataProvider
- */
- public function testCreateImageObjectSnippets($snippetName)
- {
- $snippet = $this->snippetFromMethod(
- ImageAnnotatorClient::class,
- 'createImageObject',
- $snippetName
- );
- $snippet->addLocal('imageAnnotatorClient', $this->client);
-
- $snippet->replace(
- "path/to/image.jpg",
- "php://temp"
- );
-
- $this->transport->startUnaryCall(Argument::type(Call::class), Argument::type('array'))
- ->shouldBeCalledTimes(1)
- ->willReturn($this->getPromisedResponse());
-
- $res = $snippet->invoke('image');
-
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function createImageObjectSnippetsDataProvider()
- {
- return [
- ['resource'],
- ['data'],
- ['url']
- ];
- }
-
- public function testAnnotateImage()
- {
- $snippet = $this->snippetFromMethod(ImageAnnotatorClient::class, 'annotateImage');
- $snippet->addLocal('imageAnnotatorClient', $this->client);
-
- $snippet->replace(
- "path/to/image.jpg",
- "php://temp"
- );
-
- $this->transport->startUnaryCall(Argument::type(Call::class), Argument::type('array'))
- ->shouldBeCalledTimes(1)
- ->willReturn($this->getPromisedResponse());
-
- $res = $snippet->invoke('response');
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $res->returnVal());
- }
-
- /**
- * @dataProvider detectionMethodSnippetDataProvider
- */
- public function testDetectionMethodSnippet($method)
- {
- $snippet = $this->snippetFromMethod(ImageAnnotatorClient::class, $method);
- $snippet->addLocal('imageAnnotatorClient', $this->client);
-
- $snippet->replace(
- "path/to/image.jpg",
- "php://temp"
- );
-
- $this->transport->startUnaryCall(Argument::type(Call::class), Argument::type('array'))
- ->shouldBeCalledTimes(1)
- ->willReturn($this->getPromisedResponse());
-
- $res = $snippet->invoke('response');
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $res->returnVal());
- }
-
- public function detectionMethodSnippetDataProvider()
- {
- return [
- ['faceDetection'],
- ['landmarkDetection'],
- ['logoDetection'],
- ['labelDetection'],
- ['textDetection'],
- ['documentTextDetection'],
- ['safeSearchDetection'],
- ['imagePropertiesDetection'],
- ['cropHintsDetection'],
- ['webDetection'],
- ['objectLocalization'],
- ['productSearch'],
- ];
- }
-
- private function getPromisedResponse()
- {
- $expectedAnnotationResponses = [new AnnotateImageResponse()];
- $expectedResponse = new BatchAnnotateImagesResponse();
- $expectedResponse->setResponses($expectedAnnotationResponses);
- return new FulfilledPromise(
- $expectedResponse
- );
- }
-}
diff --git a/Vision/tests/Snippet/VisionClientTest.php b/Vision/tests/Snippet/VisionClientTest.php
deleted file mode 100644
index 8e95a73cf241..000000000000
--- a/Vision/tests/Snippet/VisionClientTest.php
+++ /dev/null
@@ -1,159 +0,0 @@
-connection = $this->prophesize(ConnectionInterface::class);
- $this->client = TestHelpers::stub(VisionClient::class);
- $this->client->___setProperty('connection', $this->connection->reveal());
- }
-
- public function testClass()
- {
- $snippet = $this->snippetFromClass(VisionClient::class);
- $res = $snippet->invoke('vision');
-
- $this->assertInstanceOf(VisionClient::class, $res->returnVal());
- }
-
- public function testImage()
- {
- $snippet = $this->snippetFromMethod(VisionClient::class, 'image');
- $snippet->addLocal('vision', $this->client);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('image');
-
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testImageWithMaxResults()
- {
- $snippet = $this->snippetFromMethod(VisionClient::class, 'image', 1);
- $snippet->addLocal('vision', $this->client);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('image');
-
- $this->assertInstanceOf(Image::class, $res->returnVal());
- }
-
- public function testImages()
- {
- $snippet = $this->snippetFromMethod(VisionClient::class, 'images');
- $snippet->addLocal('vision', $this->client);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $snippet->replace(
- "__DIR__ . '/assets/wedding-photo.jpg'",
- "'php://temp'"
- );
-
- $res = $snippet->invoke('images');
- $this->assertInstanceOf(Image::class, $res->returnVal()[0]);
- $this->assertInstanceOf(Image::class, $res->returnVal()[1]);
- }
-
- public function testAnnotate()
- {
- $snippet = $this->snippetFromMethod(VisionClient::class, 'annotate');
- $snippet->addLocal('vision', $this->client);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $this->connection->annotate(Argument::any())
- ->shouldBeCalled()
- ->willReturn([
- 'responses' => [
- []
- ]
- ]);
-
- $this->client->___setProperty('connection', $this->connection->reveal());
-
- $res = $snippet->invoke('result');
-
- $this->assertInstanceOf(Annotation::class, $res->returnVal());
- }
-
- public function testAnnotateBatch()
- {
- $snippet = $this->snippetFromMethod(VisionClient::class, 'annotateBatch');
- $snippet->addLocal('vision', $this->client);
-
- $snippet->replace(
- "__DIR__ . '/assets/family-photo.jpg'",
- "'php://temp'"
- );
-
- $snippet->replace(
- "__DIR__ . '/assets/eiffel-tower.jpg'",
- "'php://temp'"
- );
-
- $this->connection->annotate(Argument::any())
- ->shouldBeCalled()
- ->willReturn([
- 'responses' => [
- [], []
- ]
- ]);
-
- $this->client->___setProperty('connection', $this->connection->reveal());
-
- $res = $snippet->invoke('result');
-
- $this->assertInstanceOf(Annotation::class, $res->returnVal()[0]);
- $this->assertInstanceOf(Annotation::class, $res->returnVal()[1]);
- }
-}
diff --git a/Vision/tests/System/AnnotationsTest.php b/Vision/tests/System/AnnotationsTest.php
deleted file mode 100644
index 7fdd914bc78b..000000000000
--- a/Vision/tests/System/AnnotationsTest.php
+++ /dev/null
@@ -1,165 +0,0 @@
-client = parent::$vision;
- }
-
- public function testAnnotate()
- {
- $image = $this->client->image(file_get_contents($this->getFixtureFilePath('landmark.jpg')), [
- 'LANDMARK_DETECTION',
- 'SAFE_SEARCH_DETECTION',
- 'IMAGE_PROPERTIES',
- 'CROP_HINTS',
- 'WEB_DETECTION'
- ]);
-
- $res = $this->client->annotate($image);
- $this->assertInstanceOf(Annotation::class, $res);
-
- // Landmarks
- $this->assertInstanceOf(Entity::class, $res->landmarks()[0]);
- $this->assertEquals('mount rushmore national memorial', strtolower($res->landmarks()[0]->description()));
-
- // Safe Search
- $this->assertInstanceOf(SafeSearch::class, $res->safeSearch());
- $this->assertStringContainsString('UNLIKELY', $res->safeSearch()->adult());
- $this->assertStringContainsString('UNLIKELY', $res->safeSearch()->spoof());
- $this->assertStringContainsString('UNLIKELY', $res->safeSearch()->medical());
- $this->assertStringContainsString('UNLIKELY', $res->safeSearch()->violence());
- $this->assertStringContainsString('UNLIKELY', $res->safeSearch()->racy());
- $this->assertFalse($res->safeSearch()->isAdult());
- $this->assertFalse($res->safeSearch()->isSpoof());
- $this->assertFalse($res->safeSearch()->isMedical());
- $this->assertFalse($res->safeSearch()->isViolent());
- $this->assertFalse($res->safeSearch()->isRacy());
-
- // Image Properties
- $this->assertInstanceOf(ImageProperties::class, $res->imageProperties());
- $this->assertIsArray($res->imageProperties()->colors());
-
- // Crop Hints
- $this->assertInstanceOf(CropHint::class, $res->cropHints()[0]);
- $this->assertArrayHasKey('vertices', $res->cropHints()[0]->boundingPoly());
- $this->assertIsFloat($res->cropHints()[0]->confidence());
- $this->assertNotNull($res->cropHints()[0]->importanceFraction());
-
- // Web Annotation
- $this->assertInstanceOf(Web::class, $res->web());
- $this->assertInstanceOf(WebEntity::class, $res->web()->entities()[0]);
-
- $desc = array_filter($res->web()->entities(), function ($e) {
- return isset($e->info()['description'])
- && strpos($e->description(), 'Monument') !== false;
- });
- $this->assertGreaterThan(0, count($desc));
-
- // flakey tests
- if (isset($res->web()->matchingImages()[0])) {
- $this->assertInstanceOf(WebImage::class, $res->web()->matchingImages()[0]);
- $this->assertInstanceOf(WebImage::class, $res->web()->partialMatchingImages()[0]);
- }
- $this->assertInstanceOf(WebPage::class, $res->web()->pages()[0]);
- }
-
- public function testFaceAndLabelDetection()
- {
- $image = $this->client->image(file_get_contents($this->getFixtureFilePath('obama.jpg')), [
- 'FACE_DETECTION',
- 'LABEL_DETECTION'
- ]);
-
- $res = $this->client->annotate($image);
-
- $this->assertInstanceOf(Annotation::class, $res);
-
- // Face Detection
- $this->assertInstanceOf(Face::class, $res->faces()[0]);
- $this->assertInstanceOf(Landmarks::class, $res->faces()[0]->landmarks());
- $this->assertTrue($res->faces()[0]->isJoyful());
- $this->assertFalse($res->faces()[0]->isSorrowful());
- $this->assertFalse($res->faces()[0]->isAngry());
- $this->assertFalse($res->faces()[0]->isSurprised());
- $this->assertFalse($res->faces()[0]->isUnderExposed());
- $this->assertFalse($res->faces()[0]->isBlurred());
- $this->assertFalse($res->faces()[0]->hasHeadwear());
-
- // Label Detection
- $this->assertInstanceOf(Entity::class, $res->labels()[0]);
- }
-
- public function testLogoDetection()
- {
- $image = $this->client->image(file_get_contents($this->getFixtureFilePath('google.jpg')), [
- 'LOGO_DETECTION'
- ]);
-
- $res = $this->client->annotate($image);
- $this->assertInstanceOf(Annotation::class, $res);
- $this->assertInstanceOf(Entity::class, $res->logos()[0]);
- $this->assertEquals('google', strtolower($res->logos()[0]->description()));
- }
-
- public function testTextDetection()
- {
- $image = $this->client->image(file_get_contents($this->getFixtureFilePath('text.jpg')), [
- 'TEXT_DETECTION'
- ]);
-
- $res = $this->client->annotate($image);
- $this->assertInstanceOf(Annotation::class, $res);
- $this->assertInstanceOf(Entity::class, $res->text()[0]);
- $this->assertEquals("Hello World", trim(explode("\n", $res->text()[0]->description())[0], '.'));
- $this->assertEquals("Goodby World!", explode("\n", $res->text()[0]->description())[1]);
- }
-
- public function testDocumentTextDetection()
- {
- $image = $this->client->image(file_get_contents($this->getFixtureFilePath('text.jpg')), [
- 'DOCUMENT_TEXT_DETECTION'
- ]);
-
- $res = $this->client->annotate($image);
-
- $this->assertInstanceOf(Annotation::class, $res);
- $this->assertInstanceOf(Document::class, $res->fullText());
- }
-}
diff --git a/Vision/tests/System/V1/ImageAnnotatorSmokeTest.php b/Vision/tests/System/V1/ImageAnnotatorSmokeTest.php
deleted file mode 100644
index befe1aaad639..000000000000
--- a/Vision/tests/System/V1/ImageAnnotatorSmokeTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-setGcsImageUri($gcsImageUri);
- $image = new Image();
- $image->setSource($source);
- $type = Type::FACE_DETECTION;
- $featuresElement = new Feature();
- $featuresElement->setType($type);
- $features = [$featuresElement];
- $requestsElement = new AnnotateImageRequest();
- $requestsElement->setImage($image);
- $requestsElement->setFeatures($features);
- $requests = [$requestsElement];
- $imageAnnotatorClient->batchAnnotateImages($requests);
- }
-}
diff --git a/Vision/tests/System/VisionTestCase.php b/Vision/tests/System/VisionTestCase.php
deleted file mode 100644
index 9cd47e1b7711..000000000000
--- a/Vision/tests/System/VisionTestCase.php
+++ /dev/null
@@ -1,51 +0,0 @@
- $keyFilePath
- ]);
- self::$hasSetUp = true;
- }
-
- protected function getFixtureFilePath($file)
- {
- return __DIR__ .'/fixtures/'. $file;
- }
-}
diff --git a/Vision/tests/System/bootstrap.php b/Vision/tests/System/bootstrap.php
deleted file mode 100644
index ef978fd2a310..000000000000
--- a/Vision/tests/System/bootstrap.php
+++ /dev/null
@@ -1,6 +0,0 @@
-info = [
- 'boundingPoly' => ['foo' => 'bar'],
- 'confidence' => 0.4,
- 'importanceFraction' => 0.1
- ];
-
- $this->hint = new CropHint($this->info);
- }
-
- public function testBoundingPoly()
- {
- $this->assertEquals($this->info['boundingPoly'], $this->hint->boundingPoly());
- }
-
- public function testConfidence()
- {
- $this->assertEquals($this->info['confidence'], $this->hint->confidence());
- }
-
- public function testImportanceFraction()
- {
- $this->assertEquals($this->info['importanceFraction'], $this->hint->importanceFraction());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/DocumentTest.php b/Vision/tests/Unit/Annotation/DocumentTest.php
deleted file mode 100644
index 6fa31f49fb3f..000000000000
--- a/Vision/tests/Unit/Annotation/DocumentTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
- 'bar'
- ];
-
- $e = new Document($res);
-
- $this->assertEquals($res, $e->info());
- $this->assertEquals('bar', $e->foo());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/EntityTest.php b/Vision/tests/Unit/Annotation/EntityTest.php
deleted file mode 100644
index a1252fbff3f1..000000000000
--- a/Vision/tests/Unit/Annotation/EntityTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
- 'bar'
- ];
-
- $e = new Entity($res);
-
- $this->assertEquals($res, $e->info());
- $this->assertEquals('bar', $e->foo());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/Face/LandmarksTest.php b/Vision/tests/Unit/Annotation/Face/LandmarksTest.php
deleted file mode 100644
index 7ab61a4c5190..000000000000
--- a/Vision/tests/Unit/Annotation/Face/LandmarksTest.php
+++ /dev/null
@@ -1,148 +0,0 @@
-data = json_decode(file_get_contents(Fixtures::FACE_LANDMARKS_FIXTURE()), true);
- $this->landmarks = new Landmarks($this->data);
- }
-
- public function testLeftEye()
- {
- $this->assertEquals($this->landmarks->leftEye(), $this->pos('LEFT_EYE'));
- }
-
- public function testLeftEyePupil()
- {
- $this->assertEquals($this->landmarks->leftEyePupil(), $this->pos('LEFT_EYE_PUPIL'));
- }
-
- public function testLeftEyeBoundaries()
- {
- $b = $this->landmarks->leftEyeBoundaries();
-
- $this->assertEquals($b['left'], $this->pos('LEFT_EYE_LEFT_CORNER'));
- $this->assertEquals($b['top'], $this->pos('LEFT_EYE_TOP_BOUNDARY'));
- $this->assertEquals($b['right'], $this->pos('LEFT_EYE_RIGHT_CORNER'));
- $this->assertEquals($b['bottom'], $this->pos('LEFT_EYE_BOTTOM_BOUNDARY'));
- }
-
- public function testLeftEyebrow()
- {
- $b = $this->landmarks->leftEyebrow();
-
- $this->assertEquals($b['left'], $this->pos('LEFT_OF_LEFT_EYEBROW'));
- $this->assertEquals($b['right'], $this->pos('RIGHT_OF_LEFT_EYEBROW'));
- $this->assertEquals($b['upperMidpoint'], $this->pos('LEFT_EYEBROW_UPPER_MIDPOINT'));
- }
-
- public function testRightEye()
- {
- $this->assertEquals($this->landmarks->rightEye(), $this->pos('RIGHT_EYE'));
- }
-
- public function testRightEyePupil()
- {
- $this->assertEquals($this->landmarks->rightEyePupil(), $this->pos('RIGHT_EYE_PUPIL'));
- }
-
- public function testRightEyeBoundaries()
- {
- $b = $this->landmarks->rightEyeBoundaries();
-
- $this->assertEquals($b['left'], $this->pos('RIGHT_EYE_LEFT_CORNER'));
- $this->assertEquals($b['top'], $this->pos('RIGHT_EYE_TOP_BOUNDARY'));
- $this->assertEquals($b['right'], $this->pos('RIGHT_EYE_RIGHT_CORNER'));
- $this->assertEquals($b['bottom'], $this->pos('RIGHT_EYE_BOTTOM_BOUNDARY'));
- }
-
- public function testRightEyebrow()
- {
- $b = $this->landmarks->rightEyebrow();
-
- $this->assertEquals($b['left'], $this->pos('LEFT_OF_RIGHT_EYEBROW'));
- $this->assertEquals($b['right'], $this->pos('RIGHT_OF_RIGHT_EYEBROW'));
- $this->assertEquals($b['upperMidpoint'], $this->pos('RIGHT_EYEBROW_UPPER_MIDPOINT'));
- }
-
- public function testMidpointBetweenEyes()
- {
- $this->assertEquals($this->landmarks->midpointBetweenEyes(), $this->pos('MIDPOINT_BETWEEN_EYES'));
- }
-
- public function testLips()
- {
- $this->assertEquals($this->landmarks->lips()['upper'], $this->pos('UPPER_LIP'));
- $this->assertEquals($this->landmarks->lips()['lower'], $this->pos('LOWER_LIP'));
- }
-
- public function testMouth()
- {
- $this->assertEquals($this->landmarks->mouth()['left'], $this->pos('MOUTH_LEFT'));
- $this->assertEquals($this->landmarks->mouth()['right'], $this->pos('MOUTH_RIGHT'));
- $this->assertEquals($this->landmarks->mouth()['center'], $this->pos('MOUTH_CENTER'));
- }
-
- public function testNose()
- {
- $this->assertEquals($this->landmarks->nose()['tip'], $this->pos('NOSE_TIP'));
- $this->assertEquals($this->landmarks->nose()['bottomRight'], $this->pos('NOSE_BOTTOM_RIGHT'));
- $this->assertEquals($this->landmarks->nose()['bottomLeft'], $this->pos('NOSE_BOTTOM_LEFT'));
- $this->assertEquals($this->landmarks->nose()['bottomCenter'], $this->pos('NOSE_BOTTOM_CENTER'));
- }
-
- public function testEars()
- {
- $this->assertEquals($this->landmarks->ears()['left'], $this->pos('LEFT_EAR_TRAGION'));
- $this->assertEquals($this->landmarks->ears()['right'], $this->pos('RIGHT_EAR_TRAGION'));
- }
-
- public function testForehead()
- {
- $this->assertEquals($this->landmarks->forehead(), $this->pos('FOREHEAD_GLABELLA'));
- }
-
- public function testChin()
- {
- $this->assertEquals($this->landmarks->chin()['gnathion'], $this->pos('CHIN_GNATHION'));
- $this->assertEquals($this->landmarks->chin()['left'], $this->pos('CHIN_LEFT_GONION'));
- $this->assertEquals($this->landmarks->chin()['right'], $this->pos('CHIN_RIGHT_GONION'));
- }
-
- private function pos($type)
- {
- $val = array_filter($this->data, function ($landmark) use ($type) {
- return ($landmark['type'] === $type);
- });
-
- return array_shift($val)['position'];
- }
-}
diff --git a/Vision/tests/Unit/Annotation/FaceTest.php b/Vision/tests/Unit/Annotation/FaceTest.php
deleted file mode 100644
index 8722cd0cfd22..000000000000
--- a/Vision/tests/Unit/Annotation/FaceTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-face = new Face([
- 'landmarks' => [],
- 'joyLikelihood' => 'VERY_LIKELY',
- 'sorrowLikelihood' => 'VERY_LIKELY',
- 'angerLikelihood' => 'VERY_LIKELY',
- 'surpriseLikelihood' => 'VERY_LIKELY',
- 'underExposedLikelihood' => 'VERY_LIKELY',
- 'blurredLikelihood' => 'VERY_LIKELY',
- 'headwearLikelihood' => 'VERY_LIKELY'
- ]);
- }
-
- public function testLandmarks()
- {
- $this->assertInstanceOf(Landmarks::class, $this->face->landmarks());
- }
-
- public function testIsJoyful()
- {
- $this->assertTrue($this->face->isJoyful());
- }
-
- public function testIsSorrowful()
- {
- $this->assertTrue($this->face->isSorrowful());
- }
-
- public function testIsAngry()
- {
- $this->assertTrue($this->face->isAngry());
- }
-
- public function testIsSurprised()
- {
- $this->assertTrue($this->face->isSurprised());
- }
-
- public function testIsUnderExposed()
- {
- $this->assertTrue($this->face->isUnderExposed());
- }
-
- public function testIsBlurred()
- {
- $this->assertTrue($this->face->isBlurred());
- }
-
- public function testHasHeadwear()
- {
- $this->assertTrue($this->face->hasHeadwear());
- }
-
- public function testCall()
- {
- $this->assertEquals('VERY_LIKELY', $this->face->headwearLikelihood());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/LikelihoodTraitTest.php b/Vision/tests/Unit/Annotation/LikelihoodTraitTest.php
deleted file mode 100644
index 618483142300..000000000000
--- a/Vision/tests/Unit/Annotation/LikelihoodTraitTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-stub = TestHelpers::impl(LikelihoodTrait::class);
- }
-
- /**
- * @dataProvider likelihood
- */
- public function testLikelihoods($expected, $value, $strength)
- {
- $this->assertEquals($expected, $this->stub->call('likelihood', [
- $value,
- $strength
- ]));
- }
-
- public function likelihood()
- {
- return [
- [true, 'VERY_LIKELY', FeatureInterface::STRENGTH_HIGH],
- [false, 'LIKELY', FeatureInterface::STRENGTH_HIGH],
- [false, 'POSSIBLE', FeatureInterface::STRENGTH_HIGH],
- [true, 'VERY_LIKELY', FeatureInterface::STRENGTH_MEDIUM],
- [true, 'LIKELY', FeatureInterface::STRENGTH_MEDIUM],
- [false, 'POSSIBLE', FeatureInterface::STRENGTH_MEDIUM],
- [true, 'VERY_LIKELY', FeatureInterface::STRENGTH_LOW],
- [true, 'LIKELY', FeatureInterface::STRENGTH_LOW],
- [true, 'POSSIBLE', FeatureInterface::STRENGTH_LOW],
- ];
- }
-
- public function testErr()
- {
- $this->expectException('InvalidArgumentException');
-
- $this->stub->call('likelihood', ['foo', 'bar']);
- }
-}
diff --git a/Vision/tests/Unit/Annotation/SafeSearchTest.php b/Vision/tests/Unit/Annotation/SafeSearchTest.php
deleted file mode 100644
index f7dc2628e173..000000000000
--- a/Vision/tests/Unit/Annotation/SafeSearchTest.php
+++ /dev/null
@@ -1,70 +0,0 @@
-safeSearch = new SafeSearch([
- 'adult' => 'VERY_LIKELY',
- 'spoof' => 'VERY_LIKELY',
- 'medical' => 'VERY_LIKELY',
- 'violence' => 'VERY_LIKELY',
- 'racy' => 'VERY_LIKELY'
- ]);
- }
-
- public function testIsAdult()
- {
- $this->assertTrue($this->safeSearch->isAdult());
- }
-
- public function testIsSpoof()
- {
- $this->assertTrue($this->safeSearch->isSpoof());
- }
-
- public function testIsMedical()
- {
- $this->assertTrue($this->safeSearch->isMedical());
- }
-
- public function testIsViolent()
- {
- $this->assertTrue($this->safeSearch->isViolent());
- }
-
- public function testIsRacy()
- {
- $this->assertTrue($this->safeSearch->isRacy());
- }
-
- public function testCall()
- {
- $this->assertEquals('VERY_LIKELY', $this->safeSearch->violence());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/Web/WebEntityTest.php b/Vision/tests/Unit/Annotation/Web/WebEntityTest.php
deleted file mode 100644
index 588dfcb5a12f..000000000000
--- a/Vision/tests/Unit/Annotation/Web/WebEntityTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-info = [
- 'entityId' => 'foo',
- 'score' => 1,
- 'description' => 'bar'
- ];
- $this->entity = new WebEntity($this->info);
- }
-
- public function testEntityId()
- {
- $this->assertEquals($this->info['entityId'], $this->entity->entityId());
- }
-
- public function testScore()
- {
- $this->assertEquals($this->info['score'], $this->entity->score());
- }
-
- public function testDescription()
- {
- $this->assertEquals($this->info['description'], $this->entity->description());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/Web/WebImageTest.php b/Vision/tests/Unit/Annotation/Web/WebImageTest.php
deleted file mode 100644
index e01f301bb239..000000000000
--- a/Vision/tests/Unit/Annotation/Web/WebImageTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-info = [
- 'url' => 'http://foo.bar/bat',
- 'score' => 0.4
- ];
- $this->image = new WebImage($this->info);
- }
-
- public function testUrl()
- {
- $this->assertEquals($this->info['url'], $this->image->url());
- }
-
- public function testScore()
- {
- $this->assertEquals($this->info['score'], $this->image->score());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/Web/WebPageTest.php b/Vision/tests/Unit/Annotation/Web/WebPageTest.php
deleted file mode 100644
index 041517f01683..000000000000
--- a/Vision/tests/Unit/Annotation/Web/WebPageTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-info = [
- 'url' => 'http://foo.bar/bat',
- 'score' => 0.4
- ];
- $this->image = new WebPage($this->info);
- }
-
- public function testUrl()
- {
- $this->assertEquals($this->info['url'], $this->image->url());
- }
-
- public function testScore()
- {
- $this->assertEquals($this->info['score'], $this->image->score());
- }
-}
diff --git a/Vision/tests/Unit/Annotation/WebTest.php b/Vision/tests/Unit/Annotation/WebTest.php
deleted file mode 100644
index 0ae8999b00ac..000000000000
--- a/Vision/tests/Unit/Annotation/WebTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-info = [
- 'webEntities' => [
- ['foo' => 'bar']
- ],
- 'fullMatchingImages' => [
- ['foo' => 'bar']
- ],
- 'partialMatchingImages' => [
- ['foo' => 'bar']
- ],
- 'pagesWithMatchingImages' => [
- ['foo' => 'bar']
- ]
- ];
- $this->annotation = new Web($this->info);
- }
-
- public function testEntities()
- {
- $this->assertInstanceOf(WebEntity::class, $this->annotation->entities()[0]);
- $this->assertEquals($this->info['webEntities'][0], $this->annotation->entities()[0]->info());
- }
-
- public function testMatchingImages()
- {
- $this->assertInstanceOf(WebImage::class, $this->annotation->matchingImages()[0]);
- $this->assertEquals($this->info['fullMatchingImages'][0], $this->annotation->matchingImages()[0]->info());
- }
-
- public function testPartialMatchingImages()
- {
- $this->assertInstanceOf(WebImage::class, $this->annotation->partialMatchingImages()[0]);
- $this->assertEquals(
- $this->info['partialMatchingImages'][0],
- $this->annotation->partialMatchingImages()[0]->info()
- );
- }
-
- public function testPages()
- {
- $this->assertInstanceOf(WebPage::class, $this->annotation->pages()[0]);
- $this->assertEquals($this->info['pagesWithMatchingImages'][0], $this->annotation->pages()[0]->info());
- }
-}
diff --git a/Vision/tests/Unit/AnnotationTest.php b/Vision/tests/Unit/AnnotationTest.php
deleted file mode 100644
index 0e0c97e3c81d..000000000000
--- a/Vision/tests/Unit/AnnotationTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
- [
- ['landmarks' => []]
- ],
- 'landmarkAnnotations' => ['foo' => ['bat' => 'bar']],
- 'logoAnnotations' => ['foo' => ['bat' => 'bar']],
- 'labelAnnotations' => ['foo' => ['bat' => 'bar']],
- 'textAnnotations' => ['foo' => ['bat' => 'bar']],
- 'safeSearchAnnotation' => ['foo' => ['bat' => 'bar']],
- 'imagePropertiesAnnotation' => ['foo' => ['bat' => 'bar']],
- 'error' => ['foo' => ['bat' => 'bar']],
- 'fullTextAnnotation' => ['foo' => 'bar'],
- 'cropHintsAnnotation' => ['cropHints' => [['bat' => 'bar']]],
- 'webDetection' => ['foo' => ['bat' => 'bar']],
- ];
-
- $ann = new Annotation($res);
-
- $this->assertInstanceOf(Face::class, $ann->faces()[0]);
- $this->assertInstanceOf(Entity::class, $ann->landmarks()[0]);
- $this->assertInstanceOf(Entity::class, $ann->logos()[0]);
- $this->assertInstanceOf(Entity::class, $ann->labels()[0]);
- $this->assertInstanceOf(Entity::class, $ann->text()[0]);
- $this->assertInstanceOf(SafeSearch::class, $ann->safeSearch());
- $this->assertInstanceOf(ImageProperties::class, $ann->imageProperties());
- $this->assertEquals($res['error'], $ann->error());
- $this->assertInstanceOf(Document::class, $ann->fullText());
- $this->assertInstanceOf(CropHint::class, $ann->cropHints()[0]);
- $this->assertInstanceOf(Web::class, $ann->web());
-
- $this->assertEquals($res, $ann->info());
- }
-}
diff --git a/Vision/tests/Unit/Connection/RestTest.php b/Vision/tests/Unit/Connection/RestTest.php
deleted file mode 100644
index da15f8aaf733..000000000000
--- a/Vision/tests/Unit/Connection/RestTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-requestWrapper = $this->prophesize(RequestWrapper::class);
- $this->successBody = '{"canI":"kickIt"}';
- }
-
- public function testApiEndpoint()
- {
- $endpoint = 'https://foobar.com/';
- $rest = TestHelpers::stub(Rest::class, [
- [
- 'apiEndpoint' => $endpoint
- ]
- ], ['requestBuilder']);
-
- $rb = $rest->___getProperty('requestBuilder');
- $r = new \ReflectionObject($rb);
- $p = $r->getProperty('baseUri');
- $p->setAccessible(true);
-
- $this->assertEquals($endpoint, $p->getValue($rb));
- }
-
- /**
- * @dataProvider methodProvider
- * @todo revisit this approach
- */
- public function testCallBasicMethods($method)
- {
- $options = [];
- $request = new Request('GET', '/somewhere');
- $response = new Response(200, [], $this->successBody);
-
- $requestBuilder = $this->prophesize(RequestBuilder::class);
- $requestBuilder->build(
- Argument::type('string'),
- Argument::type('string'),
- Argument::type('array')
- )->willReturn($request);
-
- $this->requestWrapper->send(
- Argument::type(RequestInterface::class),
- Argument::type('array')
- )->willReturn($response);
-
- $rest = new Rest();
- $rest->setRequestBuilder($requestBuilder->reveal());
- $rest->setRequestWrapper($this->requestWrapper->reveal());
-
- $this->assertEquals(json_decode($this->successBody, true), $rest->$method($options));
- }
-
- public function methodProvider()
- {
- return [
- ['annotate']
- ];
- }
-}
diff --git a/Vision/tests/Unit/Fixtures.php b/Vision/tests/Unit/Fixtures.php
deleted file mode 100644
index 2a9af3594d48..000000000000
--- a/Vision/tests/Unit/Fixtures.php
+++ /dev/null
@@ -1,33 +0,0 @@
-requestObject();
-
- $this->assertEquals($res['image']['content'], base64_encode($bytes));
- $this->assertEquals($res['features'], [ ['type' => 'LANDMARK_DETECTION'] ]);
- }
-
- public function testWithStorage()
- {
- $storage = new StorageClient(['suppressKeyFileNotice' => true]);
- $bucket = $storage->bucket('test-bucket');
- $object = $bucket->object('test-object.jpg');
-
- $gcsUri = 'gs://test-bucket/test-object.jpg';
-
- $image = new Image($object, [ 'landmarks' ]);
- $res = $image->requestObject();
-
- $this->assertEquals($res['image']['source']['imageUri'], $gcsUri);
- $this->assertEquals($res['features'], [ ['type' => 'LANDMARK_DETECTION'] ]);
- }
-
- public function testWithResource()
- {
- $resource = fopen(Fixtures::EIFFEL_TOWER_FIXTURE(), 'r');
- $bytes = file_get_contents(Fixtures::EIFFEL_TOWER_FIXTURE());
-
- $image = new Image($resource, ['landmarks']);
- $res = $image->requestObject();
-
- $this->assertEquals($res['image']['content'], base64_encode($bytes));
- $this->assertEquals($res['features'], [ ['type' => 'LANDMARK_DETECTION'] ]);
- }
-
- public function testWithExternalImage()
- {
- $externalUri = 'http://google.com/image.jpg';
- $image = new Image($externalUri, ['landmarks']);
-
- $res = $image->requestObject();
-
- $this->assertEquals($res['image']['source']['imageUri'], $externalUri);
- $this->assertEquals($res['features'], [ ['type' => 'LANDMARK_DETECTION'] ]);
- }
-
- public function testWithInvalidType()
- {
- $this->expectException('InvalidArgumentException');
-
- new Image([], ['landmarks']);
- }
-
- public function testMaxResults()
- {
- $bytes = 'foo';
- $image = new Image($bytes, ['landmarks'], [
- 'maxResults' => [
- 'landmarks' => 100
- ]
- ]);
-
- $res = $image->requestObject();
- $this->assertEquals($res['features'][0]['maxResults'], 100);
- }
-
- public function testShortNamesMapping()
- {
- $names = [
- 'faces' => 'FACE_DETECTION',
- 'landmarks' => 'LANDMARK_DETECTION',
- 'logos' => 'LOGO_DETECTION',
- 'labels' => 'LABEL_DETECTION',
- 'text' => 'TEXT_DETECTION',
- 'document' => 'DOCUMENT_TEXT_DETECTION',
- 'safeSearch' => 'SAFE_SEARCH_DETECTION',
- 'imageProperties' => 'IMAGE_PROPERTIES',
- 'crop' => 'CROP_HINTS',
- 'web' => 'WEB_DETECTION'
- ];
-
- $bytes = 'foo';
-
- $image = new Image($bytes, array_keys($names));
-
- $res = $image->requestObject();
-
- $features = [];
- foreach ($res['features'] as $feature) {
- $features[] = $feature['type'];
- }
-
- $this->assertEquals(array_values($names), $features);
- }
-
- public function testBytesWithoutEncoding()
- {
- $bytes = 'foo';
-
- $image = new Image($bytes, ['landmarks']);
-
- $res = $image->requestObject(false);
- $this->assertEquals($res['image']['content'], $bytes);
-
- $encodedRes = $image->requestObject();
- $this->assertEquals($encodedRes['image']['content'], base64_encode($bytes));
- }
-
- public function testUrlSchemes()
- {
- $urls = [
- 'http://foo.bar',
- 'https://foo.bar',
- 'gs://foo/bar',
- 'ssh://foo/bar'
- ];
-
- $images = [
- new Image($urls[0], ['faces']),
- new Image($urls[1], ['faces']),
- new Image($urls[2], ['faces']),
- new Image($urls[3], ['faces']),
- ];
-
- $this->assertEquals($urls[0], $images[0]->requestObject()['image']['source']['imageUri']);
- $this->assertEquals($urls[1], $images[1]->requestObject()['image']['source']['imageUri']);
- $this->assertEquals($urls[2], $images[2]->requestObject()['image']['source']['imageUri']);
- $this->assertArrayNotHasKey('source', $images[3]->requestObject()['image']);
- }
-}
diff --git a/Vision/tests/Unit/V1/Client/ImageAnnotatorClientTest.php b/Vision/tests/Unit/V1/Client/ImageAnnotatorClientTest.php
index 2778ff0e51bb..4a07d32936dd 100644
--- a/Vision/tests/Unit/V1/Client/ImageAnnotatorClientTest.php
+++ b/Vision/tests/Unit/V1/Client/ImageAnnotatorClientTest.php
@@ -1,6 +1,6 @@
getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ return $this->getMockBuilder(CredentialsWrapper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/** @return ImageAnnotatorClient */
@@ -102,8 +104,7 @@ public function asyncBatchAnnotateFilesTest()
$operationsTransport->addResponse($completeOperation);
// Mock request
$requests = [];
- $request = (new AsyncBatchAnnotateFilesRequest())
- ->setRequests($requests);
+ $request = (new AsyncBatchAnnotateFilesRequest())->setRequests($requests);
$response = $gapicClient->asyncBatchAnnotateFiles($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -159,17 +160,19 @@ public function asyncBatchAnnotateFilesExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$operationsTransport->addResponse(null, $status);
// Mock request
$requests = [];
- $request = (new AsyncBatchAnnotateFilesRequest())
- ->setRequests($requests);
+ $request = (new AsyncBatchAnnotateFilesRequest())->setRequests($requests);
$response = $gapicClient->asyncBatchAnnotateFiles($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -224,9 +227,7 @@ public function asyncBatchAnnotateImagesTest()
// Mock request
$requests = [];
$outputConfig = new OutputConfig();
- $request = (new AsyncBatchAnnotateImagesRequest())
- ->setRequests($requests)
- ->setOutputConfig($outputConfig);
+ $request = (new AsyncBatchAnnotateImagesRequest())->setRequests($requests)->setOutputConfig($outputConfig);
$response = $gapicClient->asyncBatchAnnotateImages($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -284,19 +285,20 @@ public function asyncBatchAnnotateImagesExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$operationsTransport->addResponse(null, $status);
// Mock request
$requests = [];
$outputConfig = new OutputConfig();
- $request = (new AsyncBatchAnnotateImagesRequest())
- ->setRequests($requests)
- ->setOutputConfig($outputConfig);
+ $request = (new AsyncBatchAnnotateImagesRequest())->setRequests($requests)->setOutputConfig($outputConfig);
$response = $gapicClient->asyncBatchAnnotateImages($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -332,8 +334,7 @@ public function batchAnnotateFilesTest()
$transport->addResponse($expectedResponse);
// Mock request
$requests = [];
- $request = (new BatchAnnotateFilesRequest())
- ->setRequests($requests);
+ $request = (new BatchAnnotateFilesRequest())->setRequests($requests);
$response = $gapicClient->batchAnnotateFiles($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -357,17 +358,19 @@ public function batchAnnotateFilesExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$requests = [];
- $request = (new BatchAnnotateFilesRequest())
- ->setRequests($requests);
+ $request = (new BatchAnnotateFilesRequest())->setRequests($requests);
try {
$gapicClient->batchAnnotateFiles($request);
// If the $gapicClient method call did not throw, fail the test
@@ -394,8 +397,7 @@ public function batchAnnotateImagesTest()
$transport->addResponse($expectedResponse);
// Mock request
$requests = [];
- $request = (new BatchAnnotateImagesRequest())
- ->setRequests($requests);
+ $request = (new BatchAnnotateImagesRequest())->setRequests($requests);
$response = $gapicClient->batchAnnotateImages($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -419,17 +421,19 @@ public function batchAnnotateImagesExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$requests = [];
- $request = (new BatchAnnotateImagesRequest())
- ->setRequests($requests);
+ $request = (new BatchAnnotateImagesRequest())->setRequests($requests);
try {
$gapicClient->batchAnnotateImages($request);
// If the $gapicClient method call did not throw, fail the test
@@ -474,8 +478,7 @@ public function asyncBatchAnnotateFilesAsyncTest()
$operationsTransport->addResponse($completeOperation);
// Mock request
$requests = [];
- $request = (new AsyncBatchAnnotateFilesRequest())
- ->setRequests($requests);
+ $request = (new AsyncBatchAnnotateFilesRequest())->setRequests($requests);
$response = $gapicClient->asyncBatchAnnotateFilesAsync($request)->wait();
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
diff --git a/Vision/tests/Unit/V1/Client/ProductSearchClientTest.php b/Vision/tests/Unit/V1/Client/ProductSearchClientTest.php
index 783e73837e72..018ccec7eb73 100644
--- a/Vision/tests/Unit/V1/Client/ProductSearchClientTest.php
+++ b/Vision/tests/Unit/V1/Client/ProductSearchClientTest.php
@@ -1,6 +1,6 @@
getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ return $this->getMockBuilder(CredentialsWrapper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/** @return ProductSearchClient */
@@ -105,9 +107,7 @@ public function addProductToProductSetTest()
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
$formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new AddProductToProductSetRequest())
- ->setName($formattedName)
- ->setProduct($formattedProduct);
+ $request = (new AddProductToProductSetRequest())->setName($formattedName)->setProduct($formattedProduct);
$gapicClient->addProductToProductSet($request);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
@@ -132,19 +132,20 @@ public function addProductToProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
$formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new AddProductToProductSetRequest())
- ->setName($formattedName)
- ->setProduct($formattedProduct);
+ $request = (new AddProductToProductSetRequest())->setName($formattedName)->setProduct($formattedProduct);
try {
$gapicClient->addProductToProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -180,9 +181,7 @@ public function createProductTest()
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$product = new Product();
- $request = (new CreateProductRequest())
- ->setParent($formattedParent)
- ->setProduct($product);
+ $request = (new CreateProductRequest())->setParent($formattedParent)->setProduct($product);
$response = $gapicClient->createProduct($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -208,19 +207,20 @@ public function createProductExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$product = new Product();
- $request = (new CreateProductRequest())
- ->setParent($formattedParent)
- ->setProduct($product);
+ $request = (new CreateProductRequest())->setParent($formattedParent)->setProduct($product);
try {
$gapicClient->createProduct($request);
// If the $gapicClient method call did not throw, fail the test
@@ -252,9 +252,7 @@ public function createProductSetTest()
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$productSet = new ProductSet();
- $request = (new CreateProductSetRequest())
- ->setParent($formattedParent)
- ->setProductSet($productSet);
+ $request = (new CreateProductSetRequest())->setParent($formattedParent)->setProductSet($productSet);
$response = $gapicClient->createProductSet($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -280,19 +278,20 @@ public function createProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$productSet = new ProductSet();
- $request = (new CreateProductSetRequest())
- ->setParent($formattedParent)
- ->setProductSet($productSet);
+ $request = (new CreateProductSetRequest())->setParent($formattedParent)->setProductSet($productSet);
try {
$gapicClient->createProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -326,9 +325,7 @@ public function createReferenceImageTest()
$referenceImage = new ReferenceImage();
$referenceImageUri = 'referenceImageUri-707360132';
$referenceImage->setUri($referenceImageUri);
- $request = (new CreateReferenceImageRequest())
- ->setParent($formattedParent)
- ->setReferenceImage($referenceImage);
+ $request = (new CreateReferenceImageRequest())->setParent($formattedParent)->setReferenceImage($referenceImage);
$response = $gapicClient->createReferenceImage($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -354,21 +351,22 @@ public function createReferenceImageExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
$referenceImage = new ReferenceImage();
$referenceImageUri = 'referenceImageUri-707360132';
$referenceImage->setUri($referenceImageUri);
- $request = (new CreateReferenceImageRequest())
- ->setParent($formattedParent)
- ->setReferenceImage($referenceImage);
+ $request = (new CreateReferenceImageRequest())->setParent($formattedParent)->setReferenceImage($referenceImage);
try {
$gapicClient->createReferenceImage($request);
// If the $gapicClient method call did not throw, fail the test
@@ -395,8 +393,7 @@ public function deleteProductTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new DeleteProductRequest())
- ->setName($formattedName);
+ $request = (new DeleteProductRequest())->setName($formattedName);
$gapicClient->deleteProduct($request);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
@@ -419,17 +416,19 @@ public function deleteProductExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new DeleteProductRequest())
- ->setName($formattedName);
+ $request = (new DeleteProductRequest())->setName($formattedName);
try {
$gapicClient->deleteProduct($request);
// If the $gapicClient method call did not throw, fail the test
@@ -456,8 +455,7 @@ public function deleteProductSetTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $request = (new DeleteProductSetRequest())
- ->setName($formattedName);
+ $request = (new DeleteProductSetRequest())->setName($formattedName);
$gapicClient->deleteProductSet($request);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
@@ -480,17 +478,19 @@ public function deleteProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $request = (new DeleteProductSetRequest())
- ->setName($formattedName);
+ $request = (new DeleteProductSetRequest())->setName($formattedName);
try {
$gapicClient->deleteProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -517,8 +517,7 @@ public function deleteReferenceImageTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- $request = (new DeleteReferenceImageRequest())
- ->setName($formattedName);
+ $request = (new DeleteReferenceImageRequest())->setName($formattedName);
$gapicClient->deleteReferenceImage($request);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
@@ -541,17 +540,19 @@ public function deleteReferenceImageExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- $request = (new DeleteReferenceImageRequest())
- ->setName($formattedName);
+ $request = (new DeleteReferenceImageRequest())->setName($formattedName);
try {
$gapicClient->deleteReferenceImage($request);
// If the $gapicClient method call did not throw, fail the test
@@ -586,8 +587,7 @@ public function getProductTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new GetProductRequest())
- ->setName($formattedName);
+ $request = (new GetProductRequest())->setName($formattedName);
$response = $gapicClient->getProduct($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -611,17 +611,19 @@ public function getProductExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new GetProductRequest())
- ->setName($formattedName);
+ $request = (new GetProductRequest())->setName($formattedName);
try {
$gapicClient->getProduct($request);
// If the $gapicClient method call did not throw, fail the test
@@ -652,8 +654,7 @@ public function getProductSetTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $request = (new GetProductSetRequest())
- ->setName($formattedName);
+ $request = (new GetProductSetRequest())->setName($formattedName);
$response = $gapicClient->getProductSet($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -677,17 +678,19 @@ public function getProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $request = (new GetProductSetRequest())
- ->setName($formattedName);
+ $request = (new GetProductSetRequest())->setName($formattedName);
try {
$gapicClient->getProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -718,8 +721,7 @@ public function getReferenceImageTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- $request = (new GetReferenceImageRequest())
- ->setName($formattedName);
+ $request = (new GetReferenceImageRequest())->setName($formattedName);
$response = $gapicClient->getReferenceImage($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -743,17 +745,19 @@ public function getReferenceImageExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- $request = (new GetReferenceImageRequest())
- ->setName($formattedName);
+ $request = (new GetReferenceImageRequest())->setName($formattedName);
try {
$gapicClient->getReferenceImage($request);
// If the $gapicClient method call did not throw, fail the test
@@ -799,9 +803,7 @@ public function importProductSetsTest()
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$inputConfig = new ImportProductSetsInputConfig();
- $request = (new ImportProductSetsRequest())
- ->setParent($formattedParent)
- ->setInputConfig($inputConfig);
+ $request = (new ImportProductSetsRequest())->setParent($formattedParent)->setInputConfig($inputConfig);
$response = $gapicClient->importProductSets($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -859,19 +861,20 @@ public function importProductSetsExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$operationsTransport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
$inputConfig = new ImportProductSetsInputConfig();
- $request = (new ImportProductSetsRequest())
- ->setParent($formattedParent)
- ->setInputConfig($inputConfig);
+ $request = (new ImportProductSetsRequest())->setParent($formattedParent)->setInputConfig($inputConfig);
$response = $gapicClient->importProductSets($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -905,17 +908,14 @@ public function listProductSetsTest()
// Mock response
$nextPageToken = '';
$productSetsElement = new ProductSet();
- $productSets = [
- $productSetsElement,
- ];
+ $productSets = [$productSetsElement];
$expectedResponse = new ListProductSetsResponse();
$expectedResponse->setNextPageToken($nextPageToken);
$expectedResponse->setProductSets($productSets);
$transport->addResponse($expectedResponse);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListProductSetsRequest())
- ->setParent($formattedParent);
+ $request = (new ListProductSetsRequest())->setParent($formattedParent);
$response = $gapicClient->listProductSets($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -942,17 +942,19 @@ public function listProductSetsExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListProductSetsRequest())
- ->setParent($formattedParent);
+ $request = (new ListProductSetsRequest())->setParent($formattedParent);
try {
$gapicClient->listProductSets($request);
// If the $gapicClient method call did not throw, fail the test
@@ -977,17 +979,14 @@ public function listProductsTest()
// Mock response
$nextPageToken = '';
$productsElement = new Product();
- $products = [
- $productsElement,
- ];
+ $products = [$productsElement];
$expectedResponse = new ListProductsResponse();
$expectedResponse->setNextPageToken($nextPageToken);
$expectedResponse->setProducts($products);
$transport->addResponse($expectedResponse);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListProductsRequest())
- ->setParent($formattedParent);
+ $request = (new ListProductsRequest())->setParent($formattedParent);
$response = $gapicClient->listProducts($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -1014,17 +1013,19 @@ public function listProductsExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new ListProductsRequest())
- ->setParent($formattedParent);
+ $request = (new ListProductsRequest())->setParent($formattedParent);
try {
$gapicClient->listProducts($request);
// If the $gapicClient method call did not throw, fail the test
@@ -1049,17 +1050,14 @@ public function listProductsInProductSetTest()
// Mock response
$nextPageToken = '';
$productsElement = new Product();
- $products = [
- $productsElement,
- ];
+ $products = [$productsElement];
$expectedResponse = new ListProductsInProductSetResponse();
$expectedResponse->setNextPageToken($nextPageToken);
$expectedResponse->setProducts($products);
$transport->addResponse($expectedResponse);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $request = (new ListProductsInProductSetRequest())
- ->setName($formattedName);
+ $request = (new ListProductsInProductSetRequest())->setName($formattedName);
$response = $gapicClient->listProductsInProductSet($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -1086,17 +1084,19 @@ public function listProductsInProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $request = (new ListProductsInProductSetRequest())
- ->setName($formattedName);
+ $request = (new ListProductsInProductSetRequest())->setName($formattedName);
try {
$gapicClient->listProductsInProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -1122,9 +1122,7 @@ public function listReferenceImagesTest()
$pageSize2 = 1024500956;
$nextPageToken = '';
$referenceImagesElement = new ReferenceImage();
- $referenceImages = [
- $referenceImagesElement,
- ];
+ $referenceImages = [$referenceImagesElement];
$expectedResponse = new ListReferenceImagesResponse();
$expectedResponse->setPageSize($pageSize2);
$expectedResponse->setNextPageToken($nextPageToken);
@@ -1132,8 +1130,7 @@ public function listReferenceImagesTest()
$transport->addResponse($expectedResponse);
// Mock request
$formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new ListReferenceImagesRequest())
- ->setParent($formattedParent);
+ $request = (new ListReferenceImagesRequest())->setParent($formattedParent);
$response = $gapicClient->listReferenceImages($request);
$this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
$resources = iterator_to_array($response->iterateAllElements());
@@ -1160,17 +1157,19 @@ public function listReferenceImagesExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new ListReferenceImagesRequest())
- ->setParent($formattedParent);
+ $request = (new ListReferenceImagesRequest())->setParent($formattedParent);
try {
$gapicClient->listReferenceImages($request);
// If the $gapicClient method call did not throw, fail the test
@@ -1215,8 +1214,7 @@ public function purgeProductsTest()
$operationsTransport->addResponse($completeOperation);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new PurgeProductsRequest())
- ->setParent($formattedParent);
+ $request = (new PurgeProductsRequest())->setParent($formattedParent);
$response = $gapicClient->purgeProducts($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -1272,17 +1270,19 @@ public function purgeProductsExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$operationsTransport->addResponse(null, $status);
// Mock request
$formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $request = (new PurgeProductsRequest())
- ->setParent($formattedParent);
+ $request = (new PurgeProductsRequest())->setParent($formattedParent);
$response = $gapicClient->purgeProducts($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -1319,9 +1319,7 @@ public function removeProductFromProductSetTest()
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
$formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new RemoveProductFromProductSetRequest())
- ->setName($formattedName)
- ->setProduct($formattedProduct);
+ $request = (new RemoveProductFromProductSetRequest())->setName($formattedName)->setProduct($formattedProduct);
$gapicClient->removeProductFromProductSet($request);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
@@ -1346,19 +1344,20 @@ public function removeProductFromProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
$formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new RemoveProductFromProductSetRequest())
- ->setName($formattedName)
- ->setProduct($formattedProduct);
+ $request = (new RemoveProductFromProductSetRequest())->setName($formattedName)->setProduct($formattedProduct);
try {
$gapicClient->removeProductFromProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -1393,8 +1392,7 @@ public function updateProductTest()
$transport->addResponse($expectedResponse);
// Mock request
$product = new Product();
- $request = (new UpdateProductRequest())
- ->setProduct($product);
+ $request = (new UpdateProductRequest())->setProduct($product);
$response = $gapicClient->updateProduct($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -1418,17 +1416,19 @@ public function updateProductExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$product = new Product();
- $request = (new UpdateProductRequest())
- ->setProduct($product);
+ $request = (new UpdateProductRequest())->setProduct($product);
try {
$gapicClient->updateProduct($request);
// If the $gapicClient method call did not throw, fail the test
@@ -1459,8 +1459,7 @@ public function updateProductSetTest()
$transport->addResponse($expectedResponse);
// Mock request
$productSet = new ProductSet();
- $request = (new UpdateProductSetRequest())
- ->setProductSet($productSet);
+ $request = (new UpdateProductSetRequest())->setProductSet($productSet);
$response = $gapicClient->updateProductSet($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
@@ -1484,17 +1483,19 @@ public function updateProductSetExceptionTest()
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$productSet = new ProductSet();
- $request = (new UpdateProductSetRequest())
- ->setProductSet($productSet);
+ $request = (new UpdateProductSetRequest())->setProductSet($productSet);
try {
$gapicClient->updateProductSet($request);
// If the $gapicClient method call did not throw, fail the test
@@ -1522,9 +1523,7 @@ public function addProductToProductSetAsyncTest()
// Mock request
$formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
$formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $request = (new AddProductToProductSetRequest())
- ->setName($formattedName)
- ->setProduct($formattedProduct);
+ $request = (new AddProductToProductSetRequest())->setName($formattedName)->setProduct($formattedProduct);
$gapicClient->addProductToProductSetAsync($request)->wait();
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
diff --git a/Vision/tests/Unit/V1/ImageAnnotatorClientExtensionTest.php b/Vision/tests/Unit/V1/ImageAnnotatorClientExtensionTest.php
deleted file mode 100644
index ddfcdfe37372..000000000000
--- a/Vision/tests/Unit/V1/ImageAnnotatorClientExtensionTest.php
+++ /dev/null
@@ -1,272 +0,0 @@
-transport = $this->prophesize(TransportInterface::class);
- $this->client = new ImageAnnotatorClient([
- 'transport' => $this->transport->reveal(),
- 'credentials' => new InsecureCredentialsWrapper(),
- ]);
- }
-
- public function testCreateImageObject()
- {
- $image = $this->client->createImageObject("gs://my-bucket/myimage.jpg");
- $this->assertSame(Image::class, get_class($image));
- $this->assertSame(ImageSource::class, get_class($image->getSource()));
- }
-
- /**
- * @dataProvider annotateImageDataProvider
- */
- public function testAnnotateImage($image, $features)
- {
- $expectedAnnotationResponses = [new AnnotateImageResponse()];
- $expectedResponse = new BatchAnnotateImagesResponse();
- $expectedResponse->setResponses($expectedAnnotationResponses);
- $this->transport->startUnaryCall(Argument::type(Call::class), Argument::type('array'))
- ->shouldBeCalledTimes(1)
- ->willReturn(
- new FulfilledPromise(
- $expectedResponse
- )
- );
-
- $res = $this->client->annotateImage($image, $features);
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $res);
- }
-
- public function annotateImageDataProvider()
- {
- return [
- [$this->createImageObject('foobar'), [(new Feature())->setType(Feature_Type::FACE_DETECTION)]],
- ['foobar', [Feature_Type::FACE_DETECTION]],
- ];
- }
-
- public function testAnnotateImageWithImageContext()
- {
- $image = $this->client->createImageObject('foobar');
- $featureType = Feature_Type::FACE_DETECTION;
- $imageContext = new ImageContext();
- $imageContext->setLanguageHints(['en']);
-
- $expectedFeature = new Feature();
- $expectedFeature->setType($featureType);
- $expectedFeatures = [$expectedFeature];
- $expectedRequest = new AnnotateImageRequest();
- $expectedRequest->setImage($image);
- $expectedRequest->setFeatures($expectedFeatures);
- $expectedRequest->setImageContext($imageContext);
- $expectedRequests = [$expectedRequest];
-
- $expectedMessage = new BatchAnnotateImagesRequest();
- $expectedMessage->setRequests($expectedRequests);
-
- $expectedAnnotationResponses = [new AnnotateImageResponse()];
- $expectedResponse = new BatchAnnotateImagesResponse();
- $expectedResponse->setResponses($expectedAnnotationResponses);
- $this->transport->startUnaryCall( Argument::allOf(
- Argument::type(Call::class),
- Argument::which('getMethod', 'google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages'),
- Argument::that(function($arg) use ($expectedMessage) {
- if ($arg->getMessage()->serializeToString() === $expectedMessage->serializeToString()) {
- return true;
- }
- return false;
- })
- ),
- Argument::type('array')
- )
- ->shouldBeCalledTimes(1)
- ->willReturn(
- new FulfilledPromise(
- $expectedResponse
- )
- );
-
- $feature = new Feature();
- $feature->setType($featureType);
- $features = [$feature];
-
- $res = $this->client->annotateImage($image, $features, [
- 'imageContext' => $imageContext,
- ]);
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $res);
- }
-
- public function testProductSearch()
- {
- $image = $this->createImageObject('foobar');
- $productSetName = 'projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID';
- $expectedFeature = new Feature();
- $expectedFeature->setType(Feature_Type::PRODUCT_SEARCH);
- $expectedFeatures = [$expectedFeature];
- $expectedProductSearchParams = new ProductSearchParams();
- $expectedProductSearchParams->setProductSet($productSetName);
- $expectedImageContext = new ImageContext();
- $expectedImageContext->setProductSearchParams($expectedProductSearchParams);
- $expectedRequest = new AnnotateImageRequest();
- $expectedRequest->setImage($this->createImageObject($image));
- $expectedRequest->setFeatures($expectedFeatures);
- $expectedRequest->setImageContext($expectedImageContext);
- $expectedRequests = [$expectedRequest];
-
- $expectedMessage = new BatchAnnotateImagesRequest();
- $expectedMessage->setRequests($expectedRequests);
-
- $expectedAnnotationResponses = [new AnnotateImageResponse()];
- $expectedResponse = new BatchAnnotateImagesResponse();
- $expectedResponse->setResponses($expectedAnnotationResponses);
- $this->transport->startUnaryCall(
- Argument::allOf(
- Argument::type(Call::class),
- Argument::which('getMethod', 'google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages'),
- Argument::that(function($arg) use ($expectedMessage) {
- if ($arg->getMessage()->serializeToString() === $expectedMessage->serializeToString()) {
- return true;
- }
- return false;
- })
- ),
- Argument::type('array')
- )
- ->shouldBeCalledTimes(1)
- ->willReturn(
- new FulfilledPromise(
- $expectedResponse
- )
- );
- $productSearchParams = new ProductSearchParams();
- $productSearchParams->setProductSet($productSetName);
-
- $res = $this->client->productSearch($image, $productSearchParams);
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $res);
- }
-
- /**
- * @dataProvider detectionMethodDataProvider
- */
- public function testDetectionMethod($methodName, $featureType, $image)
- {
- $expectedFeature = new Feature();
- $expectedFeature->setType($featureType);
- $expectedFeatures = [$expectedFeature];
- $expectedRequest = new AnnotateImageRequest();
- $expectedRequest->setImage($this->createImageObject($image));
- $expectedRequest->setFeatures($expectedFeatures);
- $expectedRequests = [$expectedRequest];
-
- $expectedMessage = new BatchAnnotateImagesRequest();
- $expectedMessage->setRequests($expectedRequests);
-
- $expectedAnnotationResponses = [new AnnotateImageResponse()];
- $expectedResponse = new BatchAnnotateImagesResponse();
- $expectedResponse->setResponses($expectedAnnotationResponses);
- $this->transport->startUnaryCall(
- Argument::allOf(
- Argument::type(Call::class),
- Argument::which('getMethod', 'google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages'),
- Argument::that(function($arg) use ($expectedMessage) {
- if ($arg->getMessage()->serializeToString() === $expectedMessage->serializeToString()) {
- return true;
- }
- return false;
- })
- ),
- Argument::type('array')
- )
- ->shouldBeCalledTimes(1)
- ->willReturn(
- new FulfilledPromise(
- $expectedResponse
- )
- );
-
- $res = $this->client->$methodName($image);
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $res);
- }
-
- public function detectionMethodDataProvider()
- {
- $items = [
- ['faceDetection', Feature_Type::FACE_DETECTION],
- ['landmarkDetection', Feature_Type::LANDMARK_DETECTION],
- ['logoDetection', Feature_Type::LOGO_DETECTION],
- ['labelDetection', Feature_Type::LABEL_DETECTION],
- ['textDetection', Feature_Type::TEXT_DETECTION],
- ['documentTextDetection', Feature_Type::DOCUMENT_TEXT_DETECTION],
- ['safeSearchDetection', Feature_Type::SAFE_SEARCH_DETECTION],
- ['imagePropertiesDetection', Feature_Type::IMAGE_PROPERTIES],
- ['cropHintsDetection', Feature_Type::CROP_HINTS],
- ['webDetection', Feature_Type::WEB_DETECTION],
- ['objectLocalization', Feature_Type::OBJECT_LOCALIZATION]
- ];
- $data = [];
- foreach ($items as $item) {
- $item[] = 'foobar';
- $item[] = $this->createImageObject('foobar');
- $data[] = $item;
- }
- return $data;
- }
-
- private function createImageObject($imageInput)
- {
- return $this->createImageHelper(Image::class, ImageSource::class, $imageInput);
- }
-}
diff --git a/Vision/tests/Unit/V1/ImageAnnotatorClientTest.php b/Vision/tests/Unit/V1/ImageAnnotatorClientTest.php
deleted file mode 100644
index 499a740207b9..000000000000
--- a/Vision/tests/Unit/V1/ImageAnnotatorClientTest.php
+++ /dev/null
@@ -1,423 +0,0 @@
-getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
- }
-
- /** @return ImageAnnotatorClient */
- private function createClient(array $options = [])
- {
- $options += [
- 'credentials' => $this->createCredentials(),
- ];
- return new ImageAnnotatorClient($options);
- }
-
- /** @test */
- public function asyncBatchAnnotateFilesTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/asyncBatchAnnotateFilesTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $expectedResponse = new AsyncBatchAnnotateFilesResponse();
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/asyncBatchAnnotateFilesTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $requests = [];
- $response = $gapicClient->asyncBatchAnnotateFiles($requests);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $apiRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($apiRequests));
- $operationsRequestsEmpty = $operationsTransport->popReceivedCalls();
- $this->assertSame(0, count($operationsRequestsEmpty));
- $actualApiFuncCall = $apiRequests[0]->getFuncCall();
- $actualApiRequestObject = $apiRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateFiles', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getRequests();
- $this->assertProtobufEquals($requests, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/asyncBatchAnnotateFilesTest');
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- $this->assertTrue($response->isDone());
- $this->assertEquals($expectedResponse, $response->getResult());
- $apiRequestsEmpty = $transport->popReceivedCalls();
- $this->assertSame(0, count($apiRequestsEmpty));
- $operationsRequests = $operationsTransport->popReceivedCalls();
- $this->assertSame(1, count($operationsRequests));
- $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
- $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
- $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
- $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function asyncBatchAnnotateFilesExceptionTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/asyncBatchAnnotateFilesTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $operationsTransport->addResponse(null, $status);
- // Mock request
- $requests = [];
- $response = $gapicClient->asyncBatchAnnotateFiles($requests);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/asyncBatchAnnotateFilesTest');
- try {
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- // If the pollUntilComplete() method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stubs are exhausted
- $transport->popReceivedCalls();
- $operationsTransport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function asyncBatchAnnotateImagesTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/asyncBatchAnnotateImagesTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $expectedResponse = new AsyncBatchAnnotateImagesResponse();
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/asyncBatchAnnotateImagesTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $requests = [];
- $outputConfig = new OutputConfig();
- $response = $gapicClient->asyncBatchAnnotateImages($requests, $outputConfig);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $apiRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($apiRequests));
- $operationsRequestsEmpty = $operationsTransport->popReceivedCalls();
- $this->assertSame(0, count($operationsRequestsEmpty));
- $actualApiFuncCall = $apiRequests[0]->getFuncCall();
- $actualApiRequestObject = $apiRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ImageAnnotator/AsyncBatchAnnotateImages', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getRequests();
- $this->assertProtobufEquals($requests, $actualValue);
- $actualValue = $actualApiRequestObject->getOutputConfig();
- $this->assertProtobufEquals($outputConfig, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/asyncBatchAnnotateImagesTest');
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- $this->assertTrue($response->isDone());
- $this->assertEquals($expectedResponse, $response->getResult());
- $apiRequestsEmpty = $transport->popReceivedCalls();
- $this->assertSame(0, count($apiRequestsEmpty));
- $operationsRequests = $operationsTransport->popReceivedCalls();
- $this->assertSame(1, count($operationsRequests));
- $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
- $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
- $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
- $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function asyncBatchAnnotateImagesExceptionTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/asyncBatchAnnotateImagesTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $operationsTransport->addResponse(null, $status);
- // Mock request
- $requests = [];
- $outputConfig = new OutputConfig();
- $response = $gapicClient->asyncBatchAnnotateImages($requests, $outputConfig);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/asyncBatchAnnotateImagesTest');
- try {
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- // If the pollUntilComplete() method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stubs are exhausted
- $transport->popReceivedCalls();
- $operationsTransport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function batchAnnotateFilesTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new BatchAnnotateFilesResponse();
- $transport->addResponse($expectedResponse);
- // Mock request
- $requests = [];
- $response = $gapicClient->batchAnnotateFiles($requests);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateFiles', $actualFuncCall);
- $actualValue = $actualRequestObject->getRequests();
- $this->assertProtobufEquals($requests, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function batchAnnotateFilesExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $requests = [];
- try {
- $gapicClient->batchAnnotateFiles($requests);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function batchAnnotateImagesTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new BatchAnnotateImagesResponse();
- $transport->addResponse($expectedResponse);
- // Mock request
- $requests = [];
- $response = $gapicClient->batchAnnotateImages($requests);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ImageAnnotator/BatchAnnotateImages', $actualFuncCall);
- $actualValue = $actualRequestObject->getRequests();
- $this->assertProtobufEquals($requests, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function batchAnnotateImagesExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $requests = [];
- try {
- $gapicClient->batchAnnotateImages($requests);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-}
diff --git a/Vision/tests/Unit/V1/ProductSearchClientTest.php b/Vision/tests/Unit/V1/ProductSearchClientTest.php
deleted file mode 100644
index f742fb2de31f..000000000000
--- a/Vision/tests/Unit/V1/ProductSearchClientTest.php
+++ /dev/null
@@ -1,1403 +0,0 @@
-getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
- }
-
- /** @return ProductSearchClient */
- private function createClient(array $options = [])
- {
- $options += [
- 'credentials' => $this->createCredentials(),
- ];
- return new ProductSearchClient($options);
- }
-
- /** @test */
- public function addProductToProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new GPBEmpty();
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $gapicClient->addProductToProductSet($formattedName, $formattedProduct);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/AddProductToProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $actualValue = $actualRequestObject->getProduct();
- $this->assertProtobufEquals($formattedProduct, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function addProductToProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- try {
- $gapicClient->addProductToProductSet($formattedName, $formattedProduct);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function createProductTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name = 'name3373707';
- $displayName = 'displayName1615086568';
- $description = 'description-1724546052';
- $productCategory = 'productCategory-1607451058';
- $expectedResponse = new Product();
- $expectedResponse->setName($name);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setDescription($description);
- $expectedResponse->setProductCategory($productCategory);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $product = new Product();
- $response = $gapicClient->createProduct($formattedParent, $product);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/CreateProduct', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $actualValue = $actualRequestObject->getProduct();
- $this->assertProtobufEquals($product, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function createProductExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $product = new Product();
- try {
- $gapicClient->createProduct($formattedParent, $product);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function createProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name = 'name3373707';
- $displayName = 'displayName1615086568';
- $expectedResponse = new ProductSet();
- $expectedResponse->setName($name);
- $expectedResponse->setDisplayName($displayName);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $productSet = new ProductSet();
- $response = $gapicClient->createProductSet($formattedParent, $productSet);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/CreateProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $actualValue = $actualRequestObject->getProductSet();
- $this->assertProtobufEquals($productSet, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function createProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $productSet = new ProductSet();
- try {
- $gapicClient->createProductSet($formattedParent, $productSet);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function createReferenceImageTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name = 'name3373707';
- $uri = 'uri116076';
- $expectedResponse = new ReferenceImage();
- $expectedResponse->setName($name);
- $expectedResponse->setUri($uri);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $referenceImage = new ReferenceImage();
- $referenceImageUri = 'referenceImageUri-707360132';
- $referenceImage->setUri($referenceImageUri);
- $response = $gapicClient->createReferenceImage($formattedParent, $referenceImage);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/CreateReferenceImage', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $actualValue = $actualRequestObject->getReferenceImage();
- $this->assertProtobufEquals($referenceImage, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function createReferenceImageExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $referenceImage = new ReferenceImage();
- $referenceImageUri = 'referenceImageUri-707360132';
- $referenceImage->setUri($referenceImageUri);
- try {
- $gapicClient->createReferenceImage($formattedParent, $referenceImage);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function deleteProductTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new GPBEmpty();
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $gapicClient->deleteProduct($formattedName);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/DeleteProduct', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function deleteProductExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- try {
- $gapicClient->deleteProduct($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function deleteProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new GPBEmpty();
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $gapicClient->deleteProductSet($formattedName);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/DeleteProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function deleteProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- try {
- $gapicClient->deleteProductSet($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function deleteReferenceImageTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new GPBEmpty();
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- $gapicClient->deleteReferenceImage($formattedName);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/DeleteReferenceImage', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function deleteReferenceImageExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- try {
- $gapicClient->deleteReferenceImage($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getProductTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name2 = 'name2-1052831874';
- $displayName = 'displayName1615086568';
- $description = 'description-1724546052';
- $productCategory = 'productCategory-1607451058';
- $expectedResponse = new Product();
- $expectedResponse->setName($name2);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setDescription($description);
- $expectedResponse->setProductCategory($productCategory);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $response = $gapicClient->getProduct($formattedName);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/GetProduct', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getProductExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- try {
- $gapicClient->getProduct($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name2 = 'name2-1052831874';
- $displayName = 'displayName1615086568';
- $expectedResponse = new ProductSet();
- $expectedResponse->setName($name2);
- $expectedResponse->setDisplayName($displayName);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $response = $gapicClient->getProductSet($formattedName);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/GetProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- try {
- $gapicClient->getProductSet($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getReferenceImageTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name2 = 'name2-1052831874';
- $uri = 'uri116076';
- $expectedResponse = new ReferenceImage();
- $expectedResponse->setName($name2);
- $expectedResponse->setUri($uri);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- $response = $gapicClient->getReferenceImage($formattedName);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/GetReferenceImage', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function getReferenceImageExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->referenceImageName('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]');
- try {
- $gapicClient->getReferenceImage($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function importProductSetsTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/importProductSetsTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $expectedResponse = new ImportProductSetsResponse();
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/importProductSetsTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $inputConfig = new ImportProductSetsInputConfig();
- $response = $gapicClient->importProductSets($formattedParent, $inputConfig);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $apiRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($apiRequests));
- $operationsRequestsEmpty = $operationsTransport->popReceivedCalls();
- $this->assertSame(0, count($operationsRequestsEmpty));
- $actualApiFuncCall = $apiRequests[0]->getFuncCall();
- $actualApiRequestObject = $apiRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/ImportProductSets', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $actualValue = $actualApiRequestObject->getInputConfig();
- $this->assertProtobufEquals($inputConfig, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/importProductSetsTest');
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- $this->assertTrue($response->isDone());
- $this->assertEquals($expectedResponse, $response->getResult());
- $apiRequestsEmpty = $transport->popReceivedCalls();
- $this->assertSame(0, count($apiRequestsEmpty));
- $operationsRequests = $operationsTransport->popReceivedCalls();
- $this->assertSame(1, count($operationsRequests));
- $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
- $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
- $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
- $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function importProductSetsExceptionTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/importProductSetsTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $operationsTransport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $inputConfig = new ImportProductSetsInputConfig();
- $response = $gapicClient->importProductSets($formattedParent, $inputConfig);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/importProductSetsTest');
- try {
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- // If the pollUntilComplete() method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stubs are exhausted
- $transport->popReceivedCalls();
- $operationsTransport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function listProductSetsTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $nextPageToken = '';
- $productSetsElement = new ProductSet();
- $productSets = [
- $productSetsElement,
- ];
- $expectedResponse = new ListProductSetsResponse();
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setProductSets($productSets);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->listProductSets($formattedParent);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getProductSets()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/ListProductSets', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listProductSetsExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- try {
- $gapicClient->listProductSets($formattedParent);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listProductsTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $nextPageToken = '';
- $productsElement = new Product();
- $products = [
- $productsElement,
- ];
- $expectedResponse = new ListProductsResponse();
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setProducts($products);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->listProducts($formattedParent);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getProducts()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/ListProducts', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listProductsExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- try {
- $gapicClient->listProducts($formattedParent);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listProductsInProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $nextPageToken = '';
- $productsElement = new Product();
- $products = [
- $productsElement,
- ];
- $expectedResponse = new ListProductsInProductSetResponse();
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setProducts($products);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $response = $gapicClient->listProductsInProductSet($formattedName);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getProducts()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/ListProductsInProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listProductsInProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- try {
- $gapicClient->listProductsInProductSet($formattedName);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listReferenceImagesTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $pageSize2 = 1024500956;
- $nextPageToken = '';
- $referenceImagesElement = new ReferenceImage();
- $referenceImages = [
- $referenceImagesElement,
- ];
- $expectedResponse = new ListReferenceImagesResponse();
- $expectedResponse->setPageSize($pageSize2);
- $expectedResponse->setNextPageToken($nextPageToken);
- $expectedResponse->setReferenceImages($referenceImages);
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $response = $gapicClient->listReferenceImages($formattedParent);
- $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
- $resources = iterator_to_array($response->iterateAllElements());
- $this->assertSame(1, count($resources));
- $this->assertEquals($expectedResponse->getReferenceImages()[0], $resources[0]);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/ListReferenceImages', $actualFuncCall);
- $actualValue = $actualRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listReferenceImagesExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- try {
- $gapicClient->listReferenceImages($formattedParent);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function purgeProductsTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/purgeProductsTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $expectedResponse = new GPBEmpty();
- $anyResponse = new Any();
- $anyResponse->setValue($expectedResponse->serializeToString());
- $completeOperation = new Operation();
- $completeOperation->setName('operations/purgeProductsTest');
- $completeOperation->setDone(true);
- $completeOperation->setResponse($anyResponse);
- $operationsTransport->addResponse($completeOperation);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->purgeProducts($formattedParent);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $apiRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($apiRequests));
- $operationsRequestsEmpty = $operationsTransport->popReceivedCalls();
- $this->assertSame(0, count($operationsRequestsEmpty));
- $actualApiFuncCall = $apiRequests[0]->getFuncCall();
- $actualApiRequestObject = $apiRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/PurgeProducts', $actualApiFuncCall);
- $actualValue = $actualApiRequestObject->getParent();
- $this->assertProtobufEquals($formattedParent, $actualValue);
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/purgeProductsTest');
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- $this->assertTrue($response->isDone());
- $this->assertEquals($expectedResponse, $response->getResult());
- $apiRequestsEmpty = $transport->popReceivedCalls();
- $this->assertSame(0, count($apiRequestsEmpty));
- $operationsRequests = $operationsTransport->popReceivedCalls();
- $this->assertSame(1, count($operationsRequests));
- $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
- $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
- $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
- $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function purgeProductsExceptionTest()
- {
- $operationsTransport = $this->createTransport();
- $operationsClient = new OperationsClient([
- 'apiEndpoint' => '',
- 'transport' => $operationsTransport,
- 'credentials' => $this->createCredentials(),
- ]);
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- 'operationsClient' => $operationsClient,
- ]);
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- // Mock response
- $incompleteOperation = new Operation();
- $incompleteOperation->setName('operations/purgeProductsTest');
- $incompleteOperation->setDone(false);
- $transport->addResponse($incompleteOperation);
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $operationsTransport->addResponse(null, $status);
- // Mock request
- $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]');
- $response = $gapicClient->purgeProducts($formattedParent);
- $this->assertFalse($response->isDone());
- $this->assertNull($response->getResult());
- $expectedOperationsRequestObject = new GetOperationRequest();
- $expectedOperationsRequestObject->setName('operations/purgeProductsTest');
- try {
- $response->pollUntilComplete([
- 'initialPollDelayMillis' => 1,
- ]);
- // If the pollUntilComplete() method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stubs are exhausted
- $transport->popReceivedCalls();
- $operationsTransport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- $this->assertTrue($operationsTransport->isExhausted());
- }
-
- /** @test */
- public function removeProductFromProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new GPBEmpty();
- $transport->addResponse($expectedResponse);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- $gapicClient->removeProductFromProductSet($formattedName, $formattedProduct);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/RemoveProductFromProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getName();
- $this->assertProtobufEquals($formattedName, $actualValue);
- $actualValue = $actualRequestObject->getProduct();
- $this->assertProtobufEquals($formattedProduct, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function removeProductFromProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $formattedName = $gapicClient->productSetName('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]');
- $formattedProduct = $gapicClient->productName('[PROJECT]', '[LOCATION]', '[PRODUCT]');
- try {
- $gapicClient->removeProductFromProductSet($formattedName, $formattedProduct);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function updateProductTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name = 'name3373707';
- $displayName = 'displayName1615086568';
- $description = 'description-1724546052';
- $productCategory = 'productCategory-1607451058';
- $expectedResponse = new Product();
- $expectedResponse->setName($name);
- $expectedResponse->setDisplayName($displayName);
- $expectedResponse->setDescription($description);
- $expectedResponse->setProductCategory($productCategory);
- $transport->addResponse($expectedResponse);
- // Mock request
- $product = new Product();
- $response = $gapicClient->updateProduct($product);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/UpdateProduct', $actualFuncCall);
- $actualValue = $actualRequestObject->getProduct();
- $this->assertProtobufEquals($product, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function updateProductExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $product = new Product();
- try {
- $gapicClient->updateProduct($product);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function updateProductSetTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $name = 'name3373707';
- $displayName = 'displayName1615086568';
- $expectedResponse = new ProductSet();
- $expectedResponse->setName($name);
- $expectedResponse->setDisplayName($displayName);
- $transport->addResponse($expectedResponse);
- // Mock request
- $productSet = new ProductSet();
- $response = $gapicClient->updateProductSet($productSet);
- $this->assertEquals($expectedResponse, $response);
- $actualRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($actualRequests));
- $actualFuncCall = $actualRequests[0]->getFuncCall();
- $actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.vision.v1.ProductSearch/UpdateProductSet', $actualFuncCall);
- $actualValue = $actualRequestObject->getProductSet();
- $this->assertProtobufEquals($productSet, $actualValue);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function updateProductSetExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $status = new stdClass();
- $status->code = Code::DATA_LOSS;
- $status->details = 'internal error';
- $expectedExceptionMessage = json_encode([
- 'message' => 'internal error',
- 'code' => Code::DATA_LOSS,
- 'status' => 'DATA_LOSS',
- 'details' => [],
- ], JSON_PRETTY_PRINT);
- $transport->addResponse(null, $status);
- // Mock request
- $productSet = new ProductSet();
- try {
- $gapicClient->updateProductSet($productSet);
- // If the $gapicClient method call did not throw, fail the test
- $this->fail('Expected an ApiException, but no exception was thrown.');
- } catch (ApiException $ex) {
- $this->assertEquals($status->code, $ex->getCode());
- $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
- }
- // Call popReceivedCalls to ensure the stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-}
diff --git a/Vision/tests/Unit/VisionClientTest.php b/Vision/tests/Unit/VisionClientTest.php
deleted file mode 100644
index abc03486a7dd..000000000000
--- a/Vision/tests/Unit/VisionClientTest.php
+++ /dev/null
@@ -1,105 +0,0 @@
-client = TestHelpers::stub(VisionClient::class, [['suppressKeyFileNotice' => true]]);
- $this->connection = $this->prophesize(ConnectionInterface::class);
- }
-
- public function testImage()
- {
- $image = $this->client->image('foobar', ['FACE_DETECTION']);
-
- $this->assertInstanceOf(Image::class, $image);
- }
-
- public function testImages()
- {
- $images = $this->client->images(['foobar', 'othertest'], ['FACE_DETECTION']);
-
- $this->assertInstanceOf(Image::class, $images[0]);
- $this->assertInstanceOf(Image::class, $images[1]);
- }
-
- public function testAnnotate()
- {
- $image = $this->client->image('foobar', ['FACE_DETECTION']);
-
- $this->connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- []
- ]
- ]);
-
- $this->client->___setProperty('connection', $this->connection->reveal());
-
- $res = $this->client->annotate($image);
-
- $this->assertInstanceOf(Annotation::class, $res);
- }
-
- public function testAnnotateBatch()
- {
- $image = $this->client->image('foobar', ['FACE_DETECTION']);
-
- $this->connection->annotate(Argument::any())
- ->willReturn([
- 'responses' => [
- [], []
- ]
- ]);
-
- $this->client->___setProperty('connection', $this->connection->reveal());
-
- $res = $this->client->annotateBatch([$image]);
-
- $this->assertIsArray($res);
-
- $this->assertInstanceOf(Annotation::class, $res[0]);
- $this->assertInstanceOf(Annotation::class, $res[1]);
- }
-
- public function testAnnotateBatchInvalidImageType()
- {
- $this->expectException('InvalidArgumentException');
-
- $this->client->annotateBatch(['test']);
- }
-}
diff --git a/Vision/tests/Unit/VisionHelpersTraitTest.php b/Vision/tests/Unit/VisionHelpersTraitTest.php
deleted file mode 100644
index 677f055c8f6c..000000000000
--- a/Vision/tests/Unit/VisionHelpersTraitTest.php
+++ /dev/null
@@ -1,147 +0,0 @@
-implementation = TestHelpers::impl(VisionHelpersTrait::class);
- }
-
- public function testAnnotateImageHelper()
- {
- $image = new Image();
- $featureType = Feature_Type::FACE_DETECTION;
- $feature = new Feature();
- $feature->setType($featureType);
- $features = [$feature];
- $imageContext = new ImageContext();
- $imageContext->setLanguageHints(['en']);
-
- $cb = function ($requests, $optionalArgs) use ($image, $features, $imageContext) {
-
- // Test that imageContext key is correctly stripped
- $this->assertArrayNotHasKey('imageContext', $optionalArgs);
-
- $this->assertCount(1, $requests);
- $request = $requests[0];
- $this->assertEquals($image, $request->getImage());
- // Use iterator_to_array to convert protobuf Repeated Field object to array for comparison
- $this->assertSame($features, iterator_to_array($request->getFeatures()));
- $this->assertSame($imageContext, $request->getImageContext());
-
- $response = new BatchAnnotateImagesResponse();
- $response->setResponses([new AnnotateImageResponse()]);
- return $response;
- };
-
- $response = $this->implementation->call('annotateImageHelper', [
- $cb,
- AnnotateImageRequest::class,
- $image,
- $features,
- ['imageContext' => $imageContext]
- ]);
-
- $this->assertInstanceOf(AnnotateImageResponse::class, $response);
- }
-
- /**
- * @dataProvider createImageHelperDataProvider
- */
- public function testCreateImageHelper($imageInput, $expectedContent, $expectedUri)
- {
- $image = $this->implementation->call('createImageHelper', [
- Image::class,
- ImageSource::class,
- $imageInput
- ]);
- $this->assertSame($expectedContent, $image->getContent());
- $imageSource = $image->getSource();
- $this->assertSame($expectedUri, is_null($imageSource) ? null : $imageSource->getImageUri());
- }
-
- public function createImageHelperDataProvider()
- {
- $content = 'imageresourcecontent';
- $stream = fopen('php://memory', 'r+');
- fwrite($stream, $content);
- rewind($stream);
- return [
- ["http://my.site/myimage.jpg", "", "http://my.site/myimage.jpg"],
- ["https://my.site/myimage.jpg", "", "https://my.site/myimage.jpg"],
- ["gs://my_bucket/myimage.jpg", "", "gs://my_bucket/myimage.jpg"],
- ["abcdefxyz", "abcdefxyz", null],
- [$stream, $content, null],
- [
- $this->createImageHelper(Image::class, ImageSource::class, 'foobar'),
- 'foobar',
- null
- ],
- [
- $this->createImageHelper(Image::class, ImageSource::class, 'https://my.site/myimage.jpg'),
- '',
- 'https://my.site/myimage.jpg'
- ],
- ];
- }
-
- /**
- * @dataProvider invalidCreateImageHelperDataProvider
- */
- public function testInvalidCreateImageHelper($imageInput)
- {
- $this->expectException('InvalidArgumentException');
-
- $this->implementation->call('createImageHelper', [
- Image::class,
- ImageSource::class,
- $imageInput
- ]);
- }
-
- public function invalidCreateImageHelperDataProvider()
- {
- return [
- [null],
- [5],
- ];
- }
-}
diff --git a/Vision/tests/Unit/fixtures/eiffel-tower.jpg b/Vision/tests/Unit/fixtures/eiffel-tower.jpg
deleted file mode 100644
index c30d5fba7a4f..000000000000
Binary files a/Vision/tests/Unit/fixtures/eiffel-tower.jpg and /dev/null differ
diff --git a/Vision/tests/Unit/fixtures/face-landmarks.json b/Vision/tests/Unit/fixtures/face-landmarks.json
deleted file mode 100644
index d8c667334217..000000000000
--- a/Vision/tests/Unit/fixtures/face-landmarks.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"type":"LEFT_EYE","position":{"x":308.27933,"y":110.89249,"z":-0.00027270196}},{"type":"RIGHT_EYE","position":{"x":331.51788,"y":111.20496,"z":2.350548}},{"type":"LEFT_OF_LEFT_EYEBROW","position":{"x":299.53412,"y":107.23482,"z":1.5736846}},{"type":"RIGHT_OF_LEFT_EYEBROW","position":{"x":315.09937,"y":106.51907,"z":-4.1759934}},{"type":"LEFT_OF_RIGHT_EYEBROW","position":{"x":325.89609,"y":107.02411,"z":-3.0099149}},{"type":"RIGHT_OF_RIGHT_EYEBROW","position":{"x":340.32013,"y":107.40395,"z":5.575222}},{"type":"MIDPOINT_BETWEEN_EYES","position":{"x":320.66379,"y":110.97186,"z":-3.7770836}},{"type":"NOSE_TIP","position":{"x":321.34717,"y":125.16118,"z":-9.9785137}},{"type":"UPPER_LIP","position":{"x":320.87494,"y":133.08592,"z":-4.1927648}},{"type":"LOWER_LIP","position":{"x":320.86026,"y":142.2162,"z":-2.0023835}},{"type":"MOUTH_LEFT","position":{"x":308.42807,"y":135.37477,"z":1.9467878}},{"type":"MOUTH_RIGHT","position":{"x":332.49655,"y":135.35747,"z":4.1006036}},{"type":"MOUTH_CENTER","position":{"x":320.91907,"y":137.47472,"z":-2.2424593}},{"type":"NOSE_BOTTOM_RIGHT","position":{"x":327.74854,"y":126.2079,"z":-0.0600314}},{"type":"NOSE_BOTTOM_LEFT","position":{"x":314.00098,"y":125.98381,"z":-1.5457965}},{"type":"NOSE_BOTTOM_CENTER","position":{"x":320.89691,"y":128.69659,"z":-4.4734907}},{"type":"LEFT_EYE_TOP_BOUNDARY","position":{"x":308.81854,"y":110.22693,"z":-1.6344631}},{"type":"LEFT_EYE_RIGHT_CORNER","position":{"x":313.00266,"y":111.64439,"z":0.55486375}},{"type":"LEFT_EYE_BOTTOM_BOUNDARY","position":{"x":308.40778,"y":112.48532,"z":-0.16273952}},{"type":"LEFT_EYE_LEFT_CORNER","position":{"x":303.75186,"y":111.80703,"z":1.6805892}},{"type":"LEFT_EYE_PUPIL","position":{"x":308.38361,"y":111.77384,"z":-0.70631891}},{"type":"RIGHT_EYE_TOP_BOUNDARY","position":{"x":331.93112,"y":110.12611,"z":0.70604396}},{"type":"RIGHT_EYE_RIGHT_CORNER","position":{"x":336.28665,"y":111.7441,"z":4.9784403}},{"type":"RIGHT_EYE_BOTTOM_BOUNDARY","position":{"x":331.71429,"y":112.73804,"z":2.1789896}},{"type":"RIGHT_EYE_LEFT_CORNER","position":{"x":327.27646,"y":111.73038,"z":1.9743615}},{"type":"RIGHT_EYE_PUPIL","position":{"x":332.10938,"y":111.69082,"z":1.6692098}},{"type":"LEFT_EYEBROW_UPPER_MIDPOINT","position":{"x":307.96561,"y":103.68542,"z":-3.2818108}},{"type":"RIGHT_EYEBROW_UPPER_MIDPOINT","position":{"x":333.07031,"y":103.58981,"z":-0.72941887}},{"type":"LEFT_EAR_TRAGION","position":{"x":290.77478,"y":122.05881,"z":27.804081}},{"type":"RIGHT_EAR_TRAGION","position":{"x":343.63831,"y":121.7981,"z":32.987568}},{"type":"FOREHEAD_GLABELLA","position":{"x":320.78729,"y":106.21458,"z":-4.5494094}},{"type":"CHIN_GNATHION","position":{"x":320.39963,"y":151.38489,"z":1.4318451}},{"type":"CHIN_LEFT_GONION","position":{"x":294.52109,"y":137.28516,"z":19.16943}},{"type":"CHIN_RIGHT_GONION","position":{"x":342.02484,"y":137.0656,"z":23.990925}}]