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

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: add topic field to Secret (#80)
* changes without context

        autosynth cannot find the source of changes triggered by earlier changes in this
        repository, or by version upgrades to tools such as linters.

* feat: added expire_time and ttl fields to Secret

PiperOrigin-RevId: 352563582

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Jan 19 07:29:20 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 9ecdacc9a00e1dd443b11bf10215d6e7648db8a7
Source-Link: googleapis/googleapis@9ecdacc

* chore: upgrade gapic-generator-python to 0.40.5

PiperOrigin-RevId: 354996675

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Feb 1 12:11:49 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 20712b8fe95001b312f62c6c5f33e3e3ec92cfaf
Source-Link: googleapis/googleapis@20712b8

* chore: update gapic-generator-python

PiperOrigin-RevId: 355923884

Source-Author: Google APIs <noreply@google.com>
Source-Date: Fri Feb 5 14:04:52 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 5e3dacee19405529b841b53797df799c2383536c
Source-Link: googleapis/googleapis@5e3dace

* chore: remove non-existent package option in java_gapic_library rules for cloud APIs

Committer: @miraleung
PiperOrigin-RevId: 356328938

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Feb 8 12:39:42 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 78e0057d81c6969507bf1195b5aad8ac3e7feafd
Source-Link: googleapis/googleapis@78e0057

* feat: added topic field to Secret

PiperOrigin-RevId: 359285402

Source-Author: Google APIs <noreply@google.com>
Source-Date: Wed Feb 24 07:59:50 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 8b3d36daaf5561496b7d4075fba4f2c52d18ca1c
Source-Link: googleapis/googleapis@8b3d36d

* chore: update gapic-generator-python to 0.40.11

PiperOrigin-RevId: 359562873

Source-Author: Google APIs <noreply@google.com>
Source-Date: Thu Feb 25 10:52:32 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 07932bb995e7dc91b43620ea8402c6668c7d102c
Source-Link: googleapis/googleapis@07932bb

* chore: upgrade gapic-generator-python to 0.42.2

PiperOrigin-RevId: 361662015

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Mar 8 14:47:18 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 28a591963253d52ce3a25a918cafbdd9928de8cf
Source-Link: googleapis/googleapis@28a5919
  • Loading branch information
yoshi-automation committed Mar 10, 2021
1 parent 0e29327 commit f83c035
Show file tree
Hide file tree
Showing 20 changed files with 1,099 additions and 285 deletions.
2 changes: 2 additions & 0 deletions google/cloud/secretmanager/__init__.py
Expand Up @@ -30,6 +30,7 @@
from google.cloud.secretmanager_v1.types.resources import Secret
from google.cloud.secretmanager_v1.types.resources import SecretPayload
from google.cloud.secretmanager_v1.types.resources import SecretVersion
from google.cloud.secretmanager_v1.types.resources import Topic
from google.cloud.secretmanager_v1.types.service import AccessSecretVersionRequest
from google.cloud.secretmanager_v1.types.service import AccessSecretVersionResponse
from google.cloud.secretmanager_v1.types.service import AddSecretVersionRequest
Expand Down Expand Up @@ -70,5 +71,6 @@
"SecretManagerServiceClient",
"SecretPayload",
"SecretVersion",
"Topic",
"UpdateSecretRequest",
)
2 changes: 2 additions & 0 deletions google/cloud/secretmanager_v1/__init__.py
Expand Up @@ -23,6 +23,7 @@
from .types.resources import Secret
from .types.resources import SecretPayload
from .types.resources import SecretVersion
from .types.resources import Topic
from .types.service import AccessSecretVersionRequest
from .types.service import AccessSecretVersionResponse
from .types.service import AddSecretVersionRequest
Expand Down Expand Up @@ -62,6 +63,7 @@
"Secret",
"SecretPayload",
"SecretVersion",
"Topic",
"UpdateSecretRequest",
"SecretManagerServiceClient",
)
Expand Up @@ -63,6 +63,8 @@ class SecretManagerServiceAsyncClient:
parse_secret_version_path = staticmethod(
SecretManagerServiceClient.parse_secret_version_path
)
topic_path = staticmethod(SecretManagerServiceClient.topic_path)
parse_topic_path = staticmethod(SecretManagerServiceClient.parse_topic_path)

common_billing_account_path = staticmethod(
SecretManagerServiceClient.common_billing_account_path
Expand Down Expand Up @@ -93,8 +95,36 @@ class SecretManagerServiceAsyncClient:
SecretManagerServiceClient.parse_common_location_path
)

from_service_account_info = SecretManagerServiceClient.from_service_account_info
from_service_account_file = SecretManagerServiceClient.from_service_account_file
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
"""Creates an instance of this client using the provided credentials info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
SecretManagerServiceAsyncClient: The constructed client.
"""
return SecretManagerServiceClient.from_service_account_info.__func__(SecretManagerServiceAsyncClient, info, *args, **kwargs) # type: ignore

