From f85c60940a27c6974aa84aaf4af2110b6ef2a2e7 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 20 Jul 2023 10:38:01 -0700 Subject: [PATCH 1/2] chore: upgrade vision samples to new surface --- vision/quickstart.php | 2 +- vision/src/detect_document_text.php | 2 +- vision/src/detect_document_text_gcs.php | 2 +- vision/src/detect_face.php | 2 +- vision/src/detect_face_gcs.php | 2 +- vision/src/detect_image_property.php | 2 +- vision/src/detect_image_property_gcs.php | 2 +- vision/src/detect_label.php | 2 +- vision/src/detect_label_gcs.php | 2 +- vision/src/detect_landmark.php | 2 +- vision/src/detect_landmark_gcs.php | 2 +- vision/src/detect_logo.php | 2 +- vision/src/detect_logo_gcs.php | 2 +- vision/src/detect_object.php | 2 +- vision/src/detect_object_gcs.php | 2 +- vision/src/detect_pdf_gcs.php | 7 +++++-- vision/src/detect_safe_search.php | 2 +- vision/src/detect_safe_search_gcs.php | 2 +- vision/src/detect_text.php | 2 +- vision/src/detect_text_gcs.php | 2 +- vision/src/detect_web.php | 2 +- vision/src/detect_web_gcs.php | 2 +- vision/src/detect_web_with_geo_metadata.php | 2 +- vision/src/detect_web_with_geo_metadata_gcs.php | 2 +- 24 files changed, 28 insertions(+), 25 deletions(-) diff --git a/vision/quickstart.php b/vision/quickstart.php index 4a0a387fda..c9cffa0bde 100644 --- a/vision/quickstart.php +++ b/vision/quickstart.php @@ -20,7 +20,7 @@ require __DIR__ . '/vendor/autoload.php'; # imports the Google Cloud client library -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; # instantiates a client $imageAnnotator = new ImageAnnotatorClient(); diff --git a/vision/src/detect_document_text.php b/vision/src/detect_document_text.php index e6f9e51c14..bf4af162ad 100644 --- a/vision/src/detect_document_text.php +++ b/vision/src/detect_document_text.php @@ -18,7 +18,7 @@ // [START vision_fulltext_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_document_text_gcs.php b/vision/src/detect_document_text_gcs.php index 6406819f87..10e8ae188e 100644 --- a/vision/src/detect_document_text_gcs.php +++ b/vision/src/detect_document_text_gcs.php @@ -18,7 +18,7 @@ // [START vision_fulltext_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_face.php b/vision/src/detect_face.php index cec248b4e4..d5f25b4428 100644 --- a/vision/src/detect_face.php +++ b/vision/src/detect_face.php @@ -18,7 +18,7 @@ namespace Google\Cloud\Samples\Vision; // [START vision_face_detection_tutorial_imports] -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; // [END vision_face_detection_tutorial_imports] /** diff --git a/vision/src/detect_face_gcs.php b/vision/src/detect_face_gcs.php index 0dfde0d3d6..d6377d3cd3 100644 --- a/vision/src/detect_face_gcs.php +++ b/vision/src/detect_face_gcs.php @@ -18,7 +18,7 @@ // [START vision_face_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_image_property.php b/vision/src/detect_image_property.php index d21f9dd0cc..48eed63aa8 100644 --- a/vision/src/detect_image_property.php +++ b/vision/src/detect_image_property.php @@ -18,7 +18,7 @@ // [START vision_image_property_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_image_property_gcs.php b/vision/src/detect_image_property_gcs.php index 9f67ae1ace..b7a79d8a6a 100644 --- a/vision/src/detect_image_property_gcs.php +++ b/vision/src/detect_image_property_gcs.php @@ -18,7 +18,7 @@ // [START vision_image_property_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_label.php b/vision/src/detect_label.php index 678145e2b1..490007dc19 100644 --- a/vision/src/detect_label.php +++ b/vision/src/detect_label.php @@ -18,7 +18,7 @@ // [START vision_label_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_label_gcs.php b/vision/src/detect_label_gcs.php index ca8d5744bb..25bafebc55 100644 --- a/vision/src/detect_label_gcs.php +++ b/vision/src/detect_label_gcs.php @@ -18,7 +18,7 @@ // [START vision_label_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_landmark.php b/vision/src/detect_landmark.php index 66011af5fb..b31813bd8a 100644 --- a/vision/src/detect_landmark.php +++ b/vision/src/detect_landmark.php @@ -18,7 +18,7 @@ // [START vision_landmark_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_landmark_gcs.php b/vision/src/detect_landmark_gcs.php index d7fb9d2112..60c1ae6562 100644 --- a/vision/src/detect_landmark_gcs.php +++ b/vision/src/detect_landmark_gcs.php @@ -18,7 +18,7 @@ // [START vision_landmark_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_logo.php b/vision/src/detect_logo.php index 6c629bb7f3..eb3eeb4d64 100644 --- a/vision/src/detect_logo.php +++ b/vision/src/detect_logo.php @@ -18,7 +18,7 @@ // [START vision_logo_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_logo_gcs.php b/vision/src/detect_logo_gcs.php index fd9d53b7ce..9c89d409d4 100644 --- a/vision/src/detect_logo_gcs.php +++ b/vision/src/detect_logo_gcs.php @@ -18,7 +18,7 @@ // [START vision_logo_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_object.php b/vision/src/detect_object.php index 081ea52a7b..77aa0c8f9d 100644 --- a/vision/src/detect_object.php +++ b/vision/src/detect_object.php @@ -18,7 +18,7 @@ // [START vision_localize_objects] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_object_gcs.php b/vision/src/detect_object_gcs.php index 91cd2dd1db..389116b218 100644 --- a/vision/src/detect_object_gcs.php +++ b/vision/src/detect_object_gcs.php @@ -18,7 +18,7 @@ // [START vision_localize_objects_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_pdf_gcs.php b/vision/src/detect_pdf_gcs.php index 2082ac356b..77c3ac1338 100644 --- a/vision/src/detect_pdf_gcs.php +++ b/vision/src/detect_pdf_gcs.php @@ -21,11 +21,12 @@ use Google\Cloud\Storage\StorageClient; use Google\Cloud\Vision\V1\AnnotateFileResponse; use Google\Cloud\Vision\V1\AsyncAnnotateFileRequest; +use Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; use Google\Cloud\Vision\V1\Feature; use Google\Cloud\Vision\V1\Feature\Type; use Google\Cloud\Vision\V1\GcsDestination; use Google\Cloud\Vision\V1\GcsSource; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; use Google\Cloud\Vision\V1\InputConfig; use Google\Cloud\Vision\V1\OutputConfig; @@ -66,7 +67,9 @@ function detect_pdf_gcs(string $path, string $output) # make request $imageAnnotator = new ImageAnnotatorClient(); - $operation = $imageAnnotator->asyncBatchAnnotateFiles($requests); + $request = (new AsyncBatchAnnotateFilesRequest()) + ->setRequests($requests); + $operation = $imageAnnotator->asyncBatchAnnotateFiles($request); print('Waiting for operation to finish.' . PHP_EOL); $operation->pollUntilComplete(); diff --git a/vision/src/detect_safe_search.php b/vision/src/detect_safe_search.php index 1275329e0b..da8fefbf8e 100644 --- a/vision/src/detect_safe_search.php +++ b/vision/src/detect_safe_search.php @@ -18,7 +18,7 @@ // [START vision_safe_search_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_safe_search_gcs.php b/vision/src/detect_safe_search_gcs.php index 1390be46af..89379453a4 100644 --- a/vision/src/detect_safe_search_gcs.php +++ b/vision/src/detect_safe_search_gcs.php @@ -18,7 +18,7 @@ // [START vision_safe_search_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_text.php b/vision/src/detect_text.php index 0bf10d6df0..133c068670 100644 --- a/vision/src/detect_text.php +++ b/vision/src/detect_text.php @@ -18,7 +18,7 @@ // [START vision_text_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_text_gcs.php b/vision/src/detect_text_gcs.php index ef9b548c23..d281e08dd4 100644 --- a/vision/src/detect_text_gcs.php +++ b/vision/src/detect_text_gcs.php @@ -18,7 +18,7 @@ // [START vision_text_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_web.php b/vision/src/detect_web.php index a071ec2970..7ad7ece823 100644 --- a/vision/src/detect_web.php +++ b/vision/src/detect_web.php @@ -18,7 +18,7 @@ // [START vision_web_detection] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path Path to the image, e.g. "path/to/your/image.jpg" diff --git a/vision/src/detect_web_gcs.php b/vision/src/detect_web_gcs.php index 330ac95f00..d3c6256946 100644 --- a/vision/src/detect_web_gcs.php +++ b/vision/src/detect_web_gcs.php @@ -18,7 +18,7 @@ // [START vision_web_detection_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; /** * @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg" diff --git a/vision/src/detect_web_with_geo_metadata.php b/vision/src/detect_web_with_geo_metadata.php index 55d4751db5..018dd32ebe 100644 --- a/vision/src/detect_web_with_geo_metadata.php +++ b/vision/src/detect_web_with_geo_metadata.php @@ -18,7 +18,7 @@ // [START vision_web_detection_include_geo] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; use Google\Cloud\Vision\V1\ImageContext; use Google\Cloud\Vision\V1\WebDetectionParams; diff --git a/vision/src/detect_web_with_geo_metadata_gcs.php b/vision/src/detect_web_with_geo_metadata_gcs.php index 8a0cc0d594..c50f9e9ca8 100644 --- a/vision/src/detect_web_with_geo_metadata_gcs.php +++ b/vision/src/detect_web_with_geo_metadata_gcs.php @@ -18,7 +18,7 @@ // [START vision_web_detection_include_geo_gcs] namespace Google\Cloud\Samples\Vision; -use Google\Cloud\Vision\V1\ImageAnnotatorClient; +use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient; use Google\Cloud\Vision\V1\ImageContext; use Google\Cloud\Vision\V1\WebDetectionParams; From 6d3957290b6bf4b51bd3375627cbf73aee5ba06a Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 20 Jul 2023 12:12:22 -0700 Subject: [PATCH 2/2] update min version --- vision/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vision/composer.json b/vision/composer.json index 5d79fa2baf..258acb585e 100644 --- a/vision/composer.json +++ b/vision/composer.json @@ -2,7 +2,7 @@ "name": "google/vision", "type": "project", "require": { - "google/cloud-vision": "^1.0.0", + "google/cloud-vision": "^1.7", "google/cloud-storage": "^1.20.1" } }