1313# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414# See the License for the specific language governing permissions and
1515# limitations under the License.
16+
1617"""Accesses the google.cloud.dialogflow.v2 Contexts API."""
1718
1819import functools
1920import pkg_resources
2021import warnings
2122
2223from google .oauth2 import service_account
24+ import google .api_core .client_options
2325import google .api_core .gapic_v1 .client_info
2426import google .api_core .gapic_v1 .config
2527import google .api_core .gapic_v1 .method
4143from google .protobuf import field_mask_pb2
4244from google .protobuf import struct_pb2
4345
46+
4447_GAPIC_LIBRARY_VERSION = pkg_resources .get_distribution ("dialogflow" ).version
4548
4649
@@ -61,7 +64,7 @@ class ContextsClient(object):
6164 matched for a ``DetectIntent`` request.
6265
6366 For more information about contexts, see the `Dialogflow
64- documentation <https://cloud.google.com/dialogflow-enterprise /docs/contexts-overview>`__.
67+ documentation <https://cloud.google.com/dialogflow/docs/contexts-overview>`__.
6568 """
6669
6770 SERVICE_ADDRESS = "dialogflow.googleapis.com:443"
@@ -117,6 +120,7 @@ def __init__(
117120 credentials = None ,
118121 client_config = None ,
119122 client_info = None ,
123+ client_options = None ,
120124 ):
121125 """Constructor.
122126
@@ -147,6 +151,9 @@ def __init__(
147151 API requests. If ``None``, then default info will be used.
148152 Generally, you only need to set this if you're developing
149153 your own client library.
154+ client_options (Union[dict, google.api_core.client_options.ClientOptions]):
155+ Client options used to set user options on the client. API Endpoint
156+ should be set through client_options.
150157 """
151158 # Raise deprecation warnings for things we want to go away.
152159 if client_config is not None :
@@ -165,6 +172,15 @@ def __init__(
165172 stacklevel = 2 ,
166173 )
167174
175+ api_endpoint = self .SERVICE_ADDRESS
176+ if client_options :
177+ if type (client_options ) == dict :
178+ client_options = google .api_core .client_options .from_dict (
179+ client_options
180+ )
181+ if client_options .api_endpoint :
182+ api_endpoint = client_options .api_endpoint
183+
168184 # Instantiate the transport.
169185 # The transport is responsible for handling serialization and
170186 # deserialization and actually sending data to the service.
@@ -173,6 +189,7 @@ def __init__(
173189 self .transport = transport (
174190 credentials = credentials ,
175191 default_class = contexts_grpc_transport .ContextsGrpcTransport ,
192+ address = api_endpoint ,
176193 )
177194 else :
178195 if credentials :
@@ -183,7 +200,7 @@ def __init__(
183200 self .transport = transport
184201 else :
185202 self .transport = contexts_grpc_transport .ContextsGrpcTransport (
186- address = self . SERVICE_ADDRESS , channel = channel , credentials = credentials
203+ address = api_endpoint , channel = channel , credentials = credentials
187204 )
188205
189206 if client_info is None :
@@ -250,19 +267,19 @@ def list_contexts(
250267 streaming is performed per-page, this determines the maximum number
251268 of resources in a page.
252269 retry (Optional[google.api_core.retry.Retry]): A retry object used
253- to retry requests. If ``None`` is specified, requests will not
254- be retried.
270+ to retry requests. If ``None`` is specified, requests will
271+ be retried using a default configuration .
255272 timeout (Optional[float]): The amount of time, in seconds, to wait
256273 for the request to complete. Note that if ``retry`` is
257274 specified, the timeout applies to each individual attempt.
258275 metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
259276 that is provided to the method.
260277
261278 Returns:
262- A :class:`~google.gax. PageIterator` instance. By default, this
263- is an iterable of :class:`~google.cloud.dialogflow_v2.types.Context` instances.
264- This object can also be configured to iterate over the pages
265- of the response through the `options` parameter .
279+ A :class:`~google.api_core.page_iterator. PageIterator` instance.
280+ An iterable of :class:`~google.cloud.dialogflow_v2.types.Context` instances.
281+ You can also iterate over the pages of the response
282+ using its `pages` property .
266283
267284 Raises:
268285 google.api_core.exceptions.GoogleAPICallError: If the request
@@ -334,8 +351,8 @@ def get_context(
334351 name (str): Required. The name of the context. Format:
335352 ``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``.
336353 retry (Optional[google.api_core.retry.Retry]): A retry object used
337- to retry requests. If ``None`` is specified, requests will not
338- be retried.
354+ to retry requests. If ``None`` is specified, requests will
355+ be retried using a default configuration .
339356 timeout (Optional[float]): The amount of time, in seconds, to wait
340357 for the request to complete. Note that if ``retry`` is
341358 specified, the timeout applies to each individual attempt.
@@ -414,8 +431,8 @@ def create_context(
414431 If a dict is provided, it must be of the same form as the protobuf
415432 message :class:`~google.cloud.dialogflow_v2.types.Context`
416433 retry (Optional[google.api_core.retry.Retry]): A retry object used
417- to retry requests. If ``None`` is specified, requests will not
418- be retried.
434+ to retry requests. If ``None`` is specified, requests will
435+ be retried using a default configuration .
419436 timeout (Optional[float]): The amount of time, in seconds, to wait
420437 for the request to complete. Note that if ``retry`` is
421438 specified, the timeout applies to each individual attempt.
@@ -492,8 +509,8 @@ def update_context(
492509 If a dict is provided, it must be of the same form as the protobuf
493510 message :class:`~google.cloud.dialogflow_v2.types.FieldMask`
494511 retry (Optional[google.api_core.retry.Retry]): A retry object used
495- to retry requests. If ``None`` is specified, requests will not
496- be retried.
512+ to retry requests. If ``None`` is specified, requests will
513+ be retried using a default configuration .
497514 timeout (Optional[float]): The amount of time, in seconds, to wait
498515 for the request to complete. Note that if ``retry`` is
499516 specified, the timeout applies to each individual attempt.
@@ -564,8 +581,8 @@ def delete_context(
564581 name (str): Required. The name of the context to delete. Format:
565582 ``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``.
566583 retry (Optional[google.api_core.retry.Retry]): A retry object used
567- to retry requests. If ``None`` is specified, requests will not
568- be retried.
584+ to retry requests. If ``None`` is specified, requests will
585+ be retried using a default configuration .
569586 timeout (Optional[float]): The amount of time, in seconds, to wait
570587 for the request to complete. Note that if ``retry`` is
571588 specified, the timeout applies to each individual attempt.
@@ -631,8 +648,8 @@ def delete_all_contexts(
631648 parent (str): Required. The name of the session to delete all contexts from. Format:
632649 ``projects/<Project ID>/agent/sessions/<Session ID>``.
633650 retry (Optional[google.api_core.retry.Retry]): A retry object used
634- to retry requests. If ``None`` is specified, requests will not
635- be retried.
651+ to retry requests. If ``None`` is specified, requests will
652+ be retried using a default configuration .
636653 timeout (Optional[float]): The amount of time, in seconds, to wait
637654 for the request to complete. Note that if ``retry`` is
638655 specified, the timeout applies to each individual attempt.
0 commit comments