From 72e624ae6430fd454380cdf6e348dbe763e56e6f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 10:54:11 +0000 Subject: [PATCH] feat(v3beta1): added support for locking an agent for changes (#281) - [ ] Regenerate this pull request now. feat(v3beta1): added data format specification for export agent PiperOrigin-RevId: 437848093 Source-Link: https://github.com/googleapis/googleapis/commit/daffb064bf5d35b76de530a9c9de6e0728c35afd Source-Link: https://github.com/googleapis/googleapis-gen/commit/b851ca5cc592a5b9c865cbe67736d67205072dce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjg1MWNhNWNjNTkyYTViOWM4NjVjYmU2NzczNmQ2NzIwNTA3MmRjZSJ9 --- .../cloud/dialogflowcx_v3/types/__init__.py | 12 ++++++--- .../services/sessions/async_client.py | 25 ++++++++++--------- .../services/sessions/client.py | 25 ++++++++++--------- .../dialogflowcx_v3beta1/types/__init__.py | 12 ++++++--- .../cloud/dialogflowcx_v3beta1/types/agent.py | 21 ++++++++++++++++ .../dialogflowcx_v3beta1/types/session.py | 10 ++++---- .../fixup_dialogflowcx_v3beta1_keywords.py | 2 +- .../gapic/dialogflowcx_v3beta1/test_agents.py | 12 +++++++++ 8 files changed, 83 insertions(+), 36 deletions(-) diff --git a/google/cloud/dialogflowcx_v3/types/__init__.py b/google/cloud/dialogflowcx_v3/types/__init__.py index f5baa497..fe4a75ea 100644 --- a/google/cloud/dialogflowcx_v3/types/__init__.py +++ b/google/cloud/dialogflowcx_v3/types/__init__.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .advanced_settings import AdvancedSettings +from .advanced_settings import ( + AdvancedSettings, +) from .agent import ( Agent, AgentValidationResult, @@ -115,7 +117,9 @@ UpdateFlowRequest, ValidateFlowRequest, ) -from .fulfillment import Fulfillment +from .fulfillment import ( + Fulfillment, +) from .intent import ( CreateIntentRequest, DeleteIntentRequest, @@ -138,7 +142,9 @@ TransitionRoute, UpdatePageRequest, ) -from .response_message import ResponseMessage +from .response_message import ( + ResponseMessage, +) from .security_settings import ( CreateSecuritySettingsRequest, DeleteSecuritySettingsRequest, diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py index 06f9f763..c95c1ed6 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py @@ -385,31 +385,32 @@ def request_generator(): method. Multiple request messages should be sent in order: - 1. The first message must contain + 1. The first message must contain [session][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.session], [query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input] plus optionally [query_params][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_params]. - If the client wants to receive an audio response, it + If the client wants to receive an audio response, it should also contain [output_audio_config][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.output_audio_config]. 2. If [query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input] was set to [query_input.audio.config][google.cloud.dialogflow.cx.v3beta1.AudioInput.config], - all subsequent messages must contain + all subsequent messages must contain [query_input.audio.audio][google.cloud.dialogflow.cx.v3beta1.AudioInput.audio] - to continue with Speech recognition. - If you decide to rather detect an intent from text + to continue with Speech recognition. + If you decide to rather detect an intent from text input after you already started Speech recognition, - please send a message with + please send a message with [query_input.text][google.cloud.dialogflow.cx.v3beta1.QueryInput.text]. - However, note that: - * Dialogflow will bill you for the audio duration so - far. * Dialogflow discards all Speech recognition - results in favor of the input text. - * Dialogflow will use the language code from the first - message. + However, note that: + + * Dialogflow will bill you for the audio duration so + far. * Dialogflow discards all Speech recognition + results in favor of the input text. + * Dialogflow will use the language code from the + first message. After you sent all input, you must half-close or abort the request stream. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py index a6a97f90..47334b56 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py @@ -777,31 +777,32 @@ def request_generator(): method. Multiple request messages should be sent in order: - 1. The first message must contain + 1. The first message must contain [session][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.session], [query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input] plus optionally [query_params][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_params]. - If the client wants to receive an audio response, it + If the client wants to receive an audio response, it should also contain [output_audio_config][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.output_audio_config]. 2. If [query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input] was set to [query_input.audio.config][google.cloud.dialogflow.cx.v3beta1.AudioInput.config], - all subsequent messages must contain + all subsequent messages must contain [query_input.audio.audio][google.cloud.dialogflow.cx.v3beta1.AudioInput.audio] - to continue with Speech recognition. - If you decide to rather detect an intent from text + to continue with Speech recognition. + If you decide to rather detect an intent from text input after you already started Speech recognition, - please send a message with + please send a message with [query_input.text][google.cloud.dialogflow.cx.v3beta1.QueryInput.text]. - However, note that: - * Dialogflow will bill you for the audio duration so - far. * Dialogflow discards all Speech recognition - results in favor of the input text. - * Dialogflow will use the language code from the first - message. + However, note that: + + * Dialogflow will bill you for the audio duration so + far. * Dialogflow discards all Speech recognition + results in favor of the input text. + * Dialogflow will use the language code from the + first message. After you sent all input, you must half-close or abort the request stream. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/dialogflowcx_v3beta1/types/__init__.py b/google/cloud/dialogflowcx_v3beta1/types/__init__.py index f5baa497..fe4a75ea 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/types/__init__.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .advanced_settings import AdvancedSettings +from .advanced_settings import ( + AdvancedSettings, +) from .agent import ( Agent, AgentValidationResult, @@ -115,7 +117,9 @@ UpdateFlowRequest, ValidateFlowRequest, ) -from .fulfillment import Fulfillment +from .fulfillment import ( + Fulfillment, +) from .intent import ( CreateIntentRequest, DeleteIntentRequest, @@ -138,7 +142,9 @@ TransitionRoute, UpdatePageRequest, ) -from .response_message import ResponseMessage +from .response_message import ( + ResponseMessage, +) from .security_settings import ( CreateSecuritySettingsRequest, DeleteSecuritySettingsRequest, diff --git a/google/cloud/dialogflowcx_v3beta1/types/agent.py b/google/cloud/dialogflowcx_v3beta1/types/agent.py index 0ab34366..fdd33881 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/agent.py +++ b/google/cloud/dialogflowcx_v3beta1/types/agent.py @@ -128,6 +128,10 @@ class Agent(proto.Message): enable_spell_correction (bool): Indicates if automatic spell correction is enabled in detect intent requests. + locked (bool): + Indiciates whether the agent is locked for changes. If the + agent is locked, modifications to the agent will be rejected + except for [RestoreAgent][]. advanced_settings (google.cloud.dialogflowcx_v3beta1.types.AdvancedSettings): Hierarchical advanced settings for this agent. The settings exposed at the lower level @@ -184,6 +188,10 @@ class Agent(proto.Message): proto.BOOL, number=20, ) + locked = proto.Field( + proto.BOOL, + number=27, + ) advanced_settings = proto.Field( proto.MESSAGE, number=22, @@ -350,12 +358,20 @@ class ExportAgentRequest(proto.Message): authentication must have write permissions for the object. For more information, see `Dialogflow access control `__. + data_format (google.cloud.dialogflowcx_v3beta1.types.ExportAgentRequest.DataFormat): + Optional. The data format of the exported agent. If not + specified, ``BLOB`` is assumed. environment (str): Optional. Environment name. If not set, draft environment is assumed. Format: ``projects//locations//agents//environments/``. """ + class DataFormat(proto.Enum): + r"""Data format of the exported agent.""" + DATA_FORMAT_UNSPECIFIED = 0 + BLOB = 1 + name = proto.Field( proto.STRING, number=1, @@ -364,6 +380,11 @@ class ExportAgentRequest(proto.Message): proto.STRING, number=2, ) + data_format = proto.Field( + proto.ENUM, + number=3, + enum=DataFormat, + ) environment = proto.Field( proto.STRING, number=5, diff --git a/google/cloud/dialogflowcx_v3beta1/types/session.py b/google/cloud/dialogflowcx_v3beta1/types/session.py index eaebaa09..e23e6939 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/session.py +++ b/google/cloud/dialogflowcx_v3beta1/types/session.py @@ -202,12 +202,12 @@ class StreamingDetectIntentRequest(proto.Message): recognition, please send a message with [query_input.text][google.cloud.dialogflow.cx.v3beta1.QueryInput.text]. - However, note that: + However, note that: - - Dialogflow will bill you for the audio duration so far. - - Dialogflow discards all Speech recognition results in favor of - the input text. - - Dialogflow will use the language code from the first message. + - Dialogflow will bill you for the audio duration so far. + - Dialogflow discards all Speech recognition results in favor of + the input text. + - Dialogflow will use the language code from the first message. After you sent all input, you must half-close or abort the request stream. diff --git a/scripts/fixup_dialogflowcx_v3beta1_keywords.py b/scripts/fixup_dialogflowcx_v3beta1_keywords.py index 87532407..24a0ece5 100644 --- a/scripts/fixup_dialogflowcx_v3beta1_keywords.py +++ b/scripts/fixup_dialogflowcx_v3beta1_keywords.py @@ -70,7 +70,7 @@ class dialogflowcxCallTransformer(cst.CSTTransformer): 'delete_webhook': ('name', 'force', ), 'deploy_flow': ('environment', 'flow_version', ), 'detect_intent': ('session', 'query_input', 'query_params', 'output_audio_config', ), - 'export_agent': ('name', 'agent_uri', 'environment', ), + 'export_agent': ('name', 'agent_uri', 'data_format', 'environment', ), 'export_flow': ('name', 'flow_uri', 'include_referenced_flows', ), 'export_test_cases': ('parent', 'gcs_uri', 'data_format', 'filter', ), 'fulfill_intent': ('match_intent_request', 'match', 'output_audio_config', ), diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py index 2edcf922..6ab5a502 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py @@ -1060,6 +1060,7 @@ def test_get_agent(request_type, transport: str = "grpc"): security_settings="security_settings_value", enable_stackdriver_logging=True, enable_spell_correction=True, + locked=True, ) response = client.get_agent(request) @@ -1081,6 +1082,7 @@ def test_get_agent(request_type, transport: str = "grpc"): assert response.security_settings == "security_settings_value" assert response.enable_stackdriver_logging is True assert response.enable_spell_correction is True + assert response.locked is True def test_get_agent_empty_call(): @@ -1128,6 +1130,7 @@ async def test_get_agent_async( security_settings="security_settings_value", enable_stackdriver_logging=True, enable_spell_correction=True, + locked=True, ) ) response = await client.get_agent(request) @@ -1150,6 +1153,7 @@ async def test_get_agent_async( assert response.security_settings == "security_settings_value" assert response.enable_stackdriver_logging is True assert response.enable_spell_correction is True + assert response.locked is True @pytest.mark.asyncio @@ -1328,6 +1332,7 @@ def test_create_agent(request_type, transport: str = "grpc"): security_settings="security_settings_value", enable_stackdriver_logging=True, enable_spell_correction=True, + locked=True, ) response = client.create_agent(request) @@ -1349,6 +1354,7 @@ def test_create_agent(request_type, transport: str = "grpc"): assert response.security_settings == "security_settings_value" assert response.enable_stackdriver_logging is True assert response.enable_spell_correction is True + assert response.locked is True def test_create_agent_empty_call(): @@ -1396,6 +1402,7 @@ async def test_create_agent_async( security_settings="security_settings_value", enable_stackdriver_logging=True, enable_spell_correction=True, + locked=True, ) ) response = await client.create_agent(request) @@ -1418,6 +1425,7 @@ async def test_create_agent_async( assert response.security_settings == "security_settings_value" assert response.enable_stackdriver_logging is True assert response.enable_spell_correction is True + assert response.locked is True @pytest.mark.asyncio @@ -1606,6 +1614,7 @@ def test_update_agent(request_type, transport: str = "grpc"): security_settings="security_settings_value", enable_stackdriver_logging=True, enable_spell_correction=True, + locked=True, ) response = client.update_agent(request) @@ -1627,6 +1636,7 @@ def test_update_agent(request_type, transport: str = "grpc"): assert response.security_settings == "security_settings_value" assert response.enable_stackdriver_logging is True assert response.enable_spell_correction is True + assert response.locked is True def test_update_agent_empty_call(): @@ -1674,6 +1684,7 @@ async def test_update_agent_async( security_settings="security_settings_value", enable_stackdriver_logging=True, enable_spell_correction=True, + locked=True, ) ) response = await client.update_agent(request) @@ -1696,6 +1707,7 @@ async def test_update_agent_async( assert response.security_settings == "security_settings_value" assert response.enable_stackdriver_logging is True assert response.enable_spell_correction is True + assert response.locked is True @pytest.mark.asyncio