|
31 | 31 | except AttributeError: # pragma: NO COVER |
32 | 32 | OptionalRetry = Union[retries.Retry, object] # type: ignore |
33 | 33 |
|
| 34 | +from google.api_core import operation # type: ignore |
| 35 | +from google.api_core import operation_async # type: ignore |
34 | 36 | from google.cloud.dialogflow_v2beta1.services.conversation_profiles import pagers |
35 | 37 | from google.cloud.dialogflow_v2beta1.types import audio_config |
36 | 38 | from google.cloud.dialogflow_v2beta1.types import conversation_profile |
@@ -744,6 +746,263 @@ def sample_delete_conversation_profile(): |
744 | 746 | request, retry=retry, timeout=timeout, metadata=metadata, |
745 | 747 | ) |
746 | 748 |
|
| 749 | + async def set_suggestion_feature_config( |
| 750 | + self, |
| 751 | + request: Union[ |
| 752 | + gcd_conversation_profile.SetSuggestionFeatureConfigRequest, dict |
| 753 | + ] = None, |
| 754 | + *, |
| 755 | + conversation_profile: str = None, |
| 756 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 757 | + timeout: float = None, |
| 758 | + metadata: Sequence[Tuple[str, str]] = (), |
| 759 | + ) -> operation_async.AsyncOperation: |
| 760 | + r"""Adds or updates a suggestion feature in a conversation profile. |
| 761 | + If the conversation profile contains the type of suggestion |
| 762 | + feature for the participant role, it will update it. Otherwise |
| 763 | + it will insert the suggestion feature. |
| 764 | +
|
| 765 | + This method is a `long-running |
| 766 | + operation <https://cloud.google.com/dialogflow/es/docs/how/long-running-operations>`__. |
| 767 | + The returned ``Operation`` type has the following |
| 768 | + method-specific fields: |
| 769 | +
|
| 770 | + - ``metadata``: |
| 771 | + [SetSuggestionFeatureConfigOperationMetadata][google.cloud.dialogflow.v2beta1.SetSuggestionFeatureConfigOperationMetadata] |
| 772 | + - ``response``: |
| 773 | + [ConversationProfile][google.cloud.dialogflow.v2beta1.ConversationProfile] |
| 774 | +
|
| 775 | + If a long running operation to add or update suggestion feature |
| 776 | + config for the same conversation profile, participant role and |
| 777 | + suggestion feature type exists, please cancel the existing long |
| 778 | + running operation before sending such request, otherwise the |
| 779 | + request will be rejected. |
| 780 | +
|
| 781 | +
|
| 782 | + .. code-block:: python |
| 783 | +
|
| 784 | + from google.cloud import dialogflow_v2beta1 |
| 785 | +
|
| 786 | + def sample_set_suggestion_feature_config(): |
| 787 | + # Create a client |
| 788 | + client = dialogflow_v2beta1.ConversationProfilesClient() |
| 789 | +
|
| 790 | + # Initialize request argument(s) |
| 791 | + request = dialogflow_v2beta1.SetSuggestionFeatureConfigRequest( |
| 792 | + conversation_profile="conversation_profile_value", |
| 793 | + participant_role="END_USER", |
| 794 | + ) |
| 795 | +
|
| 796 | + # Make the request |
| 797 | + operation = client.set_suggestion_feature_config(request=request) |
| 798 | +
|
| 799 | + print("Waiting for operation to complete...") |
| 800 | +
|
| 801 | + response = operation.result() |
| 802 | +
|
| 803 | + # Handle the response |
| 804 | + print(response) |
| 805 | +
|
| 806 | + Args: |
| 807 | + request (Union[google.cloud.dialogflow_v2beta1.types.SetSuggestionFeatureConfigRequest, dict]): |
| 808 | + The request object. The request message for |
| 809 | + [ConversationProfiles.SetSuggestionFeature][]. |
| 810 | + conversation_profile (:class:`str`): |
| 811 | + Required. The Conversation Profile to add or update the |
| 812 | + suggestion feature config. Format: |
| 813 | + ``projects/<Project ID>/locations/<Location ID>/conversationProfiles/<Conversation Profile ID>``. |
| 814 | +
|
| 815 | + This corresponds to the ``conversation_profile`` field |
| 816 | + on the ``request`` instance; if ``request`` is provided, this |
| 817 | + should not be set. |
| 818 | + retry (google.api_core.retry.Retry): Designation of what errors, if any, |
| 819 | + should be retried. |
| 820 | + timeout (float): The timeout for this request. |
| 821 | + metadata (Sequence[Tuple[str, str]]): Strings which should be |
| 822 | + sent along with the request as metadata. |
| 823 | +
|
| 824 | + Returns: |
| 825 | + google.api_core.operation_async.AsyncOperation: |
| 826 | + An object representing a long-running operation. |
| 827 | +
|
| 828 | + The result type for the operation will be |
| 829 | + :class:`google.cloud.dialogflow_v2beta1.types.ConversationProfile` |
| 830 | + Defines the services to connect to incoming Dialogflow |
| 831 | + conversations. |
| 832 | +
|
| 833 | + """ |
| 834 | + # Create or coerce a protobuf request object. |
| 835 | + # Quick check: If we got a request object, we should *not* have |
| 836 | + # gotten any keyword arguments that map to the request. |
| 837 | + has_flattened_params = any([conversation_profile]) |
| 838 | + if request is not None and has_flattened_params: |
| 839 | + raise ValueError( |
| 840 | + "If the `request` argument is set, then none of " |
| 841 | + "the individual field arguments should be set." |
| 842 | + ) |
| 843 | + |
| 844 | + request = gcd_conversation_profile.SetSuggestionFeatureConfigRequest(request) |
| 845 | + |
| 846 | + # If we have keyword arguments corresponding to fields on the |
| 847 | + # request, apply these. |
| 848 | + if conversation_profile is not None: |
| 849 | + request.conversation_profile = conversation_profile |
| 850 | + |
| 851 | + # Wrap the RPC method; this adds retry and timeout information, |
| 852 | + # and friendly error handling. |
| 853 | + rpc = gapic_v1.method_async.wrap_method( |
| 854 | + self._client._transport.set_suggestion_feature_config, |
| 855 | + default_timeout=None, |
| 856 | + client_info=DEFAULT_CLIENT_INFO, |
| 857 | + ) |
| 858 | + |
| 859 | + # Certain fields should be provided within the metadata header; |
| 860 | + # add these here. |
| 861 | + metadata = tuple(metadata) + ( |
| 862 | + gapic_v1.routing_header.to_grpc_metadata( |
| 863 | + (("conversation_profile", request.conversation_profile),) |
| 864 | + ), |
| 865 | + ) |
| 866 | + |
| 867 | + # Send the request. |
| 868 | + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) |
| 869 | + |
| 870 | + # Wrap the response in an operation future. |
| 871 | + response = operation_async.from_gapic( |
| 872 | + response, |
| 873 | + self._client._transport.operations_client, |
| 874 | + gcd_conversation_profile.ConversationProfile, |
| 875 | + metadata_type=gcd_conversation_profile.SetSuggestionFeatureConfigOperationMetadata, |
| 876 | + ) |
| 877 | + |
| 878 | + # Done; return the response. |
| 879 | + return response |
| 880 | + |
| 881 | + async def clear_suggestion_feature_config( |
| 882 | + self, |
| 883 | + request: Union[ |
| 884 | + gcd_conversation_profile.ClearSuggestionFeatureConfigRequest, dict |
| 885 | + ] = None, |
| 886 | + *, |
| 887 | + conversation_profile: str = None, |
| 888 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 889 | + timeout: float = None, |
| 890 | + metadata: Sequence[Tuple[str, str]] = (), |
| 891 | + ) -> operation_async.AsyncOperation: |
| 892 | + r"""Clears a suggestion feature from a conversation profile for the |
| 893 | + given participant role. |
| 894 | +
|
| 895 | + This method is a `long-running |
| 896 | + operation <https://cloud.google.com/dialogflow/es/docs/how/long-running-operations>`__. |
| 897 | + The returned ``Operation`` type has the following |
| 898 | + method-specific fields: |
| 899 | +
|
| 900 | + - ``metadata``: |
| 901 | + [ClearSuggestionFeatureConfigOperationMetadata][google.cloud.dialogflow.v2beta1.ClearSuggestionFeatureConfigOperationMetadata] |
| 902 | + - ``response``: |
| 903 | + [ConversationProfile][google.cloud.dialogflow.v2beta1.ConversationProfile] |
| 904 | +
|
| 905 | +
|
| 906 | + .. code-block:: python |
| 907 | +
|
| 908 | + from google.cloud import dialogflow_v2beta1 |
| 909 | +
|
| 910 | + def sample_clear_suggestion_feature_config(): |
| 911 | + # Create a client |
| 912 | + client = dialogflow_v2beta1.ConversationProfilesClient() |
| 913 | +
|
| 914 | + # Initialize request argument(s) |
| 915 | + request = dialogflow_v2beta1.ClearSuggestionFeatureConfigRequest( |
| 916 | + conversation_profile="conversation_profile_value", |
| 917 | + participant_role="END_USER", |
| 918 | + suggestion_feature_type="SMART_REPLY", |
| 919 | + ) |
| 920 | +
|
| 921 | + # Make the request |
| 922 | + operation = client.clear_suggestion_feature_config(request=request) |
| 923 | +
|
| 924 | + print("Waiting for operation to complete...") |
| 925 | +
|
| 926 | + response = operation.result() |
| 927 | +
|
| 928 | + # Handle the response |
| 929 | + print(response) |
| 930 | +
|
| 931 | + Args: |
| 932 | + request (Union[google.cloud.dialogflow_v2beta1.types.ClearSuggestionFeatureConfigRequest, dict]): |
| 933 | + The request object. The request message for |
| 934 | + [ConversationProfiles.ClearFeature][]. |
| 935 | + conversation_profile (:class:`str`): |
| 936 | + Required. The Conversation Profile to add or update the |
| 937 | + suggestion feature config. Format: |
| 938 | + ``projects/<Project ID>/locations/<Location ID>/conversationProfiles/<Conversation Profile ID>``. |
| 939 | +
|
| 940 | + This corresponds to the ``conversation_profile`` field |
| 941 | + on the ``request`` instance; if ``request`` is provided, this |
| 942 | + should not be set. |
| 943 | + retry (google.api_core.retry.Retry): Designation of what errors, if any, |
| 944 | + should be retried. |
| 945 | + timeout (float): The timeout for this request. |
| 946 | + metadata (Sequence[Tuple[str, str]]): Strings which should be |
| 947 | + sent along with the request as metadata. |
| 948 | +
|
| 949 | + Returns: |
| 950 | + google.api_core.operation_async.AsyncOperation: |
| 951 | + An object representing a long-running operation. |
| 952 | +
|
| 953 | + The result type for the operation will be |
| 954 | + :class:`google.cloud.dialogflow_v2beta1.types.ConversationProfile` |
| 955 | + Defines the services to connect to incoming Dialogflow |
| 956 | + conversations. |
| 957 | +
|
| 958 | + """ |
| 959 | + # Create or coerce a protobuf request object. |
| 960 | + # Quick check: If we got a request object, we should *not* have |
| 961 | + # gotten any keyword arguments that map to the request. |
| 962 | + has_flattened_params = any([conversation_profile]) |
| 963 | + if request is not None and has_flattened_params: |
| 964 | + raise ValueError( |
| 965 | + "If the `request` argument is set, then none of " |
| 966 | + "the individual field arguments should be set." |
| 967 | + ) |
| 968 | + |
| 969 | + request = gcd_conversation_profile.ClearSuggestionFeatureConfigRequest(request) |
| 970 | + |
| 971 | + # If we have keyword arguments corresponding to fields on the |
| 972 | + # request, apply these. |
| 973 | + if conversation_profile is not None: |
| 974 | + request.conversation_profile = conversation_profile |
| 975 | + |
| 976 | + # Wrap the RPC method; this adds retry and timeout information, |
| 977 | + # and friendly error handling. |
| 978 | + rpc = gapic_v1.method_async.wrap_method( |
| 979 | + self._client._transport.clear_suggestion_feature_config, |
| 980 | + default_timeout=None, |
| 981 | + client_info=DEFAULT_CLIENT_INFO, |
| 982 | + ) |
| 983 | + |
| 984 | + # Certain fields should be provided within the metadata header; |
| 985 | + # add these here. |
| 986 | + metadata = tuple(metadata) + ( |
| 987 | + gapic_v1.routing_header.to_grpc_metadata( |
| 988 | + (("conversation_profile", request.conversation_profile),) |
| 989 | + ), |
| 990 | + ) |
| 991 | + |
| 992 | + # Send the request. |
| 993 | + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) |
| 994 | + |
| 995 | + # Wrap the response in an operation future. |
| 996 | + response = operation_async.from_gapic( |
| 997 | + response, |
| 998 | + self._client._transport.operations_client, |
| 999 | + gcd_conversation_profile.ConversationProfile, |
| 1000 | + metadata_type=gcd_conversation_profile.ClearSuggestionFeatureConfigOperationMetadata, |
| 1001 | + ) |
| 1002 | + |
| 1003 | + # Done; return the response. |
| 1004 | + return response |
| 1005 | + |
747 | 1006 | async def __aenter__(self): |
748 | 1007 | return self |
749 | 1008 |
|
|
0 commit comments