diff --git a/.coveragerc b/.coveragerc index 0ae76c0a..dda4f66a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -22,7 +22,7 @@ omit = google/cloud/__init__.py [report] -fail_under = 83 +fail_under = 99 show_missing = True exclude_lines = # Re-enable the standard pragma diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index eecb84c2..8cb43804 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,16 @@ +# Copyright 2022 Google LLC +# +# 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. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 + digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 3e98ae70..37438d33 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -10,6 +10,5 @@ branchProtectionRules: - 'Kokoro' - 'cla/google' - 'Samples - Lint' - - 'Samples - Python 3.6' - 'Samples - Python 3.7' - 'Samples - Python 3.8' diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..f7b8344c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - main +name: docs +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docs + run: | + nox -s docs + docfx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docfx + run: | + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1e8b05c3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - main +name: lint +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + run: | + nox -s lint + - name: Run lint_setup_py + run: | + nox -s lint_setup_py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 00000000..e84424b8 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=99 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f31f975..ede80257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://pypi.org/project/google-cloud-automl/#history +## [2.7.0](https://github.com/googleapis/python-automl/compare/v2.6.0...v2.7.0) (2022-02-11) + + +### Features + +* add api key support ([#327](https://github.com/googleapis/python-automl/issues/327)) ([74c9531](https://github.com/googleapis/python-automl/commit/74c95311107acc41c60585b98f1c68e750298e85)) + + +### Bug Fixes + +* resolve DuplicateCredentialArgs error when using credentials_file ([c23e512](https://github.com/googleapis/python-automl/commit/c23e512657baa61eafd1b99a1fd9398f2cf03103)) + ## [2.6.0](https://github.com/googleapis/python-automl/compare/v2.5.2...v2.6.0) (2022-01-15) diff --git a/google/cloud/automl_v1/services/auto_ml/async_client.py b/google/cloud/automl_v1/services/auto_ml/async_client.py index adc27c99..a7557e90 100644 --- a/google/cloud/automl_v1/services/auto_ml/async_client.py +++ b/google/cloud/automl_v1/services/auto_ml/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -137,6 +137,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return AutoMlClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> AutoMlTransport: """Returns the transport used by the client instance. @@ -209,6 +245,34 @@ async def create_dataset( ) -> operation_async.AsyncOperation: r"""Creates a dataset. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_create_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + operation = client.create_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.CreateDatasetRequest, dict]): The request object. Request message for @@ -240,7 +304,7 @@ async def create_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, dataset]) if request is not None and has_flattened_params: @@ -297,6 +361,25 @@ async def get_dataset( ) -> dataset.Dataset: r"""Gets a dataset. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = client.get_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetDatasetRequest, dict]): The request object. Request message for @@ -323,7 +406,7 @@ async def get_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -380,6 +463,26 @@ async def list_datasets( ) -> pagers.ListDatasetsAsyncPager: r"""Lists datasets in a project. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_list_datasets(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1.types.ListDatasetsRequest, dict]): The request object. Request message for @@ -407,7 +510,7 @@ async def list_datasets( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -471,6 +574,29 @@ async def update_dataset( ) -> gca_dataset.Dataset: r"""Updates a dataset. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_update_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = client.update_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.UpdateDatasetRequest, dict]): The request object. Request message for @@ -504,7 +630,7 @@ async def update_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([dataset, update_mask]) if request is not None and has_flattened_params: @@ -559,6 +685,30 @@ async def delete_dataset( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_delete_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.DeleteDatasetRequest, dict]): The request object. Request message for @@ -596,7 +746,7 @@ async def delete_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -671,6 +821,34 @@ async def import_data( in the [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_import_data(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + input_config = automl_v1.InputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + request = automl_v1.ImportDataRequest( + name="name_value", + input_config=input_config, + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.ImportDataRequest, dict]): The request object. Request message for @@ -717,7 +895,7 @@ async def import_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config]) if request is not None and has_flattened_params: @@ -778,6 +956,34 @@ async def export_data( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_export_data(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + output_config = automl_v1.OutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportDataRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.ExportDataRequest, dict]): The request object. Request message for @@ -822,7 +1028,7 @@ async def export_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -879,6 +1085,25 @@ async def get_annotation_spec( ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_annotation_spec(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_annotation_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetAnnotationSpecRequest, dict]): The request object. Request message for @@ -901,7 +1126,7 @@ async def get_annotation_spec( A definition of an annotation spec. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -963,6 +1188,30 @@ async def create_model( are created for it: a global evaluation, and one evaluation for each annotation spec. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_create_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.CreateModelRequest, dict]): The request object. Request message for @@ -996,7 +1245,7 @@ async def create_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model]) if request is not None and has_flattened_params: @@ -1053,6 +1302,25 @@ async def get_model( ) -> model.Model: r"""Gets a model. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_model(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetModelRequest, dict]): The request object. Request message for @@ -1075,7 +1343,7 @@ async def get_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1132,6 +1400,26 @@ async def list_models( ) -> pagers.ListModelsAsyncPager: r"""Lists models. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_list_models(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1.types.ListModelsRequest, dict]): The request object. Request message for @@ -1159,7 +1447,7 @@ async def list_models( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1225,6 +1513,30 @@ async def delete_model( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_delete_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.DeleteModelRequest, dict]): The request object. Request message for @@ -1262,7 +1574,7 @@ async def delete_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1328,6 +1640,24 @@ async def update_model( ) -> gca_model.Model: r"""Updates a model. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_update_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.UpdateModelRequest( + ) + + # Make the request + response = client.update_model(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.UpdateModelRequest, dict]): The request object. Request message for @@ -1359,7 +1689,7 @@ async def update_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([model, update_mask]) if request is not None and has_flattened_params: @@ -1423,6 +1753,30 @@ async def deploy_model( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_deploy_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.DeployModelRequest, dict]): The request object. Request message for @@ -1460,7 +1814,7 @@ async def deploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1523,6 +1877,30 @@ async def undeploy_model( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_undeploy_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.UndeployModelRequest, dict]): The request object. Request message for @@ -1560,7 +1938,7 @@ async def undeploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1623,6 +2001,34 @@ async def export_model( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_export_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + output_config = automl_v1.ModelExportOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportModelRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.ExportModelRequest, dict]): The request object. Request message for @@ -1669,7 +2075,7 @@ async def export_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -1726,6 +2132,25 @@ async def get_model_evaluation( ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_model_evaluation(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = client.get_model_evaluation(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetModelEvaluationRequest, dict]): The request object. Request message for @@ -1748,7 +2173,7 @@ async def get_model_evaluation( Evaluation results of a model. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1806,6 +2231,27 @@ async def list_model_evaluations( ) -> pagers.ListModelEvaluationsAsyncPager: r"""Lists model evaluations. + .. code-block:: + + from google.cloud import automl_v1 + + def sample_list_model_evaluations(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListModelEvaluationsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1.types.ListModelEvaluationsRequest, dict]): The request object. Request message for @@ -1854,7 +2300,7 @@ async def list_model_evaluations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, filter]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1/services/auto_ml/client.py b/google/cloud/automl_v1/services/auto_ml/client.py index 8fdeecdd..4bf6a5ec 100644 --- a/google/cloud/automl_v1/services/auto_ml/client.py +++ b/google/cloud/automl_v1/services/auto_ml/client.py @@ -325,6 +325,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -375,57 +442,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, AutoMlTransport): # transport is a AutoMlTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -437,6 +469,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -461,6 +502,35 @@ def create_dataset( ) -> operation.Operation: r"""Creates a dataset. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_create_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + operation = client.create_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.CreateDatasetRequest, dict]): The request object. Request message for @@ -492,7 +562,7 @@ def create_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, dataset]) if request is not None and has_flattened_params: @@ -549,6 +619,26 @@ def get_dataset( ) -> dataset.Dataset: r"""Gets a dataset. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = client.get_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetDatasetRequest, dict]): The request object. Request message for @@ -575,7 +665,7 @@ def get_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -622,6 +712,27 @@ def list_datasets( ) -> pagers.ListDatasetsPager: r"""Lists datasets in a project. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_list_datasets(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1.types.ListDatasetsRequest, dict]): The request object. Request message for @@ -649,7 +760,7 @@ def list_datasets( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -703,6 +814,30 @@ def update_dataset( ) -> gca_dataset.Dataset: r"""Updates a dataset. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_update_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = client.update_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.UpdateDatasetRequest, dict]): The request object. Request message for @@ -736,7 +871,7 @@ def update_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([dataset, update_mask]) if request is not None and has_flattened_params: @@ -791,6 +926,31 @@ def delete_dataset( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_delete_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.DeleteDatasetRequest, dict]): The request object. Request message for @@ -828,7 +988,7 @@ def delete_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -893,6 +1053,35 @@ def import_data( in the [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_import_data(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + input_config = automl_v1.InputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + request = automl_v1.ImportDataRequest( + name="name_value", + input_config=input_config, + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.ImportDataRequest, dict]): The request object. Request message for @@ -939,7 +1128,7 @@ def import_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config]) if request is not None and has_flattened_params: @@ -1000,6 +1189,35 @@ def export_data( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_export_data(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + output_config = automl_v1.OutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportDataRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.ExportDataRequest, dict]): The request object. Request message for @@ -1044,7 +1262,7 @@ def export_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -1101,6 +1319,26 @@ def get_annotation_spec( ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_annotation_spec(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_annotation_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetAnnotationSpecRequest, dict]): The request object. Request message for @@ -1123,7 +1361,7 @@ def get_annotation_spec( A definition of an annotation spec. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1175,6 +1413,31 @@ def create_model( are created for it: a global evaluation, and one evaluation for each annotation spec. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_create_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.CreateModelRequest, dict]): The request object. Request message for @@ -1208,7 +1471,7 @@ def create_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model]) if request is not None and has_flattened_params: @@ -1265,6 +1528,26 @@ def get_model( ) -> model.Model: r"""Gets a model. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_model(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetModelRequest, dict]): The request object. Request message for @@ -1287,7 +1570,7 @@ def get_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1334,6 +1617,27 @@ def list_models( ) -> pagers.ListModelsPager: r"""Lists models. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_list_models(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1.types.ListModelsRequest, dict]): The request object. Request message for @@ -1361,7 +1665,7 @@ def list_models( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1417,6 +1721,31 @@ def delete_model( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_delete_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.DeleteModelRequest, dict]): The request object. Request message for @@ -1454,7 +1783,7 @@ def delete_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1510,6 +1839,25 @@ def update_model( ) -> gca_model.Model: r"""Updates a model. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_update_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.UpdateModelRequest( + ) + + # Make the request + response = client.update_model(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.UpdateModelRequest, dict]): The request object. Request message for @@ -1541,7 +1889,7 @@ def update_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([model, update_mask]) if request is not None and has_flattened_params: @@ -1605,6 +1953,31 @@ def deploy_model( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_deploy_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.DeployModelRequest, dict]): The request object. Request message for @@ -1642,7 +2015,7 @@ def deploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1705,6 +2078,31 @@ def undeploy_model( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_undeploy_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.UndeployModelRequest, dict]): The request object. Request message for @@ -1742,7 +2140,7 @@ def undeploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1805,6 +2203,35 @@ def export_model( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_export_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + output_config = automl_v1.ModelExportOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportModelRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.ExportModelRequest, dict]): The request object. Request message for @@ -1851,7 +2278,7 @@ def export_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -1908,6 +2335,26 @@ def get_model_evaluation( ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_get_model_evaluation(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = client.get_model_evaluation(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.GetModelEvaluationRequest, dict]): The request object. Request message for @@ -1930,7 +2377,7 @@ def get_model_evaluation( Evaluation results of a model. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1978,6 +2425,28 @@ def list_model_evaluations( ) -> pagers.ListModelEvaluationsPager: r"""Lists model evaluations. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_list_model_evaluations(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListModelEvaluationsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1.types.ListModelEvaluationsRequest, dict]): The request object. Request message for @@ -2026,7 +2495,7 @@ def list_model_evaluations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, filter]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1/services/auto_ml/transports/grpc.py b/google/cloud/automl_v1/services/auto_ml/transports/grpc.py index 6765f1db..7a9b613e 100644 --- a/google/cloud/automl_v1/services/auto_ml/transports/grpc.py +++ b/google/cloud/automl_v1/services/auto_ml/transports/grpc.py @@ -181,8 +181,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -255,7 +258,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py b/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py index f5644c10..0927bbfb 100644 --- a/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py @@ -226,8 +226,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -257,7 +260,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/automl_v1/services/prediction_service/async_client.py b/google/cloud/automl_v1/services/prediction_service/async_client.py index e2eeb0f0..f9e60b21 100644 --- a/google/cloud/automl_v1/services/prediction_service/async_client.py +++ b/google/cloud/automl_v1/services/prediction_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -115,6 +115,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return PredictionServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> PredictionServiceTransport: """Returns the transport used by the client instance. @@ -224,6 +260,30 @@ async def predict( - A row with column values matching the columns of the model, up to 5MB. Not available for FORECASTING ``prediction_type``. + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_predict(): + # Create a client + client = automl_v1.PredictionServiceClient() + + # Initialize request argument(s) + payload = automl_v1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = client.predict(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.PredictRequest, dict]): The request object. Request message for @@ -291,7 +351,7 @@ async def predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, payload, params]) if request is not None and has_flattened_params: @@ -365,6 +425,38 @@ async def batch_predict( - AutoML Natural Language Sentiment Analysis - AutoML Tables + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_batch_predict(): + # Create a client + client = automl_v1.PredictionServiceClient() + + # Initialize request argument(s) + input_config = automl_v1.BatchPredictInputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + output_config = automl_v1.BatchPredictOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.BatchPredictRequest( + name="name_value", + input_config=input_config, + output_config=output_config, + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.BatchPredictRequest, dict]): The request object. Request message for @@ -497,7 +589,7 @@ async def batch_predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config, output_config, params]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1/services/prediction_service/client.py b/google/cloud/automl_v1/services/prediction_service/client.py index 22de25cd..7fae2f35 100644 --- a/google/cloud/automl_v1/services/prediction_service/client.py +++ b/google/cloud/automl_v1/services/prediction_service/client.py @@ -245,6 +245,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -295,57 +362,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, PredictionServiceTransport): # transport is a PredictionServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -357,6 +389,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -418,6 +459,31 @@ def predict( - A row with column values matching the columns of the model, up to 5MB. Not available for FORECASTING ``prediction_type``. + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_predict(): + # Create a client + client = automl_v1.PredictionServiceClient() + + # Initialize request argument(s) + payload = automl_v1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = client.predict(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.PredictRequest, dict]): The request object. Request message for @@ -485,7 +551,7 @@ def predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, payload, params]) if request is not None and has_flattened_params: @@ -558,6 +624,39 @@ def batch_predict( - AutoML Natural Language Sentiment Analysis - AutoML Tables + + + .. code-block:: + + from google.cloud import automl_v1 + + def sample_batch_predict(): + # Create a client + client = automl_v1.PredictionServiceClient() + + # Initialize request argument(s) + input_config = automl_v1.BatchPredictInputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + output_config = automl_v1.BatchPredictOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.BatchPredictRequest( + name="name_value", + input_config=input_config, + output_config=output_config, + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1.types.BatchPredictRequest, dict]): The request object. Request message for @@ -690,7 +789,7 @@ def batch_predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config, output_config, params]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1/services/prediction_service/transports/grpc.py b/google/cloud/automl_v1/services/prediction_service/transports/grpc.py index ec174da7..8a41169b 100644 --- a/google/cloud/automl_v1/services/prediction_service/transports/grpc.py +++ b/google/cloud/automl_v1/services/prediction_service/transports/grpc.py @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py index cca25f11..4e924d55 100644 --- a/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/automl_v1/types/classification.py b/google/cloud/automl_v1/types/classification.py index 2103966d..503ecdf0 100644 --- a/google/cloud/automl_v1/types/classification.py +++ b/google/cloud/automl_v1/types/classification.py @@ -62,8 +62,8 @@ class ClassificationEvaluationMetrics(proto.Message): evaluation. au_roc (float): Output only. The Area Under Receiver - Operating Characteristic curve metric. Micro- - averaged for the overall evaluation. + Operating Characteristic curve metric. + Micro-averaged for the overall evaluation. log_loss (float): Output only. The Log Loss metric. confidence_metrics_entry (Sequence[google.cloud.automl_v1.types.ClassificationEvaluationMetrics.ConfidenceMetricsEntry]): diff --git a/google/cloud/automl_v1/types/model.py b/google/cloud/automl_v1/types/model.py index d451188f..fc8dcb2c 100644 --- a/google/cloud/automl_v1/types/model.py +++ b/google/cloud/automl_v1/types/model.py @@ -83,9 +83,9 @@ class Model(proto.Message): model can only serve prediction requests after it gets deployed. etag (str): - Used to perform a consistent read-modify- - rite updates. If not set, a blind "overwrite" - update happens. + Used to perform a consistent + read-modify-write updates. If not set, a blind + "overwrite" update happens. labels (Sequence[google.cloud.automl_v1.types.Model.LabelsEntry]): Optional. The labels with user-defined metadata to organize your model. diff --git a/google/cloud/automl_v1beta1/services/auto_ml/async_client.py b/google/cloud/automl_v1beta1/services/auto_ml/async_client.py index 08465444..4ebffbe6 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/async_client.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -149,6 +149,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return AutoMlClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> AutoMlTransport: """Returns the transport used by the client instance. @@ -221,6 +257,30 @@ async def create_dataset( ) -> gca_dataset.Dataset: r"""Creates a dataset. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_create_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + response = client.create_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.CreateDatasetRequest, dict]): The request object. Request message for @@ -252,7 +312,7 @@ async def create_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, dataset]) if request is not None and has_flattened_params: @@ -301,6 +361,25 @@ async def get_dataset( ) -> dataset.Dataset: r"""Gets a dataset. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = client.get_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetDatasetRequest, dict]): The request object. Request message for @@ -327,7 +406,7 @@ async def get_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -384,6 +463,26 @@ async def list_datasets( ) -> pagers.ListDatasetsAsyncPager: r"""Lists datasets in a project. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_datasets(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListDatasetsRequest, dict]): The request object. Request message for @@ -411,7 +510,7 @@ async def list_datasets( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -474,6 +573,29 @@ async def update_dataset( ) -> gca_dataset.Dataset: r"""Updates a dataset. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_update_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = client.update_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UpdateDatasetRequest, dict]): The request object. Request message for @@ -500,7 +622,7 @@ async def update_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([dataset]) if request is not None and has_flattened_params: @@ -553,6 +675,30 @@ async def delete_dataset( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_delete_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.DeleteDatasetRequest, dict]): The request object. Request message for @@ -590,7 +736,7 @@ async def delete_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -665,6 +811,30 @@ async def import_data( in the [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_import_data(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ImportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ImportDataRequest, dict]): The request object. Request message for @@ -711,7 +881,7 @@ async def import_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config]) if request is not None and has_flattened_params: @@ -772,6 +942,30 @@ async def export_data( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_export_data(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ExportDataRequest, dict]): The request object. Request message for @@ -816,7 +1010,7 @@ async def export_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -873,6 +1067,25 @@ async def get_annotation_spec( ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_annotation_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_annotation_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetAnnotationSpecRequest, dict]): The request object. Request message for @@ -895,7 +1108,7 @@ async def get_annotation_spec( A definition of an annotation spec. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -952,6 +1165,25 @@ async def get_table_spec( ) -> table_spec.TableSpec: r"""Gets a table spec. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetTableSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_table_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetTableSpecRequest, dict]): The request object. Request message for @@ -984,7 +1216,7 @@ async def get_table_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1041,6 +1273,26 @@ async def list_table_specs( ) -> pagers.ListTableSpecsAsyncPager: r"""Lists table specs in a dataset. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_table_specs(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListTableSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_table_specs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListTableSpecsRequest, dict]): The request object. Request message for @@ -1068,7 +1320,7 @@ async def list_table_specs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1131,6 +1383,24 @@ async def update_table_spec( ) -> gca_table_spec.TableSpec: r"""Updates a table spec. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_update_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateTableSpecRequest( + ) + + # Make the request + response = client.update_table_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UpdateTableSpecRequest, dict]): The request object. Request message for @@ -1163,7 +1433,7 @@ async def update_table_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([table_spec]) if request is not None and has_flattened_params: @@ -1212,6 +1482,25 @@ async def get_column_spec( ) -> column_spec.ColumnSpec: r"""Gets a column spec. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetColumnSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_column_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetColumnSpecRequest, dict]): The request object. Request message for @@ -1236,7 +1525,7 @@ async def get_column_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1293,6 +1582,26 @@ async def list_column_specs( ) -> pagers.ListColumnSpecsAsyncPager: r"""Lists column specs in a table spec. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_column_specs(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListColumnSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_column_specs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListColumnSpecsRequest, dict]): The request object. Request message for @@ -1320,7 +1629,7 @@ async def list_column_specs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1383,6 +1692,24 @@ async def update_column_spec( ) -> gca_column_spec.ColumnSpec: r"""Updates a column spec. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_update_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateColumnSpecRequest( + ) + + # Make the request + response = client.update_column_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UpdateColumnSpecRequest, dict]): The request object. Request message for @@ -1407,7 +1734,7 @@ async def update_column_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([column_spec]) if request is not None and has_flattened_params: @@ -1461,6 +1788,30 @@ async def create_model( are created for it: a global evaluation, and one evaluation for each annotation spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_create_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.CreateModelRequest, dict]): The request object. Request message for @@ -1494,7 +1845,7 @@ async def create_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model]) if request is not None and has_flattened_params: @@ -1551,6 +1902,25 @@ async def get_model( ) -> model.Model: r"""Gets a model. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_model(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetModelRequest, dict]): The request object. Request message for @@ -1573,7 +1943,7 @@ async def get_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1630,6 +2000,26 @@ async def list_models( ) -> pagers.ListModelsAsyncPager: r"""Lists models. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_models(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListModelsRequest, dict]): The request object. Request message for @@ -1657,7 +2047,7 @@ async def list_models( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1723,6 +2113,30 @@ async def delete_model( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_delete_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.DeleteModelRequest, dict]): The request object. Request message for @@ -1760,7 +2174,7 @@ async def delete_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1839,6 +2253,30 @@ async def deploy_model( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_deploy_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.DeployModelRequest, dict]): The request object. Request message for @@ -1876,7 +2314,7 @@ async def deploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1939,6 +2377,30 @@ async def undeploy_model( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_undeploy_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UndeployModelRequest, dict]): The request object. Request message for @@ -1976,7 +2438,7 @@ async def undeploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -2040,6 +2502,30 @@ async def export_model( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_export_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportModelRequest( + name="name_value", + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ExportModelRequest, dict]): The request object. Request message for @@ -2086,7 +2572,7 @@ async def export_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -2158,6 +2644,30 @@ async def export_evaluated_examples( [response][google.longrunning.Operation.response] field when it completes. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_export_evaluated_examples(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportEvaluatedExamplesRequest( + name="name_value", + ) + + # Make the request + operation = client.export_evaluated_examples(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ExportEvaluatedExamplesRequest, dict]): The request object. Request message for @@ -2203,7 +2713,7 @@ async def export_evaluated_examples( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -2260,6 +2770,25 @@ async def get_model_evaluation( ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_model_evaluation(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = client.get_model_evaluation(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetModelEvaluationRequest, dict]): The request object. Request message for @@ -2282,7 +2811,7 @@ async def get_model_evaluation( Evaluation results of a model. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -2339,6 +2868,26 @@ async def list_model_evaluations( ) -> pagers.ListModelEvaluationsAsyncPager: r"""Lists model evaluations. + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_model_evaluations(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelEvaluationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListModelEvaluationsRequest, dict]): The request object. Request message for @@ -2369,7 +2918,7 @@ async def list_model_evaluations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1beta1/services/auto_ml/client.py b/google/cloud/automl_v1beta1/services/auto_ml/client.py index 217d1a83..6c362c9e 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/client.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/client.py @@ -373,6 +373,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -423,57 +490,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, AutoMlTransport): # transport is a AutoMlTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -485,6 +517,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -509,6 +550,31 @@ def create_dataset( ) -> gca_dataset.Dataset: r"""Creates a dataset. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_create_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + response = client.create_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.CreateDatasetRequest, dict]): The request object. Request message for @@ -540,7 +606,7 @@ def create_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, dataset]) if request is not None and has_flattened_params: @@ -589,6 +655,26 @@ def get_dataset( ) -> dataset.Dataset: r"""Gets a dataset. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = client.get_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetDatasetRequest, dict]): The request object. Request message for @@ -615,7 +701,7 @@ def get_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -662,6 +748,27 @@ def list_datasets( ) -> pagers.ListDatasetsPager: r"""Lists datasets in a project. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_datasets(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListDatasetsRequest, dict]): The request object. Request message for @@ -689,7 +796,7 @@ def list_datasets( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -742,6 +849,30 @@ def update_dataset( ) -> gca_dataset.Dataset: r"""Updates a dataset. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_update_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = client.update_dataset(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UpdateDatasetRequest, dict]): The request object. Request message for @@ -768,7 +899,7 @@ def update_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([dataset]) if request is not None and has_flattened_params: @@ -821,6 +952,31 @@ def delete_dataset( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_delete_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.DeleteDatasetRequest, dict]): The request object. Request message for @@ -858,7 +1014,7 @@ def delete_dataset( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -923,6 +1079,31 @@ def import_data( in the [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_import_data(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ImportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ImportDataRequest, dict]): The request object. Request message for @@ -969,7 +1150,7 @@ def import_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config]) if request is not None and has_flattened_params: @@ -1030,6 +1211,31 @@ def export_data( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_export_data(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ExportDataRequest, dict]): The request object. Request message for @@ -1074,7 +1280,7 @@ def export_data( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -1131,6 +1337,26 @@ def get_annotation_spec( ) -> annotation_spec.AnnotationSpec: r"""Gets an annotation spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_annotation_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_annotation_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetAnnotationSpecRequest, dict]): The request object. Request message for @@ -1153,7 +1379,7 @@ def get_annotation_spec( A definition of an annotation spec. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1200,6 +1426,26 @@ def get_table_spec( ) -> table_spec.TableSpec: r"""Gets a table spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetTableSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_table_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetTableSpecRequest, dict]): The request object. Request message for @@ -1232,7 +1478,7 @@ def get_table_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1279,6 +1525,27 @@ def list_table_specs( ) -> pagers.ListTableSpecsPager: r"""Lists table specs in a dataset. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_table_specs(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListTableSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_table_specs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListTableSpecsRequest, dict]): The request object. Request message for @@ -1306,7 +1573,7 @@ def list_table_specs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1359,6 +1626,25 @@ def update_table_spec( ) -> gca_table_spec.TableSpec: r"""Updates a table spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_update_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateTableSpecRequest( + ) + + # Make the request + response = client.update_table_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UpdateTableSpecRequest, dict]): The request object. Request message for @@ -1391,7 +1677,7 @@ def update_table_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([table_spec]) if request is not None and has_flattened_params: @@ -1440,6 +1726,26 @@ def get_column_spec( ) -> column_spec.ColumnSpec: r"""Gets a column spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetColumnSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_column_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetColumnSpecRequest, dict]): The request object. Request message for @@ -1464,7 +1770,7 @@ def get_column_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1511,6 +1817,27 @@ def list_column_specs( ) -> pagers.ListColumnSpecsPager: r"""Lists column specs in a table spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_column_specs(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListColumnSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_column_specs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListColumnSpecsRequest, dict]): The request object. Request message for @@ -1538,7 +1865,7 @@ def list_column_specs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1591,6 +1918,25 @@ def update_column_spec( ) -> gca_column_spec.ColumnSpec: r"""Updates a column spec. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_update_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateColumnSpecRequest( + ) + + # Make the request + response = client.update_column_spec(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UpdateColumnSpecRequest, dict]): The request object. Request message for @@ -1615,7 +1961,7 @@ def update_column_spec( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([column_spec]) if request is not None and has_flattened_params: @@ -1669,6 +2015,31 @@ def create_model( are created for it: a global evaluation, and one evaluation for each annotation spec. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_create_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.CreateModelRequest, dict]): The request object. Request message for @@ -1702,7 +2073,7 @@ def create_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, model]) if request is not None and has_flattened_params: @@ -1759,6 +2130,26 @@ def get_model( ) -> model.Model: r"""Gets a model. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_model(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetModelRequest, dict]): The request object. Request message for @@ -1781,7 +2172,7 @@ def get_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1828,6 +2219,27 @@ def list_models( ) -> pagers.ListModelsPager: r"""Lists models. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_models(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListModelsRequest, dict]): The request object. Request message for @@ -1855,7 +2267,7 @@ def list_models( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1911,6 +2323,31 @@ def delete_model( completes, and ``delete_details`` in the [metadata][google.longrunning.Operation.metadata] field. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_delete_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.DeleteModelRequest, dict]): The request object. Request message for @@ -1948,7 +2385,7 @@ def delete_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -2017,6 +2454,31 @@ def deploy_model( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_deploy_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.DeployModelRequest, dict]): The request object. Request message for @@ -2054,7 +2516,7 @@ def deploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -2117,6 +2579,31 @@ def undeploy_model( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_undeploy_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.UndeployModelRequest, dict]): The request object. Request message for @@ -2154,7 +2641,7 @@ def undeploy_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -2218,6 +2705,31 @@ def export_model( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_export_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportModelRequest( + name="name_value", + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ExportModelRequest, dict]): The request object. Request message for @@ -2264,7 +2776,7 @@ def export_model( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -2336,6 +2848,31 @@ def export_evaluated_examples( [response][google.longrunning.Operation.response] field when it completes. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_export_evaluated_examples(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportEvaluatedExamplesRequest( + name="name_value", + ) + + # Make the request + operation = client.export_evaluated_examples(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ExportEvaluatedExamplesRequest, dict]): The request object. Request message for @@ -2381,7 +2918,7 @@ def export_evaluated_examples( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, output_config]) if request is not None and has_flattened_params: @@ -2440,6 +2977,26 @@ def get_model_evaluation( ) -> model_evaluation.ModelEvaluation: r"""Gets a model evaluation. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_get_model_evaluation(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = client.get_model_evaluation(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.GetModelEvaluationRequest, dict]): The request object. Request message for @@ -2462,7 +3019,7 @@ def get_model_evaluation( Evaluation results of a model. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -2509,6 +3066,27 @@ def list_model_evaluations( ) -> pagers.ListModelEvaluationsPager: r"""Lists model evaluations. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_list_model_evaluations(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelEvaluationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.ListModelEvaluationsRequest, dict]): The request object. Request message for @@ -2539,7 +3117,7 @@ def list_model_evaluations( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py index 5d11126f..6db0002e 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py @@ -184,8 +184,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -258,7 +261,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py index 70fff362..bb544938 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py @@ -229,8 +229,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -260,7 +263,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/automl_v1beta1/services/prediction_service/async_client.py b/google/cloud/automl_v1beta1/services/prediction_service/async_client.py index 32fe3c70..780b9401 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/async_client.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -115,6 +115,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return PredictionServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> PredictionServiceTransport: """Returns the transport used by the client instance. @@ -208,6 +244,30 @@ async def predict( - Text Sentiment - TextSnippet, content up 500 characters, UTF-8 encoded. + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceClient() + + # Initialize request argument(s) + payload = automl_v1beta1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1beta1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = client.predict(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.PredictRequest, dict]): The request object. Request message for @@ -268,7 +328,7 @@ async def predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, payload, params]) if request is not None and has_flattened_params: @@ -339,6 +399,30 @@ async def batch_predict( - Video Object Tracking \* Text Extraction - Tables + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_batch_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceClient() + + # Initialize request argument(s) + request = automl_v1beta1.BatchPredictRequest( + name="name_value", + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.BatchPredictRequest, dict]): The request object. Request message for @@ -470,7 +554,7 @@ async def batch_predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config, output_config, params]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1beta1/services/prediction_service/client.py b/google/cloud/automl_v1beta1/services/prediction_service/client.py index 71629b8c..7e6b0cc3 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/client.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/client.py @@ -245,6 +245,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -295,57 +362,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, PredictionServiceTransport): # transport is a PredictionServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -357,6 +389,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -402,6 +443,31 @@ def predict( - Text Sentiment - TextSnippet, content up 500 characters, UTF-8 encoded. + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceClient() + + # Initialize request argument(s) + payload = automl_v1beta1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1beta1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = client.predict(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.PredictRequest, dict]): The request object. Request message for @@ -462,7 +528,7 @@ def predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, payload, params]) if request is not None and has_flattened_params: @@ -532,6 +598,31 @@ def batch_predict( - Video Object Tracking \* Text Extraction - Tables + + + .. code-block:: + + from google.cloud import automl_v1beta1 + + def sample_batch_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceClient() + + # Initialize request argument(s) + request = automl_v1beta1.BatchPredictRequest( + name="name_value", + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.automl_v1beta1.types.BatchPredictRequest, dict]): The request object. Request message for @@ -663,7 +754,7 @@ def batch_predict( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, input_config, output_config, params]) if request is not None and has_flattened_params: diff --git a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py index ae97e4bf..5fa77cb5 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py index 0464e415..d99439b3 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/automl_v1beta1/types/classification.py b/google/cloud/automl_v1beta1/types/classification.py index 5cca2d9e..4296dcf5 100644 --- a/google/cloud/automl_v1beta1/types/classification.py +++ b/google/cloud/automl_v1beta1/types/classification.py @@ -116,8 +116,8 @@ class ClassificationEvaluationMetrics(proto.Message): the overall evaluation. Deprecated. au_roc (float): Output only. The Area Under Receiver - Operating Characteristic curve metric. Micro- - averaged for the overall evaluation. + Operating Characteristic curve metric. + Micro-averaged for the overall evaluation. log_loss (float): Output only. The Log Loss metric. confidence_metrics_entry (Sequence[google.cloud.automl_v1beta1.types.ClassificationEvaluationMetrics.ConfidenceMetricsEntry]): diff --git a/noxfile.py b/noxfile.py index 8e1a3af2..d0a0c139 100644 --- a/noxfile.py +++ b/noxfile.py @@ -175,7 +175,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=83") + session.run("coverage", "report", "--show-missing", "--fail-under=99") session.run("coverage", "erase") diff --git a/owlbot.py b/owlbot.py index 204c8ba0..b08d1d74 100644 --- a/owlbot.py +++ b/owlbot.py @@ -62,13 +62,17 @@ # Add templated files # ---------------------------------------------------------------------------- templated_files = common.py_library( - unit_cov_level=82, cov_level=83, samples=True, microgenerator=True, + cov_level=99, + samples=True, unit_test_extras=["pandas", "storage"], system_test_extras=["pandas", "storage"] ) s.move(templated_files) +# Work around bug in templates https://github.com/googleapis/synthtool/pull/1335 +s.replace(".github/workflows/unittest.yml", "--fail-under=100", "--fail-under=99") + python.py_samples(skip_readmes=True) s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/samples/beta/noxfile.py b/samples/beta/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/beta/noxfile.py +++ b/samples/beta/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: diff --git a/samples/beta/requirements-test.txt b/samples/beta/requirements-test.txt index 92709451..4a46ff60 100644 --- a/samples/beta/requirements-test.txt +++ b/samples/beta/requirements-test.txt @@ -1 +1 @@ -pytest==6.2.5 +pytest==7.0.0 diff --git a/samples/beta/requirements.txt b/samples/beta/requirements.txt index 22ec816c..a4ff1f94 100644 --- a/samples/beta/requirements.txt +++ b/samples/beta/requirements.txt @@ -1 +1 @@ -google-cloud-automl==2.5.2 +google-cloud-automl==2.6.0 diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_dataset_async.py new file mode 100644 index 00000000..bc4a1692 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_dataset_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_CreateDataset_async] +from google.cloud import automl_v1 + + +async def sample_create_dataset(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + operation = client.create_dataset(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_CreateDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_dataset_sync.py new file mode 100644 index 00000000..78b3dc94 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_dataset_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_CreateDataset_sync] +from google.cloud import automl_v1 + + +def sample_create_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + operation = client.create_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_CreateDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_model_async.py new file mode 100644 index 00000000..7406a304 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_CreateModel_async] +from google.cloud import automl_v1 + + +async def sample_create_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_CreateModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_model_sync.py new file mode 100644 index 00000000..c75050d1 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_create_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_CreateModel_sync] +from google.cloud import automl_v1 + + +def sample_create_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_CreateModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_dataset_async.py new file mode 100644 index 00000000..3e73d54c --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_dataset_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_DeleteDataset_async] +from google.cloud import automl_v1 + + +async def sample_delete_dataset(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_DeleteDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_dataset_sync.py new file mode 100644 index 00000000..92975363 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_dataset_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_DeleteDataset_sync] +from google.cloud import automl_v1 + + +def sample_delete_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_DeleteDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_model_async.py new file mode 100644 index 00000000..3089444c --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_DeleteModel_async] +from google.cloud import automl_v1 + + +async def sample_delete_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_DeleteModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_model_sync.py new file mode 100644 index 00000000..1b5d953d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_delete_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_DeleteModel_sync] +from google.cloud import automl_v1 + + +def sample_delete_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_DeleteModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_deploy_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_deploy_model_async.py new file mode 100644 index 00000000..fe7958b8 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_deploy_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_DeployModel_async] +from google.cloud import automl_v1 + + +async def sample_deploy_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_DeployModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_deploy_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_deploy_model_sync.py new file mode 100644 index 00000000..7782baa5 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_deploy_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_DeployModel_sync] +from google.cloud import automl_v1 + + +def sample_deploy_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_DeployModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_data_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_data_async.py new file mode 100644 index 00000000..b18a5d65 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_data_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ExportData_async] +from google.cloud import automl_v1 + + +async def sample_export_data(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + output_config = automl_v1.OutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportDataRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_ExportData_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_data_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_data_sync.py new file mode 100644 index 00000000..db7b3758 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_data_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ExportData_sync] +from google.cloud import automl_v1 + + +def sample_export_data(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + output_config = automl_v1.OutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportDataRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_ExportData_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_model_async.py new file mode 100644 index 00000000..4cbea390 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_model_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ExportModel_async] +from google.cloud import automl_v1 + + +async def sample_export_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + output_config = automl_v1.ModelExportOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportModelRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_ExportModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_model_sync.py new file mode 100644 index 00000000..f88a4d74 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_export_model_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ExportModel_sync] +from google.cloud import automl_v1 + + +def sample_export_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + output_config = automl_v1.ModelExportOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.ExportModelRequest( + name="name_value", + output_config=output_config, + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_ExportModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_annotation_spec_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_annotation_spec_async.py new file mode 100644 index 00000000..968697f8 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_annotation_spec_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnnotationSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetAnnotationSpec_async] +from google.cloud import automl_v1 + + +async def sample_get_annotation_spec(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = await client.get_annotation_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetAnnotationSpec_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_annotation_spec_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_annotation_spec_sync.py new file mode 100644 index 00000000..b1e79f6b --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_annotation_spec_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnnotationSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetAnnotationSpec_sync] +from google.cloud import automl_v1 + + +def sample_get_annotation_spec(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_annotation_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetAnnotationSpec_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_dataset_async.py new file mode 100644 index 00000000..947a1478 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_dataset_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetDataset_async] +from google.cloud import automl_v1 + + +async def sample_get_dataset(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = await client.get_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_dataset_sync.py new file mode 100644 index 00000000..7bf6023f --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_dataset_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetDataset_sync] +from google.cloud import automl_v1 + + +def sample_get_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = client.get_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_async.py new file mode 100644 index 00000000..d4da631e --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetModel_async] +from google.cloud import automl_v1 + + +async def sample_get_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_model(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_evaluation_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_evaluation_async.py new file mode 100644 index 00000000..961215f9 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_evaluation_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModelEvaluation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetModelEvaluation_async] +from google.cloud import automl_v1 + + +async def sample_get_model_evaluation(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_model_evaluation(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetModelEvaluation_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_evaluation_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_evaluation_sync.py new file mode 100644 index 00000000..520989d5 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_evaluation_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModelEvaluation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetModelEvaluation_sync] +from google.cloud import automl_v1 + + +def sample_get_model_evaluation(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = client.get_model_evaluation(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetModelEvaluation_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_sync.py new file mode 100644 index 00000000..d2d71fe7 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_get_model_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_GetModel_sync] +from google.cloud import automl_v1 + + +def sample_get_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_model(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_GetModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_import_data_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_import_data_async.py new file mode 100644 index 00000000..5496410b --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_import_data_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ImportData_async] +from google.cloud import automl_v1 + + +async def sample_import_data(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + input_config = automl_v1.InputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + request = automl_v1.ImportDataRequest( + name="name_value", + input_config=input_config, + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_ImportData_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_import_data_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_import_data_sync.py new file mode 100644 index 00000000..646d38dc --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_import_data_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ImportData_sync] +from google.cloud import automl_v1 + + +def sample_import_data(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + input_config = automl_v1.InputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + request = automl_v1.ImportDataRequest( + name="name_value", + input_config=input_config, + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_ImportData_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_datasets_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_datasets_async.py new file mode 100644 index 00000000..f29b5e26 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_datasets_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatasets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ListDatasets_async] +from google.cloud import automl_v1 + + +async def sample_list_datasets(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1_AutoMl_ListDatasets_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_datasets_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_datasets_sync.py new file mode 100644 index 00000000..6f9c39f3 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_datasets_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatasets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ListDatasets_sync] +from google.cloud import automl_v1 + + +def sample_list_datasets(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1_AutoMl_ListDatasets_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_model_evaluations_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_model_evaluations_async.py new file mode 100644 index 00000000..60ddddc4 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_model_evaluations_async.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModelEvaluations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ListModelEvaluations_async] +from google.cloud import automl_v1 + + +async def sample_list_model_evaluations(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.ListModelEvaluationsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1_AutoMl_ListModelEvaluations_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_model_evaluations_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_model_evaluations_sync.py new file mode 100644 index 00000000..89edcf79 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_model_evaluations_sync.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModelEvaluations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ListModelEvaluations_sync] +from google.cloud import automl_v1 + + +def sample_list_model_evaluations(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListModelEvaluationsRequest( + parent="parent_value", + filter="filter_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1_AutoMl_ListModelEvaluations_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_models_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_models_async.py new file mode 100644 index 00000000..92a3ba5d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_models_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ListModels_async] +from google.cloud import automl_v1 + + +async def sample_list_models(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1_AutoMl_ListModels_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_models_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_models_sync.py new file mode 100644 index 00000000..d49afd2b --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_list_models_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_ListModels_sync] +from google.cloud import automl_v1 + + +def sample_list_models(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1_AutoMl_ListModels_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_undeploy_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_undeploy_model_async.py new file mode 100644 index 00000000..6bf49672 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_undeploy_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_UndeployModel_async] +from google.cloud import automl_v1 + + +async def sample_undeploy_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_UndeployModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_undeploy_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_undeploy_model_sync.py new file mode 100644 index 00000000..6f5f25c7 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_undeploy_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_UndeployModel_sync] +from google.cloud import automl_v1 + + +def sample_undeploy_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_UndeployModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_dataset_async.py new file mode 100644 index 00000000..76842b8e --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_dataset_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_UpdateDataset_async] +from google.cloud import automl_v1 + + +async def sample_update_dataset(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = await client.update_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_UpdateDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_dataset_sync.py new file mode 100644 index 00000000..be93e90e --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_dataset_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_UpdateDataset_sync] +from google.cloud import automl_v1 + + +def sample_update_dataset(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = client.update_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_UpdateDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_model_async.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_model_async.py new file mode 100644 index 00000000..276d386f --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_model_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_UpdateModel_async] +from google.cloud import automl_v1 + + +async def sample_update_model(): + # Create a client + client = automl_v1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1.UpdateModelRequest( + ) + + # Make the request + response = await client.update_model(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_UpdateModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_model_sync.py b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_model_sync.py new file mode 100644 index 00000000..e12d43da --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_auto_ml_update_model_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_AutoMl_UpdateModel_sync] +from google.cloud import automl_v1 + + +def sample_update_model(): + # Create a client + client = automl_v1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1.UpdateModelRequest( + ) + + # Make the request + response = client.update_model(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_AutoMl_UpdateModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_prediction_service_batch_predict_async.py b/samples/generated_samples/automl_generated_automl_v1_prediction_service_batch_predict_async.py new file mode 100644 index 00000000..1ec552f5 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_prediction_service_batch_predict_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchPredict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_PredictionService_BatchPredict_async] +from google.cloud import automl_v1 + + +async def sample_batch_predict(): + # Create a client + client = automl_v1.PredictionServiceAsyncClient() + + # Initialize request argument(s) + input_config = automl_v1.BatchPredictInputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + output_config = automl_v1.BatchPredictOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.BatchPredictRequest( + name="name_value", + input_config=input_config, + output_config=output_config, + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_PredictionService_BatchPredict_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_prediction_service_batch_predict_sync.py b/samples/generated_samples/automl_generated_automl_v1_prediction_service_batch_predict_sync.py new file mode 100644 index 00000000..1613710d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_prediction_service_batch_predict_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchPredict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_PredictionService_BatchPredict_sync] +from google.cloud import automl_v1 + + +def sample_batch_predict(): + # Create a client + client = automl_v1.PredictionServiceClient() + + # Initialize request argument(s) + input_config = automl_v1.BatchPredictInputConfig() + input_config.gcs_source.input_uris = ['input_uris_value_1', 'input_uris_value_2'] + + output_config = automl_v1.BatchPredictOutputConfig() + output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value" + + request = automl_v1.BatchPredictRequest( + name="name_value", + input_config=input_config, + output_config=output_config, + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_PredictionService_BatchPredict_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1_prediction_service_predict_async.py b/samples/generated_samples/automl_generated_automl_v1_prediction_service_predict_async.py new file mode 100644 index 00000000..f4f6fb55 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_prediction_service_predict_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Predict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_PredictionService_Predict_async] +from google.cloud import automl_v1 + + +async def sample_predict(): + # Create a client + client = automl_v1.PredictionServiceAsyncClient() + + # Initialize request argument(s) + payload = automl_v1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = await client.predict(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_PredictionService_Predict_async] diff --git a/samples/generated_samples/automl_generated_automl_v1_prediction_service_predict_sync.py b/samples/generated_samples/automl_generated_automl_v1_prediction_service_predict_sync.py new file mode 100644 index 00000000..bd9917ca --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1_prediction_service_predict_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Predict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1_PredictionService_Predict_sync] +from google.cloud import automl_v1 + + +def sample_predict(): + # Create a client + client = automl_v1.PredictionServiceClient() + + # Initialize request argument(s) + payload = automl_v1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = client.predict(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1_PredictionService_Predict_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_dataset_async.py new file mode 100644 index 00000000..9b6bc874 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_dataset_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_CreateDataset_async] +from google.cloud import automl_v1beta1 + + +async def sample_create_dataset(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + response = await client.create_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_CreateDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_dataset_sync.py new file mode 100644 index 00000000..86cdec0a --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_dataset_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_CreateDataset_sync] +from google.cloud import automl_v1beta1 + + +def sample_create_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.CreateDatasetRequest( + parent="parent_value", + dataset=dataset, + ) + + # Make the request + response = client.create_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_CreateDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_model_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_model_async.py new file mode 100644 index 00000000..a3e0e9a7 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_CreateModel_async] +from google.cloud import automl_v1beta1 + + +async def sample_create_model(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_CreateModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_model_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_model_sync.py new file mode 100644 index 00000000..8fd7dfc2 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_create_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_CreateModel_sync] +from google.cloud import automl_v1beta1 + + +def sample_create_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.CreateModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_CreateModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_dataset_async.py new file mode 100644 index 00000000..cd59fd6f --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_dataset_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_DeleteDataset_async] +from google.cloud import automl_v1beta1 + + +async def sample_delete_dataset(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_DeleteDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_dataset_sync.py new file mode 100644 index 00000000..7726a074 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_dataset_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_DeleteDataset_sync] +from google.cloud import automl_v1beta1 + + +def sample_delete_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteDatasetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_DeleteDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_model_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_model_async.py new file mode 100644 index 00000000..bf91da8d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_DeleteModel_async] +from google.cloud import automl_v1beta1 + + +async def sample_delete_model(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_DeleteModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_model_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_model_sync.py new file mode 100644 index 00000000..1647cc32 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_delete_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_DeleteModel_sync] +from google.cloud import automl_v1beta1 + + +def sample_delete_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeleteModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_DeleteModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_deploy_model_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_deploy_model_async.py new file mode 100644 index 00000000..89206ebe --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_deploy_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_DeployModel_async] +from google.cloud import automl_v1beta1 + + +async def sample_deploy_model(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_DeployModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_deploy_model_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_deploy_model_sync.py new file mode 100644 index 00000000..5fbb615d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_deploy_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_DeployModel_sync] +from google.cloud import automl_v1beta1 + + +def sample_deploy_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.DeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_DeployModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_data_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_data_async.py new file mode 100644 index 00000000..86a95cb4 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_data_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ExportData_async] +from google.cloud import automl_v1beta1 + + +async def sample_export_data(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ExportData_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_data_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_data_sync.py new file mode 100644 index 00000000..086e8a44 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_data_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ExportData_sync] +from google.cloud import automl_v1beta1 + + +def sample_export_data(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.export_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ExportData_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_async.py new file mode 100644 index 00000000..36c0faf3 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportEvaluatedExamples +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ExportEvaluatedExamples_async] +from google.cloud import automl_v1beta1 + + +async def sample_export_evaluated_examples(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportEvaluatedExamplesRequest( + name="name_value", + ) + + # Make the request + operation = client.export_evaluated_examples(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ExportEvaluatedExamples_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_sync.py new file mode 100644 index 00000000..3d5e96c4 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportEvaluatedExamples +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ExportEvaluatedExamples_sync] +from google.cloud import automl_v1beta1 + + +def sample_export_evaluated_examples(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportEvaluatedExamplesRequest( + name="name_value", + ) + + # Make the request + operation = client.export_evaluated_examples(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ExportEvaluatedExamples_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_model_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_model_async.py new file mode 100644 index 00000000..139045ee --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ExportModel_async] +from google.cloud import automl_v1beta1 + + +async def sample_export_model(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportModelRequest( + name="name_value", + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ExportModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_model_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_model_sync.py new file mode 100644 index 00000000..8dbbd300 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_export_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ExportModel_sync] +from google.cloud import automl_v1beta1 + + +def sample_export_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ExportModelRequest( + name="name_value", + ) + + # Make the request + operation = client.export_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ExportModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_async.py new file mode 100644 index 00000000..27e755e8 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnnotationSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetAnnotationSpec_async] +from google.cloud import automl_v1beta1 + + +async def sample_get_annotation_spec(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = await client.get_annotation_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetAnnotationSpec_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_sync.py new file mode 100644 index 00000000..40fc48f3 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnnotationSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetAnnotationSpec_sync] +from google.cloud import automl_v1beta1 + + +def sample_get_annotation_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetAnnotationSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_annotation_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetAnnotationSpec_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_column_spec_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_column_spec_async.py new file mode 100644 index 00000000..cf5782b9 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_column_spec_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetColumnSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetColumnSpec_async] +from google.cloud import automl_v1beta1 + + +async def sample_get_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetColumnSpecRequest( + name="name_value", + ) + + # Make the request + response = await client.get_column_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetColumnSpec_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_column_spec_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_column_spec_sync.py new file mode 100644 index 00000000..76f055d0 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_column_spec_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetColumnSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetColumnSpec_sync] +from google.cloud import automl_v1beta1 + + +def sample_get_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetColumnSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_column_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetColumnSpec_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_dataset_async.py new file mode 100644 index 00000000..ae4fd6cf --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_dataset_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetDataset_async] +from google.cloud import automl_v1beta1 + + +async def sample_get_dataset(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = await client.get_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_dataset_sync.py new file mode 100644 index 00000000..cf1fe369 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_dataset_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetDataset_sync] +from google.cloud import automl_v1beta1 + + +def sample_get_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetDatasetRequest( + name="name_value", + ) + + # Make the request + response = client.get_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_async.py new file mode 100644 index 00000000..69596c40 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetModel_async] +from google.cloud import automl_v1beta1 + + +async def sample_get_model(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_model(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_async.py new file mode 100644 index 00000000..7649ab2a --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModelEvaluation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetModelEvaluation_async] +from google.cloud import automl_v1beta1 + + +async def sample_get_model_evaluation(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_model_evaluation(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetModelEvaluation_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_sync.py new file mode 100644 index 00000000..ac8e7aea --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModelEvaluation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetModelEvaluation_sync] +from google.cloud import automl_v1beta1 + + +def sample_get_model_evaluation(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelEvaluationRequest( + name="name_value", + ) + + # Make the request + response = client.get_model_evaluation(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetModelEvaluation_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_sync.py new file mode 100644 index 00000000..e2816e6e --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_model_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetModel_sync] +from google.cloud import automl_v1beta1 + + +def sample_get_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_model(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_table_spec_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_table_spec_async.py new file mode 100644 index 00000000..febd9346 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_table_spec_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTableSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetTableSpec_async] +from google.cloud import automl_v1beta1 + + +async def sample_get_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetTableSpecRequest( + name="name_value", + ) + + # Make the request + response = await client.get_table_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetTableSpec_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_table_spec_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_table_spec_sync.py new file mode 100644 index 00000000..6bc85008 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_get_table_spec_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTableSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_GetTableSpec_sync] +from google.cloud import automl_v1beta1 + + +def sample_get_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.GetTableSpecRequest( + name="name_value", + ) + + # Make the request + response = client.get_table_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_GetTableSpec_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_import_data_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_import_data_async.py new file mode 100644 index 00000000..6f670fec --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_import_data_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ImportData_async] +from google.cloud import automl_v1beta1 + + +async def sample_import_data(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ImportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ImportData_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_import_data_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_import_data_sync.py new file mode 100644 index 00000000..1ed63e73 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_import_data_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ImportData_sync] +from google.cloud import automl_v1beta1 + + +def sample_import_data(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ImportDataRequest( + name="name_value", + ) + + # Make the request + operation = client.import_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ImportData_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_column_specs_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_column_specs_async.py new file mode 100644 index 00000000..a0544e86 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_column_specs_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListColumnSpecs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListColumnSpecs_async] +from google.cloud import automl_v1beta1 + + +async def sample_list_column_specs(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListColumnSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_column_specs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListColumnSpecs_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_column_specs_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_column_specs_sync.py new file mode 100644 index 00000000..24c04088 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_column_specs_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListColumnSpecs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListColumnSpecs_sync] +from google.cloud import automl_v1beta1 + + +def sample_list_column_specs(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListColumnSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_column_specs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListColumnSpecs_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_datasets_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_datasets_async.py new file mode 100644 index 00000000..929484ff --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_datasets_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatasets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListDatasets_async] +from google.cloud import automl_v1beta1 + + +async def sample_list_datasets(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListDatasets_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_datasets_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_datasets_sync.py new file mode 100644 index 00000000..55ae4f2b --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_datasets_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDatasets +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListDatasets_sync] +from google.cloud import automl_v1beta1 + + +def sample_list_datasets(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListDatasetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_datasets(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListDatasets_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_async.py new file mode 100644 index 00000000..87c5e63c --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModelEvaluations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListModelEvaluations_async] +from google.cloud import automl_v1beta1 + + +async def sample_list_model_evaluations(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelEvaluationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListModelEvaluations_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_sync.py new file mode 100644 index 00000000..29ef57c7 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModelEvaluations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListModelEvaluations_sync] +from google.cloud import automl_v1beta1 + + +def sample_list_model_evaluations(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelEvaluationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_model_evaluations(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListModelEvaluations_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_models_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_models_async.py new file mode 100644 index 00000000..9c62881a --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_models_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListModels_async] +from google.cloud import automl_v1beta1 + + +async def sample_list_models(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListModels_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_models_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_models_sync.py new file mode 100644 index 00000000..3906f1f8 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_models_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListModels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListModels_sync] +from google.cloud import automl_v1beta1 + + +def sample_list_models(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListModelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_models(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListModels_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_table_specs_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_table_specs_async.py new file mode 100644 index 00000000..07ace909 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_table_specs_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTableSpecs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListTableSpecs_async] +from google.cloud import automl_v1beta1 + + +async def sample_list_table_specs(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListTableSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_table_specs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListTableSpecs_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_table_specs_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_table_specs_sync.py new file mode 100644 index 00000000..9f3a82e1 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_list_table_specs_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTableSpecs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_ListTableSpecs_sync] +from google.cloud import automl_v1beta1 + + +def sample_list_table_specs(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.ListTableSpecsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_table_specs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_ListTableSpecs_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_undeploy_model_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_undeploy_model_async.py new file mode 100644 index 00000000..8590201d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_undeploy_model_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UndeployModel_async] +from google.cloud import automl_v1beta1 + + +async def sample_undeploy_model(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UndeployModel_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_undeploy_model_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_undeploy_model_sync.py new file mode 100644 index 00000000..8fcb4e8d --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_undeploy_model_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UndeployModel_sync] +from google.cloud import automl_v1beta1 + + +def sample_undeploy_model(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UndeployModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UndeployModel_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_column_spec_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_column_spec_async.py new file mode 100644 index 00000000..471b71d6 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_column_spec_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateColumnSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UpdateColumnSpec_async] +from google.cloud import automl_v1beta1 + + +async def sample_update_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateColumnSpecRequest( + ) + + # Make the request + response = await client.update_column_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UpdateColumnSpec_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_column_spec_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_column_spec_sync.py new file mode 100644 index 00000000..51146b66 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_column_spec_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateColumnSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UpdateColumnSpec_sync] +from google.cloud import automl_v1beta1 + + +def sample_update_column_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateColumnSpecRequest( + ) + + # Make the request + response = client.update_column_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UpdateColumnSpec_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_dataset_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_dataset_async.py new file mode 100644 index 00000000..7b4426a1 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_dataset_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UpdateDataset_async] +from google.cloud import automl_v1beta1 + + +async def sample_update_dataset(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = await client.update_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UpdateDataset_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_dataset_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_dataset_sync.py new file mode 100644 index 00000000..5a8a7b07 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_dataset_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UpdateDataset_sync] +from google.cloud import automl_v1beta1 + + +def sample_update_dataset(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + dataset = automl_v1beta1.Dataset() + dataset.translation_dataset_metadata.source_language_code = "source_language_code_value" + dataset.translation_dataset_metadata.target_language_code = "target_language_code_value" + + request = automl_v1beta1.UpdateDatasetRequest( + dataset=dataset, + ) + + # Make the request + response = client.update_dataset(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UpdateDataset_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_table_spec_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_table_spec_async.py new file mode 100644 index 00000000..1b510969 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_table_spec_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTableSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UpdateTableSpec_async] +from google.cloud import automl_v1beta1 + + +async def sample_update_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateTableSpecRequest( + ) + + # Make the request + response = await client.update_table_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UpdateTableSpec_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_table_spec_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_table_spec_sync.py new file mode 100644 index 00000000..bf9da291 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_auto_ml_update_table_spec_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTableSpec +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_AutoMl_UpdateTableSpec_sync] +from google.cloud import automl_v1beta1 + + +def sample_update_table_spec(): + # Create a client + client = automl_v1beta1.AutoMlClient() + + # Initialize request argument(s) + request = automl_v1beta1.UpdateTableSpecRequest( + ) + + # Make the request + response = client.update_table_spec(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_AutoMl_UpdateTableSpec_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_batch_predict_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_batch_predict_async.py new file mode 100644 index 00000000..119b7b30 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_batch_predict_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchPredict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_PredictionService_BatchPredict_async] +from google.cloud import automl_v1beta1 + + +async def sample_batch_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceAsyncClient() + + # Initialize request argument(s) + request = automl_v1beta1.BatchPredictRequest( + name="name_value", + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_PredictionService_BatchPredict_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_batch_predict_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_batch_predict_sync.py new file mode 100644 index 00000000..4dff444f --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_batch_predict_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchPredict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_PredictionService_BatchPredict_sync] +from google.cloud import automl_v1beta1 + + +def sample_batch_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceClient() + + # Initialize request argument(s) + request = automl_v1beta1.BatchPredictRequest( + name="name_value", + ) + + # Make the request + operation = client.batch_predict(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_PredictionService_BatchPredict_sync] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_predict_async.py b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_predict_async.py new file mode 100644 index 00000000..f54b23f3 --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_predict_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Predict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_PredictionService_Predict_async] +from google.cloud import automl_v1beta1 + + +async def sample_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceAsyncClient() + + # Initialize request argument(s) + payload = automl_v1beta1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1beta1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = await client.predict(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_PredictionService_Predict_async] diff --git a/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_predict_sync.py b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_predict_sync.py new file mode 100644 index 00000000..17e166fd --- /dev/null +++ b/samples/generated_samples/automl_generated_automl_v1beta1_prediction_service_predict_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for Predict +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-automl + + +# [START automl_generated_automl_v1beta1_PredictionService_Predict_sync] +from google.cloud import automl_v1beta1 + + +def sample_predict(): + # Create a client + client = automl_v1beta1.PredictionServiceClient() + + # Initialize request argument(s) + payload = automl_v1beta1.ExamplePayload() + payload.image.image_bytes = b'image_bytes_blob' + + request = automl_v1beta1.PredictRequest( + name="name_value", + payload=payload, + ) + + # Make the request + response = client.predict(request=request) + + # Handle the response + print(response) + +# [END automl_generated_automl_v1beta1_PredictionService_Predict_sync] diff --git a/samples/generated_samples/snippet_metadata_automl_v1.json b/samples/generated_samples/snippet_metadata_automl_v1.json new file mode 100644 index 00000000..7ab2fc78 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_automl_v1.json @@ -0,0 +1,1784 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_create_dataset_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_CreateDataset_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_create_dataset_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_CreateDataset_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_create_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_CreateModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_create_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_CreateModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_delete_dataset_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_DeleteDataset_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_delete_dataset_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_DeleteDataset_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_delete_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_DeleteModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_delete_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_DeleteModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeployModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_deploy_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_DeployModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeployModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_deploy_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_DeployModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportData" + } + }, + "file": "automl_generated_automl_v1_auto_ml_export_data_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ExportData_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportData" + } + }, + "file": "automl_generated_automl_v1_auto_ml_export_data_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ExportData_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_export_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ExportModel_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_export_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ExportModel_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetAnnotationSpec" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_annotation_spec_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetAnnotationSpec_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetAnnotationSpec" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_annotation_spec_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetAnnotationSpec_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_dataset_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetDataset_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_dataset_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetDataset_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModelEvaluation" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_model_evaluation_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetModelEvaluation_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModelEvaluation" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_model_evaluation_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetModelEvaluation_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetModel_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_get_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_GetModel_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ImportData" + } + }, + "file": "automl_generated_automl_v1_auto_ml_import_data_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ImportData_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ImportData" + } + }, + "file": "automl_generated_automl_v1_auto_ml_import_data_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ImportData_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListDatasets" + } + }, + "file": "automl_generated_automl_v1_auto_ml_list_datasets_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ListDatasets_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListDatasets" + } + }, + "file": "automl_generated_automl_v1_auto_ml_list_datasets_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ListDatasets_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModelEvaluations" + } + }, + "file": "automl_generated_automl_v1_auto_ml_list_model_evaluations_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ListModelEvaluations_async", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModelEvaluations" + } + }, + "file": "automl_generated_automl_v1_auto_ml_list_model_evaluations_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ListModelEvaluations_sync", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModels" + } + }, + "file": "automl_generated_automl_v1_auto_ml_list_models_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ListModels_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModels" + } + }, + "file": "automl_generated_automl_v1_auto_ml_list_models_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_ListModels_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UndeployModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_undeploy_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_UndeployModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UndeployModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_undeploy_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_UndeployModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_update_dataset_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_UpdateDataset_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateDataset" + } + }, + "file": "automl_generated_automl_v1_auto_ml_update_dataset_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_UpdateDataset_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_update_model_async.py", + "regionTag": "automl_generated_automl_v1_AutoMl_UpdateModel_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateModel" + } + }, + "file": "automl_generated_automl_v1_auto_ml_update_model_sync.py", + "regionTag": "automl_generated_automl_v1_AutoMl_UpdateModel_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "BatchPredict" + } + }, + "file": "automl_generated_automl_v1_prediction_service_batch_predict_async.py", + "regionTag": "automl_generated_automl_v1_PredictionService_BatchPredict_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "BatchPredict" + } + }, + "file": "automl_generated_automl_v1_prediction_service_batch_predict_sync.py", + "regionTag": "automl_generated_automl_v1_PredictionService_BatchPredict_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "Predict" + } + }, + "file": "automl_generated_automl_v1_prediction_service_predict_async.py", + "regionTag": "automl_generated_automl_v1_PredictionService_Predict_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "Predict" + } + }, + "file": "automl_generated_automl_v1_prediction_service_predict_sync.py", + "regionTag": "automl_generated_automl_v1_PredictionService_Predict_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_automl_v1beta1.json b/samples/generated_samples/snippet_metadata_automl_v1beta1.json new file mode 100644 index 00000000..e2623801 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_automl_v1beta1.json @@ -0,0 +1,2318 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_create_dataset_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_CreateDataset_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_create_dataset_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_CreateDataset_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_create_model_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_CreateModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "CreateModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_create_model_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_CreateModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_delete_dataset_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_DeleteDataset_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_delete_dataset_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_DeleteDataset_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_delete_model_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_DeleteModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeleteModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_delete_model_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_DeleteModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeployModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_deploy_model_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_DeployModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "DeployModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_deploy_model_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_DeployModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportData" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_export_data_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ExportData_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportData" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_export_data_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ExportData_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportEvaluatedExamples" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ExportEvaluatedExamples_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportEvaluatedExamples" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_export_evaluated_examples_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ExportEvaluatedExamples_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_export_model_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ExportModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ExportModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_export_model_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ExportModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetAnnotationSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetAnnotationSpec_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetAnnotationSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_annotation_spec_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetAnnotationSpec_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetColumnSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_column_spec_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetColumnSpec_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetColumnSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_column_spec_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetColumnSpec_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_dataset_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetDataset_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_dataset_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetDataset_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModelEvaluation" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetModelEvaluation_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModelEvaluation" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_model_evaluation_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetModelEvaluation_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_model_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetModel_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_model_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetModel_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetTableSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_table_spec_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetTableSpec_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "GetTableSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_get_table_spec_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_GetTableSpec_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ImportData" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_import_data_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ImportData_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ImportData" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_import_data_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ImportData_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListColumnSpecs" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_column_specs_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListColumnSpecs_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListColumnSpecs" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_column_specs_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListColumnSpecs_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListDatasets" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_datasets_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListDatasets_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListDatasets" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_datasets_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListDatasets_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModelEvaluations" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListModelEvaluations_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModelEvaluations" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_model_evaluations_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListModelEvaluations_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModels" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_models_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListModels_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListModels" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_models_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListModels_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListTableSpecs" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_table_specs_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListTableSpecs_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "ListTableSpecs" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_list_table_specs_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_ListTableSpecs_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UndeployModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_undeploy_model_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UndeployModel_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UndeployModel" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_undeploy_model_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UndeployModel_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateColumnSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_update_column_spec_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UpdateColumnSpec_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateColumnSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_update_column_spec_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UpdateColumnSpec_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_update_dataset_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UpdateDataset_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateDataset" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_update_dataset_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UpdateDataset_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateTableSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_update_table_spec_async.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UpdateTableSpec_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "AutoMl" + }, + "shortName": "UpdateTableSpec" + } + }, + "file": "automl_generated_automl_v1beta1_auto_ml_update_table_spec_sync.py", + "regionTag": "automl_generated_automl_v1beta1_AutoMl_UpdateTableSpec_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "BatchPredict" + } + }, + "file": "automl_generated_automl_v1beta1_prediction_service_batch_predict_async.py", + "regionTag": "automl_generated_automl_v1beta1_PredictionService_BatchPredict_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "BatchPredict" + } + }, + "file": "automl_generated_automl_v1beta1_prediction_service_batch_predict_sync.py", + "regionTag": "automl_generated_automl_v1beta1_PredictionService_BatchPredict_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "Predict" + } + }, + "file": "automl_generated_automl_v1beta1_prediction_service_predict_async.py", + "regionTag": "automl_generated_automl_v1beta1_PredictionService_Predict_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "PredictionService" + }, + "shortName": "Predict" + } + }, + "file": "automl_generated_automl_v1beta1_prediction_service_predict_sync.py", + "regionTag": "automl_generated_automl_v1beta1_PredictionService_Predict_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index fbe6c1c5..27df4634 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1,2 +1,2 @@ backoff==1.11.1 -pytest==6.2.5 +pytest==7.0.0 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 390316bb..8c51bb99 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ google-cloud-translate==3.6.1 -google-cloud-storage==2.0.0 -google-cloud-automl==2.5.2 +google-cloud-storage==2.1.0 +google-cloud-automl==2.6.0 diff --git a/samples/tables/noxfile.py b/samples/tables/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/tables/noxfile.py +++ b/samples/tables/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: diff --git a/samples/tables/requirements-test.txt b/samples/tables/requirements-test.txt index 0f6247f7..8fbb4388 100644 --- a/samples/tables/requirements-test.txt +++ b/samples/tables/requirements-test.txt @@ -1,2 +1,2 @@ -pytest==6.2.5 +pytest==7.0.0 backoff==1.11.1 \ No newline at end of file diff --git a/samples/tables/requirements.txt b/samples/tables/requirements.txt index 22ec816c..a4ff1f94 100644 --- a/samples/tables/requirements.txt +++ b/samples/tables/requirements.txt @@ -1 +1 @@ -google-cloud-automl==2.5.2 +google-cloud-automl==2.6.0 diff --git a/setup.py b/setup.py index 2a501217..58d0f882 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ name = "google-cloud-automl" description = "Cloud AutoML API client library" -version = "2.6.0" +version = "2.7.0" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x diff --git a/tests/unit/gapic/automl_v1/test_auto_ml.py b/tests/unit/gapic/automl_v1/test_auto_ml.py index 2267ee42..7c4b1c05 100644 --- a/tests/unit/gapic/automl_v1/test_auto_ml.py +++ b/tests/unit/gapic/automl_v1/test_auto_ml.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -390,6 +391,81 @@ def test_auto_ml_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [AutoMlClient, AutoMlAsyncClient]) +@mock.patch.object( + AutoMlClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AutoMlClient) +) +@mock.patch.object( + AutoMlAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AutoMlAsyncClient) +) +def test_auto_ml_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -418,17 +494,23 @@ def test_auto_ml_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (AutoMlClient, transports.AutoMlGrpcTransport, "grpc"), - (AutoMlAsyncClient, transports.AutoMlGrpcAsyncIOTransport, "grpc_asyncio"), + (AutoMlClient, transports.AutoMlGrpcTransport, "grpc", grpc_helpers), + ( + AutoMlAsyncClient, + transports.AutoMlGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_auto_ml_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -462,6 +544,67 @@ def test_auto_ml_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (AutoMlClient, transports.AutoMlGrpcTransport, "grpc", grpc_helpers), + ( + AutoMlAsyncClient, + transports.AutoMlGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_auto_ml_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "automl.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="automl.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [service.CreateDatasetRequest, dict,]) def test_create_dataset(request_type, transport: str = "grpc"): client = AutoMlClient( @@ -4825,6 +4968,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.AutoMlGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AutoMlClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AutoMlClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.AutoMlGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -5501,3 +5661,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (AutoMlClient, transports.AutoMlGrpcTransport), + (AutoMlAsyncClient, transports.AutoMlGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/automl_v1/test_prediction_service.py b/tests/unit/gapic/automl_v1/test_prediction_service.py index 08f6bd1f..d1771392 100644 --- a/tests/unit/gapic/automl_v1/test_prediction_service.py +++ b/tests/unit/gapic/automl_v1/test_prediction_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -417,6 +418,87 @@ def test_prediction_service_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [PredictionServiceClient, PredictionServiceAsyncClient] +) +@mock.patch.object( + PredictionServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceClient), +) +@mock.patch.object( + PredictionServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceAsyncClient), +) +def test_prediction_service_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -449,21 +531,28 @@ def test_prediction_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (PredictionServiceClient, transports.PredictionServiceGrpcTransport, "grpc"), + ( + PredictionServiceClient, + transports.PredictionServiceGrpcTransport, + "grpc", + grpc_helpers, + ), ( PredictionServiceAsyncClient, transports.PredictionServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_prediction_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -499,6 +588,72 @@ def test_prediction_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + PredictionServiceClient, + transports.PredictionServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_prediction_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "automl.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="automl.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,]) def test_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( @@ -1029,6 +1184,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PredictionServiceClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PredictionServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.PredictionServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1620,3 +1792,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (PredictionServiceClient, transports.PredictionServiceGrpcTransport), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/automl_v1beta1/test_auto_ml.py b/tests/unit/gapic/automl_v1beta1/test_auto_ml.py index 4a36cc1f..65ab68fe 100644 --- a/tests/unit/gapic/automl_v1beta1/test_auto_ml.py +++ b/tests/unit/gapic/automl_v1beta1/test_auto_ml.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -399,6 +400,81 @@ def test_auto_ml_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [AutoMlClient, AutoMlAsyncClient]) +@mock.patch.object( + AutoMlClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AutoMlClient) +) +@mock.patch.object( + AutoMlAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AutoMlAsyncClient) +) +def test_auto_ml_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -427,17 +503,23 @@ def test_auto_ml_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (AutoMlClient, transports.AutoMlGrpcTransport, "grpc"), - (AutoMlAsyncClient, transports.AutoMlGrpcAsyncIOTransport, "grpc_asyncio"), + (AutoMlClient, transports.AutoMlGrpcTransport, "grpc", grpc_helpers), + ( + AutoMlAsyncClient, + transports.AutoMlGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_auto_ml_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -471,6 +553,67 @@ def test_auto_ml_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (AutoMlClient, transports.AutoMlGrpcTransport, "grpc", grpc_helpers), + ( + AutoMlAsyncClient, + transports.AutoMlGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_auto_ml_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "automl.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="automl.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [service.CreateDatasetRequest, dict,]) def test_create_dataset(request_type, transport: str = "grpc"): client = AutoMlClient( @@ -6410,6 +6553,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.AutoMlGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AutoMlClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AutoMlClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.AutoMlGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -7152,3 +7312,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (AutoMlClient, transports.AutoMlGrpcTransport), + (AutoMlAsyncClient, transports.AutoMlGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/automl_v1beta1/test_prediction_service.py b/tests/unit/gapic/automl_v1beta1/test_prediction_service.py index 7032ef5e..7c59b933 100644 --- a/tests/unit/gapic/automl_v1beta1/test_prediction_service.py +++ b/tests/unit/gapic/automl_v1beta1/test_prediction_service.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -420,6 +421,87 @@ def test_prediction_service_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [PredictionServiceClient, PredictionServiceAsyncClient] +) +@mock.patch.object( + PredictionServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceClient), +) +@mock.patch.object( + PredictionServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceAsyncClient), +) +def test_prediction_service_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -452,21 +534,28 @@ def test_prediction_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (PredictionServiceClient, transports.PredictionServiceGrpcTransport, "grpc"), + ( + PredictionServiceClient, + transports.PredictionServiceGrpcTransport, + "grpc", + grpc_helpers, + ), ( PredictionServiceAsyncClient, transports.PredictionServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_prediction_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -502,6 +591,72 @@ def test_prediction_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + PredictionServiceClient, + transports.PredictionServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_prediction_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "automl.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="automl.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,]) def test_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( @@ -1032,6 +1187,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PredictionServiceClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PredictionServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.PredictionServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1623,3 +1795,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (PredictionServiceClient, transports.PredictionServiceGrpcTransport), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + )