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

chore: [Many APIs] Update gapic-generator-python to v1.17.1 #12642

Merged
merged 5 commits into from
May 7, 2024
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import re
from typing import (
Callable,
Dict,
Mapping,
MutableMapping,
Expand Down Expand Up @@ -538,7 +539,13 @@ def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Optional[Union[str, StorageTransferServiceTransport]] = None,
transport: Optional[
Union[
str,
StorageTransferServiceTransport,
Callable[..., StorageTransferServiceTransport],
]
] = None,
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
Expand All @@ -550,9 +557,11 @@ def __init__(
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
transport (Union[str, StorageTransferServiceTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
transport (Optional[Union[str,StorageTransferServiceTransport,Callable[..., StorageTransferServiceTransport]]]):
The transport to use, or a Callable that constructs and returns a new transport.
If a Callable is given, it will be called with the same set of initialization
arguments as used in the StorageTransferServiceTransport constructor.
If set to None, a transport is chosen automatically.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
Custom options for the client.

Expand Down Expand Up @@ -661,8 +670,16 @@ def __init__(
api_key_value
)

Transport = type(self).get_transport_class(cast(str, transport))
self._transport = Transport(
transport_init: Union[
Type[StorageTransferServiceTransport],
Callable[..., StorageTransferServiceTransport],
] = (
type(self).get_transport_class(transport)
if isinstance(transport, str) or transport is None
else cast(Callable[..., StorageTransferServiceTransport], transport)
)
# initialize with the provided callable or the passed in class
self._transport = transport_init(
credentials=credentials,
credentials_file=self._client_options.credentials_file,
host=self._api_endpoint,
Expand Down Expand Up @@ -734,10 +751,8 @@ def sample_get_google_service_account():
Google service account
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.GetGoogleServiceAccountRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.GetGoogleServiceAccountRequest):
request = transfer.GetGoogleServiceAccountRequest(request)

Expand Down Expand Up @@ -821,10 +836,8 @@ def sample_create_transfer_job():

"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.CreateTransferJobRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.CreateTransferJobRequest):
request = transfer.CreateTransferJobRequest(request)

Expand Down Expand Up @@ -910,10 +923,8 @@ def sample_update_transfer_job():

"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.UpdateTransferJobRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.UpdateTransferJobRequest):
request = transfer.UpdateTransferJobRequest(request)

Expand Down Expand Up @@ -995,10 +1006,8 @@ def sample_get_transfer_job():

"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.GetTransferJobRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.GetTransferJobRequest):
request = transfer.GetTransferJobRequest(request)

Expand Down Expand Up @@ -1084,10 +1093,8 @@ def sample_list_transfer_jobs():

"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.ListTransferJobsRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.ListTransferJobsRequest):
request = transfer.ListTransferJobsRequest(request)

Expand Down Expand Up @@ -1162,10 +1169,8 @@ def sample_pause_transfer_operation():
sent along with the request as metadata.
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.PauseTransferOperationRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.PauseTransferOperationRequest):
request = transfer.PauseTransferOperationRequest(request)

Expand Down Expand Up @@ -1234,10 +1239,8 @@ def sample_resume_transfer_operation():
sent along with the request as metadata.
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.ResumeTransferOperationRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.ResumeTransferOperationRequest):
request = transfer.ResumeTransferOperationRequest(request)

Expand Down Expand Up @@ -1334,10 +1337,8 @@ def sample_run_transfer_job():

"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.RunTransferJobRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.RunTransferJobRequest):
request = transfer.RunTransferJobRequest(request)

Expand Down Expand Up @@ -1419,10 +1420,8 @@ def sample_delete_transfer_job():
sent along with the request as metadata.
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a transfer.DeleteTransferJobRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.DeleteTransferJobRequest):
request = transfer.DeleteTransferJobRequest(request)

Expand Down Expand Up @@ -1540,19 +1539,17 @@ def sample_create_agent_pool():
Represents an On-Premises Agent pool.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([project_id, agent_pool, agent_pool_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a transfer.CreateAgentPoolRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.CreateAgentPoolRequest):
request = transfer.CreateAgentPoolRequest(request)
# If we have keyword arguments corresponding to fields on the
Expand Down Expand Up @@ -1676,19 +1673,17 @@ def sample_update_agent_pool():
Represents an On-Premises Agent pool.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([agent_pool, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a transfer.UpdateAgentPoolRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.UpdateAgentPoolRequest):
request = transfer.UpdateAgentPoolRequest(request)
# If we have keyword arguments corresponding to fields on the
Expand Down Expand Up @@ -1783,19 +1778,17 @@ def sample_get_agent_pool():
Represents an On-Premises Agent pool.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a transfer.GetAgentPoolRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.GetAgentPoolRequest):
request = transfer.GetAgentPoolRequest(request)
# If we have keyword arguments corresponding to fields on the
Expand Down Expand Up @@ -1891,19 +1884,17 @@ def sample_list_agent_pools():

"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([project_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a transfer.ListAgentPoolsRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.ListAgentPoolsRequest):
request = transfer.ListAgentPoolsRequest(request)
# If we have keyword arguments corresponding to fields on the
Expand Down Expand Up @@ -1998,19 +1989,17 @@ def sample_delete_agent_pool():
sent along with the request as metadata.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a transfer.DeleteAgentPoolRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
# - 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, transfer.DeleteAgentPoolRequest):
request = transfer.DeleteAgentPoolRequest(request)
# If we have keyword arguments corresponding to fields on the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(
credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
channel: Optional[grpc.Channel] = None,
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
api_mtls_endpoint: Optional[str] = None,
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
Expand All @@ -73,14 +73,17 @@ def __init__(
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
This argument is ignored if ``channel`` is provided.
This argument is ignored if a ``channel`` instance is provided.
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is ignored if ``channel`` is provided.
This argument is ignored if a ``channel`` instance is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
channel (Optional[grpc.Channel]): A ``Channel`` instance through
which to make calls.
ignored if a ``channel`` instance is provided.
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
A ``Channel`` instance through which to make calls, or a Callable
that constructs and returns one. If set to None, ``self.create_channel``
is used to create the channel. If a Callable is given, it will be called
with the same arguments as used in ``self.create_channel``.
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
If provided, it overrides the ``host`` argument and tries to create
a mutual TLS channel with client SSL credentials from
Expand All @@ -90,11 +93,11 @@ def __init__(
private key bytes, both in PEM format. It is ignored if
``api_mtls_endpoint`` is None.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for the grpc channel. It is ignored if ``channel`` is provided.
for the grpc channel. It is ignored if a ``channel`` instance is provided.
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
A callback to provide client certificate bytes and private key bytes,
both in PEM format. It is used to configure a mutual TLS channel. It is
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
Expand All @@ -121,7 +124,7 @@ def __init__(
if client_cert_source:
warnings.warn("client_cert_source is deprecated", DeprecationWarning)

if channel:
if isinstance(channel, grpc.Channel):
# Ignore credentials if a channel was passed.
credentials = False
# If a channel was explicitly provided, set it.
Expand Down Expand Up @@ -162,7 +165,9 @@ def __init__(
)

if not self._grpc_channel:
self._grpc_channel = type(self).create_channel(
# initialize with the provided callable or the default channel
channel_init = channel or type(self).create_channel
self._grpc_channel = channel_init(
self._host,
# use the credentials which are saved
credentials=self._credentials,
Expand Down
Loading
Loading