Skip to content

Commit b737ea0

Browse files
fix: update GOOGLE_API_USE_MTLS values (#449)
Go client uses lower case, so change the values to lower case.
1 parent eaa6f36 commit b737ea0

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
152152
(1) The ``api_endpoint`` property can be used to override the
153153
default endpoint provided by the client. GOOGLE_API_USE_MTLS
154154
environment variable can also be used to override the endpoint:
155-
"Always" (always use the default mTLS endpoint), "Never" (always
155+
"always" (always use the default mTLS endpoint), "never" (always
156156
use the default regular endpoint, this is the default value for
157-
the environment variable) and "Auto" (auto switch to the default
157+
the environment variable) and "auto" (auto switch to the default
158158
mTLS endpoint if client SSL credentials is present). However,
159159
the ``api_endpoint`` property takes precedence if provided.
160160
(2) The ``client_cert_source`` property is used to provide client
@@ -171,12 +171,12 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
171171
client_options = ClientOptions.ClientOptions()
172172

173173
if transport is None and client_options.api_endpoint is None:
174-
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "Never")
175-
if use_mtls_env == "Never":
174+
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "never")
175+
if use_mtls_env == "never":
176176
client_options.api_endpoint = self.DEFAULT_ENDPOINT
177-
elif use_mtls_env == "Always":
177+
elif use_mtls_env == "always":
178178
client_options.api_endpoint = self.DEFAULT_MTLS_ENDPOINT
179-
elif use_mtls_env == "Auto":
179+
elif use_mtls_env == "auto":
180180
has_client_cert_source = (
181181
client_options.client_cert_source is not None
182182
or mtls.has_default_client_cert_source()

gapic/ads-templates/tests/unit/%name_%version/%sub/test_%service.py.j2

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
100100
)
101101

102102
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is
103-
# "Never".
104-
os.environ["GOOGLE_API_USE_MTLS"] = "Never"
103+
# "never".
104+
os.environ["GOOGLE_API_USE_MTLS"] = "never"
105105
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
106106
grpc_transport.return_value = None
107107
client = {{ service.client_name }}()
@@ -113,8 +113,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
113113
)
114114

115115
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is
116-
# "Always".
117-
os.environ["GOOGLE_API_USE_MTLS"] = "Always"
116+
# "always".
117+
os.environ["GOOGLE_API_USE_MTLS"] = "always"
118118
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
119119
grpc_transport.return_value = None
120120
client = {{ service.client_name }}()
@@ -126,8 +126,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
126126
)
127127

128128
# Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is
129-
# "Auto", and client_cert_source is provided.
130-
os.environ["GOOGLE_API_USE_MTLS"] = "Auto"
129+
# "auto", and client_cert_source is provided.
130+
os.environ["GOOGLE_API_USE_MTLS"] = "auto"
131131
options = client_options.ClientOptions(client_cert_source=client_cert_source_callback)
132132
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
133133
grpc_transport.return_value = None
@@ -140,8 +140,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
140140
)
141141

142142
# Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is
143-
# "Auto", and default_client_cert_source is provided.
144-
os.environ["GOOGLE_API_USE_MTLS"] = "Auto"
143+
# "auto", and default_client_cert_source is provided.
144+
os.environ["GOOGLE_API_USE_MTLS"] = "auto"
145145
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
146146
with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True):
147147
grpc_transport.return_value = None
@@ -154,8 +154,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
154154
)
155155

156156
# Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is
157-
# "Auto", but client_cert_source and default_client_cert_source are None.
158-
os.environ["GOOGLE_API_USE_MTLS"] = "Auto"
157+
# "auto", but client_cert_source and default_client_cert_source are None.
158+
os.environ["GOOGLE_API_USE_MTLS"] = "auto"
159159
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
160160
with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False):
161161
grpc_transport.return_value = None

gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
152152
(1) The ``api_endpoint`` property can be used to override the
153153
default endpoint provided by the client. GOOGLE_API_USE_MTLS
154154
environment variable can also be used to override the endpoint:
155-
"Always" (always use the default mTLS endpoint), "Never" (always
155+
"always" (always use the default mTLS endpoint), "never" (always
156156
use the default regular endpoint, this is the default value for
157-
the environment variable) and "Auto" (auto switch to the default
157+
the environment variable) and "auto" (auto switch to the default
158158
mTLS endpoint if client SSL credentials is present). However,
159159
the ``api_endpoint`` property takes precedence if provided.
160160
(2) The ``client_cert_source`` property is used to provide client
@@ -171,12 +171,12 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
171171
client_options = ClientOptions.ClientOptions()
172172

173173
if transport is None and client_options.api_endpoint is None:
174-
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "Never")
175-
if use_mtls_env == "Never":
174+
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "never")
175+
if use_mtls_env == "never":
176176
client_options.api_endpoint = self.DEFAULT_ENDPOINT
177-
elif use_mtls_env == "Always":
177+
elif use_mtls_env == "always":
178178
client_options.api_endpoint = self.DEFAULT_MTLS_ENDPOINT
179-
elif use_mtls_env == "Auto":
179+
elif use_mtls_env == "auto":
180180
has_client_cert_source = (
181181
client_options.client_cert_source is not None
182182
or mtls.has_default_client_cert_source()

gapic/templates/tests/unit/%name_%version/%sub/test_%service.py.j2

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
100100
)
101101

102102
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is
103-
# "Never".
104-
os.environ["GOOGLE_API_USE_MTLS"] = "Never"
103+
# "never".
104+
os.environ["GOOGLE_API_USE_MTLS"] = "never"
105105
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
106106
grpc_transport.return_value = None
107107
client = {{ service.client_name }}()
@@ -113,8 +113,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
113113
)
114114

115115
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS is
116-
# "Always".
117-
os.environ["GOOGLE_API_USE_MTLS"] = "Always"
116+
# "always".
117+
os.environ["GOOGLE_API_USE_MTLS"] = "always"
118118
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
119119
grpc_transport.return_value = None
120120
client = {{ service.client_name }}()
@@ -126,8 +126,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
126126
)
127127

128128
# Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is
129-
# "Auto", and client_cert_source is provided.
130-
os.environ["GOOGLE_API_USE_MTLS"] = "Auto"
129+
# "auto", and client_cert_source is provided.
130+
os.environ["GOOGLE_API_USE_MTLS"] = "auto"
131131
options = client_options.ClientOptions(client_cert_source=client_cert_source_callback)
132132
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
133133
grpc_transport.return_value = None
@@ -140,8 +140,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
140140
)
141141

142142
# Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is
143-
# "Auto", and default_client_cert_source is provided.
144-
os.environ["GOOGLE_API_USE_MTLS"] = "Auto"
143+
# "auto", and default_client_cert_source is provided.
144+
os.environ["GOOGLE_API_USE_MTLS"] = "auto"
145145
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
146146
with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True):
147147
grpc_transport.return_value = None
@@ -154,8 +154,8 @@ def test_{{ service.client_name|snake_case }}_client_options():
154154
)
155155

156156
# Check the case api_endpoint is not provided, GOOGLE_API_USE_MTLS is
157-
# "Auto", but client_cert_source and default_client_cert_source are None.
158-
os.environ["GOOGLE_API_USE_MTLS"] = "Auto"
157+
# "auto", but client_cert_source and default_client_cert_source are None.
158+
os.environ["GOOGLE_API_USE_MTLS"] = "auto"
159159
with mock.patch('{{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + service.meta.address.subpackage)|join(".") }}.services.{{ service.name|snake_case }}.transports.{{ service.name }}GrpcTransport.__init__') as grpc_transport:
160160
with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False):
161161
grpc_transport.return_value = None

0 commit comments

Comments
 (0)