Skip to content

Commit

Permalink
feat: run synthtool to pick up mtls feature (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 authored Jan 20, 2021
1 parent 6a48ff7 commit 79055a3
Show file tree
Hide file tree
Showing 221 changed files with 6,344 additions and 6,863 deletions.
1 change: 0 additions & 1 deletion packages/google-cloud-compute/.trampolinerc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
required_envvars+=(
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
"NOX_SESSION"
)

# Add env vars which are passed down into the container here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,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 @@ -325,7 +321,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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = 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 All @@ -74,8 +74,9 @@ def __init__(
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` 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 @@ -90,6 +91,8 @@ def __init__(
host=host, credentials=credentials, client_info=client_info,
)
self._session = AuthorizedSession(self._credentials)
if client_cert_source_for_mtls:
self._session.configure_mtls_channel(client_cert_source_for_mtls)

def aggregated_list(
self,
Expand Down Expand Up @@ -123,12 +126,12 @@ def aggregated_list(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"pageToken": request.page_token,
"filter": request.filter,
"orderBy": request.order_by,
"includeAllScopes": request.include_all_scopes,
"returnPartialSuccess": request.return_partial_success,
"maxResults": request.max_results,
"orderBy": request.order_by,
"filter": request.filter,
"pageToken": request.page_token,
"includeAllScopes": request.include_all_scopes,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down Expand Up @@ -233,11 +236,11 @@ def list(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"pageToken": request.page_token,
"filter": request.filter,
"orderBy": request.order_by,
"returnPartialSuccess": request.return_partial_success,
"maxResults": request.max_results,
"orderBy": request.order_by,
"filter": request.filter,
"pageToken": request.page_token,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,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 @@ -321,7 +317,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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = 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 All @@ -73,8 +73,9 @@ def __init__(
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` 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 @@ -89,6 +90,8 @@ def __init__(
host=host, credentials=credentials, client_info=client_info,
)
self._session = AuthorizedSession(self._credentials)
if client_cert_source_for_mtls:
self._session.configure_mtls_channel(client_cert_source_for_mtls)

def aggregated_list(
self,
Expand Down Expand Up @@ -122,12 +125,12 @@ def aggregated_list(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"pageToken": request.page_token,
"filter": request.filter,
"orderBy": request.order_by,
"includeAllScopes": request.include_all_scopes,
"returnPartialSuccess": request.return_partial_success,
"maxResults": request.max_results,
"orderBy": request.order_by,
"filter": request.filter,
"pageToken": request.page_token,
"includeAllScopes": request.include_all_scopes,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down Expand Up @@ -410,11 +413,11 @@ def list(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"pageToken": request.page_token,
"filter": request.filter,
"orderBy": request.order_by,
"returnPartialSuccess": request.return_partial_success,
"maxResults": request.max_results,
"orderBy": request.order_by,
"filter": request.filter,
"pageToken": request.page_token,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,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 @@ -321,7 +317,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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = 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 All @@ -73,8 +73,9 @@ def __init__(
This argument is ignored if ``channel`` is provided.
scopes (Optional(Sequence[str])): A list of scopes. This argument is
ignored if ``channel`` is provided.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` is provided.
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
certificate to configure mutual TLS HTTP channel. It is ignored
if ``channel`` 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 @@ -89,6 +90,8 @@ def __init__(
host=host, credentials=credentials, client_info=client_info,
)
self._session = AuthorizedSession(self._credentials)
if client_cert_source_for_mtls:
self._session.configure_mtls_channel(client_cert_source_for_mtls)

def aggregated_list(
self,
Expand Down Expand Up @@ -122,12 +125,12 @@ def aggregated_list(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"pageToken": request.page_token,
"filter": request.filter,
"orderBy": request.order_by,
"includeAllScopes": request.include_all_scopes,
"returnPartialSuccess": request.return_partial_success,
"maxResults": request.max_results,
"orderBy": request.order_by,
"filter": request.filter,
"pageToken": request.page_token,
"includeAllScopes": request.include_all_scopes,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down Expand Up @@ -406,11 +409,11 @@ def list(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"pageToken": request.page_token,
"filter": request.filter,
"orderBy": request.order_by,
"returnPartialSuccess": request.return_partial_success,
"maxResults": request.max_results,
"orderBy": request.order_by,
"filter": request.filter,
"pageToken": request.page_token,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down Expand Up @@ -491,8 +494,8 @@ def patch(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"requestId": request.request_id,
"autoscaler": request.autoscaler,
"requestId": request.request_id,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down Expand Up @@ -573,8 +576,8 @@ def update(
# TODO(yon-mg): handle nested fields corerctly rather than using only top level fields
# not required for GCE
query_params = {
"requestId": request.request_id,
"autoscaler": request.autoscaler,
"requestId": request.request_id,
}
# TODO(yon-mg): further discussion needed whether 'python truthiness' is appropriate here
# discards default values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,21 +266,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 @@ -323,7 +319,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
Loading

0 comments on commit 79055a3

Please sign in to comment.