Skip to content

Commit 6226fa0

Browse files
feat: add Autoscaling API (#475)
* feat: add Autoscaling API PiperOrigin-RevId: 410080804 Source-Link: googleapis/googleapis@0fd6a32 Source-Link: googleapis/googleapis-gen@788247b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzg4MjQ3YjdjYmRhNWIwNWYyYWM0ZjZjMTNmMTBmZjI2NWUxODNmMCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * resolve issue where samples templates are not updated * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot 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> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 0fa5ad8 commit 6226fa0

12 files changed

Lines changed: 811 additions & 5 deletions

File tree

packages/google-cloud-bigtable/google/cloud/bigtable_admin_v2/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
from .types.bigtable_instance_admin import ListClustersResponse
3737
from .types.bigtable_instance_admin import ListInstancesRequest
3838
from .types.bigtable_instance_admin import ListInstancesResponse
39+
from .types.bigtable_instance_admin import PartialUpdateClusterMetadata
40+
from .types.bigtable_instance_admin import PartialUpdateClusterRequest
3941
from .types.bigtable_instance_admin import PartialUpdateInstanceRequest
4042
from .types.bigtable_instance_admin import UpdateAppProfileMetadata
4143
from .types.bigtable_instance_admin import UpdateAppProfileRequest
@@ -73,6 +75,8 @@
7375
from .types.common import OperationProgress
7476
from .types.common import StorageType
7577
from .types.instance import AppProfile
78+
from .types.instance import AutoscalingLimits
79+
from .types.instance import AutoscalingTargets
7680
from .types.instance import Cluster
7781
from .types.instance import Instance
7882
from .types.table import Backup
@@ -89,6 +93,8 @@
8993
"BigtableInstanceAdminAsyncClient",
9094
"BigtableTableAdminAsyncClient",
9195
"AppProfile",
96+
"AutoscalingLimits",
97+
"AutoscalingTargets",
9298
"Backup",
9399
"BackupInfo",
94100
"BigtableInstanceAdminClient",
@@ -140,6 +146,8 @@
140146
"ModifyColumnFamiliesRequest",
141147
"OperationProgress",
142148
"OptimizeRestoredTableMetadata",
149+
"PartialUpdateClusterMetadata",
150+
"PartialUpdateClusterRequest",
143151
"PartialUpdateInstanceRequest",
144152
"RestoreInfo",
145153
"RestoreSourceType",

packages/google-cloud-bigtable/google/cloud/bigtable_admin_v2/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
"list_instances"
7676
]
7777
},
78+
"PartialUpdateCluster": {
79+
"methods": [
80+
"partial_update_cluster"
81+
]
82+
},
7883
"PartialUpdateInstance": {
7984
"methods": [
8085
"partial_update_instance"
@@ -175,6 +180,11 @@
175180
"list_instances"
176181
]
177182
},
183+
"PartialUpdateCluster": {
184+
"methods": [
185+
"partial_update_cluster"
186+
]
187+
},
178188
"PartialUpdateInstance": {
179189
"methods": [
180190
"partial_update_instance"

packages/google-cloud-bigtable/google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ async def create_instance(
206206
) -> operation_async.AsyncOperation:
207207
r"""Create an instance within a project.
208208
209+
Note that exactly one of Cluster.serve_nodes and
210+
Cluster.cluster_config.cluster_autoscaling_config can be set. If
211+
serve_nodes is set to non-zero, then the cluster is manually
212+
scaled. If cluster_config.cluster_autoscaling_config is
213+
non-empty, then autoscaling is enabled.
214+
209215
Args:
210216
request (Union[google.cloud.bigtable_admin_v2.types.CreateInstanceRequest, dict]):
211217
The request object. Request message for
@@ -738,6 +744,12 @@ async def create_cluster(
738744
) -> operation_async.AsyncOperation:
739745
r"""Creates a cluster within an instance.
740746
747+
Note that exactly one of Cluster.serve_nodes and
748+
Cluster.cluster_config.cluster_autoscaling_config can be set. If
749+
serve_nodes is set to non-zero, then the cluster is manually
750+
scaled. If cluster_config.cluster_autoscaling_config is
751+
non-empty, then autoscaling is enabled.
752+
741753
Args:
742754
request (Union[google.cloud.bigtable_admin_v2.types.CreateClusterRequest, dict]):
743755
The request object. Request message for
@@ -1009,6 +1021,10 @@ async def update_cluster(
10091021
) -> operation_async.AsyncOperation:
10101022
r"""Updates a cluster within an instance.
10111023
1024+
Note that UpdateCluster does not support updating
1025+
cluster_config.cluster_autoscaling_config. In order to update
1026+
it, you must use PartialUpdateCluster.
1027+
10121028
Args:
10131029
request (Union[google.cloud.bigtable_admin_v2.types.Cluster, dict]):
10141030
The request object. A resizable group of nodes in a
@@ -1072,6 +1088,126 @@ async def update_cluster(
10721088
# Done; return the response.
10731089
return response
10741090

1091+
async def partial_update_cluster(
1092+
self,
1093+
request: Union[
1094+
bigtable_instance_admin.PartialUpdateClusterRequest, dict
1095+
] = None,
1096+
*,
1097+
cluster: instance.Cluster = None,
1098+
update_mask: field_mask_pb2.FieldMask = None,
1099+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1100+
timeout: float = None,
1101+
metadata: Sequence[Tuple[str, str]] = (),
1102+
) -> operation_async.AsyncOperation:
1103+
r"""Partially updates a cluster within a project. This method is the
1104+
preferred way to update a Cluster.
1105+
1106+
To enable and update autoscaling, set
1107+
cluster_config.cluster_autoscaling_config. When autoscaling is
1108+
enabled, serve_nodes is treated as an OUTPUT_ONLY field, meaning
1109+
that updates to it are ignored. Note that an update cannot
1110+
simultaneously set serve_nodes to non-zero and
1111+
cluster_config.cluster_autoscaling_config to non-empty, and also
1112+
specify both in the update_mask.
1113+
1114+
To disable autoscaling, clear
1115+
cluster_config.cluster_autoscaling_config, and explicitly set a
1116+
serve_node count via the update_mask.
1117+
1118+
Args:
1119+
request (Union[google.cloud.bigtable_admin_v2.types.PartialUpdateClusterRequest, dict]):
1120+
The request object. Request message for
1121+
BigtableInstanceAdmin.PartialUpdateCluster.
1122+
cluster (:class:`google.cloud.bigtable_admin_v2.types.Cluster`):
1123+
Required. The Cluster which contains the partial updates
1124+
to be applied, subject to the update_mask.
1125+
1126+
This corresponds to the ``cluster`` field
1127+
on the ``request`` instance; if ``request`` is provided, this
1128+
should not be set.
1129+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
1130+
Required. The subset of Cluster
1131+
fields which should be replaced.
1132+
1133+
This corresponds to the ``update_mask`` field
1134+
on the ``request`` instance; if ``request`` is provided, this
1135+
should not be set.
1136+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1137+
should be retried.
1138+
timeout (float): The timeout for this request.
1139+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1140+
sent along with the request as metadata.
1141+
1142+
Returns:
1143+
google.api_core.operation_async.AsyncOperation:
1144+
An object representing a long-running operation.
1145+
1146+
The result type for the operation will be :class:`google.cloud.bigtable_admin_v2.types.Cluster` A resizable group of nodes in a particular cloud location, capable
1147+
of serving all
1148+
[Tables][google.bigtable.admin.v2.Table] in the
1149+
parent [Instance][google.bigtable.admin.v2.Instance].
1150+
1151+
"""
1152+
# Create or coerce a protobuf request object.
1153+
# Sanity check: If we got a request object, we should *not* have
1154+
# gotten any keyword arguments that map to the request.
1155+
has_flattened_params = any([cluster, update_mask])
1156+
if request is not None and has_flattened_params:
1157+
raise ValueError(
1158+
"If the `request` argument is set, then none of "
1159+
"the individual field arguments should be set."
1160+
)
1161+
1162+
request = bigtable_instance_admin.PartialUpdateClusterRequest(request)
1163+
1164+
# If we have keyword arguments corresponding to fields on the
1165+
# request, apply these.
1166+
if cluster is not None:
1167+
request.cluster = cluster
1168+
if update_mask is not None:
1169+
request.update_mask = update_mask
1170+
1171+
# Wrap the RPC method; this adds retry and timeout information,
1172+
# and friendly error handling.
1173+
rpc = gapic_v1.method_async.wrap_method(
1174+
self._client._transport.partial_update_cluster,
1175+
default_retry=retries.Retry(
1176+
initial=1.0,
1177+
maximum=60.0,
1178+
multiplier=2,
1179+
predicate=retries.if_exception_type(
1180+
core_exceptions.DeadlineExceeded,
1181+
core_exceptions.ServiceUnavailable,
1182+
),
1183+
deadline=60.0,
1184+
),
1185+
default_timeout=60.0,
1186+
client_info=DEFAULT_CLIENT_INFO,
1187+
)
1188+
1189+
# Certain fields should be provided within the metadata header;
1190+
# add these here.
1191+
metadata = tuple(metadata) + (
1192+
gapic_v1.routing_header.to_grpc_metadata(
1193+
(("cluster.name", request.cluster.name),)
1194+
),
1195+
)
1196+
1197+
# Send the request.
1198+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1199+
1200+
# Wrap the response in an operation future.
1201+
response = operation_async.from_gapic(
1202+
response,
1203+
self._client._transport.operations_client,
1204+
instance.Cluster,
1205+
metadata_type=bigtable_instance_admin.PartialUpdateClusterMetadata,
1206+
)
1207+
1208+
# Done; return the response.
1209+
return response
1210+
10751211
async def delete_cluster(
10761212
self,
10771213
request: Union[bigtable_instance_admin.DeleteClusterRequest, dict] = None,

packages/google-cloud-bigtable/google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ def create_instance(
437437
) -> operation.Operation:
438438
r"""Create an instance within a project.
439439
440+
Note that exactly one of Cluster.serve_nodes and
441+
Cluster.cluster_config.cluster_autoscaling_config can be set. If
442+
serve_nodes is set to non-zero, then the cluster is manually
443+
scaled. If cluster_config.cluster_autoscaling_config is
444+
non-empty, then autoscaling is enabled.
445+
440446
Args:
441447
request (Union[google.cloud.bigtable_admin_v2.types.CreateInstanceRequest, dict]):
442448
The request object. Request message for
@@ -931,6 +937,12 @@ def create_cluster(
931937
) -> operation.Operation:
932938
r"""Creates a cluster within an instance.
933939
940+
Note that exactly one of Cluster.serve_nodes and
941+
Cluster.cluster_config.cluster_autoscaling_config can be set. If
942+
serve_nodes is set to non-zero, then the cluster is manually
943+
scaled. If cluster_config.cluster_autoscaling_config is
944+
non-empty, then autoscaling is enabled.
945+
934946
Args:
935947
request (Union[google.cloud.bigtable_admin_v2.types.CreateClusterRequest, dict]):
936948
The request object. Request message for
@@ -1182,6 +1194,10 @@ def update_cluster(
11821194
) -> operation.Operation:
11831195
r"""Updates a cluster within an instance.
11841196
1197+
Note that UpdateCluster does not support updating
1198+
cluster_config.cluster_autoscaling_config. In order to update
1199+
it, you must use PartialUpdateCluster.
1200+
11851201
Args:
11861202
request (Union[google.cloud.bigtable_admin_v2.types.Cluster, dict]):
11871203
The request object. A resizable group of nodes in a
@@ -1236,6 +1252,116 @@ def update_cluster(
12361252
# Done; return the response.
12371253
return response
12381254

1255+
def partial_update_cluster(
1256+
self,
1257+
request: Union[
1258+
bigtable_instance_admin.PartialUpdateClusterRequest, dict
1259+
] = None,
1260+
*,
1261+
cluster: instance.Cluster = None,
1262+
update_mask: field_mask_pb2.FieldMask = None,
1263+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1264+
timeout: float = None,
1265+
metadata: Sequence[Tuple[str, str]] = (),
1266+
) -> operation.Operation:
1267+
r"""Partially updates a cluster within a project. This method is the
1268+
preferred way to update a Cluster.
1269+
1270+
To enable and update autoscaling, set
1271+
cluster_config.cluster_autoscaling_config. When autoscaling is
1272+
enabled, serve_nodes is treated as an OUTPUT_ONLY field, meaning
1273+
that updates to it are ignored. Note that an update cannot
1274+
simultaneously set serve_nodes to non-zero and
1275+
cluster_config.cluster_autoscaling_config to non-empty, and also
1276+
specify both in the update_mask.
1277+
1278+
To disable autoscaling, clear
1279+
cluster_config.cluster_autoscaling_config, and explicitly set a
1280+
serve_node count via the update_mask.
1281+
1282+
Args:
1283+
request (Union[google.cloud.bigtable_admin_v2.types.PartialUpdateClusterRequest, dict]):
1284+
The request object. Request message for
1285+
BigtableInstanceAdmin.PartialUpdateCluster.
1286+
cluster (google.cloud.bigtable_admin_v2.types.Cluster):
1287+
Required. The Cluster which contains the partial updates
1288+
to be applied, subject to the update_mask.
1289+
1290+
This corresponds to the ``cluster`` field
1291+
on the ``request`` instance; if ``request`` is provided, this
1292+
should not be set.
1293+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
1294+
Required. The subset of Cluster
1295+
fields which should be replaced.
1296+
1297+
This corresponds to the ``update_mask`` field
1298+
on the ``request`` instance; if ``request`` is provided, this
1299+
should not be set.
1300+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1301+
should be retried.
1302+
timeout (float): The timeout for this request.
1303+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1304+
sent along with the request as metadata.
1305+
1306+
Returns:
1307+
google.api_core.operation.Operation:
1308+
An object representing a long-running operation.
1309+
1310+
The result type for the operation will be :class:`google.cloud.bigtable_admin_v2.types.Cluster` A resizable group of nodes in a particular cloud location, capable
1311+
of serving all
1312+
[Tables][google.bigtable.admin.v2.Table] in the
1313+
parent [Instance][google.bigtable.admin.v2.Instance].
1314+
1315+
"""
1316+
# Create or coerce a protobuf request object.
1317+
# Sanity check: If we got a request object, we should *not* have
1318+
# gotten any keyword arguments that map to the request.
1319+
has_flattened_params = any([cluster, update_mask])
1320+
if request is not None and has_flattened_params:
1321+
raise ValueError(
1322+
"If the `request` argument is set, then none of "
1323+
"the individual field arguments should be set."
1324+
)
1325+
1326+
# Minor optimization to avoid making a copy if the user passes
1327+
# in a bigtable_instance_admin.PartialUpdateClusterRequest.
1328+
# There's no risk of modifying the input as we've already verified
1329+
# there are no flattened fields.
1330+
if not isinstance(request, bigtable_instance_admin.PartialUpdateClusterRequest):
1331+
request = bigtable_instance_admin.PartialUpdateClusterRequest(request)
1332+
# If we have keyword arguments corresponding to fields on the
1333+
# request, apply these.
1334+
if cluster is not None:
1335+
request.cluster = cluster
1336+
if update_mask is not None:
1337+
request.update_mask = update_mask
1338+
1339+
# Wrap the RPC method; this adds retry and timeout information,
1340+
# and friendly error handling.
1341+
rpc = self._transport._wrapped_methods[self._transport.partial_update_cluster]
1342+
1343+
# Certain fields should be provided within the metadata header;
1344+
# add these here.
1345+
metadata = tuple(metadata) + (
1346+
gapic_v1.routing_header.to_grpc_metadata(
1347+
(("cluster.name", request.cluster.name),)
1348+
),
1349+
)
1350+
1351+
# Send the request.
1352+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1353+
1354+
# Wrap the response in an operation future.
1355+
response = operation.from_gapic(
1356+
response,
1357+
self._transport.operations_client,
1358+
instance.Cluster,
1359+
metadata_type=bigtable_instance_admin.PartialUpdateClusterMetadata,
1360+
)
1361+
1362+
# Done; return the response.
1363+
return response
1364+
12391365
def delete_cluster(
12401366
self,
12411367
request: Union[bigtable_instance_admin.DeleteClusterRequest, dict] = None,

0 commit comments

Comments
 (0)