Skip to content

Commit 483f139

Browse files
feat: Add ListHotTablets API method and protobufs (#542)
* feat: Add ListHotTablets API method and protobufs PiperOrigin-RevId: 436758628 Source-Link: googleapis/googleapis@92ab86a Source-Link: googleapis/googleapis-gen@931ef11 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTMxZWYxMTRkNWY4NDVhYmYxMTdiZjhlMGEyOTgzNmNhMzAwYjY5NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 84cfb0a commit 483f139

File tree

13 files changed

+1011
-15
lines changed

13 files changed

+1011
-15
lines changed

google/cloud/bigtable_admin_v2/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
from .types.bigtable_instance_admin import ListAppProfilesResponse
3535
from .types.bigtable_instance_admin import ListClustersRequest
3636
from .types.bigtable_instance_admin import ListClustersResponse
37+
from .types.bigtable_instance_admin import ListHotTabletsRequest
38+
from .types.bigtable_instance_admin import ListHotTabletsResponse
3739
from .types.bigtable_instance_admin import ListInstancesRequest
3840
from .types.bigtable_instance_admin import ListInstancesResponse
3941
from .types.bigtable_instance_admin import PartialUpdateClusterMetadata
@@ -78,6 +80,7 @@
7880
from .types.instance import AutoscalingLimits
7981
from .types.instance import AutoscalingTargets
8082
from .types.instance import Cluster
83+
from .types.instance import HotTablet
8184
from .types.instance import Instance
8285
from .types.table import Backup
8386
from .types.table import BackupInfo
@@ -130,13 +133,16 @@
130133
"GetInstanceRequest",
131134
"GetSnapshotRequest",
132135
"GetTableRequest",
136+
"HotTablet",
133137
"Instance",
134138
"ListAppProfilesRequest",
135139
"ListAppProfilesResponse",
136140
"ListBackupsRequest",
137141
"ListBackupsResponse",
138142
"ListClustersRequest",
139143
"ListClustersResponse",
144+
"ListHotTabletsRequest",
145+
"ListHotTabletsResponse",
140146
"ListInstancesRequest",
141147
"ListInstancesResponse",
142148
"ListSnapshotsRequest",

google/cloud/bigtable_admin_v2/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
"list_clusters"
7171
]
7272
},
73+
"ListHotTablets": {
74+
"methods": [
75+
"list_hot_tablets"
76+
]
77+
},
7378
"ListInstances": {
7479
"methods": [
7580
"list_instances"
@@ -175,6 +180,11 @@
175180
"list_clusters"
176181
]
177182
},
183+
"ListHotTablets": {
184+
"methods": [
185+
"list_hot_tablets"
186+
]
187+
},
178188
"ListInstances": {
179189
"methods": [
180190
"list_instances"

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ class BigtableInstanceAdminAsyncClient:
6969
parse_crypto_key_path = staticmethod(
7070
BigtableInstanceAdminClient.parse_crypto_key_path
7171
)
72+
hot_tablet_path = staticmethod(BigtableInstanceAdminClient.hot_tablet_path)
73+
parse_hot_tablet_path = staticmethod(
74+
BigtableInstanceAdminClient.parse_hot_tablet_path
75+
)
7276
instance_path = staticmethod(BigtableInstanceAdminClient.instance_path)
7377
parse_instance_path = staticmethod(BigtableInstanceAdminClient.parse_instance_path)
78+
table_path = staticmethod(BigtableInstanceAdminClient.table_path)
79+
parse_table_path = staticmethod(BigtableInstanceAdminClient.parse_table_path)
7480
common_billing_account_path = staticmethod(
7581
BigtableInstanceAdminClient.common_billing_account_path
7682
)
@@ -2109,6 +2115,98 @@ async def test_iam_permissions(
21092115
# Done; return the response.
21102116
return response
21112117

2118+
async def list_hot_tablets(
2119+
self,
2120+
request: Union[bigtable_instance_admin.ListHotTabletsRequest, dict] = None,
2121+
*,
2122+
parent: str = None,
2123+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2124+
timeout: float = None,
2125+
metadata: Sequence[Tuple[str, str]] = (),
2126+
) -> pagers.ListHotTabletsAsyncPager:
2127+
r"""Lists hot tablets in a cluster, within the time range
2128+
provided. Hot tablets are ordered based on CPU usage.
2129+
2130+
Args:
2131+
request (Union[google.cloud.bigtable_admin_v2.types.ListHotTabletsRequest, dict]):
2132+
The request object. Request message for
2133+
BigtableInstanceAdmin.ListHotTablets.
2134+
parent (:class:`str`):
2135+
Required. The cluster name to list hot tablets. Value is
2136+
in the following form:
2137+
``projects/{project}/instances/{instance}/clusters/{cluster}``.
2138+
2139+
This corresponds to the ``parent`` field
2140+
on the ``request`` instance; if ``request`` is provided, this
2141+
should not be set.
2142+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2143+
should be retried.
2144+
timeout (float): The timeout for this request.
2145+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2146+
sent along with the request as metadata.
2147+
2148+
Returns:
2149+
google.cloud.bigtable_admin_v2.services.bigtable_instance_admin.pagers.ListHotTabletsAsyncPager:
2150+
Response message for
2151+
BigtableInstanceAdmin.ListHotTablets.
2152+
Iterating over this object will yield
2153+
results and resolve additional pages
2154+
automatically.
2155+
2156+
"""
2157+
# Create or coerce a protobuf request object.
2158+
# Quick check: If we got a request object, we should *not* have
2159+
# gotten any keyword arguments that map to the request.
2160+
has_flattened_params = any([parent])
2161+
if request is not None and has_flattened_params:
2162+
raise ValueError(
2163+
"If the `request` argument is set, then none of "
2164+
"the individual field arguments should be set."
2165+
)
2166+
2167+
request = bigtable_instance_admin.ListHotTabletsRequest(request)
2168+
2169+
# If we have keyword arguments corresponding to fields on the
2170+
# request, apply these.
2171+
if parent is not None:
2172+
request.parent = parent
2173+
2174+
# Wrap the RPC method; this adds retry and timeout information,
2175+
# and friendly error handling.
2176+
rpc = gapic_v1.method_async.wrap_method(
2177+
self._client._transport.list_hot_tablets,
2178+
default_retry=retries.Retry(
2179+
initial=1.0,
2180+
maximum=60.0,
2181+
multiplier=2,
2182+
predicate=retries.if_exception_type(
2183+
core_exceptions.DeadlineExceeded,
2184+
core_exceptions.ServiceUnavailable,
2185+
),
2186+
deadline=60.0,
2187+
),
2188+
default_timeout=60.0,
2189+
client_info=DEFAULT_CLIENT_INFO,
2190+
)
2191+
2192+
# Certain fields should be provided within the metadata header;
2193+
# add these here.
2194+
metadata = tuple(metadata) + (
2195+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2196+
)
2197+
2198+
# Send the request.
2199+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2200+
2201+
# This method is paged; wrap the response in a pager, which provides
2202+
# an `__aiter__` convenience method.
2203+
response = pagers.ListHotTabletsAsyncPager(
2204+
method=rpc, request=request, response=response, metadata=metadata,
2205+
)
2206+
2207+
# Done; return the response.
2208+
return response
2209+
21122210
async def __aenter__(self):
21132211
return self
21142212

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,24 @@ def parse_crypto_key_path(path: str) -> Dict[str, str]:
227227
)
228228
return m.groupdict() if m else {}
229229

230+
@staticmethod
231+
def hot_tablet_path(
232+
project: str, instance: str, cluster: str, hot_tablet: str,
233+
) -> str:
234+
"""Returns a fully-qualified hot_tablet string."""
235+
return "projects/{project}/instances/{instance}/clusters/{cluster}/hotTablets/{hot_tablet}".format(
236+
project=project, instance=instance, cluster=cluster, hot_tablet=hot_tablet,
237+
)
238+
239+
@staticmethod
240+
def parse_hot_tablet_path(path: str) -> Dict[str, str]:
241+
"""Parses a hot_tablet path into its component segments."""
242+
m = re.match(
243+
r"^projects/(?P<project>.+?)/instances/(?P<instance>.+?)/clusters/(?P<cluster>.+?)/hotTablets/(?P<hot_tablet>.+?)$",
244+
path,
245+
)
246+
return m.groupdict() if m else {}
247+
230248
@staticmethod
231249
def instance_path(project: str, instance: str,) -> str:
232250
"""Returns a fully-qualified instance string."""
@@ -240,6 +258,22 @@ def parse_instance_path(path: str) -> Dict[str, str]:
240258
m = re.match(r"^projects/(?P<project>.+?)/instances/(?P<instance>.+?)$", path)
241259
return m.groupdict() if m else {}
242260

261+
@staticmethod
262+
def table_path(project: str, instance: str, table: str,) -> str:
263+
"""Returns a fully-qualified table string."""
264+
return "projects/{project}/instances/{instance}/tables/{table}".format(
265+
project=project, instance=instance, table=table,
266+
)
267+
268+
@staticmethod
269+
def parse_table_path(path: str) -> Dict[str, str]:
270+
"""Parses a table path into its component segments."""
271+
m = re.match(
272+
r"^projects/(?P<project>.+?)/instances/(?P<instance>.+?)/tables/(?P<table>.+?)$",
273+
path,
274+
)
275+
return m.groupdict() if m else {}
276+
243277
@staticmethod
244278
def common_billing_account_path(billing_account: str,) -> str:
245279
"""Returns a fully-qualified billing_account string."""
@@ -2215,6 +2249,88 @@ def test_iam_permissions(
22152249
# Done; return the response.
22162250
return response
22172251

2252+
def list_hot_tablets(
2253+
self,
2254+
request: Union[bigtable_instance_admin.ListHotTabletsRequest, dict] = None,
2255+
*,
2256+
parent: str = None,
2257+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2258+
timeout: float = None,
2259+
metadata: Sequence[Tuple[str, str]] = (),
2260+
) -> pagers.ListHotTabletsPager:
2261+
r"""Lists hot tablets in a cluster, within the time range
2262+
provided. Hot tablets are ordered based on CPU usage.
2263+
2264+
Args:
2265+
request (Union[google.cloud.bigtable_admin_v2.types.ListHotTabletsRequest, dict]):
2266+
The request object. Request message for
2267+
BigtableInstanceAdmin.ListHotTablets.
2268+
parent (str):
2269+
Required. The cluster name to list hot tablets. Value is
2270+
in the following form:
2271+
``projects/{project}/instances/{instance}/clusters/{cluster}``.
2272+
2273+
This corresponds to the ``parent`` field
2274+
on the ``request`` instance; if ``request`` is provided, this
2275+
should not be set.
2276+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2277+
should be retried.
2278+
timeout (float): The timeout for this request.
2279+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2280+
sent along with the request as metadata.
2281+
2282+
Returns:
2283+
google.cloud.bigtable_admin_v2.services.bigtable_instance_admin.pagers.ListHotTabletsPager:
2284+
Response message for
2285+
BigtableInstanceAdmin.ListHotTablets.
2286+
Iterating over this object will yield
2287+
results and resolve additional pages
2288+
automatically.
2289+
2290+
"""
2291+
# Create or coerce a protobuf request object.
2292+
# Quick check: If we got a request object, we should *not* have
2293+
# gotten any keyword arguments that map to the request.
2294+
has_flattened_params = any([parent])
2295+
if request is not None and has_flattened_params:
2296+
raise ValueError(
2297+
"If the `request` argument is set, then none of "
2298+
"the individual field arguments should be set."
2299+
)
2300+
2301+
# Minor optimization to avoid making a copy if the user passes
2302+
# in a bigtable_instance_admin.ListHotTabletsRequest.
2303+
# There's no risk of modifying the input as we've already verified
2304+
# there are no flattened fields.
2305+
if not isinstance(request, bigtable_instance_admin.ListHotTabletsRequest):
2306+
request = bigtable_instance_admin.ListHotTabletsRequest(request)
2307+
# If we have keyword arguments corresponding to fields on the
2308+
# request, apply these.
2309+
if parent is not None:
2310+
request.parent = parent
2311+
2312+
# Wrap the RPC method; this adds retry and timeout information,
2313+
# and friendly error handling.
2314+
rpc = self._transport._wrapped_methods[self._transport.list_hot_tablets]
2315+
2316+
# Certain fields should be provided within the metadata header;
2317+
# add these here.
2318+
metadata = tuple(metadata) + (
2319+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2320+
)
2321+
2322+
# Send the request.
2323+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2324+
2325+
# This method is paged; wrap the response in a pager, which provides
2326+
# an `__iter__` convenience method.
2327+
response = pagers.ListHotTabletsPager(
2328+
method=rpc, request=request, response=response, metadata=metadata,
2329+
)
2330+
2331+
# Done; return the response.
2332+
return response
2333+
22182334
def __enter__(self):
22192335
return self
22202336

0 commit comments

Comments
 (0)