@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
SecretManagerServiceAsyncClient: The constructed client.
"""
return SecretManagerServiceClient.from_service_account_file.__func__(SecretManagerServiceAsyncClient, filename, *args, **kwargs) # type: ignore

from_service_account_json = from_service_account_file

@property
Expand Down
Expand Up @@ -199,6 +199,17 @@ def parse_secret_version_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

@staticmethod
def topic_path(project: str, topic: str,) -> str:
"""Return a fully-qualified topic string."""
return "projects/{project}/topics/{topic}".format(project=project, topic=topic,)

@staticmethod
def parse_topic_path(path: str) -> Dict[str, str]:
"""Parse a topic path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/topics/(?P<topic>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_billing_account_path(billing_account: str,) -> str:
"""Return a fully-qualified billing_account string."""
Expand Down Expand Up @@ -313,21 +324,17 @@ def __init__(
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
)

ssl_credentials = None
client_cert_source_func = None
is_mtls = False
if use_client_cert:
if client_options.client_cert_source:
import grpc # type: ignore

cert, key = client_options.client_cert_source()
ssl_credentials = grpc.ssl_channel_credentials(
certificate_chain=cert, private_key=key
)
is_mtls = True
client_cert_source_func = client_options.client_cert_source
else:
creds = SslCredentials()
is_mtls = creds.is_mtls
ssl_credentials = creds.ssl_credentials if is_mtls else None
is_mtls = mtls.has_default_client_cert_source()
client_cert_source_func = (
mtls.default_client_cert_source() if is_mtls else None
)

# Figure out which api endpoint to use.
if client_options.api_endpoint is not None:
Expand Down Expand Up @@ -370,7 +377,7 @@ def __init__(
credentials_file=client_options.credentials_file,
host=api_endpoint,
scopes=client_options.scopes,
ssl_channel_credentials=ssl_credentials,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
)
Expand Down Expand Up @@ -1488,10 +1495,13 @@ def set_iam_policy(
"""
# Create or coerce a protobuf request object.

# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
request = iam_policy.SetIamPolicyRequest(**request)
elif not request:
# Null request, just make one.
request = iam_policy.SetIamPolicyRequest()

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
Expand Down Expand Up @@ -1593,10 +1603,13 @@ def get_iam_policy(
"""
# Create or coerce a protobuf request object.

# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
request = iam_policy.GetIamPolicyRequest(**request)
elif not request:
# Null request, just make one.
request = iam_policy.GetIamPolicyRequest()

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
Expand Down Expand Up @@ -1648,10 +1661,13 @@ def test_iam_permissions(
"""
# Create or coerce a protobuf request object.

# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
request = iam_policy.TestIamPermissionsRequest(**request)
elif not request:
# Null request, just make one.
request = iam_policy.TestIamPermissionsRequest()

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
Expand Down
Expand Up @@ -15,7 +15,16 @@
# limitations under the License.
#

from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
from typing import (
Any,
AsyncIterable,
Awaitable,
Callable,
Iterable,
Sequence,
Tuple,
Optional,
)

from google.cloud.secretmanager_v1.types import resources
from google.cloud.secretmanager_v1.types import service
Expand Down
Expand Up @@ -67,6 +67,7 @@ def __init__(
api_mtls_endpoint: str = None,
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
ssl_channel_credentials: grpc.ChannelCredentials = None,
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
Expand Down Expand Up @@ -97,6 +98,10 @@ def __init__(
``api_mtls_endpoint`` is None.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` 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 mutual TLS channel. It is
ignored if ``channel`` 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 @@ -113,6 +118,11 @@ def __init__(
"""
self._ssl_channel_credentials = ssl_channel_credentials

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
if client_cert_source:
warnings.warn("client_cert_source is deprecated", DeprecationWarning)

if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
Expand All @@ -122,11 +132,6 @@ def __init__(
self._grpc_channel = channel
self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
DeprecationWarning,
)

host = (
api_mtls_endpoint
if ":" in api_mtls_endpoint
Expand Down Expand Up @@ -170,12 +175,18 @@ def __init__(
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
)

if client_cert_source_for_mtls and not ssl_channel_credentials:
cert, key = client_cert_source_for_mtls()
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
certificate_chain=cert, private_key=key
)

# create a new channel. The provided one is ignored.
self._grpc_channel = type(self).create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
ssl_credentials=ssl_channel_credentials,
ssl_credentials=self._ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
Expand Down
Expand Up @@ -111,6 +111,7 @@ def __init__(
api_mtls_endpoint: str = None,
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
ssl_channel_credentials: grpc.ChannelCredentials = None,
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
Expand Down Expand Up @@ -142,6 +143,10 @@ def __init__(
``api_mtls_endpoint`` is None.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` 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 mutual TLS channel. It is
ignored if ``channel`` 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 @@ -158,6 +163,11 @@ def __init__(
"""
self._ssl_channel_credentials = ssl_channel_credentials

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
if client_cert_source:
warnings.warn("client_cert_source is deprecated", DeprecationWarning)

if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
Expand All @@ -167,11 +177,6 @@ def __init__(
self._grpc_channel = channel
self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
DeprecationWarning,
)

host = (
api_mtls_endpoint
if ":" in api_mtls_endpoint
Expand Down Expand Up @@ -215,12 +220,18 @@ def __init__(
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
)

if client_cert_source_for_mtls and not ssl_channel_credentials:
cert, key = client_cert_source_for_mtls()
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
certificate_chain=cert, private_key=key
)

# create a new channel. The provided one is ignored.
self._grpc_channel = type(self).create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
ssl_credentials=ssl_channel_credentials,
ssl_credentials=self._ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
Expand Down

0 comments on commit f83c035

Please sign in to comment.