1+ # TODO: Add a header if needed.
2+
3+ # ======== 🦕 HERE THERE BE DINOSAURS 🦖 =========
4+ # This content is subject to significant change. Not for review yet.
5+ # Included as a proof of concept for context or testing ONLY.
6+ # ================================================
7+
8+ # Imports
9+ import os
10+
11+ from typing import (
12+ Dict,
13+ Optional,
14+ Sequence,
15+ Tuple,
16+ Union,
17+ )
18+
19+
20+ {% for imp in service_imports %}
21+ {{ imp }}
22+ {% endfor %}
23+ from google.cloud.bigquery_v2.services.centralized_service import _helpers
24+
25+ {% for imp in type_imports %}
26+ {{ imp }}
27+ {% endfor %}
28+ from google.cloud.bigquery_v2.types import dataset_reference
29+
30+ from google.api_core import client_options as client_options_lib
31+ from google.api_core import gapic_v1
32+ from google.api_core import retry as retries
33+ from google.auth import credentials as auth_credentials
34+
35+ # Create type aliases
36+ try:
37+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
38+ except AttributeError: # pragma: NO COVER
39+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
40+
41+ DatasetIdentifier = Union[str, dataset_reference.DatasetReference]
42+
43+ DEFAULT_RETRY: OptionalRetry = gapic_v1.method.DEFAULT
44+ DEFAULT_TIMEOUT: Union[float, object] = gapic_v1.method.DEFAULT
45+ DEFAULT_METADATA: Sequence[Tuple[str, Union[str, bytes]]] = ()
46+
47+
48+ class BigQueryClient:
49+ def __init__(self, credentials=None, client_options=None):
50+ self._clients = {}
51+ self._credentials = credentials
52+ self._client_options = client_options
53+
54+ # --- *METHOD SECTION ---
55+ {% for method in methods %}
56+ def {{ method.name }}(
57+ self,
58+ *,
59+ request: Optional["{{ method.service_module_name.replace('_service', '') }}.{{ method.name.replace('_', ' ').title().replace(' ', '') }}Request"] = None,
60+ retry: OptionalRetry = DEFAULT_RETRY,
61+ timeout: Union[float, object] = DEFAULT_TIMEOUT,
62+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = DEFAULT_METADATA,
63+ ) -> "{{ method.return_type }}":
64+ """
65+ TODO: Docstring is purposefully blank. microgenerator will add automatically.
66+ """
67+
68+ return self.{{ method.service_module_name }}_client.{{ method.name }}(
69+ request=request,
70+ retry=retry,
71+ timeout=timeout,
72+ metadata=metadata,
73+ )
74+ {% endfor %}
75+
76+ {#- *ServiceClient Properties Section: methods to get/set service clients -#}
77+ # --- *SERVICECLIENT PROPERTIES ---
78+ {% for service in services %}
79+ @property
80+ def {{ service.property_name }}(self):
81+ if "{{ service.service_name }}" not in self._clients:
82+ self._clients["{{ service.service_name }}"] = {{ service.service_module_name }}.{{ service.service_client_class }}(
83+ credentials=self._credentials, client_options=self._client_options
84+ )
85+ return self._clients["{{ service.service_name }}"]
86+
87+ @{{ service.property_name }}.setter
88+ def {{ service.property_name }}(self, value):
89+ if not isinstance(value, {{ service.service_module_name }}.{{ service.service_client_class }}):
90+ raise TypeError(
91+ "Expected an instance of {{ service.service_module_name }}.{{ service.service_client_class }}."
92+ )
93+ self._clients["{{ service.service_name }}"] = value
94+ {% endfor %}
95+
96+ {#- Helper Section: methods included from partial template -#}
97+ {% - include "partials/_client_helpers.j2" %}
98+
99+
100+ # ======== 🦕 HERE THERE WERE DINOSAURS 🦖 =========
101+ # The above content is subject to significant change. Not for review yet.
102+ # Included as a proof of concept for context or testing ONLY.
103+ # ================================================
0 commit comments