Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [google-cloud-backupdr] add InitializeServiceAPI #13420

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
CreateManagementServerRequest,
DeleteManagementServerRequest,
GetManagementServerRequest,
InitializeServiceRequest,
InitializeServiceResponse,
ListManagementServersRequest,
ListManagementServersResponse,
ManagementServer,
Expand Down Expand Up @@ -128,6 +130,8 @@
"CreateManagementServerRequest",
"DeleteManagementServerRequest",
"GetManagementServerRequest",
"InitializeServiceRequest",
"InitializeServiceResponse",
"ListManagementServersRequest",
"ListManagementServersResponse",
"ManagementServer",
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__ = "0.1.7" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
CreateManagementServerRequest,
DeleteManagementServerRequest,
GetManagementServerRequest,
InitializeServiceRequest,
InitializeServiceResponse,
ListManagementServersRequest,
ListManagementServersResponse,
ManagementServer,
Expand Down Expand Up @@ -173,6 +175,8 @@
"GetDataSourceRequest",
"GetManagementServerRequest",
"GuestOsFeature",
"InitializeServiceRequest",
"InitializeServiceResponse",
"InstanceParams",
"KeyRevocationActionType",
"ListBackupPlanAssociationsRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
"get_management_server"
]
},
"InitializeService": {
"methods": [
"initialize_service"
]
},
"ListBackupPlanAssociations": {
"methods": [
"list_backup_plan_associations"
Expand Down Expand Up @@ -230,6 +235,11 @@
"get_management_server"
]
},
"InitializeService": {
"methods": [
"initialize_service"
]
},
"ListBackupPlanAssociations": {
"methods": [
"list_backup_plan_associations"
Expand Down Expand Up @@ -370,6 +380,11 @@
"get_management_server"
]
},
"InitializeService": {
"methods": [
"initialize_service"
]
},
"ListBackupPlanAssociations": {
"methods": [
"list_backup_plan_associations"
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__ = "0.1.7" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -3153,6 +3153,7 @@ async def sample_create_backup_plan_association():

# Initialize request argument(s)
backup_plan_association = backupdr_v1.BackupPlanAssociation()
backup_plan_association.resource_type = "resource_type_value"
backup_plan_association.resource = "resource_value"
backup_plan_association.backup_plan = "backup_plan_value"

Expand Down Expand Up @@ -3796,6 +3797,108 @@ async def sample_trigger_backup():
# Done; return the response.
return response

async def initialize_service(
self,
request: Optional[Union[backupdr.InitializeServiceRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operation_async.AsyncOperation:
r"""Initializes the service related config for a project.

.. 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 backupdr_v1

async def sample_initialize_service():
# Create a client
client = backupdr_v1.BackupDRAsyncClient()

# Initialize request argument(s)
request = backupdr_v1.InitializeServiceRequest(
name="name_value",
resource_type="resource_type_value",
)

# Make the request
operation = client.initialize_service(request=request)

print("Waiting for operation to complete...")

response = (await operation).result()

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.backupdr_v1.types.InitializeServiceRequest, dict]]):
The request object. Request message for initializing the
service.
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, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.

Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.backupdr_v1.types.InitializeServiceResponse`
Response message for initializing the service.

"""
# 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, backupdr.InitializeServiceRequest):
request = backupdr.InitializeServiceRequest(request)

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

# 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,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
backupdr.InitializeServiceResponse,
metadata_type=backupdr.OperationMetadata,
)

# Done; return the response.
return response

async def list_operations(
self,
request: Optional[operations_pb2.ListOperationsRequest] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3590,6 +3590,7 @@ def sample_create_backup_plan_association():

# Initialize request argument(s)
backup_plan_association = backupdr_v1.BackupPlanAssociation()
backup_plan_association.resource_type = "resource_type_value"
backup_plan_association.resource = "resource_value"
backup_plan_association.backup_plan = "backup_plan_value"

Expand Down Expand Up @@ -4226,6 +4227,106 @@ def sample_trigger_backup():
# Done; return the response.
return response

def initialize_service(
self,
request: Optional[Union[backupdr.InitializeServiceRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operation.Operation:
r"""Initializes the service related config for a project.

.. 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 backupdr_v1

def sample_initialize_service():
# Create a client
client = backupdr_v1.BackupDRClient()

# Initialize request argument(s)
request = backupdr_v1.InitializeServiceRequest(
name="name_value",
resource_type="resource_type_value",
)

# Make the request
operation = client.initialize_service(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.backupdr_v1.types.InitializeServiceRequest, dict]):
The request object. Request message for initializing the
service.
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, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.

Returns:
google.api_core.operation.Operation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.backupdr_v1.types.InitializeServiceResponse`
Response message for initializing the service.

"""
# 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, backupdr.InitializeServiceRequest):
request = backupdr.InitializeServiceRequest(request)

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

# 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,
)

# Wrap the response in an operation future.
response = operation.from_gapic(
response,
self._transport.operations_client,
backupdr.InitializeServiceResponse,
metadata_type=backupdr.OperationMetadata,
)

# Done; return the response.
return response

def __enter__(self) -> "BackupDRClient":
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,20 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.initialize_service: gapic_v1.method.wrap_method(
self.initialize_service,
default_retry=retries.Retry(
initial=1.0,
maximum=10.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
),
deadline=60.0,
),
default_timeout=60.0,
client_info=client_info,
),
self.get_location: gapic_v1.method.wrap_method(
self.get_location,
default_timeout=None,
Expand Down Expand Up @@ -698,6 +712,15 @@ def trigger_backup(
]:
raise NotImplementedError()

@property
def initialize_service(
self,
) -> Callable[
[backupdr.InitializeServiceRequest],
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
]:
raise NotImplementedError()

@property
def list_operations(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,32 @@ def trigger_backup(
)
return self._stubs["trigger_backup"]

@property
def initialize_service(
self,
) -> Callable[[backupdr.InitializeServiceRequest], operations_pb2.Operation]:
r"""Return a callable for the initialize service method over gRPC.

Initializes the service related config for a project.

Returns:
Callable[[~.InitializeServiceRequest],
~.Operation]:
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 "initialize_service" not in self._stubs:
self._stubs["initialize_service"] = self._logged_channel.unary_unary(
"/google.cloud.backupdr.v1.BackupDR/InitializeService",
request_serializer=backupdr.InitializeServiceRequest.serialize,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["initialize_service"]

def close(self):
self._logged_channel.close()

Expand Down
Loading
Loading