Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
feat: add AWS connection type (#19)
Browse files Browse the repository at this point in the history
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/56edb2e9-da3a-409f-a2ed-e969b45e2c63/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 339292950
Source-Link: googleapis/googleapis@07d41a7
PiperOrigin-RevId: 334870265
Source-Link: googleapis/googleapis@aa72330
PiperOrigin-RevId: 333159182
Source-Link: googleapis/googleapis@3dbeac0
PiperOrigin-RevId: 333125205
Source-Link: googleapis/googleapis@4ede775
Source-Link: googleapis/googleapis@aaac658
PiperOrigin-RevId: 332381118
Source-Link: googleapis/googleapis@3de2cc8
PiperOrigin-RevId: 331031262
Source-Link: googleapis/googleapis@6a18a3c
PiperOrigin-RevId: 330793532
Source-Link: googleapis/googleapis@f17ea33
PiperOrigin-RevId: 328807403
Source-Link: googleapis/googleapis@1163f49
PiperOrigin-RevId: 328383688
Source-Link: googleapis/googleapis@1a97126
PiperOrigin-RevId: 328157915
Source-Link: googleapis/googleapis@f75a734
PiperOrigin-RevId: 327860232
Source-Link: googleapis/googleapis@806d812
PiperOrigin-RevId: 327246996
Source-Link: googleapis/googleapis@09c2579
  • Loading branch information
yoshi-automation authored Oct 28, 2020
1 parent c2bb07d commit 3d1a41a
Show file tree
Hide file tree
Showing 13 changed files with 1,065 additions and 535 deletions.
1 change: 1 addition & 0 deletions docs/connection_v1/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Types for Google Cloud Bigquery Connection v1 API

.. automodule:: google.cloud.bigquery.connection_v1.types
:members:
:show-inheritance:
4 changes: 4 additions & 0 deletions google/cloud/bigquery/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from google.cloud.bigquery.connection_v1.services.connection_service.client import (
ConnectionServiceClient,
)
from google.cloud.bigquery.connection_v1.types.connection import AwsCrossAccountRole
from google.cloud.bigquery.connection_v1.types.connection import AwsProperties
from google.cloud.bigquery.connection_v1.types.connection import CloudSqlCredential
from google.cloud.bigquery.connection_v1.types.connection import CloudSqlProperties
from google.cloud.bigquery.connection_v1.types.connection import Connection
Expand All @@ -32,6 +34,8 @@
from google.cloud.bigquery.connection_v1.types.connection import UpdateConnectionRequest

__all__ = (
"AwsCrossAccountRole",
"AwsProperties",
"CloudSqlCredential",
"CloudSqlProperties",
"Connection",
Expand Down
4 changes: 4 additions & 0 deletions google/cloud/bigquery/connection_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#

from .services.connection_service import ConnectionServiceClient
from .types.connection import AwsCrossAccountRole
from .types.connection import AwsProperties
from .types.connection import CloudSqlCredential
from .types.connection import CloudSqlProperties
from .types.connection import Connection
Expand All @@ -28,6 +30,8 @@


__all__ = (
"AwsCrossAccountRole",
"AwsProperties",
"CloudSqlCredential",
"CloudSqlProperties",
"Connection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from google.iam.v1 import policy_pb2 as policy # type: ignore
from google.protobuf import field_mask_pb2 as field_mask # type: ignore

from .transports.base import ConnectionServiceTransport
from .transports.base import ConnectionServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import ConnectionServiceGrpcAsyncIOTransport
from .client import ConnectionServiceClient

Expand All @@ -49,10 +49,49 @@ class ConnectionServiceAsyncClient:
DEFAULT_MTLS_ENDPOINT = ConnectionServiceClient.DEFAULT_MTLS_ENDPOINT

connection_path = staticmethod(ConnectionServiceClient.connection_path)
parse_connection_path = staticmethod(ConnectionServiceClient.parse_connection_path)

common_billing_account_path = staticmethod(
ConnectionServiceClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
ConnectionServiceClient.parse_common_billing_account_path
)

common_folder_path = staticmethod(ConnectionServiceClient.common_folder_path)
parse_common_folder_path = staticmethod(
ConnectionServiceClient.parse_common_folder_path
)

common_organization_path = staticmethod(
ConnectionServiceClient.common_organization_path
)
parse_common_organization_path = staticmethod(
ConnectionServiceClient.parse_common_organization_path
)

common_project_path = staticmethod(ConnectionServiceClient.common_project_path)
parse_common_project_path = staticmethod(
ConnectionServiceClient.parse_common_project_path
)

common_location_path = staticmethod(ConnectionServiceClient.common_location_path)
parse_common_location_path = staticmethod(
ConnectionServiceClient.parse_common_location_path
)

from_service_account_file = ConnectionServiceClient.from_service_account_file
from_service_account_json = from_service_account_file

@property
def transport(self) -> ConnectionServiceTransport:
"""Return the transport used by the client instance.
Returns:
ConnectionServiceTransport: The transport used by the client instance.
"""
return self._client.transport

get_transport_class = functools.partial(
type(ConnectionServiceClient).get_transport_class, type(ConnectionServiceClient)
)
Expand All @@ -63,6 +102,7 @@ def __init__(
credentials: credentials.Credentials = None,
transport: Union[str, ConnectionServiceTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiate the connection service client.
Expand All @@ -78,24 +118,30 @@ def __init__(
client_options (ClientOptions): Custom options for the client. It
won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
environment variable can also be used to override the endpoint:
"always" (always use the default mTLS endpoint), "never" (always
use the default regular endpoint, this is the default value for
the environment variable) and "auto" (auto switch to the default
mTLS endpoint if client SSL credentials is present). However,
the ``api_endpoint`` property takes precedence if provided.
(2) The ``client_cert_source`` property is used to provide client
SSL credentials for mutual TLS transport. If not provided, the
default SSL credentials will be used if present.
use the default regular endpoint) and "auto" (auto switch to the
default mTLS endpoint if client certificate is present, this is
the default value). However, the ``api_endpoint`` property takes
precedence if provided.
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
is "true", then the ``client_cert_source`` property can be used
to provide client certificate for mutual TLS transport. If
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
creation failed for any reason.
"""

self._client = ConnectionServiceClient(
credentials=credentials, transport=transport, client_options=client_options,
credentials=credentials,
transport=transport,
client_options=client_options,
client_info=client_info,
)

async def create_connection(
Expand Down Expand Up @@ -149,7 +195,8 @@ async def create_connection(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent, connection, connection_id]):
has_flattened_params = any([parent, connection, connection_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."
Expand All @@ -172,7 +219,7 @@ async def create_connection(
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.create_connection,
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -225,7 +272,8 @@ async def get_connection(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
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."
Expand All @@ -252,7 +300,7 @@ async def get_connection(
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -307,7 +355,8 @@ async def list_connections(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent]):
has_flattened_params = any([parent])
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."
Expand All @@ -334,7 +383,7 @@ async def list_connections(
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -409,7 +458,8 @@ async def update_connection(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name, connection, update_mask]):
has_flattened_params = any([name, connection, 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."
Expand All @@ -432,7 +482,7 @@ async def update_connection(
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_connection,
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -478,7 +528,8 @@ async def delete_connection(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
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."
Expand All @@ -505,7 +556,7 @@ async def delete_connection(
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -623,7 +674,8 @@ async def get_iam_policy(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([resource]):
has_flattened_params = any([resource])
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."
Expand All @@ -635,20 +687,14 @@ async def get_iam_policy(
request = iam_policy.GetIamPolicyRequest(**request)

elif not request:
request = iam_policy.GetIamPolicyRequest()

# If we have keyword arguments corresponding to fields on the
# request, apply these.

if resource is not None:
request.resource = resource
request = iam_policy.GetIamPolicyRequest(resource=resource,)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_iam_policy,
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -769,7 +815,8 @@ async def set_iam_policy(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([resource]):
has_flattened_params = any([resource])
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."
Expand All @@ -781,20 +828,14 @@ async def set_iam_policy(
request = iam_policy.SetIamPolicyRequest(**request)

elif not request:
request = iam_policy.SetIamPolicyRequest()

# If we have keyword arguments corresponding to fields on the
# request, apply these.

if resource is not None:
request.resource = resource
request = iam_policy.SetIamPolicyRequest(resource=resource,)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.set_iam_policy,
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand Down Expand Up @@ -862,7 +903,8 @@ async def test_iam_permissions(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([resource, permissions]):
has_flattened_params = any([resource, permissions])
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."
Expand All @@ -874,23 +916,16 @@ async def test_iam_permissions(
request = iam_policy.TestIamPermissionsRequest(**request)

elif not request:
request = iam_policy.TestIamPermissionsRequest()

# If we have keyword arguments corresponding to fields on the
# request, apply these.

if resource is not None:
request.resource = resource

if permissions:
request.permissions.extend(permissions)
request = iam_policy.TestIamPermissionsRequest(
resource=resource, permissions=permissions,
)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.test_iam_permissions,
default_timeout=60.0,
client_info=_client_info,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
Expand All @@ -907,13 +942,13 @@ async def test_iam_permissions(


try:
_client_info = gapic_v1.client_info.ClientInfo(
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-bigquery-connection",
).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()


__all__ = ("ConnectionServiceAsyncClient",)
Loading

0 comments on commit 3d1a41a

Please sign in to comment.