From 277b4a62770e15dcea6900bd93fb34daa66d4c00 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 17 May 2017 09:59:22 -0700 Subject: [PATCH] Video Intelligence GAPIC-only This adds the video intelligence library, published as a GAPIC only with a thin manual wrapper for consistency. --- videointelligence/LICENSE | 202 +++ videointelligence/MANIFEST.in | 4 + videointelligence/README.rst | 41 + videointelligence/google/__init__.py | 20 + videointelligence/google/cloud/__init__.py | 20 + .../google/cloud/gapic/__init__.py | 1 + .../cloud/gapic/videointelligence/__init__.py | 1 + .../videointelligence/v1beta1/__init__.py | 0 .../gapic/videointelligence/v1beta1/enums.py | 87 ++ .../video_intelligence_service_client.py | 239 ++++ ...eo_intelligence_service_client_config.json | 33 + .../google/cloud/proto/__init__.py | 1 + .../cloud/proto/videointelligence/__init__.py | 1 + .../videointelligence/v1beta1/__init__.py | 1 + .../v1beta1/video_intelligence_pb2.py | 1106 +++++++++++++++++ .../v1beta1/video_intelligence_pb2_grpc.py | 52 + .../google/cloud/videointelligence.py | 28 + .../videointelligence_v1beta1/__init__.py | 28 + .../cloud/videointelligence_v1beta1/types.py | 28 + videointelligence/nox.py | 41 + videointelligence/setup.cfg | 2 + videointelligence/setup.py | 68 + .../test_video_intelligence_service_client.py | 87 ++ 23 files changed, 2091 insertions(+) create mode 100644 videointelligence/LICENSE create mode 100644 videointelligence/MANIFEST.in create mode 100644 videointelligence/README.rst create mode 100644 videointelligence/google/__init__.py create mode 100644 videointelligence/google/cloud/__init__.py create mode 100644 videointelligence/google/cloud/gapic/__init__.py create mode 100644 videointelligence/google/cloud/gapic/videointelligence/__init__.py create mode 100644 videointelligence/google/cloud/gapic/videointelligence/v1beta1/__init__.py create mode 100644 videointelligence/google/cloud/gapic/videointelligence/v1beta1/enums.py create mode 100644 videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client.py create mode 100644 videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client_config.json create mode 100644 videointelligence/google/cloud/proto/__init__.py create mode 100644 videointelligence/google/cloud/proto/videointelligence/__init__.py create mode 100644 videointelligence/google/cloud/proto/videointelligence/v1beta1/__init__.py create mode 100644 videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2.py create mode 100644 videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2_grpc.py create mode 100644 videointelligence/google/cloud/videointelligence.py create mode 100644 videointelligence/google/cloud/videointelligence_v1beta1/__init__.py create mode 100644 videointelligence/google/cloud/videointelligence_v1beta1/types.py create mode 100644 videointelligence/nox.py create mode 100644 videointelligence/setup.cfg create mode 100644 videointelligence/setup.py create mode 100644 videointelligence/tests/gapic/v1beta1/test_video_intelligence_service_client.py diff --git a/videointelligence/LICENSE b/videointelligence/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/videointelligence/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/videointelligence/MANIFEST.in b/videointelligence/MANIFEST.in new file mode 100644 index 000000000000..8f5e2b1a8b1b --- /dev/null +++ b/videointelligence/MANIFEST.in @@ -0,0 +1,4 @@ +include README.rst LICENSE requirements.txt +recursive-include google *.json *.proto +recursive-include unit_tests * +global-exclude *.pyc __pycache__ diff --git a/videointelligence/README.rst b/videointelligence/README.rst new file mode 100644 index 000000000000..1790007d95b4 --- /dev/null +++ b/videointelligence/README.rst @@ -0,0 +1,41 @@ +Python Client for Google Cloud Video Intelligence +================================================= + + Python idiomatic client for `Google Cloud Video Intelligence`_ + +.. _Google Cloud Video Intelligence: https://cloud.google.com/videointelligence/ + +|pypi| |versions| + +- `Documentation`_ + +.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/video-intelligence-usage.html + +Quick Start +----------- + +.. code-block:: console + + $ pip install --upgrade google-cloud-video-intelligence + +Authentication +-------------- + +With ``google-cloud-python`` we try to make authentication as painless as +possible. Check out the `Authentication section`_ in our documentation to +learn more. You may also find the `authentication document`_ shared by all +the ``google-cloud-*`` libraries to be helpful. + +.. _Authentication section: http://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html +.. _authentication document: https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication + +Using the API +------------- + +The Google Cloud `Video Intelligence`_ (`Video Intelligence API docs`_) +API enables developers to +understand the content of a video by encapsulating powerful machine +learning models in an easy to use REST API. + +.. _Video Intelligence: https://cloud.google.com/videointelligence/ +.. _Video Intelligence API docs: https://cloud.google.com/videointelligence/reference/rest/ diff --git a/videointelligence/google/__init__.py b/videointelligence/google/__init__.py new file mode 100644 index 000000000000..b2b833373882 --- /dev/null +++ b/videointelligence/google/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/videointelligence/google/cloud/__init__.py b/videointelligence/google/cloud/__init__.py new file mode 100644 index 000000000000..b2b833373882 --- /dev/null +++ b/videointelligence/google/cloud/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/videointelligence/google/cloud/gapic/__init__.py b/videointelligence/google/cloud/gapic/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/videointelligence/google/cloud/gapic/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/videointelligence/google/cloud/gapic/videointelligence/__init__.py b/videointelligence/google/cloud/gapic/videointelligence/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/videointelligence/google/cloud/gapic/videointelligence/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/videointelligence/google/cloud/gapic/videointelligence/v1beta1/__init__.py b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/videointelligence/google/cloud/gapic/videointelligence/v1beta1/enums.py b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/enums.py new file mode 100644 index 000000000000..13b9bd25f0b2 --- /dev/null +++ b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/enums.py @@ -0,0 +1,87 @@ +# Copyright 2016 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Wrappers for protocol buffer enum types.""" + + +class Feature(object): + """ + Video annotation feature. + + Attributes: + FEATURE_UNSPECIFIED (int): Unspecified. + LABEL_DETECTION (int): Label detection. Detect objects, such as dog or flower. + FACE_DETECTION (int): Human face detection and tracking. + SHOT_CHANGE_DETECTION (int): Shot change detection. + SAFE_SEARCH_DETECTION (int): Safe search detection. + """ + FEATURE_UNSPECIFIED = 0 + LABEL_DETECTION = 1 + FACE_DETECTION = 2 + SHOT_CHANGE_DETECTION = 3 + SAFE_SEARCH_DETECTION = 4 + + +class LabelLevel(object): + """ + Label level (scope). + + Attributes: + LABEL_LEVEL_UNSPECIFIED (int): Unspecified. + VIDEO_LEVEL (int): Video-level. Corresponds to the whole video. + SEGMENT_LEVEL (int): Segment-level. Corresponds to one of ``AnnotateSpec.segments``. + SHOT_LEVEL (int): Shot-level. Corresponds to a single shot (i.e. a series of frames + without a major camera position or background change). + FRAME_LEVEL (int): Frame-level. Corresponds to a single video frame. + """ + LABEL_LEVEL_UNSPECIFIED = 0 + VIDEO_LEVEL = 1 + SEGMENT_LEVEL = 2 + SHOT_LEVEL = 3 + FRAME_LEVEL = 4 + + +class LabelDetectionMode(object): + """ + Label detection mode. + + Attributes: + LABEL_DETECTION_MODE_UNSPECIFIED (int): Unspecified. + SHOT_MODE (int): Detect shot-level labels. + FRAME_MODE (int): Detect frame-level labels. + SHOT_AND_FRAME_MODE (int): Detect both shot-level and frame-level labels. + """ + LABEL_DETECTION_MODE_UNSPECIFIED = 0 + SHOT_MODE = 1 + FRAME_MODE = 2 + SHOT_AND_FRAME_MODE = 3 + + +class Likelihood(object): + """ + Bucketized representation of likelihood. + + Attributes: + UNKNOWN (int): Unknown likelihood. + VERY_UNLIKELY (int): Very unlikely. + UNLIKELY (int): Unlikely. + POSSIBLE (int): Possible. + LIKELY (int): Likely. + VERY_LIKELY (int): Very likely. + """ + UNKNOWN = 0 + VERY_UNLIKELY = 1 + UNLIKELY = 2 + POSSIBLE = 3 + LIKELY = 4 + VERY_LIKELY = 5 diff --git a/videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client.py b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client.py new file mode 100644 index 000000000000..733a95c3240a --- /dev/null +++ b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client.py @@ -0,0 +1,239 @@ +# Copyright 2017, Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# EDITING INSTRUCTIONS +# This file was generated from the file +# https://github.com/google/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto, +# and updates to that file get reflected here through a refresh process. +# For the short term, the refresh process will only be runnable by Google engineers. +# +# The only allowed edits are to method and file documentation. A 3-way +# merge preserves those additions if the generated source changes. +"""Accesses the google.cloud.videointelligence.v1beta1 VideoIntelligenceService API.""" + +import collections +import json +import os +import pkg_resources +import platform + +from google.gapic.longrunning import operations_client +from google.gax import api_callable +from google.gax import config +from google.gax import path_template +import google.gax + +from google.cloud.gapic.videointelligence.v1beta1 import enums +from google.cloud.proto.videointelligence.v1beta1 import video_intelligence_pb2 + + +class VideoIntelligenceServiceClient(object): + """Service that implements Google Cloud Video Intelligence API.""" + + SERVICE_ADDRESS = 'videointelligence.googleapis.com' + """The default address of the service.""" + + DEFAULT_SERVICE_PORT = 443 + """The default port of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _ALL_SCOPES = ('https://www.googleapis.com/auth/cloud-platform', ) + + def __init__(self, + service_path=SERVICE_ADDRESS, + port=DEFAULT_SERVICE_PORT, + channel=None, + credentials=None, + ssl_credentials=None, + scopes=None, + client_config=None, + app_name=None, + app_version='', + lib_name=None, + lib_version='', + metrics_headers=()): + """Constructor. + + Args: + service_path (string): The domain name of the API remote host. + port (int): The port on which to connect to the remote host. + channel (:class:`grpc.Channel`): A ``Channel`` instance through + which to make calls. + credentials (object): The authorization credentials to attach to + requests. These credentials identify this application to the + service. + ssl_credentials (:class:`grpc.ChannelCredentials`): A + ``ChannelCredentials`` instance for use with an SSL-enabled + channel. + scopes (list[string]): A list of OAuth2 scopes to attach to requests. + client_config (dict): + A dictionary for call options for each method. See + :func:`google.gax.construct_settings` for the structure of + this data. Falls back to the default config if not specified + or the specified config is missing data points. + app_name (string): The name of the application calling + the service. Recommended for analytics purposes. + app_version (string): The version of the application calling + the service. Recommended for analytics purposes. + lib_name (string): The API library software used for calling + the service. (Unless you are writing an API client itself, + leave this as default.) + lib_version (string): The API library software version used + for calling the service. (Unless you are writing an API client + itself, leave this as default.) + metrics_headers (dict): A dictionary of values for tracking + client library metrics. Ultimately serializes to a string + (e.g. 'foo/1.2.3 bar/3.14.1'). This argument should be + considered private. + + Returns: + A VideoIntelligenceServiceClient object. + """ + # Unless the calling application specifically requested + # OAuth scopes, request everything. + if scopes is None: + scopes = self._ALL_SCOPES + + # Initialize an empty client config, if none is set. + if client_config is None: + client_config = {} + + # Initialize metrics_headers as an ordered dictionary + # (cuts down on cardinality of the resulting string slightly). + metrics_headers = collections.OrderedDict(metrics_headers) + metrics_headers['gl-python'] = platform.python_version() + + # The library may or may not be set, depending on what is + # calling this client. Newer client libraries set the library name + # and version. + if lib_name: + metrics_headers[lib_name] = lib_version + + # Finally, track the GAPIC package version. + metrics_headers['gapic'] = pkg_resources.get_distribution( + 'google-cloud-videointelligence', ).version + + # Load the configuration defaults. + default_client_config = json.loads( + pkg_resources.resource_string( + __name__, 'video_intelligence_service_client_config.json') + .decode()) + defaults = api_callable.construct_settings( + 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', + default_client_config, + client_config, + config.STATUS_CODE_NAMES, + metrics_headers=metrics_headers, ) + self.video_intelligence_service_stub = config.create_stub( + video_intelligence_pb2.VideoIntelligenceServiceStub, + channel=channel, + service_path=service_path, + service_port=port, + credentials=credentials, + scopes=scopes, + ssl_credentials=ssl_credentials) + + self.operations_client = operations_client.OperationsClient( + service_path=service_path, + port=port, + channel=channel, + credentials=credentials, + ssl_credentials=ssl_credentials, + scopes=scopes, + client_config=client_config, + metrics_headers=metrics_headers, ) + + self._annotate_video = api_callable.create_api_call( + self.video_intelligence_service_stub.AnnotateVideo, + settings=defaults['annotate_video']) + + # Service calls + def annotate_video(self, + input_uri, + features, + input_content=None, + video_context=None, + output_uri=None, + location_id=None, + options=None): + """ + Performs asynchronous video annotation. Progress and results can be + retrieved through the ``google.longrunning.Operations`` interface. + ``Operation.metadata`` contains ``AnnotateVideoProgress`` (progress). + ``Operation.response`` contains ``AnnotateVideoResponse`` (results). + + Example: + >>> from google.cloud.gapic.videointelligence.v1beta1 import video_intelligence_service_client + >>> from google.cloud.gapic.videointelligence.v1beta1 import enums + >>> client = video_intelligence_service_client.VideoIntelligenceServiceClient() + >>> input_uri = '' + >>> features = [] + >>> response = client.annotate_video(input_uri, features) + >>> + >>> def callback(operation_future): + >>> # Handle result. + >>> result = operation_future.result() + >>> + >>> response.add_done_callback(callback) + >>> + >>> # Handle metadata. + >>> metadata = response.metadata() + + Args: + input_uri (string): Input video location. Currently, only + `Google Cloud Storage `_ URIs are + supported, which must be specified in the following format: + ``gs://bucket-id/object-id`` (other URI formats return + ``google.rpc.Code.INVALID_ARGUMENT``). For more information, see + `Request URIs `_. + A video URI may include wildcards in ``object-id``, and thus identify + multiple videos. Supported wildcards: '*' to match 0 or more characters; + '?' to match 1 character. If unset, the input video should be embedded + in the request as ``input_content``. If set, ``input_content`` should be unset. + features (list[enum :class:`google.cloud.gapic.videointelligence.v1beta1.enums.Feature`]): Requested video annotation features. + input_content (string): The video data bytes. Encoding: base64. If unset, the input video(s) + should be specified via ``input_uri``. If set, ``input_uri`` should be unset. + video_context (:class:`google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2.VideoContext`): Additional video context and/or feature-specific parameters. + output_uri (string): Optional location where the output (in JSON format) should be stored. + Currently, only `Google Cloud Storage `_ + URIs are supported, which must be specified in the following format: + ``gs://bucket-id/object-id`` (other URI formats return + ``google.rpc.Code.INVALID_ARGUMENT``). For more information, see + `Request URIs `_. + location_id (string): Optional cloud region where annotation should take place. Supported cloud + regions: ``us-east1``, ``us-west1``, ``europe-west1``, ``asia-east1``. If no region + is specified, a region will be determined based on video file location. + options (:class:`google.gax.CallOptions`): Overrides the default + settings for this call, e.g, timeout, retries etc. + + Returns: + A :class:`google.gax._OperationFuture` instance. + + Raises: + :exc:`google.gax.errors.GaxError` if the RPC is aborted. + :exc:`ValueError` if the parameters are invalid. + """ + # Create the request object. + request = video_intelligence_pb2.AnnotateVideoRequest( + input_uri=input_uri, + features=features, + input_content=input_content, + video_context=video_context, + output_uri=output_uri, + location_id=location_id) + return google.gax._OperationFuture( + self._annotate_video(request, options), self.operations_client, + video_intelligence_pb2.AnnotateVideoResponse, + video_intelligence_pb2.AnnotateVideoProgress, options) diff --git a/videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client_config.json b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client_config.json new file mode 100644 index 000000000000..7dd61bbb7b5d --- /dev/null +++ b/videointelligence/google/cloud/gapic/videointelligence/v1beta1/video_intelligence_service_client_config.json @@ -0,0 +1,33 @@ +{ + "interfaces": { + "google.cloud.videointelligence.v1beta1.VideoIntelligenceService": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 2.5, + "max_retry_delay_millis": 120000, + "initial_rpc_timeout_millis": 120000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 120000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "AnnotateVideo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/videointelligence/google/cloud/proto/__init__.py b/videointelligence/google/cloud/proto/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/videointelligence/google/cloud/proto/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/videointelligence/google/cloud/proto/videointelligence/__init__.py b/videointelligence/google/cloud/proto/videointelligence/__init__.py new file mode 100644 index 000000000000..de40ea7ca058 --- /dev/null +++ b/videointelligence/google/cloud/proto/videointelligence/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/videointelligence/google/cloud/proto/videointelligence/v1beta1/__init__.py b/videointelligence/google/cloud/proto/videointelligence/v1beta1/__init__.py new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/videointelligence/google/cloud/proto/videointelligence/v1beta1/__init__.py @@ -0,0 +1 @@ + diff --git a/videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2.py b/videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2.py new file mode 100644 index 000000000000..9046090f92d7 --- /dev/null +++ b/videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2.py @@ -0,0 +1,1106 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/proto/videointelligence/v1beta1/video_intelligence.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/proto/videointelligence/v1beta1/video_intelligence.proto', + package='google.cloud.videointelligence.v1beta1', + syntax='proto3', + serialized_pb=_b('\nEgoogle/cloud/proto/videointelligence/v1beta1/video_intelligence.proto\x12&google.cloud.videointelligence.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a#google/longrunning/operations.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x17google/rpc/status.proto\"\xf9\x01\n\x14\x41nnotateVideoRequest\x12\x11\n\tinput_uri\x18\x01 \x01(\t\x12\x15\n\rinput_content\x18\x06 \x01(\t\x12\x41\n\x08\x66\x65\x61tures\x18\x02 \x03(\x0e\x32/.google.cloud.videointelligence.v1beta1.Feature\x12K\n\rvideo_context\x18\x03 \x01(\x0b\x32\x34.google.cloud.videointelligence.v1beta1.VideoContext\x12\x12\n\noutput_uri\x18\x04 \x01(\t\x12\x13\n\x0blocation_id\x18\x05 \x01(\t\"\xd2\x02\n\x0cVideoContext\x12\x46\n\x08segments\x18\x01 \x03(\x0b\x32\x34.google.cloud.videointelligence.v1beta1.VideoSegment\x12X\n\x14label_detection_mode\x18\x02 \x01(\x0e\x32:.google.cloud.videointelligence.v1beta1.LabelDetectionMode\x12\x19\n\x11stationary_camera\x18\x03 \x01(\x08\x12\x1d\n\x15label_detection_model\x18\x04 \x01(\t\x12\x1c\n\x14\x66\x61\x63\x65_detection_model\x18\x05 \x01(\t\x12#\n\x1bshot_change_detection_model\x18\x06 \x01(\t\x12#\n\x1bsafe_search_detection_model\x18\x07 \x01(\t\"B\n\x0cVideoSegment\x12\x19\n\x11start_time_offset\x18\x01 \x01(\x03\x12\x17\n\x0f\x65nd_time_offset\x18\x02 \x01(\x03\"\xad\x01\n\rLabelLocation\x12\x45\n\x07segment\x18\x01 \x01(\x0b\x32\x34.google.cloud.videointelligence.v1beta1.VideoSegment\x12\x12\n\nconfidence\x18\x02 \x01(\x02\x12\x41\n\x05level\x18\x03 \x01(\x0e\x32\x32.google.cloud.videointelligence.v1beta1.LabelLevel\"\x87\x01\n\x0fLabelAnnotation\x12\x13\n\x0b\x64\x65scription\x18\x01 \x01(\t\x12\x15\n\rlanguage_code\x18\x02 \x01(\t\x12H\n\tlocations\x18\x03 \x03(\x0b\x32\x35.google.cloud.videointelligence.v1beta1.LabelLocation\"\xfd\x02\n\x14SafeSearchAnnotation\x12\x41\n\x05\x61\x64ult\x18\x01 \x01(\x0e\x32\x32.google.cloud.videointelligence.v1beta1.Likelihood\x12\x41\n\x05spoof\x18\x02 \x01(\x0e\x32\x32.google.cloud.videointelligence.v1beta1.Likelihood\x12\x43\n\x07medical\x18\x03 \x01(\x0e\x32\x32.google.cloud.videointelligence.v1beta1.Likelihood\x12\x43\n\x07violent\x18\x04 \x01(\x0e\x32\x32.google.cloud.videointelligence.v1beta1.Likelihood\x12@\n\x04racy\x18\x05 \x01(\x0e\x32\x32.google.cloud.videointelligence.v1beta1.Likelihood\x12\x13\n\x0btime_offset\x18\x06 \x01(\x03\"G\n\x0b\x42oundingBox\x12\x0c\n\x04left\x18\x01 \x01(\x05\x12\r\n\x05right\x18\x02 \x01(\x05\x12\x0e\n\x06\x62ottom\x18\x03 \x01(\x05\x12\x0b\n\x03top\x18\x04 \x01(\x05\"n\n\x0c\x46\x61\x63\x65Location\x12I\n\x0c\x62ounding_box\x18\x01 \x01(\x0b\x32\x33.google.cloud.videointelligence.v1beta1.BoundingBox\x12\x13\n\x0btime_offset\x18\x02 \x01(\x03\"\xb4\x01\n\x0e\x46\x61\x63\x65\x41nnotation\x12\x11\n\tthumbnail\x18\x01 \x01(\t\x12\x46\n\x08segments\x18\x02 \x03(\x0b\x32\x34.google.cloud.videointelligence.v1beta1.VideoSegment\x12G\n\tlocations\x18\x03 \x03(\x0b\x32\x34.google.cloud.videointelligence.v1beta1.FaceLocation\"\xa3\x03\n\x16VideoAnnotationResults\x12\x11\n\tinput_uri\x18\x01 \x01(\t\x12R\n\x11label_annotations\x18\x02 \x03(\x0b\x32\x37.google.cloud.videointelligence.v1beta1.LabelAnnotation\x12P\n\x10\x66\x61\x63\x65_annotations\x18\x03 \x03(\x0b\x32\x36.google.cloud.videointelligence.v1beta1.FaceAnnotation\x12N\n\x10shot_annotations\x18\x04 \x03(\x0b\x32\x34.google.cloud.videointelligence.v1beta1.VideoSegment\x12]\n\x17safe_search_annotations\x18\x06 \x03(\x0b\x32<.google.cloud.videointelligence.v1beta1.SafeSearchAnnotation\x12!\n\x05\x65rror\x18\x05 \x01(\x0b\x32\x12.google.rpc.Status\"s\n\x15\x41nnotateVideoResponse\x12Z\n\x12\x61nnotation_results\x18\x01 \x03(\x0b\x32>.google.cloud.videointelligence.v1beta1.VideoAnnotationResults\"\xa7\x01\n\x17VideoAnnotationProgress\x12\x11\n\tinput_uri\x18\x01 \x01(\t\x12\x18\n\x10progress_percent\x18\x02 \x01(\x05\x12.\n\nstart_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0bupdate_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"u\n\x15\x41nnotateVideoProgress\x12\\\n\x13\x61nnotation_progress\x18\x01 \x03(\x0b\x32?.google.cloud.videointelligence.v1beta1.VideoAnnotationProgress*\x81\x01\n\x07\x46\x65\x61ture\x12\x17\n\x13\x46\x45\x41TURE_UNSPECIFIED\x10\x00\x12\x13\n\x0fLABEL_DETECTION\x10\x01\x12\x12\n\x0e\x46\x41\x43\x45_DETECTION\x10\x02\x12\x19\n\x15SHOT_CHANGE_DETECTION\x10\x03\x12\x19\n\x15SAFE_SEARCH_DETECTION\x10\x04*n\n\nLabelLevel\x12\x1b\n\x17LABEL_LEVEL_UNSPECIFIED\x10\x00\x12\x0f\n\x0bVIDEO_LEVEL\x10\x01\x12\x11\n\rSEGMENT_LEVEL\x10\x02\x12\x0e\n\nSHOT_LEVEL\x10\x03\x12\x0f\n\x0b\x46RAME_LEVEL\x10\x04*r\n\x12LabelDetectionMode\x12$\n LABEL_DETECTION_MODE_UNSPECIFIED\x10\x00\x12\r\n\tSHOT_MODE\x10\x01\x12\x0e\n\nFRAME_MODE\x10\x02\x12\x17\n\x13SHOT_AND_FRAME_MODE\x10\x03*e\n\nLikelihood\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x11\n\rVERY_UNLIKELY\x10\x01\x12\x0c\n\x08UNLIKELY\x10\x02\x12\x0c\n\x08POSSIBLE\x10\x03\x12\n\n\x06LIKELY\x10\x04\x12\x0f\n\x0bVERY_LIKELY\x10\x05\x32\xae\x01\n\x18VideoIntelligenceService\x12\x91\x01\n\rAnnotateVideo\x12<.google.cloud.videointelligence.v1beta1.AnnotateVideoRequest\x1a\x1d.google.longrunning.Operation\"#\x82\xd3\xe4\x93\x02\x1d\"\x18/v1beta1/videos:annotate:\x01*B\xcf\x01\n*com.google.cloud.videointelligence.v1beta1B\x1dVideoIntelligenceServiceProtoP\x01ZWgoogle.golang.org/genproto/googleapis/cloud/videointelligence/v1beta1;videointelligence\xaa\x02&Google.Cloud.VideoIntelligence.V1Beta1b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_longrunning_dot_operations__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,google_dot_rpc_dot_status__pb2.DESCRIPTOR,]) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +_FEATURE = _descriptor.EnumDescriptor( + name='Feature', + full_name='google.cloud.videointelligence.v1beta1.Feature', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='FEATURE_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='LABEL_DETECTION', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='FACE_DETECTION', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SHOT_CHANGE_DETECTION', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SAFE_SEARCH_DETECTION', index=4, number=4, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=2794, + serialized_end=2923, +) +_sym_db.RegisterEnumDescriptor(_FEATURE) + +Feature = enum_type_wrapper.EnumTypeWrapper(_FEATURE) +_LABELLEVEL = _descriptor.EnumDescriptor( + name='LabelLevel', + full_name='google.cloud.videointelligence.v1beta1.LabelLevel', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='LABEL_LEVEL_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='VIDEO_LEVEL', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SEGMENT_LEVEL', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SHOT_LEVEL', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='FRAME_LEVEL', index=4, number=4, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=2925, + serialized_end=3035, +) +_sym_db.RegisterEnumDescriptor(_LABELLEVEL) + +LabelLevel = enum_type_wrapper.EnumTypeWrapper(_LABELLEVEL) +_LABELDETECTIONMODE = _descriptor.EnumDescriptor( + name='LabelDetectionMode', + full_name='google.cloud.videointelligence.v1beta1.LabelDetectionMode', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='LABEL_DETECTION_MODE_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SHOT_MODE', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='FRAME_MODE', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SHOT_AND_FRAME_MODE', index=3, number=3, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=3037, + serialized_end=3151, +) +_sym_db.RegisterEnumDescriptor(_LABELDETECTIONMODE) + +LabelDetectionMode = enum_type_wrapper.EnumTypeWrapper(_LABELDETECTIONMODE) +_LIKELIHOOD = _descriptor.EnumDescriptor( + name='Likelihood', + full_name='google.cloud.videointelligence.v1beta1.Likelihood', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='UNKNOWN', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='VERY_UNLIKELY', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='UNLIKELY', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='POSSIBLE', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='LIKELY', index=4, number=4, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='VERY_LIKELY', index=5, number=5, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=3153, + serialized_end=3254, +) +_sym_db.RegisterEnumDescriptor(_LIKELIHOOD) + +Likelihood = enum_type_wrapper.EnumTypeWrapper(_LIKELIHOOD) +FEATURE_UNSPECIFIED = 0 +LABEL_DETECTION = 1 +FACE_DETECTION = 2 +SHOT_CHANGE_DETECTION = 3 +SAFE_SEARCH_DETECTION = 4 +LABEL_LEVEL_UNSPECIFIED = 0 +VIDEO_LEVEL = 1 +SEGMENT_LEVEL = 2 +SHOT_LEVEL = 3 +FRAME_LEVEL = 4 +LABEL_DETECTION_MODE_UNSPECIFIED = 0 +SHOT_MODE = 1 +FRAME_MODE = 2 +SHOT_AND_FRAME_MODE = 3 +UNKNOWN = 0 +VERY_UNLIKELY = 1 +UNLIKELY = 2 +POSSIBLE = 3 +LIKELY = 4 +VERY_LIKELY = 5 + + + +_ANNOTATEVIDEOREQUEST = _descriptor.Descriptor( + name='AnnotateVideoRequest', + full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='input_uri', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest.input_uri', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='input_content', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest.input_content', index=1, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='features', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest.features', index=2, + number=2, type=14, cpp_type=8, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='video_context', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest.video_context', index=3, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='output_uri', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest.output_uri', index=4, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='location_id', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoRequest.location_id', index=5, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=239, + serialized_end=488, +) + + +_VIDEOCONTEXT = _descriptor.Descriptor( + name='VideoContext', + full_name='google.cloud.videointelligence.v1beta1.VideoContext', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='segments', full_name='google.cloud.videointelligence.v1beta1.VideoContext.segments', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='label_detection_mode', full_name='google.cloud.videointelligence.v1beta1.VideoContext.label_detection_mode', index=1, + number=2, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='stationary_camera', full_name='google.cloud.videointelligence.v1beta1.VideoContext.stationary_camera', index=2, + number=3, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='label_detection_model', full_name='google.cloud.videointelligence.v1beta1.VideoContext.label_detection_model', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='face_detection_model', full_name='google.cloud.videointelligence.v1beta1.VideoContext.face_detection_model', index=4, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='shot_change_detection_model', full_name='google.cloud.videointelligence.v1beta1.VideoContext.shot_change_detection_model', index=5, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='safe_search_detection_model', full_name='google.cloud.videointelligence.v1beta1.VideoContext.safe_search_detection_model', index=6, + number=7, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=491, + serialized_end=829, +) + + +_VIDEOSEGMENT = _descriptor.Descriptor( + name='VideoSegment', + full_name='google.cloud.videointelligence.v1beta1.VideoSegment', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='start_time_offset', full_name='google.cloud.videointelligence.v1beta1.VideoSegment.start_time_offset', index=0, + number=1, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='end_time_offset', full_name='google.cloud.videointelligence.v1beta1.VideoSegment.end_time_offset', index=1, + number=2, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=831, + serialized_end=897, +) + + +_LABELLOCATION = _descriptor.Descriptor( + name='LabelLocation', + full_name='google.cloud.videointelligence.v1beta1.LabelLocation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='segment', full_name='google.cloud.videointelligence.v1beta1.LabelLocation.segment', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='confidence', full_name='google.cloud.videointelligence.v1beta1.LabelLocation.confidence', index=1, + number=2, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='level', full_name='google.cloud.videointelligence.v1beta1.LabelLocation.level', index=2, + number=3, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=900, + serialized_end=1073, +) + + +_LABELANNOTATION = _descriptor.Descriptor( + name='LabelAnnotation', + full_name='google.cloud.videointelligence.v1beta1.LabelAnnotation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='description', full_name='google.cloud.videointelligence.v1beta1.LabelAnnotation.description', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='language_code', full_name='google.cloud.videointelligence.v1beta1.LabelAnnotation.language_code', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='locations', full_name='google.cloud.videointelligence.v1beta1.LabelAnnotation.locations', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1076, + serialized_end=1211, +) + + +_SAFESEARCHANNOTATION = _descriptor.Descriptor( + name='SafeSearchAnnotation', + full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='adult', full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation.adult', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='spoof', full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation.spoof', index=1, + number=2, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='medical', full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation.medical', index=2, + number=3, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='violent', full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation.violent', index=3, + number=4, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='racy', full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation.racy', index=4, + number=5, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='time_offset', full_name='google.cloud.videointelligence.v1beta1.SafeSearchAnnotation.time_offset', index=5, + number=6, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1214, + serialized_end=1595, +) + + +_BOUNDINGBOX = _descriptor.Descriptor( + name='BoundingBox', + full_name='google.cloud.videointelligence.v1beta1.BoundingBox', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='left', full_name='google.cloud.videointelligence.v1beta1.BoundingBox.left', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='right', full_name='google.cloud.videointelligence.v1beta1.BoundingBox.right', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='bottom', full_name='google.cloud.videointelligence.v1beta1.BoundingBox.bottom', index=2, + number=3, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='top', full_name='google.cloud.videointelligence.v1beta1.BoundingBox.top', index=3, + number=4, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1597, + serialized_end=1668, +) + + +_FACELOCATION = _descriptor.Descriptor( + name='FaceLocation', + full_name='google.cloud.videointelligence.v1beta1.FaceLocation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='bounding_box', full_name='google.cloud.videointelligence.v1beta1.FaceLocation.bounding_box', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='time_offset', full_name='google.cloud.videointelligence.v1beta1.FaceLocation.time_offset', index=1, + number=2, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1670, + serialized_end=1780, +) + + +_FACEANNOTATION = _descriptor.Descriptor( + name='FaceAnnotation', + full_name='google.cloud.videointelligence.v1beta1.FaceAnnotation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='thumbnail', full_name='google.cloud.videointelligence.v1beta1.FaceAnnotation.thumbnail', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='segments', full_name='google.cloud.videointelligence.v1beta1.FaceAnnotation.segments', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='locations', full_name='google.cloud.videointelligence.v1beta1.FaceAnnotation.locations', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1783, + serialized_end=1963, +) + + +_VIDEOANNOTATIONRESULTS = _descriptor.Descriptor( + name='VideoAnnotationResults', + full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='input_uri', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults.input_uri', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='label_annotations', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults.label_annotations', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='face_annotations', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults.face_annotations', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='shot_annotations', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults.shot_annotations', index=3, + number=4, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='safe_search_annotations', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults.safe_search_annotations', index=4, + number=6, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='error', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationResults.error', index=5, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1966, + serialized_end=2385, +) + + +_ANNOTATEVIDEORESPONSE = _descriptor.Descriptor( + name='AnnotateVideoResponse', + full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='annotation_results', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoResponse.annotation_results', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2387, + serialized_end=2502, +) + + +_VIDEOANNOTATIONPROGRESS = _descriptor.Descriptor( + name='VideoAnnotationProgress', + full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationProgress', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='input_uri', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationProgress.input_uri', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='progress_percent', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationProgress.progress_percent', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='start_time', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationProgress.start_time', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='update_time', full_name='google.cloud.videointelligence.v1beta1.VideoAnnotationProgress.update_time', index=3, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2505, + serialized_end=2672, +) + + +_ANNOTATEVIDEOPROGRESS = _descriptor.Descriptor( + name='AnnotateVideoProgress', + full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoProgress', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='annotation_progress', full_name='google.cloud.videointelligence.v1beta1.AnnotateVideoProgress.annotation_progress', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2674, + serialized_end=2791, +) + +_ANNOTATEVIDEOREQUEST.fields_by_name['features'].enum_type = _FEATURE +_ANNOTATEVIDEOREQUEST.fields_by_name['video_context'].message_type = _VIDEOCONTEXT +_VIDEOCONTEXT.fields_by_name['segments'].message_type = _VIDEOSEGMENT +_VIDEOCONTEXT.fields_by_name['label_detection_mode'].enum_type = _LABELDETECTIONMODE +_LABELLOCATION.fields_by_name['segment'].message_type = _VIDEOSEGMENT +_LABELLOCATION.fields_by_name['level'].enum_type = _LABELLEVEL +_LABELANNOTATION.fields_by_name['locations'].message_type = _LABELLOCATION +_SAFESEARCHANNOTATION.fields_by_name['adult'].enum_type = _LIKELIHOOD +_SAFESEARCHANNOTATION.fields_by_name['spoof'].enum_type = _LIKELIHOOD +_SAFESEARCHANNOTATION.fields_by_name['medical'].enum_type = _LIKELIHOOD +_SAFESEARCHANNOTATION.fields_by_name['violent'].enum_type = _LIKELIHOOD +_SAFESEARCHANNOTATION.fields_by_name['racy'].enum_type = _LIKELIHOOD +_FACELOCATION.fields_by_name['bounding_box'].message_type = _BOUNDINGBOX +_FACEANNOTATION.fields_by_name['segments'].message_type = _VIDEOSEGMENT +_FACEANNOTATION.fields_by_name['locations'].message_type = _FACELOCATION +_VIDEOANNOTATIONRESULTS.fields_by_name['label_annotations'].message_type = _LABELANNOTATION +_VIDEOANNOTATIONRESULTS.fields_by_name['face_annotations'].message_type = _FACEANNOTATION +_VIDEOANNOTATIONRESULTS.fields_by_name['shot_annotations'].message_type = _VIDEOSEGMENT +_VIDEOANNOTATIONRESULTS.fields_by_name['safe_search_annotations'].message_type = _SAFESEARCHANNOTATION +_VIDEOANNOTATIONRESULTS.fields_by_name['error'].message_type = google_dot_rpc_dot_status__pb2._STATUS +_ANNOTATEVIDEORESPONSE.fields_by_name['annotation_results'].message_type = _VIDEOANNOTATIONRESULTS +_VIDEOANNOTATIONPROGRESS.fields_by_name['start_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_VIDEOANNOTATIONPROGRESS.fields_by_name['update_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_ANNOTATEVIDEOPROGRESS.fields_by_name['annotation_progress'].message_type = _VIDEOANNOTATIONPROGRESS +DESCRIPTOR.message_types_by_name['AnnotateVideoRequest'] = _ANNOTATEVIDEOREQUEST +DESCRIPTOR.message_types_by_name['VideoContext'] = _VIDEOCONTEXT +DESCRIPTOR.message_types_by_name['VideoSegment'] = _VIDEOSEGMENT +DESCRIPTOR.message_types_by_name['LabelLocation'] = _LABELLOCATION +DESCRIPTOR.message_types_by_name['LabelAnnotation'] = _LABELANNOTATION +DESCRIPTOR.message_types_by_name['SafeSearchAnnotation'] = _SAFESEARCHANNOTATION +DESCRIPTOR.message_types_by_name['BoundingBox'] = _BOUNDINGBOX +DESCRIPTOR.message_types_by_name['FaceLocation'] = _FACELOCATION +DESCRIPTOR.message_types_by_name['FaceAnnotation'] = _FACEANNOTATION +DESCRIPTOR.message_types_by_name['VideoAnnotationResults'] = _VIDEOANNOTATIONRESULTS +DESCRIPTOR.message_types_by_name['AnnotateVideoResponse'] = _ANNOTATEVIDEORESPONSE +DESCRIPTOR.message_types_by_name['VideoAnnotationProgress'] = _VIDEOANNOTATIONPROGRESS +DESCRIPTOR.message_types_by_name['AnnotateVideoProgress'] = _ANNOTATEVIDEOPROGRESS +DESCRIPTOR.enum_types_by_name['Feature'] = _FEATURE +DESCRIPTOR.enum_types_by_name['LabelLevel'] = _LABELLEVEL +DESCRIPTOR.enum_types_by_name['LabelDetectionMode'] = _LABELDETECTIONMODE +DESCRIPTOR.enum_types_by_name['Likelihood'] = _LIKELIHOOD + +AnnotateVideoRequest = _reflection.GeneratedProtocolMessageType('AnnotateVideoRequest', (_message.Message,), dict( + DESCRIPTOR = _ANNOTATEVIDEOREQUEST, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.AnnotateVideoRequest) + )) +_sym_db.RegisterMessage(AnnotateVideoRequest) + +VideoContext = _reflection.GeneratedProtocolMessageType('VideoContext', (_message.Message,), dict( + DESCRIPTOR = _VIDEOCONTEXT, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.VideoContext) + )) +_sym_db.RegisterMessage(VideoContext) + +VideoSegment = _reflection.GeneratedProtocolMessageType('VideoSegment', (_message.Message,), dict( + DESCRIPTOR = _VIDEOSEGMENT, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.VideoSegment) + )) +_sym_db.RegisterMessage(VideoSegment) + +LabelLocation = _reflection.GeneratedProtocolMessageType('LabelLocation', (_message.Message,), dict( + DESCRIPTOR = _LABELLOCATION, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.LabelLocation) + )) +_sym_db.RegisterMessage(LabelLocation) + +LabelAnnotation = _reflection.GeneratedProtocolMessageType('LabelAnnotation', (_message.Message,), dict( + DESCRIPTOR = _LABELANNOTATION, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.LabelAnnotation) + )) +_sym_db.RegisterMessage(LabelAnnotation) + +SafeSearchAnnotation = _reflection.GeneratedProtocolMessageType('SafeSearchAnnotation', (_message.Message,), dict( + DESCRIPTOR = _SAFESEARCHANNOTATION, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.SafeSearchAnnotation) + )) +_sym_db.RegisterMessage(SafeSearchAnnotation) + +BoundingBox = _reflection.GeneratedProtocolMessageType('BoundingBox', (_message.Message,), dict( + DESCRIPTOR = _BOUNDINGBOX, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.BoundingBox) + )) +_sym_db.RegisterMessage(BoundingBox) + +FaceLocation = _reflection.GeneratedProtocolMessageType('FaceLocation', (_message.Message,), dict( + DESCRIPTOR = _FACELOCATION, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.FaceLocation) + )) +_sym_db.RegisterMessage(FaceLocation) + +FaceAnnotation = _reflection.GeneratedProtocolMessageType('FaceAnnotation', (_message.Message,), dict( + DESCRIPTOR = _FACEANNOTATION, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.FaceAnnotation) + )) +_sym_db.RegisterMessage(FaceAnnotation) + +VideoAnnotationResults = _reflection.GeneratedProtocolMessageType('VideoAnnotationResults', (_message.Message,), dict( + DESCRIPTOR = _VIDEOANNOTATIONRESULTS, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.VideoAnnotationResults) + )) +_sym_db.RegisterMessage(VideoAnnotationResults) + +AnnotateVideoResponse = _reflection.GeneratedProtocolMessageType('AnnotateVideoResponse', (_message.Message,), dict( + DESCRIPTOR = _ANNOTATEVIDEORESPONSE, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.AnnotateVideoResponse) + )) +_sym_db.RegisterMessage(AnnotateVideoResponse) + +VideoAnnotationProgress = _reflection.GeneratedProtocolMessageType('VideoAnnotationProgress', (_message.Message,), dict( + DESCRIPTOR = _VIDEOANNOTATIONPROGRESS, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.VideoAnnotationProgress) + )) +_sym_db.RegisterMessage(VideoAnnotationProgress) + +AnnotateVideoProgress = _reflection.GeneratedProtocolMessageType('AnnotateVideoProgress', (_message.Message,), dict( + DESCRIPTOR = _ANNOTATEVIDEOPROGRESS, + __module__ = 'google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2' + # @@protoc_insertion_point(class_scope:google.cloud.videointelligence.v1beta1.AnnotateVideoProgress) + )) +_sym_db.RegisterMessage(AnnotateVideoProgress) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n*com.google.cloud.videointelligence.v1beta1B\035VideoIntelligenceServiceProtoP\001ZWgoogle.golang.org/genproto/googleapis/cloud/videointelligence/v1beta1;videointelligence\252\002&Google.Cloud.VideoIntelligence.V1Beta1')) +try: + # THESE ELEMENTS WILL BE DEPRECATED. + # Please use the generated *_pb2_grpc.py files instead. + import grpc + from grpc.framework.common import cardinality + from grpc.framework.interfaces.face import utilities as face_utilities + from grpc.beta import implementations as beta_implementations + from grpc.beta import interfaces as beta_interfaces + + + class VideoIntelligenceServiceStub(object): + """Service that implements Google Cloud Video Intelligence API. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.AnnotateVideo = channel.unary_unary( + '/google.cloud.videointelligence.v1beta1.VideoIntelligenceService/AnnotateVideo', + request_serializer=AnnotateVideoRequest.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + ) + + + class VideoIntelligenceServiceServicer(object): + """Service that implements Google Cloud Video Intelligence API. + """ + + def AnnotateVideo(self, request, context): + """Performs asynchronous video annotation. Progress and results can be + retrieved through the `google.longrunning.Operations` interface. + `Operation.metadata` contains `AnnotateVideoProgress` (progress). + `Operation.response` contains `AnnotateVideoResponse` (results). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + + def add_VideoIntelligenceServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'AnnotateVideo': grpc.unary_unary_rpc_method_handler( + servicer.AnnotateVideo, + request_deserializer=AnnotateVideoRequest.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + class BetaVideoIntelligenceServiceServicer(object): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This class was generated + only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" + """Service that implements Google Cloud Video Intelligence API. + """ + def AnnotateVideo(self, request, context): + """Performs asynchronous video annotation. Progress and results can be + retrieved through the `google.longrunning.Operations` interface. + `Operation.metadata` contains `AnnotateVideoProgress` (progress). + `Operation.response` contains `AnnotateVideoResponse` (results). + """ + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + + + class BetaVideoIntelligenceServiceStub(object): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This class was generated + only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" + """Service that implements Google Cloud Video Intelligence API. + """ + def AnnotateVideo(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + """Performs asynchronous video annotation. Progress and results can be + retrieved through the `google.longrunning.Operations` interface. + `Operation.metadata` contains `AnnotateVideoProgress` (progress). + `Operation.response` contains `AnnotateVideoResponse` (results). + """ + raise NotImplementedError() + AnnotateVideo.future = None + + + def beta_create_VideoIntelligenceService_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This function was + generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" + request_deserializers = { + ('google.cloud.videointelligence.v1beta1.VideoIntelligenceService', 'AnnotateVideo'): AnnotateVideoRequest.FromString, + } + response_serializers = { + ('google.cloud.videointelligence.v1beta1.VideoIntelligenceService', 'AnnotateVideo'): google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + } + method_implementations = { + ('google.cloud.videointelligence.v1beta1.VideoIntelligenceService', 'AnnotateVideo'): face_utilities.unary_unary_inline(servicer.AnnotateVideo), + } + server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) + return beta_implementations.server(method_implementations, options=server_options) + + + def beta_create_VideoIntelligenceService_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This function was + generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" + request_serializers = { + ('google.cloud.videointelligence.v1beta1.VideoIntelligenceService', 'AnnotateVideo'): AnnotateVideoRequest.SerializeToString, + } + response_deserializers = { + ('google.cloud.videointelligence.v1beta1.VideoIntelligenceService', 'AnnotateVideo'): google_dot_longrunning_dot_operations__pb2.Operation.FromString, + } + cardinalities = { + 'AnnotateVideo': cardinality.Cardinality.UNARY_UNARY, + } + stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) + return beta_implementations.dynamic_stub(channel, 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', cardinalities, options=stub_options) +except ImportError: + pass +# @@protoc_insertion_point(module_scope) diff --git a/videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2_grpc.py b/videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2_grpc.py new file mode 100644 index 000000000000..4ea0e1df20f5 --- /dev/null +++ b/videointelligence/google/cloud/proto/videointelligence/v1beta1/video_intelligence_pb2_grpc.py @@ -0,0 +1,52 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc +from grpc.framework.common import cardinality +from grpc.framework.interfaces.face import utilities as face_utilities + +import google.cloud.proto.videointelligence.v1beta1.video_intelligence_pb2 as google_dot_cloud_dot_proto_dot_videointelligence_dot_v1beta1_dot_video__intelligence__pb2 +import google.longrunning.operations_pb2 as google_dot_longrunning_dot_operations__pb2 + + +class VideoIntelligenceServiceStub(object): + """Service that implements Google Cloud Video Intelligence API. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.AnnotateVideo = channel.unary_unary( + '/google.cloud.videointelligence.v1beta1.VideoIntelligenceService/AnnotateVideo', + request_serializer=google_dot_cloud_dot_proto_dot_videointelligence_dot_v1beta1_dot_video__intelligence__pb2.AnnotateVideoRequest.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + ) + + +class VideoIntelligenceServiceServicer(object): + """Service that implements Google Cloud Video Intelligence API. + """ + + def AnnotateVideo(self, request, context): + """Performs asynchronous video annotation. Progress and results can be + retrieved through the `google.longrunning.Operations` interface. + `Operation.metadata` contains `AnnotateVideoProgress` (progress). + `Operation.response` contains `AnnotateVideoResponse` (results). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_VideoIntelligenceServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'AnnotateVideo': grpc.unary_unary_rpc_method_handler( + servicer.AnnotateVideo, + request_deserializer=google_dot_cloud_dot_proto_dot_videointelligence_dot_v1beta1_dot_video__intelligence__pb2.AnnotateVideoRequest.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/videointelligence/google/cloud/videointelligence.py b/videointelligence/google/cloud/videointelligence.py new file mode 100644 index 000000000000..c18f22d228ec --- /dev/null +++ b/videointelligence/google/cloud/videointelligence.py @@ -0,0 +1,28 @@ +# Copyright 2017, Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +from google.cloud.videointelligence_v1beta1 import enums +from google.cloud.videointelligence_v1beta1 import types +from google.cloud.videointelligence_v1beta1 import ( + VideoIntelligenceServiceClient, +) + + +__all__ = ( + 'enums', + 'types', + 'VideoIntelligenceServiceClient', +) diff --git a/videointelligence/google/cloud/videointelligence_v1beta1/__init__.py b/videointelligence/google/cloud/videointelligence_v1beta1/__init__.py new file mode 100644 index 000000000000..60b42da4de3f --- /dev/null +++ b/videointelligence/google/cloud/videointelligence_v1beta1/__init__.py @@ -0,0 +1,28 @@ +# Copyright 2017, Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +from google.cloud.gapic.videointelligence.v1beta1.video_intelligence_service_client import VideoIntelligenceServiceClient +from google.cloud.gapic.videointelligence.v1beta1 import enums + +from google.cloud.gapic.videointelligence_v1beta1 import types + + + +__all__ = ( + 'enums', + 'types', + 'VideoIntelligenceServiceClient', +) diff --git a/videointelligence/google/cloud/videointelligence_v1beta1/types.py b/videointelligence/google/cloud/videointelligence_v1beta1/types.py new file mode 100644 index 000000000000..482b4adad57d --- /dev/null +++ b/videointelligence/google/cloud/videointelligence_v1beta1/types.py @@ -0,0 +1,28 @@ +# Copyright 2017, Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import +import sys + +from google.cloud.proto.videointelligence.v1beta1 import video_intelligence_pb2 +from google.gax.utils.messages import get_messages + + +names = [] +for name, message in get_messages(video_intelligence_pb2): + setattr(sys.modules[__name__], name, message) + names.append(name) + + +__all__ = tuple(sorted(names)) diff --git a/videointelligence/nox.py b/videointelligence/nox.py new file mode 100644 index 000000000000..0f6bd713afbe --- /dev/null +++ b/videointelligence/nox.py @@ -0,0 +1,41 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +import nox + + +@nox.session +@nox.parametrize('python_version', ['2.7', '3.4', '3.5', '3.6']) +def unit_tests(session, python_version): + """Run the unit test suite.""" + + # Run unit tests against all supported versions of Python. + session.interpreter = 'python{}'.format(python_version) + + # Install all test dependencies, then install this package in-place. + session.install('mock', 'pytest', 'pytest-cov') + session.install('-e', '.') + + # Run py.test against the unit tests. + session.run('py.test', '--quiet', 'tests/') + +@nox.session +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.interpreter = 'python3.6' + session.install('docutils', 'pygments') + session.run( + 'python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/videointelligence/setup.cfg b/videointelligence/setup.cfg new file mode 100644 index 000000000000..2a9acf13daa9 --- /dev/null +++ b/videointelligence/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/videointelligence/setup.py b/videointelligence/setup.py new file mode 100644 index 000000000000..9325a8ffb09a --- /dev/null +++ b/videointelligence/setup.py @@ -0,0 +1,68 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import io +import os + +from setuptools import find_packages +from setuptools import setup + + +PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) + +with io.open(os.path.join(PACKAGE_ROOT, 'README.rst'), 'r') as readme_file: + readme = readme_file.read() + + +setup( + author='Google Cloud Platform', + author_email='googleapis-packages@google.com', + name='google-cloud-videointelligence', + version='0.25.0', + description='Python Client for Google Cloud Video Intelligence', + long_description=readme, + namespace_packages=[ + 'google', + 'google.cloud', + 'google.cloud.gapic', + 'google.cloud.gapic.videointelligence', + 'google.cloud.proto', + 'google.cloud.proto.videointelligence', + ], + packages=find_packages(exclude=('tests*',)), + install_requires=( + 'googleapis-common-protos >= 1.5.2, < 2.0dev', + 'google-gax >= 0.15.12, < 0.16dev', + 'six >= 1.10.0', + ), + url='https://github.com/GoogleCloudPlatform/google-cloud-python', + license='Apache 2.0', + platforms='Posix; MacOS X; Windows', + include_package_data=True, + zip_safe=False, + scripts=[], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Topic :: Internet', + ], +) diff --git a/videointelligence/tests/gapic/v1beta1/test_video_intelligence_service_client.py b/videointelligence/tests/gapic/v1beta1/test_video_intelligence_service_client.py new file mode 100644 index 000000000000..3d2dcb325420 --- /dev/null +++ b/videointelligence/tests/gapic/v1beta1/test_video_intelligence_service_client.py @@ -0,0 +1,87 @@ +# Copyright 2017, Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Unit tests.""" + +import mock +import unittest + +from google.gax import errors +from google.rpc import status_pb2 + +from google.cloud.gapic.videointelligence.v1beta1 import video_intelligence_service_client +from google.cloud.proto.videointelligence.v1beta1 import video_intelligence_pb2 +from google.longrunning import operations_pb2 + + +class CustomException(Exception): + pass + + +class TestVideoIntelligenceServiceClient(unittest.TestCase): + @mock.patch('google.gax.config.create_stub', spec=True) + def test_annotate_video(self, mock_create_stub): + # Mock gRPC layer + grpc_stub = mock.Mock() + mock_create_stub.return_value = grpc_stub + + client = video_intelligence_service_client.VideoIntelligenceServiceClient( + ) + + # Mock request + input_uri = 'inputUri1707300727' + features = [] + + # Mock response + expected_response = video_intelligence_pb2.AnnotateVideoResponse() + operation = operations_pb2.Operation( + name='operations/test_annotate_video', done=True) + operation.response.Pack(expected_response) + grpc_stub.AnnotateVideo.return_value = operation + + response = client.annotate_video(input_uri, features) + self.assertEqual(expected_response, response.result()) + + grpc_stub.AnnotateVideo.assert_called_once() + args, kwargs = grpc_stub.AnnotateVideo.call_args + self.assertEqual(len(args), 2) + self.assertEqual(len(kwargs), 1) + self.assertIn('metadata', kwargs) + actual_request = args[0] + + expected_request = video_intelligence_pb2.AnnotateVideoRequest( + input_uri=input_uri, features=features) + self.assertEqual(expected_request, actual_request) + + @mock.patch('google.gax.config.create_stub', spec=True) + def test_annotate_video_exception(self, mock_create_stub): + # Mock gRPC layer + grpc_stub = mock.Mock() + mock_create_stub.return_value = grpc_stub + + client = video_intelligence_service_client.VideoIntelligenceServiceClient( + ) + + # Mock request + input_uri = 'inputUri1707300727' + features = [] + + # Mock exception response + error = status_pb2.Status() + operation = operations_pb2.Operation( + name='operations/test_annotate_video_exception', done=True) + operation.error.CopyFrom(error) + grpc_stub.AnnotateVideo.return_value = operation + + response = client.annotate_video(input_uri, features) + self.assertEqual(error, response.exception())