Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- evalkit_cambrian/lib/python3.10/site-packages/cv2/qt/fonts/DejaVuSansCondensed-Oblique.ttf +3 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/__init__.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/_rest_streaming_base.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/bidi.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/client_info.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/client_logging.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/datetime_helpers.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/extended_operation.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/general_helpers.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/grpc_helpers.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/grpc_helpers_async.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/iam.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/operation.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/page_iterator.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/page_iterator_async.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/path_template.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/protobuf_helpers.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/rest_helpers.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/rest_streaming.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/rest_streaming_async.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/retry_async.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/timeout.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/universe.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/version.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__init__.py +40 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/__init__.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/abstract_operations_base_client.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/abstract_operations_client.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_async_client.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client_config.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_rest_client_async.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_async.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_base.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/abstract_operations_base_client.py +370 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/abstract_operations_client.py +387 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_async_client.py +364 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_client.py +378 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_client_config.py +60 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_rest_client_async.py +345 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/pagers.py +67 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/pagers_async.py +71 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/pagers_base.py +73 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__init__.py +39 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/__init__.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/base.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest.cpython-310.pyc +0 -0
- evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest_asyncio.cpython-310.pyc +0 -0
.gitattributes
CHANGED
|
@@ -457,3 +457,4 @@ janus/lib/python3.10/site-packages/torch/_decomp/__pycache__/decompositions.cpyt
|
|
| 457 |
janus/lib/python3.10/site-packages/torch/onnx/__pycache__/symbolic_opset9.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 458 |
evalkit_llava/bin/x86_64-conda-linux-gnu-ld filter=lfs diff=lfs merge=lfs -text
|
| 459 |
janus/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/uts46data.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 457 |
janus/lib/python3.10/site-packages/torch/onnx/__pycache__/symbolic_opset9.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 458 |
evalkit_llava/bin/x86_64-conda-linux-gnu-ld filter=lfs diff=lfs merge=lfs -text
|
| 459 |
janus/lib/python3.10/site-packages/pip/_vendor/idna/__pycache__/uts46data.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 460 |
+
evalkit_cambrian/lib/python3.10/site-packages/cv2/qt/fonts/DejaVuSansCondensed-Oblique.ttf filter=lfs diff=lfs merge=lfs -text
|
evalkit_cambrian/lib/python3.10/site-packages/cv2/qt/fonts/DejaVuSansCondensed-Oblique.ttf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:48f994e81284666ab4bf89ef4d73085b07fae6c2c7e28820ab243e9941c4829e
|
| 3 |
+
size 576004
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (379 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/_rest_streaming_base.cpython-310.pyc
ADDED
|
Binary file (2.92 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/bidi.cpython-310.pyc
ADDED
|
Binary file (22 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/client_info.cpython-310.pyc
ADDED
|
Binary file (3.05 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/client_logging.cpython-310.pyc
ADDED
|
Binary file (4.08 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/datetime_helpers.cpython-310.pyc
ADDED
|
Binary file (8.09 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/extended_operation.cpython-310.pyc
ADDED
|
Binary file (7.08 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/general_helpers.cpython-310.pyc
ADDED
|
Binary file (223 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/grpc_helpers.cpython-310.pyc
ADDED
|
Binary file (19.7 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/grpc_helpers_async.cpython-310.pyc
ADDED
|
Binary file (13.1 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/iam.cpython-310.pyc
ADDED
|
Binary file (12.1 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/operation.cpython-310.pyc
ADDED
|
Binary file (11.5 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/page_iterator.cpython-310.pyc
ADDED
|
Binary file (17.8 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/page_iterator_async.cpython-310.pyc
ADDED
|
Binary file (8.84 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/path_template.cpython-310.pyc
ADDED
|
Binary file (9.34 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/protobuf_helpers.cpython-310.pyc
ADDED
|
Binary file (9.29 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/rest_helpers.cpython-310.pyc
ADDED
|
Binary file (3.28 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/rest_streaming.cpython-310.pyc
ADDED
|
Binary file (2.12 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/rest_streaming_async.cpython-310.pyc
ADDED
|
Binary file (2.92 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/retry_async.cpython-310.pyc
ADDED
|
Binary file (584 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/timeout.cpython-310.pyc
ADDED
|
Binary file (8.48 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/universe.cpython-310.pyc
ADDED
|
Binary file (2.69 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/__pycache__/version.cpython-310.pyc
ADDED
|
Binary file (198 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__init__.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""Package for interacting with the google.longrunning.operations meta-API."""
|
| 16 |
+
|
| 17 |
+
from google.api_core.operations_v1.abstract_operations_client import AbstractOperationsClient
|
| 18 |
+
from google.api_core.operations_v1.operations_async_client import OperationsAsyncClient
|
| 19 |
+
from google.api_core.operations_v1.operations_client import OperationsClient
|
| 20 |
+
from google.api_core.operations_v1.transports.rest import OperationsRestTransport
|
| 21 |
+
|
| 22 |
+
__all__ = [
|
| 23 |
+
"AbstractOperationsClient",
|
| 24 |
+
"OperationsAsyncClient",
|
| 25 |
+
"OperationsClient",
|
| 26 |
+
"OperationsRestTransport"
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
from google.api_core.operations_v1.transports.rest_asyncio import (
|
| 31 |
+
AsyncOperationsRestTransport,
|
| 32 |
+
)
|
| 33 |
+
from google.api_core.operations_v1.operations_rest_client_async import AsyncOperationsRestClient
|
| 34 |
+
|
| 35 |
+
__all__ += ["AsyncOperationsRestClient", "AsyncOperationsRestTransport"]
|
| 36 |
+
except ImportError:
|
| 37 |
+
# This import requires the `async_rest` extra.
|
| 38 |
+
# Don't raise an exception if `AsyncOperationsRestTransport` cannot be imported
|
| 39 |
+
# as other transports are still available.
|
| 40 |
+
pass
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (989 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/abstract_operations_base_client.cpython-310.pyc
ADDED
|
Binary file (12.7 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/abstract_operations_client.cpython-310.pyc
ADDED
|
Binary file (13 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_async_client.cpython-310.pyc
ADDED
|
Binary file (12.3 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client.cpython-310.pyc
ADDED
|
Binary file (12.8 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client_config.cpython-310.pyc
ADDED
|
Binary file (946 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_rest_client_async.cpython-310.pyc
ADDED
|
Binary file (11.2 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers.cpython-310.pyc
ADDED
|
Binary file (2.28 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_async.cpython-310.pyc
ADDED
|
Binary file (2.52 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_base.cpython-310.pyc
ADDED
|
Binary file (2.6 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/abstract_operations_base_client.py
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
from collections import OrderedDict
|
| 17 |
+
import os
|
| 18 |
+
import re
|
| 19 |
+
from typing import Dict, Optional, Type, Union
|
| 20 |
+
|
| 21 |
+
from google.api_core import client_options as client_options_lib # type: ignore
|
| 22 |
+
from google.api_core import gapic_v1 # type: ignore
|
| 23 |
+
from google.api_core.operations_v1.transports.base import (
|
| 24 |
+
DEFAULT_CLIENT_INFO,
|
| 25 |
+
OperationsTransport,
|
| 26 |
+
)
|
| 27 |
+
from google.api_core.operations_v1.transports.rest import OperationsRestTransport
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
from google.api_core.operations_v1.transports.rest_asyncio import (
|
| 31 |
+
AsyncOperationsRestTransport,
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
HAS_ASYNC_REST_DEPENDENCIES = True
|
| 35 |
+
except ImportError as e:
|
| 36 |
+
HAS_ASYNC_REST_DEPENDENCIES = False
|
| 37 |
+
ASYNC_REST_EXCEPTION = e
|
| 38 |
+
|
| 39 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 40 |
+
from google.auth.exceptions import MutualTLSChannelError # type: ignore
|
| 41 |
+
from google.auth.transport import mtls # type: ignore
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class AbstractOperationsBaseClientMeta(type):
|
| 45 |
+
"""Metaclass for the Operations Base client.
|
| 46 |
+
|
| 47 |
+
This provides base class-level methods for building and retrieving
|
| 48 |
+
support objects (e.g. transport) without polluting the client instance
|
| 49 |
+
objects.
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[OperationsTransport]]
|
| 53 |
+
_transport_registry["rest"] = OperationsRestTransport
|
| 54 |
+
if HAS_ASYNC_REST_DEPENDENCIES:
|
| 55 |
+
_transport_registry["rest_asyncio"] = AsyncOperationsRestTransport
|
| 56 |
+
|
| 57 |
+
def get_transport_class(
|
| 58 |
+
cls,
|
| 59 |
+
label: Optional[str] = None,
|
| 60 |
+
) -> Type[OperationsTransport]:
|
| 61 |
+
"""Returns an appropriate transport class.
|
| 62 |
+
|
| 63 |
+
Args:
|
| 64 |
+
label: The name of the desired transport. If none is
|
| 65 |
+
provided, then the first transport in the registry is used.
|
| 66 |
+
|
| 67 |
+
Returns:
|
| 68 |
+
The transport class to use.
|
| 69 |
+
"""
|
| 70 |
+
# If a specific transport is requested, return that one.
|
| 71 |
+
if (
|
| 72 |
+
label == "rest_asyncio" and not HAS_ASYNC_REST_DEPENDENCIES
|
| 73 |
+
): # pragma: NO COVER
|
| 74 |
+
raise ASYNC_REST_EXCEPTION
|
| 75 |
+
|
| 76 |
+
if label:
|
| 77 |
+
return cls._transport_registry[label]
|
| 78 |
+
|
| 79 |
+
# No transport is requested; return the default (that is, the first one
|
| 80 |
+
# in the dictionary).
|
| 81 |
+
return next(iter(cls._transport_registry.values()))
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class AbstractOperationsBaseClient(metaclass=AbstractOperationsBaseClientMeta):
|
| 85 |
+
"""Manages long-running operations with an API service.
|
| 86 |
+
|
| 87 |
+
When an API method normally takes long time to complete, it can be
|
| 88 |
+
designed to return [Operation][google.api_core.operations_v1.Operation] to the
|
| 89 |
+
client, and the client can use this interface to receive the real
|
| 90 |
+
response asynchronously by polling the operation resource, or pass
|
| 91 |
+
the operation resource to another API (such as Google Cloud Pub/Sub
|
| 92 |
+
API) to receive the response. Any API service that returns
|
| 93 |
+
long-running operations should implement the ``Operations``
|
| 94 |
+
interface so developers can have a consistent client experience.
|
| 95 |
+
"""
|
| 96 |
+
|
| 97 |
+
@staticmethod
|
| 98 |
+
def _get_default_mtls_endpoint(api_endpoint):
|
| 99 |
+
"""Converts api endpoint to mTLS endpoint.
|
| 100 |
+
|
| 101 |
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
| 102 |
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
| 103 |
+
Args:
|
| 104 |
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
| 105 |
+
Returns:
|
| 106 |
+
str: converted mTLS api endpoint.
|
| 107 |
+
"""
|
| 108 |
+
if not api_endpoint:
|
| 109 |
+
return api_endpoint
|
| 110 |
+
|
| 111 |
+
mtls_endpoint_re = re.compile(
|
| 112 |
+
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
m = mtls_endpoint_re.match(api_endpoint)
|
| 116 |
+
name, mtls, sandbox, googledomain = m.groups()
|
| 117 |
+
if mtls or not googledomain:
|
| 118 |
+
return api_endpoint
|
| 119 |
+
|
| 120 |
+
if sandbox:
|
| 121 |
+
return api_endpoint.replace(
|
| 122 |
+
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
| 126 |
+
|
| 127 |
+
DEFAULT_ENDPOINT = "longrunning.googleapis.com"
|
| 128 |
+
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
|
| 129 |
+
DEFAULT_ENDPOINT
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
@classmethod
|
| 133 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 134 |
+
"""
|
| 135 |
+
This class method should be overridden by the subclasses.
|
| 136 |
+
|
| 137 |
+
Args:
|
| 138 |
+
info (dict): The service account private key info.
|
| 139 |
+
args: Additional arguments to pass to the constructor.
|
| 140 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 141 |
+
|
| 142 |
+
Raises:
|
| 143 |
+
NotImplementedError: If the method is called on the base class.
|
| 144 |
+
"""
|
| 145 |
+
raise NotImplementedError("`from_service_account_info` is not implemented.")
|
| 146 |
+
|
| 147 |
+
@classmethod
|
| 148 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 149 |
+
"""
|
| 150 |
+
This class method should be overridden by the subclasses.
|
| 151 |
+
|
| 152 |
+
Args:
|
| 153 |
+
filename (str): The path to the service account private key json
|
| 154 |
+
file.
|
| 155 |
+
args: Additional arguments to pass to the constructor.
|
| 156 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 157 |
+
|
| 158 |
+
Raises:
|
| 159 |
+
NotImplementedError: If the method is called on the base class.
|
| 160 |
+
"""
|
| 161 |
+
raise NotImplementedError("`from_service_account_file` is not implemented.")
|
| 162 |
+
|
| 163 |
+
from_service_account_json = from_service_account_file
|
| 164 |
+
|
| 165 |
+
@property
|
| 166 |
+
def transport(self) -> OperationsTransport:
|
| 167 |
+
"""Returns the transport used by the client instance.
|
| 168 |
+
|
| 169 |
+
Returns:
|
| 170 |
+
OperationsTransport: The transport used by the client
|
| 171 |
+
instance.
|
| 172 |
+
"""
|
| 173 |
+
return self._transport
|
| 174 |
+
|
| 175 |
+
@staticmethod
|
| 176 |
+
def common_billing_account_path(
|
| 177 |
+
billing_account: str,
|
| 178 |
+
) -> str:
|
| 179 |
+
"""Returns a fully-qualified billing_account string."""
|
| 180 |
+
return "billingAccounts/{billing_account}".format(
|
| 181 |
+
billing_account=billing_account,
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
@staticmethod
|
| 185 |
+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
|
| 186 |
+
"""Parse a billing_account path into its component segments."""
|
| 187 |
+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
|
| 188 |
+
return m.groupdict() if m else {}
|
| 189 |
+
|
| 190 |
+
@staticmethod
|
| 191 |
+
def common_folder_path(
|
| 192 |
+
folder: str,
|
| 193 |
+
) -> str:
|
| 194 |
+
"""Returns a fully-qualified folder string."""
|
| 195 |
+
return "folders/{folder}".format(
|
| 196 |
+
folder=folder,
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
@staticmethod
|
| 200 |
+
def parse_common_folder_path(path: str) -> Dict[str, str]:
|
| 201 |
+
"""Parse a folder path into its component segments."""
|
| 202 |
+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
|
| 203 |
+
return m.groupdict() if m else {}
|
| 204 |
+
|
| 205 |
+
@staticmethod
|
| 206 |
+
def common_organization_path(
|
| 207 |
+
organization: str,
|
| 208 |
+
) -> str:
|
| 209 |
+
"""Returns a fully-qualified organization string."""
|
| 210 |
+
return "organizations/{organization}".format(
|
| 211 |
+
organization=organization,
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
+
@staticmethod
|
| 215 |
+
def parse_common_organization_path(path: str) -> Dict[str, str]:
|
| 216 |
+
"""Parse a organization path into its component segments."""
|
| 217 |
+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
|
| 218 |
+
return m.groupdict() if m else {}
|
| 219 |
+
|
| 220 |
+
@staticmethod
|
| 221 |
+
def common_project_path(
|
| 222 |
+
project: str,
|
| 223 |
+
) -> str:
|
| 224 |
+
"""Returns a fully-qualified project string."""
|
| 225 |
+
return "projects/{project}".format(
|
| 226 |
+
project=project,
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
@staticmethod
|
| 230 |
+
def parse_common_project_path(path: str) -> Dict[str, str]:
|
| 231 |
+
"""Parse a project path into its component segments."""
|
| 232 |
+
m = re.match(r"^projects/(?P<project>.+?)$", path)
|
| 233 |
+
return m.groupdict() if m else {}
|
| 234 |
+
|
| 235 |
+
@staticmethod
|
| 236 |
+
def common_location_path(
|
| 237 |
+
project: str,
|
| 238 |
+
location: str,
|
| 239 |
+
) -> str:
|
| 240 |
+
"""Returns a fully-qualified location string."""
|
| 241 |
+
return "projects/{project}/locations/{location}".format(
|
| 242 |
+
project=project,
|
| 243 |
+
location=location,
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
@staticmethod
|
| 247 |
+
def parse_common_location_path(path: str) -> Dict[str, str]:
|
| 248 |
+
"""Parse a location path into its component segments."""
|
| 249 |
+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
|
| 250 |
+
return m.groupdict() if m else {}
|
| 251 |
+
|
| 252 |
+
def __init__(
|
| 253 |
+
self,
|
| 254 |
+
*,
|
| 255 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 256 |
+
transport: Union[str, OperationsTransport, None] = None,
|
| 257 |
+
client_options: Optional[client_options_lib.ClientOptions] = None,
|
| 258 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 259 |
+
) -> None:
|
| 260 |
+
"""Instantiates the operations client.
|
| 261 |
+
|
| 262 |
+
Args:
|
| 263 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 264 |
+
authorization credentials to attach to requests. These
|
| 265 |
+
credentials identify the application to the service; if none
|
| 266 |
+
are specified, the client will attempt to ascertain the
|
| 267 |
+
credentials from the environment.
|
| 268 |
+
transport (Union[str, OperationsTransport]): The
|
| 269 |
+
transport to use. If set to None, a transport is chosen
|
| 270 |
+
automatically.
|
| 271 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 272 |
+
client. It won't take effect if a ``transport`` instance is provided.
|
| 273 |
+
(1) The ``api_endpoint`` property can be used to override the
|
| 274 |
+
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
|
| 275 |
+
environment variable can also be used to override the endpoint:
|
| 276 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 277 |
+
use the default regular endpoint) and "auto" (auto switch to the
|
| 278 |
+
default mTLS endpoint if client certificate is present, this is
|
| 279 |
+
the default value). However, the ``api_endpoint`` property takes
|
| 280 |
+
precedence if provided.
|
| 281 |
+
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 282 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 283 |
+
to provide client certificate for mutual TLS transport. If
|
| 284 |
+
not provided, the default SSL client certificate will be used if
|
| 285 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 286 |
+
set, no client certificate will be used.
|
| 287 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 288 |
+
The client info used to send a user-agent string along with
|
| 289 |
+
API requests. If ``None``, then default info will be used.
|
| 290 |
+
Generally, you only need to set this if you're developing
|
| 291 |
+
your own client library.
|
| 292 |
+
|
| 293 |
+
Raises:
|
| 294 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 295 |
+
creation failed for any reason.
|
| 296 |
+
"""
|
| 297 |
+
if isinstance(client_options, dict):
|
| 298 |
+
client_options = client_options_lib.from_dict(client_options)
|
| 299 |
+
if client_options is None:
|
| 300 |
+
client_options = client_options_lib.ClientOptions()
|
| 301 |
+
|
| 302 |
+
# Create SSL credentials for mutual TLS if needed.
|
| 303 |
+
use_client_cert = os.getenv(
|
| 304 |
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
| 305 |
+
).lower()
|
| 306 |
+
if use_client_cert not in ("true", "false"):
|
| 307 |
+
raise ValueError(
|
| 308 |
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
|
| 309 |
+
)
|
| 310 |
+
client_cert_source_func = None
|
| 311 |
+
is_mtls = False
|
| 312 |
+
if use_client_cert == "true":
|
| 313 |
+
if client_options.client_cert_source:
|
| 314 |
+
is_mtls = True
|
| 315 |
+
client_cert_source_func = client_options.client_cert_source
|
| 316 |
+
else:
|
| 317 |
+
is_mtls = mtls.has_default_client_cert_source()
|
| 318 |
+
if is_mtls:
|
| 319 |
+
client_cert_source_func = mtls.default_client_cert_source()
|
| 320 |
+
else:
|
| 321 |
+
client_cert_source_func = None
|
| 322 |
+
|
| 323 |
+
# Figure out which api endpoint to use.
|
| 324 |
+
if client_options.api_endpoint is not None:
|
| 325 |
+
api_endpoint = client_options.api_endpoint
|
| 326 |
+
else:
|
| 327 |
+
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
| 328 |
+
if use_mtls_env == "never":
|
| 329 |
+
api_endpoint = self.DEFAULT_ENDPOINT
|
| 330 |
+
elif use_mtls_env == "always":
|
| 331 |
+
api_endpoint = self.DEFAULT_MTLS_ENDPOINT
|
| 332 |
+
elif use_mtls_env == "auto":
|
| 333 |
+
if is_mtls:
|
| 334 |
+
api_endpoint = self.DEFAULT_MTLS_ENDPOINT
|
| 335 |
+
else:
|
| 336 |
+
api_endpoint = self.DEFAULT_ENDPOINT
|
| 337 |
+
else:
|
| 338 |
+
raise MutualTLSChannelError(
|
| 339 |
+
"Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted "
|
| 340 |
+
"values: never, auto, always"
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
# Save or instantiate the transport.
|
| 344 |
+
# Ordinarily, we provide the transport, but allowing a custom transport
|
| 345 |
+
# instance provides an extensibility point for unusual situations.
|
| 346 |
+
if isinstance(transport, OperationsTransport):
|
| 347 |
+
# transport is a OperationsTransport instance.
|
| 348 |
+
if credentials or client_options.credentials_file:
|
| 349 |
+
raise ValueError(
|
| 350 |
+
"When providing a transport instance, "
|
| 351 |
+
"provide its credentials directly."
|
| 352 |
+
)
|
| 353 |
+
if client_options.scopes:
|
| 354 |
+
raise ValueError(
|
| 355 |
+
"When providing a transport instance, provide its scopes "
|
| 356 |
+
"directly."
|
| 357 |
+
)
|
| 358 |
+
self._transport = transport
|
| 359 |
+
else:
|
| 360 |
+
Transport = type(self).get_transport_class(transport)
|
| 361 |
+
self._transport = Transport(
|
| 362 |
+
credentials=credentials,
|
| 363 |
+
credentials_file=client_options.credentials_file,
|
| 364 |
+
host=api_endpoint,
|
| 365 |
+
scopes=client_options.scopes,
|
| 366 |
+
client_cert_source_for_mtls=client_cert_source_func,
|
| 367 |
+
quota_project_id=client_options.quota_project_id,
|
| 368 |
+
client_info=client_info,
|
| 369 |
+
always_use_jwt_access=True,
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2020 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from typing import Optional, Sequence, Tuple, Union
|
| 17 |
+
|
| 18 |
+
from google.api_core import client_options as client_options_lib # type: ignore
|
| 19 |
+
from google.api_core import gapic_v1 # type: ignore
|
| 20 |
+
from google.api_core import retry as retries # type: ignore
|
| 21 |
+
from google.api_core.operations_v1 import pagers
|
| 22 |
+
from google.api_core.operations_v1.transports.base import (
|
| 23 |
+
DEFAULT_CLIENT_INFO,
|
| 24 |
+
OperationsTransport,
|
| 25 |
+
)
|
| 26 |
+
from google.api_core.operations_v1.abstract_operations_base_client import (
|
| 27 |
+
AbstractOperationsBaseClient,
|
| 28 |
+
)
|
| 29 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 30 |
+
from google.longrunning import operations_pb2
|
| 31 |
+
from google.oauth2 import service_account # type: ignore
|
| 32 |
+
import grpc
|
| 33 |
+
|
| 34 |
+
OptionalRetry = Union[retries.Retry, object]
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class AbstractOperationsClient(AbstractOperationsBaseClient):
|
| 38 |
+
"""Manages long-running operations with an API service.
|
| 39 |
+
|
| 40 |
+
When an API method normally takes long time to complete, it can be
|
| 41 |
+
designed to return [Operation][google.api_core.operations_v1.Operation] to the
|
| 42 |
+
client, and the client can use this interface to receive the real
|
| 43 |
+
response asynchronously by polling the operation resource, or pass
|
| 44 |
+
the operation resource to another API (such as Google Cloud Pub/Sub
|
| 45 |
+
API) to receive the response. Any API service that returns
|
| 46 |
+
long-running operations should implement the ``Operations``
|
| 47 |
+
interface so developers can have a consistent client experience.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
def __init__(
|
| 51 |
+
self,
|
| 52 |
+
*,
|
| 53 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 54 |
+
transport: Union[str, OperationsTransport, None] = None,
|
| 55 |
+
client_options: Optional[client_options_lib.ClientOptions] = None,
|
| 56 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 57 |
+
) -> None:
|
| 58 |
+
"""Instantiates the operations client.
|
| 59 |
+
|
| 60 |
+
Args:
|
| 61 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 62 |
+
authorization credentials to attach to requests. These
|
| 63 |
+
credentials identify the application to the service; if none
|
| 64 |
+
are specified, the client will attempt to ascertain the
|
| 65 |
+
credentials from the environment.
|
| 66 |
+
transport (Union[str, OperationsTransport]): The
|
| 67 |
+
transport to use. If set to None, a transport is chosen
|
| 68 |
+
automatically.
|
| 69 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 70 |
+
client. It won't take effect if a ``transport`` instance is provided.
|
| 71 |
+
(1) The ``api_endpoint`` property can be used to override the
|
| 72 |
+
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
|
| 73 |
+
environment variable can also be used to override the endpoint:
|
| 74 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 75 |
+
use the default regular endpoint) and "auto" (auto switch to the
|
| 76 |
+
default mTLS endpoint if client certificate is present, this is
|
| 77 |
+
the default value). However, the ``api_endpoint`` property takes
|
| 78 |
+
precedence if provided.
|
| 79 |
+
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 80 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 81 |
+
to provide client certificate for mutual TLS transport. If
|
| 82 |
+
not provided, the default SSL client certificate will be used if
|
| 83 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 84 |
+
set, no client certificate will be used.
|
| 85 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 86 |
+
The client info used to send a user-agent string along with
|
| 87 |
+
API requests. If ``None``, then default info will be used.
|
| 88 |
+
Generally, you only need to set this if you're developing
|
| 89 |
+
your own client library.
|
| 90 |
+
|
| 91 |
+
Raises:
|
| 92 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 93 |
+
creation failed for any reason.
|
| 94 |
+
"""
|
| 95 |
+
super().__init__(
|
| 96 |
+
credentials=credentials,
|
| 97 |
+
transport=transport,
|
| 98 |
+
client_options=client_options,
|
| 99 |
+
client_info=client_info,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
@classmethod
|
| 103 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 104 |
+
"""Creates an instance of this client using the provided credentials
|
| 105 |
+
info.
|
| 106 |
+
|
| 107 |
+
Args:
|
| 108 |
+
info (dict): The service account private key info.
|
| 109 |
+
args: Additional arguments to pass to the constructor.
|
| 110 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 111 |
+
|
| 112 |
+
Returns:
|
| 113 |
+
AbstractOperationsClient: The constructed client.
|
| 114 |
+
"""
|
| 115 |
+
credentials = service_account.Credentials.from_service_account_info(info)
|
| 116 |
+
kwargs["credentials"] = credentials
|
| 117 |
+
return cls(*args, **kwargs)
|
| 118 |
+
|
| 119 |
+
@classmethod
|
| 120 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 121 |
+
"""Creates an instance of this client using the provided credentials
|
| 122 |
+
file.
|
| 123 |
+
|
| 124 |
+
Args:
|
| 125 |
+
filename (str): The path to the service account private key json
|
| 126 |
+
file.
|
| 127 |
+
args: Additional arguments to pass to the constructor.
|
| 128 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 129 |
+
|
| 130 |
+
Returns:
|
| 131 |
+
AbstractOperationsClient: The constructed client.
|
| 132 |
+
"""
|
| 133 |
+
credentials = service_account.Credentials.from_service_account_file(filename)
|
| 134 |
+
kwargs["credentials"] = credentials
|
| 135 |
+
return cls(*args, **kwargs)
|
| 136 |
+
|
| 137 |
+
from_service_account_json = from_service_account_file
|
| 138 |
+
|
| 139 |
+
def list_operations(
|
| 140 |
+
self,
|
| 141 |
+
name: str,
|
| 142 |
+
filter_: Optional[str] = None,
|
| 143 |
+
*,
|
| 144 |
+
page_size: Optional[int] = None,
|
| 145 |
+
page_token: Optional[str] = None,
|
| 146 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 147 |
+
timeout: Optional[float] = None,
|
| 148 |
+
compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
|
| 149 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 150 |
+
) -> pagers.ListOperationsPager:
|
| 151 |
+
r"""Lists operations that match the specified filter in the request.
|
| 152 |
+
If the server doesn't support this method, it returns
|
| 153 |
+
``UNIMPLEMENTED``.
|
| 154 |
+
|
| 155 |
+
NOTE: the ``name`` binding allows API services to override the
|
| 156 |
+
binding to use different resource name schemes, such as
|
| 157 |
+
``users/*/operations``. To override the binding, API services
|
| 158 |
+
can add a binding such as ``"/v1/{name=users/*}/operations"`` to
|
| 159 |
+
their service configuration. For backwards compatibility, the
|
| 160 |
+
default name includes the operations collection id, however
|
| 161 |
+
overriding users must ensure the name binding is the parent
|
| 162 |
+
resource, without the operations collection id.
|
| 163 |
+
|
| 164 |
+
Args:
|
| 165 |
+
name (str):
|
| 166 |
+
The name of the operation's parent
|
| 167 |
+
resource.
|
| 168 |
+
filter_ (str):
|
| 169 |
+
The standard list filter.
|
| 170 |
+
This corresponds to the ``filter`` field
|
| 171 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 172 |
+
should not be set.
|
| 173 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 174 |
+
should be retried.
|
| 175 |
+
timeout (float): The timeout for this request.
|
| 176 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 177 |
+
sent along with the request as metadata.
|
| 178 |
+
|
| 179 |
+
Returns:
|
| 180 |
+
google.api_core.operations_v1.pagers.ListOperationsPager:
|
| 181 |
+
The response message for
|
| 182 |
+
[Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].
|
| 183 |
+
|
| 184 |
+
Iterating over this object will yield results and
|
| 185 |
+
resolve additional pages automatically.
|
| 186 |
+
|
| 187 |
+
"""
|
| 188 |
+
# Create a protobuf request object.
|
| 189 |
+
request = operations_pb2.ListOperationsRequest(name=name, filter=filter_)
|
| 190 |
+
if page_size is not None:
|
| 191 |
+
request.page_size = page_size
|
| 192 |
+
if page_token is not None:
|
| 193 |
+
request.page_token = page_token
|
| 194 |
+
|
| 195 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 196 |
+
# and friendly error handling.
|
| 197 |
+
rpc = self._transport._wrapped_methods[self._transport.list_operations]
|
| 198 |
+
|
| 199 |
+
# Certain fields should be provided within the metadata header;
|
| 200 |
+
# add these here.
|
| 201 |
+
metadata = tuple(metadata or ()) + (
|
| 202 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
# Send the request.
|
| 206 |
+
response = rpc(
|
| 207 |
+
request,
|
| 208 |
+
retry=retry,
|
| 209 |
+
timeout=timeout,
|
| 210 |
+
compression=compression,
|
| 211 |
+
metadata=metadata,
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
+
# This method is paged; wrap the response in a pager, which provides
|
| 215 |
+
# an `__iter__` convenience method.
|
| 216 |
+
response = pagers.ListOperationsPager(
|
| 217 |
+
method=rpc,
|
| 218 |
+
request=request,
|
| 219 |
+
response=response,
|
| 220 |
+
metadata=metadata,
|
| 221 |
+
)
|
| 222 |
+
|
| 223 |
+
# Done; return the response.
|
| 224 |
+
return response
|
| 225 |
+
|
| 226 |
+
def get_operation(
|
| 227 |
+
self,
|
| 228 |
+
name: str,
|
| 229 |
+
*,
|
| 230 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 231 |
+
timeout: Optional[float] = None,
|
| 232 |
+
compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
|
| 233 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 234 |
+
) -> operations_pb2.Operation:
|
| 235 |
+
r"""Gets the latest state of a long-running operation.
|
| 236 |
+
Clients can use this method to poll the operation result
|
| 237 |
+
at intervals as recommended by the API service.
|
| 238 |
+
|
| 239 |
+
Args:
|
| 240 |
+
name (str):
|
| 241 |
+
The name of the operation resource.
|
| 242 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 243 |
+
should be retried.
|
| 244 |
+
timeout (float): The timeout for this request.
|
| 245 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 246 |
+
sent along with the request as metadata.
|
| 247 |
+
|
| 248 |
+
Returns:
|
| 249 |
+
google.longrunning.operations_pb2.Operation:
|
| 250 |
+
This resource represents a long-
|
| 251 |
+
running operation that is the result of a
|
| 252 |
+
network API call.
|
| 253 |
+
|
| 254 |
+
"""
|
| 255 |
+
|
| 256 |
+
request = operations_pb2.GetOperationRequest(name=name)
|
| 257 |
+
|
| 258 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 259 |
+
# and friendly error handling.
|
| 260 |
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
| 261 |
+
|
| 262 |
+
# Certain fields should be provided within the metadata header;
|
| 263 |
+
# add these here.
|
| 264 |
+
metadata = tuple(metadata or ()) + (
|
| 265 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# Send the request.
|
| 269 |
+
response = rpc(
|
| 270 |
+
request,
|
| 271 |
+
retry=retry,
|
| 272 |
+
timeout=timeout,
|
| 273 |
+
compression=compression,
|
| 274 |
+
metadata=metadata,
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
# Done; return the response.
|
| 278 |
+
return response
|
| 279 |
+
|
| 280 |
+
def delete_operation(
|
| 281 |
+
self,
|
| 282 |
+
name: str,
|
| 283 |
+
*,
|
| 284 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 285 |
+
timeout: Optional[float] = None,
|
| 286 |
+
compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
|
| 287 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 288 |
+
) -> None:
|
| 289 |
+
r"""Deletes a long-running operation. This method indicates that the
|
| 290 |
+
client is no longer interested in the operation result. It does
|
| 291 |
+
not cancel the operation. If the server doesn't support this
|
| 292 |
+
method, it returns ``google.rpc.Code.UNIMPLEMENTED``.
|
| 293 |
+
|
| 294 |
+
Args:
|
| 295 |
+
name (str):
|
| 296 |
+
The name of the operation resource to
|
| 297 |
+
be deleted.
|
| 298 |
+
|
| 299 |
+
This corresponds to the ``name`` field
|
| 300 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 301 |
+
should not be set.
|
| 302 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 303 |
+
should be retried.
|
| 304 |
+
timeout (float): The timeout for this request.
|
| 305 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 306 |
+
sent along with the request as metadata.
|
| 307 |
+
"""
|
| 308 |
+
# Create the request object.
|
| 309 |
+
request = operations_pb2.DeleteOperationRequest(name=name)
|
| 310 |
+
|
| 311 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 312 |
+
# and friendly error handling.
|
| 313 |
+
rpc = self._transport._wrapped_methods[self._transport.delete_operation]
|
| 314 |
+
|
| 315 |
+
# Certain fields should be provided within the metadata header;
|
| 316 |
+
# add these here.
|
| 317 |
+
metadata = tuple(metadata or ()) + (
|
| 318 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 319 |
+
)
|
| 320 |
+
|
| 321 |
+
# Send the request.
|
| 322 |
+
rpc(
|
| 323 |
+
request,
|
| 324 |
+
retry=retry,
|
| 325 |
+
timeout=timeout,
|
| 326 |
+
compression=compression,
|
| 327 |
+
metadata=metadata,
|
| 328 |
+
)
|
| 329 |
+
|
| 330 |
+
def cancel_operation(
|
| 331 |
+
self,
|
| 332 |
+
name: Optional[str] = None,
|
| 333 |
+
*,
|
| 334 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 335 |
+
timeout: Optional[float] = None,
|
| 336 |
+
compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
|
| 337 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 338 |
+
) -> None:
|
| 339 |
+
r"""Starts asynchronous cancellation on a long-running operation.
|
| 340 |
+
The server makes a best effort to cancel the operation, but
|
| 341 |
+
success is not guaranteed. If the server doesn't support this
|
| 342 |
+
method, it returns ``google.rpc.Code.UNIMPLEMENTED``. Clients
|
| 343 |
+
can use
|
| 344 |
+
[Operations.GetOperation][google.api_core.operations_v1.Operations.GetOperation]
|
| 345 |
+
or other methods to check whether the cancellation succeeded or
|
| 346 |
+
whether the operation completed despite cancellation. On
|
| 347 |
+
successful cancellation, the operation is not deleted; instead,
|
| 348 |
+
it becomes an operation with an
|
| 349 |
+
[Operation.error][google.api_core.operations_v1.Operation.error] value with
|
| 350 |
+
a [google.rpc.Status.code][google.rpc.Status.code] of 1,
|
| 351 |
+
corresponding to ``Code.CANCELLED``.
|
| 352 |
+
|
| 353 |
+
Args:
|
| 354 |
+
name (str):
|
| 355 |
+
The name of the operation resource to
|
| 356 |
+
be cancelled.
|
| 357 |
+
|
| 358 |
+
This corresponds to the ``name`` field
|
| 359 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 360 |
+
should not be set.
|
| 361 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 362 |
+
should be retried.
|
| 363 |
+
timeout (float): The timeout for this request.
|
| 364 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 365 |
+
sent along with the request as metadata.
|
| 366 |
+
"""
|
| 367 |
+
# Create the request object.
|
| 368 |
+
request = operations_pb2.CancelOperationRequest(name=name)
|
| 369 |
+
|
| 370 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 371 |
+
# and friendly error handling.
|
| 372 |
+
rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
|
| 373 |
+
|
| 374 |
+
# Certain fields should be provided within the metadata header;
|
| 375 |
+
# add these here.
|
| 376 |
+
metadata = tuple(metadata or ()) + (
|
| 377 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 378 |
+
)
|
| 379 |
+
|
| 380 |
+
# Send the request.
|
| 381 |
+
rpc(
|
| 382 |
+
request,
|
| 383 |
+
retry=retry,
|
| 384 |
+
timeout=timeout,
|
| 385 |
+
compression=compression,
|
| 386 |
+
metadata=metadata,
|
| 387 |
+
)
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_async_client.py
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""An async client for the google.longrunning.operations meta-API.
|
| 16 |
+
|
| 17 |
+
.. _Google API Style Guide:
|
| 18 |
+
https://cloud.google.com/apis/design/design_pattern
|
| 19 |
+
s#long_running_operations
|
| 20 |
+
.. _google/longrunning/operations.proto:
|
| 21 |
+
https://github.com/googleapis/googleapis/blob/master/google/longrunning
|
| 22 |
+
/operations.proto
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
import functools
|
| 26 |
+
|
| 27 |
+
from google.api_core import exceptions as core_exceptions
|
| 28 |
+
from google.api_core import gapic_v1, page_iterator_async
|
| 29 |
+
from google.api_core import retry_async as retries
|
| 30 |
+
from google.api_core import timeout as timeouts
|
| 31 |
+
from google.longrunning import operations_pb2
|
| 32 |
+
from grpc import Compression
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class OperationsAsyncClient:
|
| 36 |
+
"""Async client for interacting with long-running operations.
|
| 37 |
+
|
| 38 |
+
Args:
|
| 39 |
+
channel (aio.Channel): The gRPC AsyncIO channel associated with the
|
| 40 |
+
service that implements the ``google.longrunning.operations``
|
| 41 |
+
interface.
|
| 42 |
+
client_config (dict):
|
| 43 |
+
A dictionary of call options for each method. If not specified
|
| 44 |
+
the default configuration is used.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
def __init__(self, channel, client_config=None):
|
| 48 |
+
# Create the gRPC client stub with gRPC AsyncIO channel.
|
| 49 |
+
self.operations_stub = operations_pb2.OperationsStub(channel)
|
| 50 |
+
|
| 51 |
+
default_retry = retries.AsyncRetry(
|
| 52 |
+
initial=0.1, # seconds
|
| 53 |
+
maximum=60.0, # seconds
|
| 54 |
+
multiplier=1.3,
|
| 55 |
+
predicate=retries.if_exception_type(
|
| 56 |
+
core_exceptions.DeadlineExceeded,
|
| 57 |
+
core_exceptions.ServiceUnavailable,
|
| 58 |
+
),
|
| 59 |
+
timeout=600.0, # seconds
|
| 60 |
+
)
|
| 61 |
+
default_timeout = timeouts.TimeToDeadlineTimeout(timeout=600.0)
|
| 62 |
+
|
| 63 |
+
default_compression = Compression.NoCompression
|
| 64 |
+
|
| 65 |
+
self._get_operation = gapic_v1.method_async.wrap_method(
|
| 66 |
+
self.operations_stub.GetOperation,
|
| 67 |
+
default_retry=default_retry,
|
| 68 |
+
default_timeout=default_timeout,
|
| 69 |
+
default_compression=default_compression,
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
self._list_operations = gapic_v1.method_async.wrap_method(
|
| 73 |
+
self.operations_stub.ListOperations,
|
| 74 |
+
default_retry=default_retry,
|
| 75 |
+
default_timeout=default_timeout,
|
| 76 |
+
default_compression=default_compression,
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
self._cancel_operation = gapic_v1.method_async.wrap_method(
|
| 80 |
+
self.operations_stub.CancelOperation,
|
| 81 |
+
default_retry=default_retry,
|
| 82 |
+
default_timeout=default_timeout,
|
| 83 |
+
default_compression=default_compression,
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
self._delete_operation = gapic_v1.method_async.wrap_method(
|
| 87 |
+
self.operations_stub.DeleteOperation,
|
| 88 |
+
default_retry=default_retry,
|
| 89 |
+
default_timeout=default_timeout,
|
| 90 |
+
default_compression=default_compression,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
async def get_operation(
|
| 94 |
+
self,
|
| 95 |
+
name,
|
| 96 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 97 |
+
timeout=gapic_v1.method_async.DEFAULT,
|
| 98 |
+
compression=gapic_v1.method_async.DEFAULT,
|
| 99 |
+
metadata=None,
|
| 100 |
+
):
|
| 101 |
+
"""Gets the latest state of a long-running operation.
|
| 102 |
+
|
| 103 |
+
Clients can use this method to poll the operation result at intervals
|
| 104 |
+
as recommended by the API service.
|
| 105 |
+
|
| 106 |
+
Example:
|
| 107 |
+
>>> from google.api_core import operations_v1
|
| 108 |
+
>>> api = operations_v1.OperationsClient()
|
| 109 |
+
>>> name = ''
|
| 110 |
+
>>> response = await api.get_operation(name)
|
| 111 |
+
|
| 112 |
+
Args:
|
| 113 |
+
name (str): The name of the operation resource.
|
| 114 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 115 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 116 |
+
the client configuration will be used. If ``None``, then this
|
| 117 |
+
method will not retry the RPC at all.
|
| 118 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 119 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 120 |
+
applies to each individual attempt and the overall time it
|
| 121 |
+
takes for this method to complete may be longer. If
|
| 122 |
+
unspecified, the the default timeout in the client
|
| 123 |
+
configuration is used. If ``None``, then the RPC method will
|
| 124 |
+
not time out.
|
| 125 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 126 |
+
e.g. grpc.compression.Gzip.
|
| 127 |
+
metadata (Optional[List[Tuple[str, str]]]):
|
| 128 |
+
Additional gRPC metadata.
|
| 129 |
+
|
| 130 |
+
Returns:
|
| 131 |
+
google.longrunning.operations_pb2.Operation: The state of the
|
| 132 |
+
operation.
|
| 133 |
+
|
| 134 |
+
Raises:
|
| 135 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 136 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 137 |
+
subclass will be raised.
|
| 138 |
+
"""
|
| 139 |
+
request = operations_pb2.GetOperationRequest(name=name)
|
| 140 |
+
|
| 141 |
+
# Add routing header
|
| 142 |
+
metadata = metadata or []
|
| 143 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 144 |
+
|
| 145 |
+
return await self._get_operation(
|
| 146 |
+
request,
|
| 147 |
+
retry=retry,
|
| 148 |
+
timeout=timeout,
|
| 149 |
+
compression=compression,
|
| 150 |
+
metadata=metadata,
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
async def list_operations(
|
| 154 |
+
self,
|
| 155 |
+
name,
|
| 156 |
+
filter_,
|
| 157 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 158 |
+
timeout=gapic_v1.method_async.DEFAULT,
|
| 159 |
+
compression=gapic_v1.method_async.DEFAULT,
|
| 160 |
+
metadata=None,
|
| 161 |
+
):
|
| 162 |
+
"""
|
| 163 |
+
Lists operations that match the specified filter in the request.
|
| 164 |
+
|
| 165 |
+
Example:
|
| 166 |
+
>>> from google.api_core import operations_v1
|
| 167 |
+
>>> api = operations_v1.OperationsClient()
|
| 168 |
+
>>> name = ''
|
| 169 |
+
>>>
|
| 170 |
+
>>> # Iterate over all results
|
| 171 |
+
>>> for operation in await api.list_operations(name):
|
| 172 |
+
>>> # process operation
|
| 173 |
+
>>> pass
|
| 174 |
+
>>>
|
| 175 |
+
>>> # Or iterate over results one page at a time
|
| 176 |
+
>>> iter = await api.list_operations(name)
|
| 177 |
+
>>> for page in iter.pages:
|
| 178 |
+
>>> for operation in page:
|
| 179 |
+
>>> # process operation
|
| 180 |
+
>>> pass
|
| 181 |
+
|
| 182 |
+
Args:
|
| 183 |
+
name (str): The name of the operation collection.
|
| 184 |
+
filter_ (str): The standard list filter.
|
| 185 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 186 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 187 |
+
the client configuration will be used. If ``None``, then this
|
| 188 |
+
method will not retry the RPC at all.
|
| 189 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 190 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 191 |
+
applies to each individual attempt and the overall time it
|
| 192 |
+
takes for this method to complete may be longer. If
|
| 193 |
+
unspecified, the the default timeout in the client
|
| 194 |
+
configuration is used. If ``None``, then the RPC method will
|
| 195 |
+
not time out.
|
| 196 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 197 |
+
e.g. grpc.compression.Gzip.
|
| 198 |
+
metadata (Optional[List[Tuple[str, str]]]): Additional gRPC
|
| 199 |
+
metadata.
|
| 200 |
+
|
| 201 |
+
Returns:
|
| 202 |
+
google.api_core.page_iterator.Iterator: An iterator that yields
|
| 203 |
+
:class:`google.longrunning.operations_pb2.Operation` instances.
|
| 204 |
+
|
| 205 |
+
Raises:
|
| 206 |
+
google.api_core.exceptions.MethodNotImplemented: If the server
|
| 207 |
+
does not support this method. Services are not required to
|
| 208 |
+
implement this method.
|
| 209 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 210 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 211 |
+
subclass will be raised.
|
| 212 |
+
"""
|
| 213 |
+
# Create the request object.
|
| 214 |
+
request = operations_pb2.ListOperationsRequest(name=name, filter=filter_)
|
| 215 |
+
|
| 216 |
+
# Add routing header
|
| 217 |
+
metadata = metadata or []
|
| 218 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 219 |
+
|
| 220 |
+
# Create the method used to fetch pages
|
| 221 |
+
method = functools.partial(
|
| 222 |
+
self._list_operations,
|
| 223 |
+
retry=retry,
|
| 224 |
+
timeout=timeout,
|
| 225 |
+
compression=compression,
|
| 226 |
+
metadata=metadata,
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
iterator = page_iterator_async.AsyncGRPCIterator(
|
| 230 |
+
client=None,
|
| 231 |
+
method=method,
|
| 232 |
+
request=request,
|
| 233 |
+
items_field="operations",
|
| 234 |
+
request_token_field="page_token",
|
| 235 |
+
response_token_field="next_page_token",
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
return iterator
|
| 239 |
+
|
| 240 |
+
async def cancel_operation(
|
| 241 |
+
self,
|
| 242 |
+
name,
|
| 243 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 244 |
+
timeout=gapic_v1.method_async.DEFAULT,
|
| 245 |
+
compression=gapic_v1.method_async.DEFAULT,
|
| 246 |
+
metadata=None,
|
| 247 |
+
):
|
| 248 |
+
"""Starts asynchronous cancellation on a long-running operation.
|
| 249 |
+
|
| 250 |
+
The server makes a best effort to cancel the operation, but success is
|
| 251 |
+
not guaranteed. Clients can use :meth:`get_operation` or service-
|
| 252 |
+
specific methods to check whether the cancellation succeeded or whether
|
| 253 |
+
the operation completed despite cancellation. On successful
|
| 254 |
+
cancellation, the operation is not deleted; instead, it becomes an
|
| 255 |
+
operation with an ``Operation.error`` value with a
|
| 256 |
+
``google.rpc.Status.code`` of ``1``, corresponding to
|
| 257 |
+
``Code.CANCELLED``.
|
| 258 |
+
|
| 259 |
+
Example:
|
| 260 |
+
>>> from google.api_core import operations_v1
|
| 261 |
+
>>> api = operations_v1.OperationsClient()
|
| 262 |
+
>>> name = ''
|
| 263 |
+
>>> api.cancel_operation(name)
|
| 264 |
+
|
| 265 |
+
Args:
|
| 266 |
+
name (str): The name of the operation resource to be cancelled.
|
| 267 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 268 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 269 |
+
the client configuration will be used. If ``None``, then this
|
| 270 |
+
method will not retry the RPC at all.
|
| 271 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 272 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 273 |
+
applies to each individual attempt and the overall time it
|
| 274 |
+
takes for this method to complete may be longer. If
|
| 275 |
+
unspecified, the the default timeout in the client
|
| 276 |
+
configuration is used. If ``None``, then the RPC method will
|
| 277 |
+
not time out.
|
| 278 |
+
|
| 279 |
+
Raises:
|
| 280 |
+
google.api_core.exceptions.MethodNotImplemented: If the server
|
| 281 |
+
does not support this method. Services are not required to
|
| 282 |
+
implement this method.
|
| 283 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 284 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 285 |
+
subclass will be raised.
|
| 286 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 287 |
+
e.g. grpc.compression.Gzip.
|
| 288 |
+
metadata (Optional[List[Tuple[str, str]]]): Additional gRPC
|
| 289 |
+
metadata.
|
| 290 |
+
"""
|
| 291 |
+
# Create the request object.
|
| 292 |
+
request = operations_pb2.CancelOperationRequest(name=name)
|
| 293 |
+
|
| 294 |
+
# Add routing header
|
| 295 |
+
metadata = metadata or []
|
| 296 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 297 |
+
|
| 298 |
+
await self._cancel_operation(
|
| 299 |
+
request,
|
| 300 |
+
retry=retry,
|
| 301 |
+
timeout=timeout,
|
| 302 |
+
compression=compression,
|
| 303 |
+
metadata=metadata,
|
| 304 |
+
)
|
| 305 |
+
|
| 306 |
+
async def delete_operation(
|
| 307 |
+
self,
|
| 308 |
+
name,
|
| 309 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 310 |
+
timeout=gapic_v1.method_async.DEFAULT,
|
| 311 |
+
compression=gapic_v1.method_async.DEFAULT,
|
| 312 |
+
metadata=None,
|
| 313 |
+
):
|
| 314 |
+
"""Deletes a long-running operation.
|
| 315 |
+
|
| 316 |
+
This method indicates that the client is no longer interested in the
|
| 317 |
+
operation result. It does not cancel the operation.
|
| 318 |
+
|
| 319 |
+
Example:
|
| 320 |
+
>>> from google.api_core import operations_v1
|
| 321 |
+
>>> api = operations_v1.OperationsClient()
|
| 322 |
+
>>> name = ''
|
| 323 |
+
>>> api.delete_operation(name)
|
| 324 |
+
|
| 325 |
+
Args:
|
| 326 |
+
name (str): The name of the operation resource to be deleted.
|
| 327 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 328 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 329 |
+
the client configuration will be used. If ``None``, then this
|
| 330 |
+
method will not retry the RPC at all.
|
| 331 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 332 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 333 |
+
applies to each individual attempt and the overall time it
|
| 334 |
+
takes for this method to complete may be longer. If
|
| 335 |
+
unspecified, the the default timeout in the client
|
| 336 |
+
configuration is used. If ``None``, then the RPC method will
|
| 337 |
+
not time out.
|
| 338 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 339 |
+
e.g. grpc.compression.Gzip.
|
| 340 |
+
metadata (Optional[List[Tuple[str, str]]]): Additional gRPC
|
| 341 |
+
metadata.
|
| 342 |
+
|
| 343 |
+
Raises:
|
| 344 |
+
google.api_core.exceptions.MethodNotImplemented: If the server
|
| 345 |
+
does not support this method. Services are not required to
|
| 346 |
+
implement this method.
|
| 347 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 348 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 349 |
+
subclass will be raised.
|
| 350 |
+
"""
|
| 351 |
+
# Create the request object.
|
| 352 |
+
request = operations_pb2.DeleteOperationRequest(name=name)
|
| 353 |
+
|
| 354 |
+
# Add routing header
|
| 355 |
+
metadata = metadata or []
|
| 356 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 357 |
+
|
| 358 |
+
await self._delete_operation(
|
| 359 |
+
request,
|
| 360 |
+
retry=retry,
|
| 361 |
+
timeout=timeout,
|
| 362 |
+
compression=compression,
|
| 363 |
+
metadata=metadata,
|
| 364 |
+
)
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_client.py
ADDED
|
@@ -0,0 +1,378 @@
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""A client for the google.longrunning.operations meta-API.
|
| 16 |
+
|
| 17 |
+
This is a client that deals with long-running operations that follow the
|
| 18 |
+
pattern outlined by the `Google API Style Guide`_.
|
| 19 |
+
|
| 20 |
+
When an API method normally takes long time to complete, it can be designed to
|
| 21 |
+
return ``Operation`` to the client, and the client can use this interface to
|
| 22 |
+
receive the real response asynchronously by polling the operation resource to
|
| 23 |
+
receive the response.
|
| 24 |
+
|
| 25 |
+
It is not a separate service, but rather an interface implemented by a larger
|
| 26 |
+
service. The protocol-level definition is available at
|
| 27 |
+
`google/longrunning/operations.proto`_. Typically, this will be constructed
|
| 28 |
+
automatically by another client class to deal with operations.
|
| 29 |
+
|
| 30 |
+
.. _Google API Style Guide:
|
| 31 |
+
https://cloud.google.com/apis/design/design_pattern
|
| 32 |
+
s#long_running_operations
|
| 33 |
+
.. _google/longrunning/operations.proto:
|
| 34 |
+
https://github.com/googleapis/googleapis/blob/master/google/longrunning
|
| 35 |
+
/operations.proto
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
import functools
|
| 39 |
+
|
| 40 |
+
from google.api_core import exceptions as core_exceptions
|
| 41 |
+
from google.api_core import gapic_v1
|
| 42 |
+
from google.api_core import page_iterator
|
| 43 |
+
from google.api_core import retry as retries
|
| 44 |
+
from google.api_core import timeout as timeouts
|
| 45 |
+
from google.longrunning import operations_pb2
|
| 46 |
+
from grpc import Compression
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class OperationsClient(object):
|
| 50 |
+
"""Client for interacting with long-running operations within a service.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
channel (grpc.Channel): The gRPC channel associated with the service
|
| 54 |
+
that implements the ``google.longrunning.operations`` interface.
|
| 55 |
+
client_config (dict):
|
| 56 |
+
A dictionary of call options for each method. If not specified
|
| 57 |
+
the default configuration is used.
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
def __init__(self, channel, client_config=None):
|
| 61 |
+
# Create the gRPC client stub.
|
| 62 |
+
self.operations_stub = operations_pb2.OperationsStub(channel)
|
| 63 |
+
|
| 64 |
+
default_retry = retries.Retry(
|
| 65 |
+
initial=0.1, # seconds
|
| 66 |
+
maximum=60.0, # seconds
|
| 67 |
+
multiplier=1.3,
|
| 68 |
+
predicate=retries.if_exception_type(
|
| 69 |
+
core_exceptions.DeadlineExceeded,
|
| 70 |
+
core_exceptions.ServiceUnavailable,
|
| 71 |
+
),
|
| 72 |
+
timeout=600.0, # seconds
|
| 73 |
+
)
|
| 74 |
+
default_timeout = timeouts.TimeToDeadlineTimeout(timeout=600.0)
|
| 75 |
+
|
| 76 |
+
default_compression = Compression.NoCompression
|
| 77 |
+
|
| 78 |
+
self._get_operation = gapic_v1.method.wrap_method(
|
| 79 |
+
self.operations_stub.GetOperation,
|
| 80 |
+
default_retry=default_retry,
|
| 81 |
+
default_timeout=default_timeout,
|
| 82 |
+
default_compression=default_compression,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
self._list_operations = gapic_v1.method.wrap_method(
|
| 86 |
+
self.operations_stub.ListOperations,
|
| 87 |
+
default_retry=default_retry,
|
| 88 |
+
default_timeout=default_timeout,
|
| 89 |
+
default_compression=default_compression,
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
self._cancel_operation = gapic_v1.method.wrap_method(
|
| 93 |
+
self.operations_stub.CancelOperation,
|
| 94 |
+
default_retry=default_retry,
|
| 95 |
+
default_timeout=default_timeout,
|
| 96 |
+
default_compression=default_compression,
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
self._delete_operation = gapic_v1.method.wrap_method(
|
| 100 |
+
self.operations_stub.DeleteOperation,
|
| 101 |
+
default_retry=default_retry,
|
| 102 |
+
default_timeout=default_timeout,
|
| 103 |
+
default_compression=default_compression,
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
# Service calls
|
| 107 |
+
def get_operation(
|
| 108 |
+
self,
|
| 109 |
+
name,
|
| 110 |
+
retry=gapic_v1.method.DEFAULT,
|
| 111 |
+
timeout=gapic_v1.method.DEFAULT,
|
| 112 |
+
compression=gapic_v1.method.DEFAULT,
|
| 113 |
+
metadata=None,
|
| 114 |
+
):
|
| 115 |
+
"""Gets the latest state of a long-running operation.
|
| 116 |
+
|
| 117 |
+
Clients can use this method to poll the operation result at intervals
|
| 118 |
+
as recommended by the API service.
|
| 119 |
+
|
| 120 |
+
Example:
|
| 121 |
+
>>> from google.api_core import operations_v1
|
| 122 |
+
>>> api = operations_v1.OperationsClient()
|
| 123 |
+
>>> name = ''
|
| 124 |
+
>>> response = api.get_operation(name)
|
| 125 |
+
|
| 126 |
+
Args:
|
| 127 |
+
name (str): The name of the operation resource.
|
| 128 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 129 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 130 |
+
the client configuration will be used. If ``None``, then this
|
| 131 |
+
method will not retry the RPC at all.
|
| 132 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 133 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 134 |
+
applies to each individual attempt and the overall time it
|
| 135 |
+
takes for this method to complete may be longer. If
|
| 136 |
+
unspecified, the the default timeout in the client
|
| 137 |
+
configuration is used. If ``None``, then the RPC method will
|
| 138 |
+
not time out.
|
| 139 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 140 |
+
e.g. grpc.compression.Gzip.
|
| 141 |
+
metadata (Optional[List[Tuple[str, str]]]):
|
| 142 |
+
Additional gRPC metadata.
|
| 143 |
+
|
| 144 |
+
Returns:
|
| 145 |
+
google.longrunning.operations_pb2.Operation: The state of the
|
| 146 |
+
operation.
|
| 147 |
+
|
| 148 |
+
Raises:
|
| 149 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 150 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 151 |
+
subclass will be raised.
|
| 152 |
+
"""
|
| 153 |
+
request = operations_pb2.GetOperationRequest(name=name)
|
| 154 |
+
|
| 155 |
+
# Add routing header
|
| 156 |
+
metadata = metadata or []
|
| 157 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 158 |
+
|
| 159 |
+
return self._get_operation(
|
| 160 |
+
request,
|
| 161 |
+
retry=retry,
|
| 162 |
+
timeout=timeout,
|
| 163 |
+
compression=compression,
|
| 164 |
+
metadata=metadata,
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
def list_operations(
|
| 168 |
+
self,
|
| 169 |
+
name,
|
| 170 |
+
filter_,
|
| 171 |
+
retry=gapic_v1.method.DEFAULT,
|
| 172 |
+
timeout=gapic_v1.method.DEFAULT,
|
| 173 |
+
compression=gapic_v1.method.DEFAULT,
|
| 174 |
+
metadata=None,
|
| 175 |
+
):
|
| 176 |
+
"""
|
| 177 |
+
Lists operations that match the specified filter in the request.
|
| 178 |
+
|
| 179 |
+
Example:
|
| 180 |
+
>>> from google.api_core import operations_v1
|
| 181 |
+
>>> api = operations_v1.OperationsClient()
|
| 182 |
+
>>> name = ''
|
| 183 |
+
>>>
|
| 184 |
+
>>> # Iterate over all results
|
| 185 |
+
>>> for operation in api.list_operations(name):
|
| 186 |
+
>>> # process operation
|
| 187 |
+
>>> pass
|
| 188 |
+
>>>
|
| 189 |
+
>>> # Or iterate over results one page at a time
|
| 190 |
+
>>> iter = api.list_operations(name)
|
| 191 |
+
>>> for page in iter.pages:
|
| 192 |
+
>>> for operation in page:
|
| 193 |
+
>>> # process operation
|
| 194 |
+
>>> pass
|
| 195 |
+
|
| 196 |
+
Args:
|
| 197 |
+
name (str): The name of the operation collection.
|
| 198 |
+
filter_ (str): The standard list filter.
|
| 199 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 200 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 201 |
+
the client configuration will be used. If ``None``, then this
|
| 202 |
+
method will not retry the RPC at all.
|
| 203 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 204 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 205 |
+
applies to each individual attempt and the overall time it
|
| 206 |
+
takes for this method to complete may be longer. If
|
| 207 |
+
unspecified, the the default timeout in the client
|
| 208 |
+
configuration is used. If ``None``, then the RPC method will
|
| 209 |
+
not time out.
|
| 210 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 211 |
+
e.g. grpc.compression.Gzip.
|
| 212 |
+
metadata (Optional[List[Tuple[str, str]]]): Additional gRPC
|
| 213 |
+
metadata.
|
| 214 |
+
|
| 215 |
+
Returns:
|
| 216 |
+
google.api_core.page_iterator.Iterator: An iterator that yields
|
| 217 |
+
:class:`google.longrunning.operations_pb2.Operation` instances.
|
| 218 |
+
|
| 219 |
+
Raises:
|
| 220 |
+
google.api_core.exceptions.MethodNotImplemented: If the server
|
| 221 |
+
does not support this method. Services are not required to
|
| 222 |
+
implement this method.
|
| 223 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 224 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 225 |
+
subclass will be raised.
|
| 226 |
+
"""
|
| 227 |
+
# Create the request object.
|
| 228 |
+
request = operations_pb2.ListOperationsRequest(name=name, filter=filter_)
|
| 229 |
+
|
| 230 |
+
# Add routing header
|
| 231 |
+
metadata = metadata or []
|
| 232 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 233 |
+
|
| 234 |
+
# Create the method used to fetch pages
|
| 235 |
+
method = functools.partial(
|
| 236 |
+
self._list_operations,
|
| 237 |
+
retry=retry,
|
| 238 |
+
timeout=timeout,
|
| 239 |
+
compression=compression,
|
| 240 |
+
metadata=metadata,
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
iterator = page_iterator.GRPCIterator(
|
| 244 |
+
client=None,
|
| 245 |
+
method=method,
|
| 246 |
+
request=request,
|
| 247 |
+
items_field="operations",
|
| 248 |
+
request_token_field="page_token",
|
| 249 |
+
response_token_field="next_page_token",
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
return iterator
|
| 253 |
+
|
| 254 |
+
def cancel_operation(
|
| 255 |
+
self,
|
| 256 |
+
name,
|
| 257 |
+
retry=gapic_v1.method.DEFAULT,
|
| 258 |
+
timeout=gapic_v1.method.DEFAULT,
|
| 259 |
+
compression=gapic_v1.method.DEFAULT,
|
| 260 |
+
metadata=None,
|
| 261 |
+
):
|
| 262 |
+
"""Starts asynchronous cancellation on a long-running operation.
|
| 263 |
+
|
| 264 |
+
The server makes a best effort to cancel the operation, but success is
|
| 265 |
+
not guaranteed. Clients can use :meth:`get_operation` or service-
|
| 266 |
+
specific methods to check whether the cancellation succeeded or whether
|
| 267 |
+
the operation completed despite cancellation. On successful
|
| 268 |
+
cancellation, the operation is not deleted; instead, it becomes an
|
| 269 |
+
operation with an ``Operation.error`` value with a
|
| 270 |
+
``google.rpc.Status.code`` of ``1``, corresponding to
|
| 271 |
+
``Code.CANCELLED``.
|
| 272 |
+
|
| 273 |
+
Example:
|
| 274 |
+
>>> from google.api_core import operations_v1
|
| 275 |
+
>>> api = operations_v1.OperationsClient()
|
| 276 |
+
>>> name = ''
|
| 277 |
+
>>> api.cancel_operation(name)
|
| 278 |
+
|
| 279 |
+
Args:
|
| 280 |
+
name (str): The name of the operation resource to be cancelled.
|
| 281 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 282 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 283 |
+
the client configuration will be used. If ``None``, then this
|
| 284 |
+
method will not retry the RPC at all.
|
| 285 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 286 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 287 |
+
applies to each individual attempt and the overall time it
|
| 288 |
+
takes for this method to complete may be longer. If
|
| 289 |
+
unspecified, the the default timeout in the client
|
| 290 |
+
configuration is used. If ``None``, then the RPC method will
|
| 291 |
+
not time out.
|
| 292 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 293 |
+
e.g. grpc.compression.Gzip.
|
| 294 |
+
metadata (Optional[List[Tuple[str, str]]]): Additional gRPC
|
| 295 |
+
metadata.
|
| 296 |
+
|
| 297 |
+
Raises:
|
| 298 |
+
google.api_core.exceptions.MethodNotImplemented: If the server
|
| 299 |
+
does not support this method. Services are not required to
|
| 300 |
+
implement this method.
|
| 301 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 302 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 303 |
+
subclass will be raised.
|
| 304 |
+
"""
|
| 305 |
+
# Create the request object.
|
| 306 |
+
request = operations_pb2.CancelOperationRequest(name=name)
|
| 307 |
+
|
| 308 |
+
# Add routing header
|
| 309 |
+
metadata = metadata or []
|
| 310 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 311 |
+
|
| 312 |
+
self._cancel_operation(
|
| 313 |
+
request,
|
| 314 |
+
retry=retry,
|
| 315 |
+
timeout=timeout,
|
| 316 |
+
compression=compression,
|
| 317 |
+
metadata=metadata,
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
def delete_operation(
|
| 321 |
+
self,
|
| 322 |
+
name,
|
| 323 |
+
retry=gapic_v1.method.DEFAULT,
|
| 324 |
+
timeout=gapic_v1.method.DEFAULT,
|
| 325 |
+
compression=gapic_v1.method.DEFAULT,
|
| 326 |
+
metadata=None,
|
| 327 |
+
):
|
| 328 |
+
"""Deletes a long-running operation.
|
| 329 |
+
|
| 330 |
+
This method indicates that the client is no longer interested in the
|
| 331 |
+
operation result. It does not cancel the operation.
|
| 332 |
+
|
| 333 |
+
Example:
|
| 334 |
+
>>> from google.api_core import operations_v1
|
| 335 |
+
>>> api = operations_v1.OperationsClient()
|
| 336 |
+
>>> name = ''
|
| 337 |
+
>>> api.delete_operation(name)
|
| 338 |
+
|
| 339 |
+
Args:
|
| 340 |
+
name (str): The name of the operation resource to be deleted.
|
| 341 |
+
retry (google.api_core.retry.Retry): The retry strategy to use
|
| 342 |
+
when invoking the RPC. If unspecified, the default retry from
|
| 343 |
+
the client configuration will be used. If ``None``, then this
|
| 344 |
+
method will not retry the RPC at all.
|
| 345 |
+
timeout (float): The amount of time in seconds to wait for the RPC
|
| 346 |
+
to complete. Note that if ``retry`` is used, this timeout
|
| 347 |
+
applies to each individual attempt and the overall time it
|
| 348 |
+
takes for this method to complete may be longer. If
|
| 349 |
+
unspecified, the the default timeout in the client
|
| 350 |
+
configuration is used. If ``None``, then the RPC method will
|
| 351 |
+
not time out.
|
| 352 |
+
compression (grpc.Compression): An element of grpc.compression
|
| 353 |
+
e.g. grpc.compression.Gzip.
|
| 354 |
+
metadata (Optional[List[Tuple[str, str]]]): Additional gRPC
|
| 355 |
+
metadata.
|
| 356 |
+
|
| 357 |
+
Raises:
|
| 358 |
+
google.api_core.exceptions.MethodNotImplemented: If the server
|
| 359 |
+
does not support this method. Services are not required to
|
| 360 |
+
implement this method.
|
| 361 |
+
google.api_core.exceptions.GoogleAPICallError: If an error occurred
|
| 362 |
+
while invoking the RPC, the appropriate ``GoogleAPICallError``
|
| 363 |
+
subclass will be raised.
|
| 364 |
+
"""
|
| 365 |
+
# Create the request object.
|
| 366 |
+
request = operations_pb2.DeleteOperationRequest(name=name)
|
| 367 |
+
|
| 368 |
+
# Add routing header
|
| 369 |
+
metadata = metadata or []
|
| 370 |
+
metadata.append(gapic_v1.routing_header.to_grpc_metadata({"name": name}))
|
| 371 |
+
|
| 372 |
+
self._delete_operation(
|
| 373 |
+
request,
|
| 374 |
+
retry=retry,
|
| 375 |
+
timeout=timeout,
|
| 376 |
+
compression=compression,
|
| 377 |
+
metadata=metadata,
|
| 378 |
+
)
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/operations_client_config.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""gapic configuration for the google.longrunning.operations client."""
|
| 16 |
+
|
| 17 |
+
# DEPRECATED: retry and timeout classes are instantiated directly
|
| 18 |
+
config = {
|
| 19 |
+
"interfaces": {
|
| 20 |
+
"google.longrunning.Operations": {
|
| 21 |
+
"retry_codes": {
|
| 22 |
+
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
|
| 23 |
+
"non_idempotent": [],
|
| 24 |
+
},
|
| 25 |
+
"retry_params": {
|
| 26 |
+
"default": {
|
| 27 |
+
"initial_retry_delay_millis": 100,
|
| 28 |
+
"retry_delay_multiplier": 1.3,
|
| 29 |
+
"max_retry_delay_millis": 60000,
|
| 30 |
+
"initial_rpc_timeout_millis": 20000,
|
| 31 |
+
"rpc_timeout_multiplier": 1.0,
|
| 32 |
+
"max_rpc_timeout_millis": 600000,
|
| 33 |
+
"total_timeout_millis": 600000,
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"methods": {
|
| 37 |
+
"GetOperation": {
|
| 38 |
+
"timeout_millis": 60000,
|
| 39 |
+
"retry_codes_name": "idempotent",
|
| 40 |
+
"retry_params_name": "default",
|
| 41 |
+
},
|
| 42 |
+
"ListOperations": {
|
| 43 |
+
"timeout_millis": 60000,
|
| 44 |
+
"retry_codes_name": "idempotent",
|
| 45 |
+
"retry_params_name": "default",
|
| 46 |
+
},
|
| 47 |
+
"CancelOperation": {
|
| 48 |
+
"timeout_millis": 60000,
|
| 49 |
+
"retry_codes_name": "idempotent",
|
| 50 |
+
"retry_params_name": "default",
|
| 51 |
+
},
|
| 52 |
+
"DeleteOperation": {
|
| 53 |
+
"timeout_millis": 60000,
|
| 54 |
+
"retry_codes_name": "idempotent",
|
| 55 |
+
"retry_params_name": "default",
|
| 56 |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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from typing import Optional, Sequence, Tuple, Union
|
| 17 |
+
|
| 18 |
+
from google.api_core import client_options as client_options_lib # type: ignore
|
| 19 |
+
from google.api_core import gapic_v1 # type: ignore
|
| 20 |
+
from google.api_core.operations_v1 import pagers_async as pagers
|
| 21 |
+
from google.api_core.operations_v1.transports.base import (
|
| 22 |
+
DEFAULT_CLIENT_INFO,
|
| 23 |
+
OperationsTransport,
|
| 24 |
+
)
|
| 25 |
+
from google.api_core.operations_v1.abstract_operations_base_client import (
|
| 26 |
+
AbstractOperationsBaseClient,
|
| 27 |
+
)
|
| 28 |
+
from google.longrunning import operations_pb2
|
| 29 |
+
|
| 30 |
+
try:
|
| 31 |
+
from google.auth.aio import credentials as ga_credentials # type: ignore
|
| 32 |
+
except ImportError as e: # pragma: NO COVER
|
| 33 |
+
raise ImportError(
|
| 34 |
+
"The `async_rest` extra of `google-api-core` is required to use long-running operations. Install it by running "
|
| 35 |
+
"`pip install google-api-core[async_rest]`."
|
| 36 |
+
) from e
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class AsyncOperationsRestClient(AbstractOperationsBaseClient):
|
| 40 |
+
"""Manages long-running operations with a REST API service for the asynchronous client.
|
| 41 |
+
|
| 42 |
+
When an API method normally takes long time to complete, it can be
|
| 43 |
+
designed to return [Operation][google.api_core.operations_v1.Operation] to the
|
| 44 |
+
client, and the client can use this interface to receive the real
|
| 45 |
+
response asynchronously by polling the operation resource, or pass
|
| 46 |
+
the operation resource to another API (such as Google Cloud Pub/Sub
|
| 47 |
+
API) to receive the response. Any API service that returns
|
| 48 |
+
long-running operations should implement the ``Operations``
|
| 49 |
+
interface so developers can have a consistent client experience.
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
def __init__(
|
| 53 |
+
self,
|
| 54 |
+
*,
|
| 55 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 56 |
+
transport: Union[str, OperationsTransport, None] = None,
|
| 57 |
+
client_options: Optional[client_options_lib.ClientOptions] = None,
|
| 58 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 59 |
+
) -> None:
|
| 60 |
+
"""Instantiates the operations client.
|
| 61 |
+
|
| 62 |
+
Args:
|
| 63 |
+
credentials (Optional[google.auth.aio.credentials.Credentials]): The
|
| 64 |
+
authorization credentials to attach to requests. These
|
| 65 |
+
credentials identify the application to the service; if none
|
| 66 |
+
are specified, the client will attempt to ascertain the
|
| 67 |
+
credentials from the environment.
|
| 68 |
+
transport (Union[str, OperationsTransport]): The
|
| 69 |
+
transport to use. If set to None, this defaults to 'rest_asyncio'.
|
| 70 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 71 |
+
client. It won't take effect if a ``transport`` instance is provided.
|
| 72 |
+
(1) The ``api_endpoint`` property can be used to override the
|
| 73 |
+
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
|
| 74 |
+
environment variable can also be used to override the endpoint:
|
| 75 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 76 |
+
use the default regular endpoint) and "auto" (auto switch to the
|
| 77 |
+
default mTLS endpoint if client certificate is present, this is
|
| 78 |
+
the default value). However, the ``api_endpoint`` property takes
|
| 79 |
+
precedence if provided.
|
| 80 |
+
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 81 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 82 |
+
to provide client certificate for mutual TLS transport. If
|
| 83 |
+
not provided, the default SSL client certificate will be used if
|
| 84 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 85 |
+
set, no client certificate will be used.
|
| 86 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 87 |
+
The client info used to send a user-agent string along with
|
| 88 |
+
API requests. If ``None``, then default info will be used.
|
| 89 |
+
Generally, you only need to set this if you're developing
|
| 90 |
+
your own client library.
|
| 91 |
+
|
| 92 |
+
Raises:
|
| 93 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 94 |
+
creation failed for any reason.
|
| 95 |
+
"""
|
| 96 |
+
super().__init__(
|
| 97 |
+
credentials=credentials, # type: ignore
|
| 98 |
+
# NOTE: If a transport is not provided, we force the client to use the async
|
| 99 |
+
# REST transport.
|
| 100 |
+
transport=transport or "rest_asyncio",
|
| 101 |
+
client_options=client_options,
|
| 102 |
+
client_info=client_info,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
async def get_operation(
|
| 106 |
+
self,
|
| 107 |
+
name: str,
|
| 108 |
+
*,
|
| 109 |
+
# TODO(https://github.com/googleapis/python-api-core/issues/722): Leverage `retry`
|
| 110 |
+
# to allow configuring retryable error codes.
|
| 111 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 112 |
+
timeout: Optional[float] = None,
|
| 113 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 114 |
+
) -> operations_pb2.Operation:
|
| 115 |
+
r"""Gets the latest state of a long-running operation.
|
| 116 |
+
Clients can use this method to poll the operation result
|
| 117 |
+
at intervals as recommended by the API service.
|
| 118 |
+
|
| 119 |
+
Args:
|
| 120 |
+
name (str):
|
| 121 |
+
The name of the operation resource.
|
| 122 |
+
timeout (float): The timeout for this request.
|
| 123 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 124 |
+
sent along with the request as metadata.
|
| 125 |
+
|
| 126 |
+
Returns:
|
| 127 |
+
google.longrunning.operations_pb2.Operation:
|
| 128 |
+
This resource represents a long-
|
| 129 |
+
running operation that is the result of a
|
| 130 |
+
network API call.
|
| 131 |
+
|
| 132 |
+
"""
|
| 133 |
+
|
| 134 |
+
request = operations_pb2.GetOperationRequest(name=name)
|
| 135 |
+
|
| 136 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 137 |
+
# and friendly error handling.
|
| 138 |
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
| 139 |
+
|
| 140 |
+
# Certain fields should be provided within the metadata header;
|
| 141 |
+
# add these here.
|
| 142 |
+
metadata = tuple(metadata or ()) + (
|
| 143 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
# Send the request.
|
| 147 |
+
response = await rpc(
|
| 148 |
+
request,
|
| 149 |
+
retry=retry,
|
| 150 |
+
timeout=timeout,
|
| 151 |
+
metadata=metadata,
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
# Done; return the response.
|
| 155 |
+
return response
|
| 156 |
+
|
| 157 |
+
async def list_operations(
|
| 158 |
+
self,
|
| 159 |
+
name: str,
|
| 160 |
+
filter_: Optional[str] = None,
|
| 161 |
+
*,
|
| 162 |
+
page_size: Optional[int] = None,
|
| 163 |
+
page_token: Optional[str] = None,
|
| 164 |
+
# TODO(https://github.com/googleapis/python-api-core/issues/722): Leverage `retry`
|
| 165 |
+
# to allow configuring retryable error codes.
|
| 166 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 167 |
+
timeout: Optional[float] = None,
|
| 168 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 169 |
+
) -> pagers.ListOperationsAsyncPager:
|
| 170 |
+
r"""Lists operations that match the specified filter in the request.
|
| 171 |
+
If the server doesn't support this method, it returns
|
| 172 |
+
``UNIMPLEMENTED``.
|
| 173 |
+
|
| 174 |
+
NOTE: the ``name`` binding allows API services to override the
|
| 175 |
+
binding to use different resource name schemes, such as
|
| 176 |
+
``users/*/operations``. To override the binding, API services
|
| 177 |
+
can add a binding such as ``"/v1/{name=users/*}/operations"`` to
|
| 178 |
+
their service configuration. For backwards compatibility, the
|
| 179 |
+
default name includes the operations collection id, however
|
| 180 |
+
overriding users must ensure the name binding is the parent
|
| 181 |
+
resource, without the operations collection id.
|
| 182 |
+
|
| 183 |
+
Args:
|
| 184 |
+
name (str):
|
| 185 |
+
The name of the operation's parent
|
| 186 |
+
resource.
|
| 187 |
+
filter_ (str):
|
| 188 |
+
The standard list filter.
|
| 189 |
+
This corresponds to the ``filter`` field
|
| 190 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 191 |
+
should not be set.
|
| 192 |
+
timeout (float): The timeout for this request.
|
| 193 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 194 |
+
sent along with the request as metadata.
|
| 195 |
+
|
| 196 |
+
Returns:
|
| 197 |
+
google.api_core.operations_v1.pagers.ListOperationsPager:
|
| 198 |
+
The response message for
|
| 199 |
+
[Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].
|
| 200 |
+
|
| 201 |
+
Iterating over this object will yield results and
|
| 202 |
+
resolve additional pages automatically.
|
| 203 |
+
|
| 204 |
+
"""
|
| 205 |
+
# Create a protobuf request object.
|
| 206 |
+
request = operations_pb2.ListOperationsRequest(name=name, filter=filter_)
|
| 207 |
+
if page_size is not None:
|
| 208 |
+
request.page_size = page_size
|
| 209 |
+
if page_token is not None:
|
| 210 |
+
request.page_token = page_token
|
| 211 |
+
|
| 212 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 213 |
+
# and friendly error handling.
|
| 214 |
+
rpc = self._transport._wrapped_methods[self._transport.list_operations]
|
| 215 |
+
|
| 216 |
+
# Certain fields should be provided within the metadata header;
|
| 217 |
+
# add these here.
|
| 218 |
+
metadata = tuple(metadata or ()) + (
|
| 219 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
# Send the request.
|
| 223 |
+
response = await rpc(
|
| 224 |
+
request,
|
| 225 |
+
retry=retry,
|
| 226 |
+
timeout=timeout,
|
| 227 |
+
metadata=metadata,
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
# This method is paged; wrap the response in a pager, which provides
|
| 231 |
+
# an `__iter__` convenience method.
|
| 232 |
+
response = pagers.ListOperationsAsyncPager(
|
| 233 |
+
method=rpc,
|
| 234 |
+
request=request,
|
| 235 |
+
response=response,
|
| 236 |
+
metadata=metadata,
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
# Done; return the response.
|
| 240 |
+
return response
|
| 241 |
+
|
| 242 |
+
async def delete_operation(
|
| 243 |
+
self,
|
| 244 |
+
name: str,
|
| 245 |
+
*,
|
| 246 |
+
# TODO(https://github.com/googleapis/python-api-core/issues/722): Leverage `retry`
|
| 247 |
+
# to allow configuring retryable error codes.
|
| 248 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 249 |
+
timeout: Optional[float] = None,
|
| 250 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 251 |
+
) -> None:
|
| 252 |
+
r"""Deletes a long-running operation. This method indicates that the
|
| 253 |
+
client is no longer interested in the operation result. It does
|
| 254 |
+
not cancel the operation. If the server doesn't support this
|
| 255 |
+
method, it returns ``google.rpc.Code.UNIMPLEMENTED``.
|
| 256 |
+
|
| 257 |
+
Args:
|
| 258 |
+
name (str):
|
| 259 |
+
The name of the operation resource to
|
| 260 |
+
be deleted.
|
| 261 |
+
|
| 262 |
+
This corresponds to the ``name`` field
|
| 263 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 264 |
+
should not be set.
|
| 265 |
+
timeout (float): The timeout for this request.
|
| 266 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 267 |
+
sent along with the request as metadata.
|
| 268 |
+
"""
|
| 269 |
+
# Create the request object.
|
| 270 |
+
request = operations_pb2.DeleteOperationRequest(name=name)
|
| 271 |
+
|
| 272 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 273 |
+
# and friendly error handling.
|
| 274 |
+
rpc = self._transport._wrapped_methods[self._transport.delete_operation]
|
| 275 |
+
|
| 276 |
+
# Certain fields should be provided within the metadata header;
|
| 277 |
+
# add these here.
|
| 278 |
+
metadata = tuple(metadata or ()) + (
|
| 279 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 280 |
+
)
|
| 281 |
+
|
| 282 |
+
# Send the request.
|
| 283 |
+
await rpc(
|
| 284 |
+
request,
|
| 285 |
+
retry=retry,
|
| 286 |
+
timeout=timeout,
|
| 287 |
+
metadata=metadata,
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
async def cancel_operation(
|
| 291 |
+
self,
|
| 292 |
+
name: Optional[str] = None,
|
| 293 |
+
*,
|
| 294 |
+
# TODO(https://github.com/googleapis/python-api-core/issues/722): Leverage `retry`
|
| 295 |
+
# to allow configuring retryable error codes.
|
| 296 |
+
retry=gapic_v1.method_async.DEFAULT,
|
| 297 |
+
timeout: Optional[float] = None,
|
| 298 |
+
metadata: Sequence[Tuple[str, str]] = (),
|
| 299 |
+
) -> None:
|
| 300 |
+
r"""Starts asynchronous cancellation on a long-running operation.
|
| 301 |
+
The server makes a best effort to cancel the operation, but
|
| 302 |
+
success is not guaranteed. If the server doesn't support this
|
| 303 |
+
method, it returns ``google.rpc.Code.UNIMPLEMENTED``. Clients
|
| 304 |
+
can use
|
| 305 |
+
[Operations.GetOperation][google.api_core.operations_v1.Operations.GetOperation]
|
| 306 |
+
or other methods to check whether the cancellation succeeded or
|
| 307 |
+
whether the operation completed despite cancellation. On
|
| 308 |
+
successful cancellation, the operation is not deleted; instead,
|
| 309 |
+
it becomes an operation with an
|
| 310 |
+
[Operation.error][google.api_core.operations_v1.Operation.error] value with
|
| 311 |
+
a [google.rpc.Status.code][google.rpc.Status.code] of 1,
|
| 312 |
+
corresponding to ``Code.CANCELLED``.
|
| 313 |
+
|
| 314 |
+
Args:
|
| 315 |
+
name (str):
|
| 316 |
+
The name of the operation resource to
|
| 317 |
+
be cancelled.
|
| 318 |
+
|
| 319 |
+
This corresponds to the ``name`` field
|
| 320 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 321 |
+
should not be set.
|
| 322 |
+
timeout (float): The timeout for this request.
|
| 323 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 324 |
+
sent along with the request as metadata.
|
| 325 |
+
"""
|
| 326 |
+
# Create the request object.
|
| 327 |
+
request = operations_pb2.CancelOperationRequest(name=name)
|
| 328 |
+
|
| 329 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 330 |
+
# and friendly error handling.
|
| 331 |
+
rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
|
| 332 |
+
|
| 333 |
+
# Certain fields should be provided within the metadata header;
|
| 334 |
+
# add these here.
|
| 335 |
+
metadata = tuple(metadata or ()) + (
|
| 336 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 337 |
+
)
|
| 338 |
+
|
| 339 |
+
# Send the request.
|
| 340 |
+
await rpc(
|
| 341 |
+
request,
|
| 342 |
+
retry=retry,
|
| 343 |
+
timeout=timeout,
|
| 344 |
+
metadata=metadata,
|
| 345 |
+
)
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/pagers.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2020 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from typing import (
|
| 17 |
+
Callable,
|
| 18 |
+
Iterator,
|
| 19 |
+
Sequence,
|
| 20 |
+
Tuple,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from google.longrunning import operations_pb2
|
| 24 |
+
from google.api_core.operations_v1.pagers_base import ListOperationsPagerBase
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class ListOperationsPager(ListOperationsPagerBase):
|
| 28 |
+
"""A pager for iterating through ``list_operations`` requests.
|
| 29 |
+
|
| 30 |
+
This class thinly wraps an initial
|
| 31 |
+
:class:`google.longrunning.operations_pb2.ListOperationsResponse` object, and
|
| 32 |
+
provides an ``__iter__`` method to iterate through its
|
| 33 |
+
``operations`` field.
|
| 34 |
+
|
| 35 |
+
If there are more pages, the ``__iter__`` method will make additional
|
| 36 |
+
``ListOperations`` requests and continue to iterate
|
| 37 |
+
through the ``operations`` field on the
|
| 38 |
+
corresponding responses.
|
| 39 |
+
|
| 40 |
+
All the usual :class:`google.longrunning.operations_pb2.ListOperationsResponse`
|
| 41 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 42 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
def __init__(
|
| 46 |
+
self,
|
| 47 |
+
method: Callable[..., operations_pb2.ListOperationsResponse],
|
| 48 |
+
request: operations_pb2.ListOperationsRequest,
|
| 49 |
+
response: operations_pb2.ListOperationsResponse,
|
| 50 |
+
*,
|
| 51 |
+
metadata: Sequence[Tuple[str, str]] = ()
|
| 52 |
+
):
|
| 53 |
+
super().__init__(
|
| 54 |
+
method=method, request=request, response=response, metadata=metadata
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
@property
|
| 58 |
+
def pages(self) -> Iterator[operations_pb2.ListOperationsResponse]:
|
| 59 |
+
yield self._response
|
| 60 |
+
while self._response.next_page_token:
|
| 61 |
+
self._request.page_token = self._response.next_page_token
|
| 62 |
+
self._response = self._method(self._request, metadata=self._metadata)
|
| 63 |
+
yield self._response
|
| 64 |
+
|
| 65 |
+
def __iter__(self) -> Iterator[operations_pb2.Operation]:
|
| 66 |
+
for page in self.pages:
|
| 67 |
+
yield from page.operations
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/pagers_async.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from typing import (
|
| 17 |
+
Callable,
|
| 18 |
+
AsyncIterator,
|
| 19 |
+
Sequence,
|
| 20 |
+
Tuple,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from google.longrunning import operations_pb2
|
| 24 |
+
from google.api_core.operations_v1.pagers_base import ListOperationsPagerBase
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class ListOperationsAsyncPager(ListOperationsPagerBase):
|
| 28 |
+
"""A pager for iterating through ``list_operations`` requests.
|
| 29 |
+
|
| 30 |
+
This class thinly wraps an initial
|
| 31 |
+
:class:`google.longrunning.operations_pb2.ListOperationsResponse` object, and
|
| 32 |
+
provides an ``__iter__`` method to iterate through its
|
| 33 |
+
``operations`` field.
|
| 34 |
+
|
| 35 |
+
If there are more pages, the ``__iter__`` method will make additional
|
| 36 |
+
``ListOperations`` requests and continue to iterate
|
| 37 |
+
through the ``operations`` field on the
|
| 38 |
+
corresponding responses.
|
| 39 |
+
|
| 40 |
+
All the usual :class:`google.longrunning.operations_pb2.ListOperationsResponse`
|
| 41 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 42 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
def __init__(
|
| 46 |
+
self,
|
| 47 |
+
method: Callable[..., operations_pb2.ListOperationsResponse],
|
| 48 |
+
request: operations_pb2.ListOperationsRequest,
|
| 49 |
+
response: operations_pb2.ListOperationsResponse,
|
| 50 |
+
*,
|
| 51 |
+
metadata: Sequence[Tuple[str, str]] = ()
|
| 52 |
+
):
|
| 53 |
+
super().__init__(
|
| 54 |
+
method=method, request=request, response=response, metadata=metadata
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
@property
|
| 58 |
+
async def pages(self) -> AsyncIterator[operations_pb2.ListOperationsResponse]:
|
| 59 |
+
yield self._response
|
| 60 |
+
while self._response.next_page_token:
|
| 61 |
+
self._request.page_token = self._response.next_page_token
|
| 62 |
+
self._response = await self._method(self._request, metadata=self._metadata)
|
| 63 |
+
yield self._response
|
| 64 |
+
|
| 65 |
+
def __aiter__(self) -> AsyncIterator[operations_pb2.Operation]:
|
| 66 |
+
async def async_generator():
|
| 67 |
+
async for page in self.pages:
|
| 68 |
+
for operation in page.operations:
|
| 69 |
+
yield operation
|
| 70 |
+
|
| 71 |
+
return async_generator()
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/pagers_base.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from typing import (
|
| 17 |
+
Any,
|
| 18 |
+
Callable,
|
| 19 |
+
Sequence,
|
| 20 |
+
Tuple,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
from google.longrunning import operations_pb2
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class ListOperationsPagerBase:
|
| 27 |
+
"""A pager for iterating through ``list_operations`` requests.
|
| 28 |
+
|
| 29 |
+
This class thinly wraps an initial
|
| 30 |
+
:class:`google.longrunning.operations_pb2.ListOperationsResponse` object, and
|
| 31 |
+
provides an ``__iter__`` method to iterate through its
|
| 32 |
+
``operations`` field.
|
| 33 |
+
|
| 34 |
+
If there are more pages, the ``__iter__`` method will make additional
|
| 35 |
+
``ListOperations`` requests and continue to iterate
|
| 36 |
+
through the ``operations`` field on the
|
| 37 |
+
corresponding responses.
|
| 38 |
+
|
| 39 |
+
All the usual :class:`google.longrunning.operations_pb2.ListOperationsResponse`
|
| 40 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 41 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
def __init__(
|
| 45 |
+
self,
|
| 46 |
+
method: Callable[..., operations_pb2.ListOperationsResponse],
|
| 47 |
+
request: operations_pb2.ListOperationsRequest,
|
| 48 |
+
response: operations_pb2.ListOperationsResponse,
|
| 49 |
+
*,
|
| 50 |
+
metadata: Sequence[Tuple[str, str]] = ()
|
| 51 |
+
):
|
| 52 |
+
"""Instantiate the pager.
|
| 53 |
+
|
| 54 |
+
Args:
|
| 55 |
+
method (Callable): The method that was originally called, and
|
| 56 |
+
which instantiated this pager.
|
| 57 |
+
request (google.longrunning.operations_pb2.ListOperationsRequest):
|
| 58 |
+
The initial request object.
|
| 59 |
+
response (google.longrunning.operations_pb2.ListOperationsResponse):
|
| 60 |
+
The initial response object.
|
| 61 |
+
metadata (Sequence[Tuple[str, str]]): Strings which should be
|
| 62 |
+
sent along with the request as metadata.
|
| 63 |
+
"""
|
| 64 |
+
self._method = method
|
| 65 |
+
self._request = request
|
| 66 |
+
self._response = response
|
| 67 |
+
self._metadata = metadata
|
| 68 |
+
|
| 69 |
+
def __getattr__(self, name: str) -> Any:
|
| 70 |
+
return getattr(self._response, name)
|
| 71 |
+
|
| 72 |
+
def __repr__(self) -> str:
|
| 73 |
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__init__.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2020 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from collections import OrderedDict
|
| 17 |
+
from typing import cast, Dict, Tuple
|
| 18 |
+
|
| 19 |
+
from .base import OperationsTransport
|
| 20 |
+
from .rest import OperationsRestTransport
|
| 21 |
+
|
| 22 |
+
# Compile a registry of transports.
|
| 23 |
+
_transport_registry: Dict[str, OperationsTransport] = OrderedDict()
|
| 24 |
+
_transport_registry["rest"] = cast(OperationsTransport, OperationsRestTransport)
|
| 25 |
+
|
| 26 |
+
__all__: Tuple[str, ...] = ("OperationsTransport", "OperationsRestTransport")
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
from .rest_asyncio import AsyncOperationsRestTransport
|
| 30 |
+
|
| 31 |
+
__all__ += ("AsyncOperationsRestTransport",)
|
| 32 |
+
_transport_registry["rest_asyncio"] = cast(
|
| 33 |
+
OperationsTransport, AsyncOperationsRestTransport
|
| 34 |
+
)
|
| 35 |
+
except ImportError:
|
| 36 |
+
# This import requires the `async_rest` extra.
|
| 37 |
+
# Don't raise an exception if `AsyncOperationsRestTransport` cannot be imported
|
| 38 |
+
# as other transports are still available.
|
| 39 |
+
pass
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (709 Bytes). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/base.cpython-310.pyc
ADDED
|
Binary file (7.85 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest.cpython-310.pyc
ADDED
|
Binary file (13.6 kB). View file
|
|
|
evalkit_cambrian/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest_asyncio.cpython-310.pyc
ADDED
|
Binary file (13.8 kB). View file
|
|
|