Skip to content

Commit 4d490cf

Browse files
feat(spanner): add autoscaling config to the instance proto (#1022)
* feat(spanner): add autoscaling config to the instance proto PiperOrigin-RevId: 573098210 Source-Link: googleapis/googleapis@d6467db Source-Link: googleapis/googleapis-gen@9ea8b73 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWVhOGI3MzQ1ZWYyZDkzYTQ5YjE1YTMzMmE2ODJhNjE3MTRmMDczZSJ9 * 🦉 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 e9c6e27 commit 4d490cf

File tree

3 files changed

+140
-4
lines changed

3 files changed

+140
-4
lines changed

google/cloud/spanner_admin_instance_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .services.instance_admin import InstanceAdminAsyncClient
2323

2424
from .types.common import OperationProgress
25+
from .types.spanner_instance_admin import AutoscalingConfig
2526
from .types.spanner_instance_admin import CreateInstanceConfigMetadata
2627
from .types.spanner_instance_admin import CreateInstanceConfigRequest
2728
from .types.spanner_instance_admin import CreateInstanceMetadata
@@ -46,6 +47,7 @@
4647

4748
__all__ = (
4849
"InstanceAdminAsyncClient",
50+
"AutoscalingConfig",
4951
"CreateInstanceConfigMetadata",
5052
"CreateInstanceConfigRequest",
5153
"CreateInstanceMetadata",

google/cloud/spanner_admin_instance_v1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
OperationProgress,
1818
)
1919
from .spanner_instance_admin import (
20+
AutoscalingConfig,
2021
CreateInstanceConfigMetadata,
2122
CreateInstanceConfigRequest,
2223
CreateInstanceMetadata,
@@ -42,6 +43,7 @@
4243

4344
__all__ = (
4445
"OperationProgress",
46+
"AutoscalingConfig",
4547
"CreateInstanceConfigMetadata",
4648
"CreateInstanceConfigRequest",
4749
"CreateInstanceMetadata",

google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py

Lines changed: 136 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
manifest={
3131
"ReplicaInfo",
3232
"InstanceConfig",
33+
"AutoscalingConfig",
3334
"Instance",
3435
"ListInstanceConfigsRequest",
3536
"ListInstanceConfigsResponse",
@@ -297,6 +298,116 @@ class State(proto.Enum):
297298
)
298299

299300

301+
class AutoscalingConfig(proto.Message):
302+
r"""Autoscaling config for an instance.
303+
304+
Attributes:
305+
autoscaling_limits (google.cloud.spanner_admin_instance_v1.types.AutoscalingConfig.AutoscalingLimits):
306+
Required. Autoscaling limits for an instance.
307+
autoscaling_targets (google.cloud.spanner_admin_instance_v1.types.AutoscalingConfig.AutoscalingTargets):
308+
Required. The autoscaling targets for an
309+
instance.
310+
"""
311+
312+
class AutoscalingLimits(proto.Message):
313+
r"""The autoscaling limits for the instance. Users can define the
314+
minimum and maximum compute capacity allocated to the instance, and
315+
the autoscaler will only scale within that range. Users can either
316+
use nodes or processing units to specify the limits, but should use
317+
the same unit to set both the min_limit and max_limit.
318+
319+
This message has `oneof`_ fields (mutually exclusive fields).
320+
For each oneof, at most one member field can be set at the same time.
321+
Setting any member of the oneof automatically clears all other
322+
members.
323+
324+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
325+
326+
Attributes:
327+
min_nodes (int):
328+
Minimum number of nodes allocated to the
329+
instance. If set, this number should be greater
330+
than or equal to 1.
331+
332+
This field is a member of `oneof`_ ``min_limit``.
333+
min_processing_units (int):
334+
Minimum number of processing units allocated
335+
to the instance. If set, this number should be
336+
multiples of 1000.
337+
338+
This field is a member of `oneof`_ ``min_limit``.
339+
max_nodes (int):
340+
Maximum number of nodes allocated to the instance. If set,
341+
this number should be greater than or equal to min_nodes.
342+
343+
This field is a member of `oneof`_ ``max_limit``.
344+
max_processing_units (int):
345+
Maximum number of processing units allocated to the
346+
instance. If set, this number should be multiples of 1000
347+
and be greater than or equal to min_processing_units.
348+
349+
This field is a member of `oneof`_ ``max_limit``.
350+
"""
351+
352+
min_nodes: int = proto.Field(
353+
proto.INT32,
354+
number=1,
355+
oneof="min_limit",
356+
)
357+
min_processing_units: int = proto.Field(
358+
proto.INT32,
359+
number=2,
360+
oneof="min_limit",
361+
)
362+
max_nodes: int = proto.Field(
363+
proto.INT32,
364+
number=3,
365+
oneof="max_limit",
366+
)
367+
max_processing_units: int = proto.Field(
368+
proto.INT32,
369+
number=4,
370+
oneof="max_limit",
371+
)
372+
373+
class AutoscalingTargets(proto.Message):
374+
r"""The autoscaling targets for an instance.
375+
376+
Attributes:
377+
high_priority_cpu_utilization_percent (int):
378+
Required. The target high priority cpu utilization
379+
percentage that the autoscaler should be trying to achieve
380+
for the instance. This number is on a scale from 0 (no
381+
utilization) to 100 (full utilization). The valid range is
382+
[10, 90] inclusive.
383+
storage_utilization_percent (int):
384+
Required. The target storage utilization percentage that the
385+
autoscaler should be trying to achieve for the instance.
386+
This number is on a scale from 0 (no utilization) to 100
387+
(full utilization). The valid range is [10, 100] inclusive.
388+
"""
389+
390+
high_priority_cpu_utilization_percent: int = proto.Field(
391+
proto.INT32,
392+
number=1,
393+
)
394+
storage_utilization_percent: int = proto.Field(
395+
proto.INT32,
396+
number=2,
397+
)
398+
399+
autoscaling_limits: AutoscalingLimits = proto.Field(
400+
proto.MESSAGE,
401+
number=1,
402+
message=AutoscalingLimits,
403+
)
404+
autoscaling_targets: AutoscalingTargets = proto.Field(
405+
proto.MESSAGE,
406+
number=2,
407+
message=AutoscalingTargets,
408+
)
409+
410+
300411
class Instance(proto.Message):
301412
r"""An isolated set of Cloud Spanner resources on which databases
302413
can be hosted.
@@ -325,21 +436,37 @@ class Instance(proto.Message):
325436
node_count (int):
326437
The number of nodes allocated to this instance. At most one
327438
of either node_count or processing_units should be present
328-
in the message. This may be zero in API responses for
329-
instances that are not yet in state ``READY``.
439+
in the message.
440+
441+
Users can set the node_count field to specify the target
442+
number of nodes allocated to the instance.
443+
444+
This may be zero in API responses for instances that are not
445+
yet in state ``READY``.
330446
331447
See `the
332448
documentation <https://cloud.google.com/spanner/docs/compute-capacity>`__
333449
for more information about nodes and processing units.
334450
processing_units (int):
335451
The number of processing units allocated to this instance.
336452
At most one of processing_units or node_count should be
337-
present in the message. This may be zero in API responses
338-
for instances that are not yet in state ``READY``.
453+
present in the message.
454+
455+
Users can set the processing_units field to specify the
456+
target number of processing units allocated to the instance.
457+
458+
This may be zero in API responses for instances that are not
459+
yet in state ``READY``.
339460
340461
See `the
341462
documentation <https://cloud.google.com/spanner/docs/compute-capacity>`__
342463
for more information about nodes and processing units.
464+
autoscaling_config (google.cloud.spanner_admin_instance_v1.types.AutoscalingConfig):
465+
Optional. The autoscaling configuration. Autoscaling is
466+
enabled if this field is set. When autoscaling is enabled,
467+
node_count and processing_units are treated as OUTPUT_ONLY
468+
fields and reflect the current compute capacity allocated to
469+
the instance.
343470
state (google.cloud.spanner_admin_instance_v1.types.Instance.State):
344471
Output only. The current instance state. For
345472
[CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance],
@@ -424,6 +551,11 @@ class State(proto.Enum):
424551
proto.INT32,
425552
number=9,
426553
)
554+
autoscaling_config: "AutoscalingConfig" = proto.Field(
555+
proto.MESSAGE,
556+
number=17,
557+
message="AutoscalingConfig",
558+
)
427559
state: State = proto.Field(
428560
proto.ENUM,
429561
number=6,

0 commit comments

Comments
 (0)