def delete_all_contexts( self, request: Union[context.DeleteAllContextsRequest, dict] = None, *, parent: str = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes all active contexts in the specified session. .. code-block:: python from google.cloud import dialogflow_v2 def sample_delete_all_contexts(): # Create a client client = dialogflow_v2.ContextsClient() # Initialize request argument(s) request = dialogflow_v2.DeleteAllContextsRequest( parent="parent_value", ) # Make the request client.delete_all_contexts(request=request) Args: request (Union[google.cloud.dialogflow_v2.types.DeleteAllContextsRequest, dict]): The request object. The request message for [Contexts.DeleteAllContexts][google.cloud.dialogflow.v2.Contexts.DeleteAllContexts]. parent (str): Required. The name of the session to delete all contexts from. Format: ``projects/<Project ID>/agent/sessions/<Session ID>`` or ``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``. If ``Environment ID`` is not specified we assume default 'draft' environment. If ``User ID`` is not specified, we assume default '-' user. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ # Create or coerce a protobuf request object. # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") # Minor optimization to avoid making a copy if the user passes # in a context.DeleteAllContextsRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, context.DeleteAllContextsRequest): request = context.DeleteAllContextsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.delete_all_contexts] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("parent", request.parent), )), ) # Send the request. rpc( request, retry=retry, timeout=timeout, metadata=metadata, )
async def delete_all_contexts( self, request: context.DeleteAllContextsRequest = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes all active contexts in the specified session. Args: request (:class:`~.context.DeleteAllContextsRequest`): The request object. The request message for [Contexts.DeleteAllContexts][google.cloud.dialogflow.v2.Contexts.DeleteAllContexts]. parent (:class:`str`): Required. The name of the session to delete all contexts from. Format: ``projects/<Project ID>/agent/sessions/<Session ID>`` or ``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``. If ``Environment ID`` is not specified we assume default 'draft' environment. If ``User ID`` is not specified, we assume default '-' user. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") request = context.DeleteAllContextsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( self._client._transport.delete_all_contexts, default_timeout=None, client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("parent", request.parent), )), ) # Send the request. await rpc( request, retry=retry, timeout=timeout, metadata=metadata, )