Skip to content

Commit

Permalink
feat: [google-cloud-bigquery-reservation] Add the managed disaster re…
Browse files Browse the repository at this point in the history
…covery API(https://cloud.google.com/bigquery/docs/managed-disaster-recovery) (#13316)

BEGIN_COMMIT_OVERRIDE
feat: Add the managed disaster recovery
API(https://cloud.google.com/bigquery/docs/managed-disaster-recovery)
feat: Add a new field `is_flat_rate` to
`.google.cloud.bigquery.reservation.v1.CapacityCommitment` to
distinguish between flat rate and edition commitments
docs: Clarify that `Autoscale.current_slots` in message
`.google.cloud.bigquery.reservation.v1.Reservation` can temporarily be
larger than `Autoscale.max_slots` if users reduce `Autoscale.max_slots`
docs: Update comment for `slot_capacity` in message
`.google.cloud.bigquery.reservation.v1.Reservation` to provide more
clarity about reservation baselines, committed slots and autoscaler SKU
charges when the baseline exceeds committed slots
docs: Update comments for `commitment_start_time` and
`commitment_end_time` in message
`.google.cloud.bigquery.reservation.v1.CapacityCommitment` to provide
details on how these values are affected by commitment renewal
END_COMMIT_OVERRIDE

- [ ] Regenerate this pull request now.

feat: Add a new field `is_flat_rate` to
`.google.cloud.bigquery.reservation.v1.CapacityCommitment` to
distinguish between flat rate and edition commitments
docs: Clarify that `Autoscale.current_slots` in message
`.google.cloud.bigquery.reservation.v1.Reservation` can temporarily be
larger than `Autoscale.max_slots` if users reduce `Autoscale.max_slots`
docs: Update comment for `slot_capacity` in message
`.google.cloud.bigquery.reservation.v1.Reservation` to provide more
clarity about reservation baselines, committed slots and autoscaler SKU
charges when the baseline exceeds committed slots
docs: Update comments for `commitment_start_time` and
`commitment_end_time` in message
`.google.cloud.bigquery.reservation.v1.CapacityCommitment` to provide
details on how these values are affected by commitment renewal

PiperOrigin-RevId: 702079972

Source-Link:
googleapis/googleapis@4743cf9

Source-Link:
googleapis/googleapis-gen@30e9360
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LXJlc2VydmF0aW9uLy5Pd2xCb3QueWFtbCIsImgiOiIzMGU5MzYwMDBiZmFiOTliZjI4NTZiYjg0NmE1MGViMGVlMDM4NWI3In0=

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: ohmayr <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent a33d01b commit e87d4e9
Show file tree
Hide file tree
Showing 19 changed files with 1,616 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
DeleteCapacityCommitmentRequest,
DeleteReservationRequest,
Edition,
FailoverReservationRequest,
GetBiReservationRequest,
GetCapacityCommitmentRequest,
GetReservationRequest,
Expand Down Expand Up @@ -72,6 +73,7 @@
"DeleteAssignmentRequest",
"DeleteCapacityCommitmentRequest",
"DeleteReservationRequest",
"FailoverReservationRequest",
"GetBiReservationRequest",
"GetCapacityCommitmentRequest",
"GetReservationRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.14.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
DeleteCapacityCommitmentRequest,
DeleteReservationRequest,
Edition,
FailoverReservationRequest,
GetBiReservationRequest,
GetCapacityCommitmentRequest,
GetReservationRequest,
Expand Down Expand Up @@ -70,6 +71,7 @@
"DeleteCapacityCommitmentRequest",
"DeleteReservationRequest",
"Edition",
"FailoverReservationRequest",
"GetBiReservationRequest",
"GetCapacityCommitmentRequest",
"GetReservationRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"delete_reservation"
]
},
"FailoverReservation": {
"methods": [
"failover_reservation"
]
},
"GetBiReservation": {
"methods": [
"get_bi_reservation"
Expand Down Expand Up @@ -150,6 +155,11 @@
"delete_reservation"
]
},
"FailoverReservation": {
"methods": [
"failover_reservation"
]
},
"GetBiReservation": {
"methods": [
"get_bi_reservation"
Expand Down Expand Up @@ -260,6 +270,11 @@
"delete_reservation"
]
},
"FailoverReservation": {
"methods": [
"failover_reservation"
]
},
"GetBiReservation": {
"methods": [
"get_bi_reservation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.14.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,95 @@ async def sample_update_reservation():
# Done; return the response.
return response

async def failover_reservation(
self,
request: Optional[Union[reservation.FailoverReservationRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> reservation.Reservation:
r"""Fail over a reservation to the secondary location. The operation
should be done in the current secondary location, which will be
promoted to the new primary location for the reservation.
Attempting to failover a reservation in the current primary
location will fail with the error code
``google.rpc.Code.FAILED_PRECONDITION``.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import bigquery_reservation_v1
async def sample_failover_reservation():
# Create a client
client = bigquery_reservation_v1.ReservationServiceAsyncClient()
# Initialize request argument(s)
request = bigquery_reservation_v1.FailoverReservationRequest(
name="name_value",
)
# Make the request
response = await client.failover_reservation(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.bigquery_reservation_v1.types.FailoverReservationRequest, dict]]):
The request object. The request for
ReservationService.FailoverReservation.
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.bigquery_reservation_v1.types.Reservation:
A reservation is a mechanism used to
guarantee slots to users.
"""
# Create or coerce a protobuf request object.
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, reservation.FailoverReservationRequest):
request = reservation.FailoverReservationRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.failover_reservation
]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def create_capacity_commitment(
self,
request: Optional[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,93 @@ def sample_update_reservation():
# Done; return the response.
return response

def failover_reservation(
self,
request: Optional[Union[reservation.FailoverReservationRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> reservation.Reservation:
r"""Fail over a reservation to the secondary location. The operation
should be done in the current secondary location, which will be
promoted to the new primary location for the reservation.
Attempting to failover a reservation in the current primary
location will fail with the error code
``google.rpc.Code.FAILED_PRECONDITION``.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import bigquery_reservation_v1
def sample_failover_reservation():
# Create a client
client = bigquery_reservation_v1.ReservationServiceClient()
# Initialize request argument(s)
request = bigquery_reservation_v1.FailoverReservationRequest(
name="name_value",
)
# Make the request
response = client.failover_reservation(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.bigquery_reservation_v1.types.FailoverReservationRequest, dict]):
The request object. The request for
ReservationService.FailoverReservation.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.bigquery_reservation_v1.types.Reservation:
A reservation is a mechanism used to
guarantee slots to users.
"""
# Create or coerce a protobuf request object.
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, reservation.FailoverReservationRequest):
request = reservation.FailoverReservationRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.failover_reservation]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Validate the universe domain.
self._validate_universe_domain()

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def create_capacity_commitment(
self,
request: Optional[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=300.0,
client_info=client_info,
),
self.failover_reservation: gapic_v1.method.wrap_method(
self.failover_reservation,
default_timeout=None,
client_info=client_info,
),
self.create_capacity_commitment: gapic_v1.method.wrap_method(
self.create_capacity_commitment,
default_timeout=300.0,
Expand Down Expand Up @@ -397,6 +402,15 @@ def update_reservation(
]:
raise NotImplementedError()

@property
def failover_reservation(
self,
) -> Callable[
[reservation.FailoverReservationRequest],
Union[reservation.Reservation, Awaitable[reservation.Reservation]],
]:
raise NotImplementedError()

@property
def create_capacity_commitment(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,37 @@ def update_reservation(
)
return self._stubs["update_reservation"]

@property
def failover_reservation(
self,
) -> Callable[[reservation.FailoverReservationRequest], reservation.Reservation]:
r"""Return a callable for the failover reservation method over gRPC.
Fail over a reservation to the secondary location. The operation
should be done in the current secondary location, which will be
promoted to the new primary location for the reservation.
Attempting to failover a reservation in the current primary
location will fail with the error code
``google.rpc.Code.FAILED_PRECONDITION``.
Returns:
Callable[[~.FailoverReservationRequest],
~.Reservation]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "failover_reservation" not in self._stubs:
self._stubs["failover_reservation"] = self.grpc_channel.unary_unary(
"/google.cloud.bigquery.reservation.v1.ReservationService/FailoverReservation",
request_serializer=reservation.FailoverReservationRequest.serialize,
response_deserializer=reservation.Reservation.deserialize,
)
return self._stubs["failover_reservation"]

@property
def create_capacity_commitment(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,39 @@ def update_reservation(
)
return self._stubs["update_reservation"]

@property
def failover_reservation(
self,
) -> Callable[
[reservation.FailoverReservationRequest], Awaitable[reservation.Reservation]
]:
r"""Return a callable for the failover reservation method over gRPC.
Fail over a reservation to the secondary location. The operation
should be done in the current secondary location, which will be
promoted to the new primary location for the reservation.
Attempting to failover a reservation in the current primary
location will fail with the error code
``google.rpc.Code.FAILED_PRECONDITION``.
Returns:
Callable[[~.FailoverReservationRequest],
Awaitable[~.Reservation]]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "failover_reservation" not in self._stubs:
self._stubs["failover_reservation"] = self.grpc_channel.unary_unary(
"/google.cloud.bigquery.reservation.v1.ReservationService/FailoverReservation",
request_serializer=reservation.FailoverReservationRequest.serialize,
response_deserializer=reservation.Reservation.deserialize,
)
return self._stubs["failover_reservation"]

@property
def create_capacity_commitment(
self,
Expand Down Expand Up @@ -1076,6 +1109,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=300.0,
client_info=client_info,
),
self.failover_reservation: self._wrap_method(
self.failover_reservation,
default_timeout=None,
client_info=client_info,
),
self.create_capacity_commitment: self._wrap_method(
self.create_capacity_commitment,
default_timeout=300.0,
Expand Down
Loading

0 comments on commit e87d4e9

Please sign in to comment.