Skip to content

Commit db12cda

Browse files
authored
Add 'client_options' support, update list method docstrings (via synth). (#8535)
Supersedes #8320.
1 parent 91084e6 commit db12cda

11 files changed

+99
-38
lines changed

google/cloud/logging_v2/gapic/config_service_v2_client.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -109,6 +110,7 @@ def __init__(
109110
credentials=None,
110111
client_config=None,
111112
client_info=None,
113+
client_options=None,
112114
):
113115
"""Constructor.
114116
@@ -139,6 +141,9 @@ def __init__(
139141
API requests. If ``None``, then default info will be used.
140142
Generally, you only need to set this if you're developing
141143
your own client library.
144+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
145+
Client options used to set user options on the client. API Endpoint
146+
should be set through client_options.
142147
"""
143148
# Raise deprecation warnings for things we want to go away.
144149
if client_config is not None:
@@ -157,6 +162,15 @@ def __init__(
157162
stacklevel=2,
158163
)
159164

165+
api_endpoint = self.SERVICE_ADDRESS
166+
if client_options:
167+
if type(client_options) == dict:
168+
client_options = google.api_core.client_options.from_dict(
169+
client_options
170+
)
171+
if client_options.api_endpoint:
172+
api_endpoint = client_options.api_endpoint
173+
160174
# Instantiate the transport.
161175
# The transport is responsible for handling serialization and
162176
# deserialization and actually sending data to the service.
@@ -165,6 +179,7 @@ def __init__(
165179
self.transport = transport(
166180
credentials=credentials,
167181
default_class=config_service_v2_grpc_transport.ConfigServiceV2GrpcTransport,
182+
address=api_endpoint,
168183
)
169184
else:
170185
if credentials:
@@ -175,7 +190,7 @@ def __init__(
175190
self.transport = transport
176191
else:
177192
self.transport = config_service_v2_grpc_transport.ConfigServiceV2GrpcTransport(
178-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
193+
address=api_endpoint, channel=channel, credentials=credentials
179194
)
180195

181196
if client_info is None:
@@ -257,10 +272,10 @@ def list_sinks(
257272
that is provided to the method.
258273
259274
Returns:
260-
A :class:`~google.gax.PageIterator` instance. By default, this
261-
is an iterable of :class:`~google.cloud.logging_v2.types.LogSink` instances.
262-
This object can also be configured to iterate over the pages
263-
of the response through the `options` parameter.
275+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
276+
An iterable of :class:`~google.cloud.logging_v2.types.LogSink` instances.
277+
You can also iterate over the pages of the response
278+
using its `pages` property.
264279
265280
Raises:
266281
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -753,10 +768,10 @@ def list_exclusions(
753768
that is provided to the method.
754769
755770
Returns:
756-
A :class:`~google.gax.PageIterator` instance. By default, this
757-
is an iterable of :class:`~google.cloud.logging_v2.types.LogExclusion` instances.
758-
This object can also be configured to iterate over the pages
759-
of the response through the `options` parameter.
771+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
772+
An iterable of :class:`~google.cloud.logging_v2.types.LogExclusion` instances.
773+
You can also iterate over the pages of the response
774+
using its `pages` property.
760775
761776
Raises:
762777
google.api_core.exceptions.GoogleAPICallError: If the request

google/cloud/logging_v2/gapic/logging_service_v2_client.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -94,6 +95,7 @@ def __init__(
9495
credentials=None,
9596
client_config=None,
9697
client_info=None,
98+
client_options=None,
9799
):
98100
"""Constructor.
99101
@@ -124,6 +126,9 @@ def __init__(
124126
API requests. If ``None``, then default info will be used.
125127
Generally, you only need to set this if you're developing
126128
your own client library.
129+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
130+
Client options used to set user options on the client. API Endpoint
131+
should be set through client_options.
127132
"""
128133
# Raise deprecation warnings for things we want to go away.
129134
if client_config is not None:
@@ -142,6 +147,15 @@ def __init__(
142147
stacklevel=2,
143148
)
144149

150+
api_endpoint = self.SERVICE_ADDRESS
151+
if client_options:
152+
if type(client_options) == dict:
153+
client_options = google.api_core.client_options.from_dict(
154+
client_options
155+
)
156+
if client_options.api_endpoint:
157+
api_endpoint = client_options.api_endpoint
158+
145159
# Instantiate the transport.
146160
# The transport is responsible for handling serialization and
147161
# deserialization and actually sending data to the service.
@@ -150,6 +164,7 @@ def __init__(
150164
self.transport = transport(
151165
credentials=credentials,
152166
default_class=logging_service_v2_grpc_transport.LoggingServiceV2GrpcTransport,
167+
address=api_endpoint,
153168
)
154169
else:
155170
if credentials:
@@ -160,7 +175,7 @@ def __init__(
160175
self.transport = transport
161176
else:
162177
self.transport = logging_service_v2_grpc_transport.LoggingServiceV2GrpcTransport(
163-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
178+
address=api_endpoint, channel=channel, credentials=credentials
164179
)
165180

166181
if client_info is None:
@@ -500,10 +515,10 @@ def list_log_entries(
500515
that is provided to the method.
501516
502517
Returns:
503-
A :class:`~google.gax.PageIterator` instance. By default, this
504-
is an iterable of :class:`~google.cloud.logging_v2.types.LogEntry` instances.
505-
This object can also be configured to iterate over the pages
506-
of the response through the `options` parameter.
518+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
519+
An iterable of :class:`~google.cloud.logging_v2.types.LogEntry` instances.
520+
You can also iterate over the pages of the response
521+
using its `pages` property.
507522
508523
Raises:
509524
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -590,10 +605,10 @@ def list_monitored_resource_descriptors(
590605
that is provided to the method.
591606
592607
Returns:
593-
A :class:`~google.gax.PageIterator` instance. By default, this
594-
is an iterable of :class:`~google.cloud.logging_v2.types.MonitoredResourceDescriptor` instances.
595-
This object can also be configured to iterate over the pages
596-
of the response through the `options` parameter.
608+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
609+
An iterable of :class:`~google.cloud.logging_v2.types.MonitoredResourceDescriptor` instances.
610+
You can also iterate over the pages of the response
611+
using its `pages` property.
597612
598613
Raises:
599614
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -692,10 +707,10 @@ def list_logs(
692707
that is provided to the method.
693708
694709
Returns:
695-
A :class:`~google.gax.PageIterator` instance. By default, this
696-
is an iterable of :class:`str` instances.
697-
This object can also be configured to iterate over the pages
698-
of the response through the `options` parameter.
710+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
711+
An iterable of :class:`str` instances.
712+
You can also iterate over the pages of the response
713+
using its `pages` property.
699714
700715
Raises:
701716
google.api_core.exceptions.GoogleAPICallError: If the request

google/cloud/logging_v2/gapic/metrics_service_v2_client.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -99,6 +100,7 @@ def __init__(
99100
credentials=None,
100101
client_config=None,
101102
client_info=None,
103+
client_options=None,
102104
):
103105
"""Constructor.
104106
@@ -129,6 +131,9 @@ def __init__(
129131
API requests. If ``None``, then default info will be used.
130132
Generally, you only need to set this if you're developing
131133
your own client library.
134+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
135+
Client options used to set user options on the client. API Endpoint
136+
should be set through client_options.
132137
"""
133138
# Raise deprecation warnings for things we want to go away.
134139
if client_config is not None:
@@ -147,6 +152,15 @@ def __init__(
147152
stacklevel=2,
148153
)
149154

155+
api_endpoint = self.SERVICE_ADDRESS
156+
if client_options:
157+
if type(client_options) == dict:
158+
client_options = google.api_core.client_options.from_dict(
159+
client_options
160+
)
161+
if client_options.api_endpoint:
162+
api_endpoint = client_options.api_endpoint
163+
150164
# Instantiate the transport.
151165
# The transport is responsible for handling serialization and
152166
# deserialization and actually sending data to the service.
@@ -155,6 +169,7 @@ def __init__(
155169
self.transport = transport(
156170
credentials=credentials,
157171
default_class=metrics_service_v2_grpc_transport.MetricsServiceV2GrpcTransport,
172+
address=api_endpoint,
158173
)
159174
else:
160175
if credentials:
@@ -165,7 +180,7 @@ def __init__(
165180
self.transport = transport
166181
else:
167182
self.transport = metrics_service_v2_grpc_transport.MetricsServiceV2GrpcTransport(
168-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
183+
address=api_endpoint, channel=channel, credentials=credentials
169184
)
170185

171186
if client_info is None:
@@ -244,10 +259,10 @@ def list_log_metrics(
244259
that is provided to the method.
245260
246261
Returns:
247-
A :class:`~google.gax.PageIterator` instance. By default, this
248-
is an iterable of :class:`~google.cloud.logging_v2.types.LogMetric` instances.
249-
This object can also be configured to iterate over the pages
250-
of the response through the `options` parameter.
262+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
263+
An iterable of :class:`~google.cloud.logging_v2.types.LogMetric` instances.
264+
You can also iterate over the pages of the response
265+
using its `pages` property.
251266
252267
Raises:
253268
google.api_core.exceptions.GoogleAPICallError: If the request

google/cloud/logging_v2/gapic/transports/config_service_v2_grpc_transport.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def __init__(
7777
}
7878

7979
@classmethod
80-
def create_channel(cls, address="logging.googleapis.com:443", credentials=None):
80+
def create_channel(
81+
cls, address="logging.googleapis.com:443", credentials=None, **kwargs
82+
):
8183
"""Create and return a gRPC channel object.
8284
8385
Args:
@@ -87,12 +89,14 @@ def create_channel(cls, address="logging.googleapis.com:443", credentials=None):
8789
credentials identify this application to the service. If
8890
none are specified, the client will attempt to ascertain
8991
the credentials from the environment.
92+
kwargs (dict): Keyword arguments, which are passed to the
93+
channel creation.
9094
9195
Returns:
9296
grpc.Channel: A gRPC channel object.
9397
"""
9498
return google.api_core.grpc_helpers.create_channel(
95-
address, credentials=credentials, scopes=cls._OAUTH_SCOPES
99+
address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs
96100
)
97101

98102
@property

google/cloud/logging_v2/gapic/transports/logging_service_v2_grpc_transport.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def __init__(
7575
}
7676

7777
@classmethod
78-
def create_channel(cls, address="logging.googleapis.com:443", credentials=None):
78+
def create_channel(
79+
cls, address="logging.googleapis.com:443", credentials=None, **kwargs
80+
):
7981
"""Create and return a gRPC channel object.
8082
8183
Args:
@@ -85,12 +87,14 @@ def create_channel(cls, address="logging.googleapis.com:443", credentials=None):
8587
credentials identify this application to the service. If
8688
none are specified, the client will attempt to ascertain
8789
the credentials from the environment.
90+
kwargs (dict): Keyword arguments, which are passed to the
91+
channel creation.
8892
8993
Returns:
9094
grpc.Channel: A gRPC channel object.
9195
"""
9296
return google.api_core.grpc_helpers.create_channel(
93-
address, credentials=credentials, scopes=cls._OAUTH_SCOPES
97+
address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs
9498
)
9599

96100
@property

google/cloud/logging_v2/gapic/transports/metrics_service_v2_grpc_transport.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def __init__(
7777
}
7878

7979
@classmethod
80-
def create_channel(cls, address="logging.googleapis.com:443", credentials=None):
80+
def create_channel(
81+
cls, address="logging.googleapis.com:443", credentials=None, **kwargs
82+
):
8183
"""Create and return a gRPC channel object.
8284
8385
Args:
@@ -87,12 +89,14 @@ def create_channel(cls, address="logging.googleapis.com:443", credentials=None):
8789
credentials identify this application to the service. If
8890
none are specified, the client will attempt to ascertain
8991
the credentials from the environment.
92+
kwargs (dict): Keyword arguments, which are passed to the
93+
channel creation.
9094
9195
Returns:
9296
grpc.Channel: A gRPC channel object.
9397
"""
9498
return google.api_core.grpc_helpers.create_channel(
95-
address, credentials=credentials, scopes=cls._OAUTH_SCOPES
99+
address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs
96100
)
97101

98102
@property

google/cloud/logging_v2/proto/log_entry_pb2.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google/cloud/logging_v2/proto/logging_config_pb2.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google/cloud/logging_v2/proto/logging_metrics_pb2.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google/cloud/logging_v2/proto/logging_pb2.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)