Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 72e624a

Browse files
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: googleapis/googleapis@daffb06 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b851ca5cc592a5b9c865cbe67736d67205072dce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjg1MWNhNWNjNTkyYTViOWM4NjVjYmU2NzczNmQ2NzIwNTA3MmRjZSJ9
1 parent 956596a commit 72e624a

File tree

8 files changed

+83
-36
lines changed

8 files changed

+83
-36
lines changed

google/cloud/dialogflowcx_v3/types/__init__.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from .advanced_settings import AdvancedSettings
16+
from .advanced_settings import (
17+
AdvancedSettings,
18+
)
1719
from .agent import (
1820
Agent,
1921
AgentValidationResult,
@@ -115,7 +117,9 @@
115117
UpdateFlowRequest,
116118
ValidateFlowRequest,
117119
)
118-
from .fulfillment import Fulfillment
120+
from .fulfillment import (
121+
Fulfillment,
122+
)
119123
from .intent import (
120124
CreateIntentRequest,
121125
DeleteIntentRequest,
@@ -138,7 +142,9 @@
138142
TransitionRoute,
139143
UpdatePageRequest,
140144
)
141-
from .response_message import ResponseMessage
145+
from .response_message import (
146+
ResponseMessage,
147+
)
142148
from .security_settings import (
143149
CreateSecuritySettingsRequest,
144150
DeleteSecuritySettingsRequest,

google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -385,31 +385,32 @@ def request_generator():
385385
method.
386386
Multiple request messages should be sent in order:
387387
388-
1. The first message must contain
388+
1. The first message must contain
389389
[session][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.session],
390390
[query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input]
391391
plus optionally
392392
[query_params][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_params].
393-
If the client wants to receive an audio response, it
393+
If the client wants to receive an audio response, it
394394
should also contain
395395
[output_audio_config][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.output_audio_config].
396396
2. If
397397
[query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input]
398398
was set to
399399
[query_input.audio.config][google.cloud.dialogflow.cx.v3beta1.AudioInput.config],
400-
all subsequent messages must contain
400+
all subsequent messages must contain
401401
[query_input.audio.audio][google.cloud.dialogflow.cx.v3beta1.AudioInput.audio]
402-
to continue with Speech recognition.
403-
If you decide to rather detect an intent from text
402+
to continue with Speech recognition.
403+
If you decide to rather detect an intent from text
404404
input after you already started Speech recognition,
405-
please send a message with
405+
please send a message with
406406
[query_input.text][google.cloud.dialogflow.cx.v3beta1.QueryInput.text].
407-
However, note that:
408-
* Dialogflow will bill you for the audio duration so
409-
far. * Dialogflow discards all Speech recognition
410-
results in favor of the input text.
411-
* Dialogflow will use the language code from the first
412-
message.
407+
However, note that:
408+
409+
* Dialogflow will bill you for the audio duration so
410+
far. * Dialogflow discards all Speech recognition
411+
results in favor of the input text.
412+
* Dialogflow will use the language code from the
413+
first message.
413414
After you sent all input, you must half-close or abort
414415
the request stream.
415416
retry (google.api_core.retry.Retry): Designation of what errors, if any,

google/cloud/dialogflowcx_v3beta1/services/sessions/client.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -777,31 +777,32 @@ def request_generator():
777777
method.
778778
Multiple request messages should be sent in order:
779779
780-
1. The first message must contain
780+
1. The first message must contain
781781
[session][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.session],
782782
[query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input]
783783
plus optionally
784784
[query_params][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_params].
785-
If the client wants to receive an audio response, it
785+
If the client wants to receive an audio response, it
786786
should also contain
787787
[output_audio_config][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.output_audio_config].
788788
2. If
789789
[query_input][google.cloud.dialogflow.cx.v3beta1.StreamingDetectIntentRequest.query_input]
790790
was set to
791791
[query_input.audio.config][google.cloud.dialogflow.cx.v3beta1.AudioInput.config],
792-
all subsequent messages must contain
792+
all subsequent messages must contain
793793
[query_input.audio.audio][google.cloud.dialogflow.cx.v3beta1.AudioInput.audio]
794-
to continue with Speech recognition.
795-
If you decide to rather detect an intent from text
794+
to continue with Speech recognition.
795+
If you decide to rather detect an intent from text
796796
input after you already started Speech recognition,
797-
please send a message with
797+
please send a message with
798798
[query_input.text][google.cloud.dialogflow.cx.v3beta1.QueryInput.text].
799-
However, note that:
800-
* Dialogflow will bill you for the audio duration so
801-
far. * Dialogflow discards all Speech recognition
802-
results in favor of the input text.
803-
* Dialogflow will use the language code from the first
804-
message.
799+
However, note that:
800+
801+
* Dialogflow will bill you for the audio duration so
802+
far. * Dialogflow discards all Speech recognition
803+
results in favor of the input text.
804+
* Dialogflow will use the language code from the
805+
first message.
805806
After you sent all input, you must half-close or abort
806807
the request stream.
807808
retry (google.api_core.retry.Retry): Designation of what errors, if any,

google/cloud/dialogflowcx_v3beta1/types/__init__.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from .advanced_settings import AdvancedSettings
16+
from .advanced_settings import (
17+
AdvancedSettings,
18+
)
1719
from .agent import (
1820
Agent,
1921
AgentValidationResult,
@@ -115,7 +117,9 @@
115117
UpdateFlowRequest,
116118
ValidateFlowRequest,
117119
)
118-
from .fulfillment import Fulfillment
120+
from .fulfillment import (
121+
Fulfillment,
122+
)
119123
from .intent import (
120124
CreateIntentRequest,
121125
DeleteIntentRequest,
@@ -138,7 +142,9 @@
138142
TransitionRoute,
139143
UpdatePageRequest,
140144
)
141-
from .response_message import ResponseMessage
145+
from .response_message import (
146+
ResponseMessage,
147+
)
142148
from .security_settings import (
143149
CreateSecuritySettingsRequest,
144150
DeleteSecuritySettingsRequest,

google/cloud/dialogflowcx_v3beta1/types/agent.py

+21
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ class Agent(proto.Message):
128128
enable_spell_correction (bool):
129129
Indicates if automatic spell correction is
130130
enabled in detect intent requests.
131+
locked (bool):
132+
Indiciates whether the agent is locked for changes. If the
133+
agent is locked, modifications to the agent will be rejected
134+
except for [RestoreAgent][].
131135
advanced_settings (google.cloud.dialogflowcx_v3beta1.types.AdvancedSettings):
132136
Hierarchical advanced settings for this
133137
agent. The settings exposed at the lower level
@@ -184,6 +188,10 @@ class Agent(proto.Message):
184188
proto.BOOL,
185189
number=20,
186190
)
191+
locked = proto.Field(
192+
proto.BOOL,
193+
number=27,
194+
)
187195
advanced_settings = proto.Field(
188196
proto.MESSAGE,
189197
number=22,
@@ -350,12 +358,20 @@ class ExportAgentRequest(proto.Message):
350358
authentication must have write permissions for the object.
351359
For more information, see `Dialogflow access
352360
control <https://cloud.google.com/dialogflow/cx/docs/concept/access-control#storage>`__.
361+
data_format (google.cloud.dialogflowcx_v3beta1.types.ExportAgentRequest.DataFormat):
362+
Optional. The data format of the exported agent. If not
363+
specified, ``BLOB`` is assumed.
353364
environment (str):
354365
Optional. Environment name. If not set, draft environment is
355366
assumed. Format:
356367
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment ID>``.
357368
"""
358369

370+
class DataFormat(proto.Enum):
371+
r"""Data format of the exported agent."""
372+
DATA_FORMAT_UNSPECIFIED = 0
373+
BLOB = 1
374+
359375
name = proto.Field(
360376
proto.STRING,
361377
number=1,
@@ -364,6 +380,11 @@ class ExportAgentRequest(proto.Message):
364380
proto.STRING,
365381
number=2,
366382
)
383+
data_format = proto.Field(
384+
proto.ENUM,
385+
number=3,
386+
enum=DataFormat,
387+
)
367388
environment = proto.Field(
368389
proto.STRING,
369390
number=5,

google/cloud/dialogflowcx_v3beta1/types/session.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ class StreamingDetectIntentRequest(proto.Message):
202202
recognition, please send a message with
203203
[query_input.text][google.cloud.dialogflow.cx.v3beta1.QueryInput.text].
204204
205-
However, note that:
205+
However, note that:
206206
207-
- Dialogflow will bill you for the audio duration so far.
208-
- Dialogflow discards all Speech recognition results in favor of
209-
the input text.
210-
- Dialogflow will use the language code from the first message.
207+
- Dialogflow will bill you for the audio duration so far.
208+
- Dialogflow discards all Speech recognition results in favor of
209+
the input text.
210+
- Dialogflow will use the language code from the first message.
211211
212212
After you sent all input, you must half-close or abort the request
213213
stream.

scripts/fixup_dialogflowcx_v3beta1_keywords.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class dialogflowcxCallTransformer(cst.CSTTransformer):
7070
'delete_webhook': ('name', 'force', ),
7171
'deploy_flow': ('environment', 'flow_version', ),
7272
'detect_intent': ('session', 'query_input', 'query_params', 'output_audio_config', ),
73-
'export_agent': ('name', 'agent_uri', 'environment', ),
73+
'export_agent': ('name', 'agent_uri', 'data_format', 'environment', ),
7474
'export_flow': ('name', 'flow_uri', 'include_referenced_flows', ),
7575
'export_test_cases': ('parent', 'gcs_uri', 'data_format', 'filter', ),
7676
'fulfill_intent': ('match_intent_request', 'match', 'output_audio_config', ),

tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py

+12
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ def test_get_agent(request_type, transport: str = "grpc"):
10601060
security_settings="security_settings_value",
10611061
enable_stackdriver_logging=True,
10621062
enable_spell_correction=True,
1063+
locked=True,
10631064
)
10641065
response = client.get_agent(request)
10651066

@@ -1081,6 +1082,7 @@ def test_get_agent(request_type, transport: str = "grpc"):
10811082
assert response.security_settings == "security_settings_value"
10821083
assert response.enable_stackdriver_logging is True
10831084
assert response.enable_spell_correction is True
1085+
assert response.locked is True
10841086

10851087

10861088
def test_get_agent_empty_call():
@@ -1128,6 +1130,7 @@ async def test_get_agent_async(
11281130
security_settings="security_settings_value",
11291131
enable_stackdriver_logging=True,
11301132
enable_spell_correction=True,
1133+
locked=True,
11311134
)
11321135
)
11331136
response = await client.get_agent(request)
@@ -1150,6 +1153,7 @@ async def test_get_agent_async(
11501153
assert response.security_settings == "security_settings_value"
11511154
assert response.enable_stackdriver_logging is True
11521155
assert response.enable_spell_correction is True
1156+
assert response.locked is True
11531157

11541158

11551159
@pytest.mark.asyncio
@@ -1328,6 +1332,7 @@ def test_create_agent(request_type, transport: str = "grpc"):
13281332
security_settings="security_settings_value",
13291333
enable_stackdriver_logging=True,
13301334
enable_spell_correction=True,
1335+
locked=True,
13311336
)
13321337
response = client.create_agent(request)
13331338

@@ -1349,6 +1354,7 @@ def test_create_agent(request_type, transport: str = "grpc"):
13491354
assert response.security_settings == "security_settings_value"
13501355
assert response.enable_stackdriver_logging is True
13511356
assert response.enable_spell_correction is True
1357+
assert response.locked is True
13521358

13531359

13541360
def test_create_agent_empty_call():
@@ -1396,6 +1402,7 @@ async def test_create_agent_async(
13961402
security_settings="security_settings_value",
13971403
enable_stackdriver_logging=True,
13981404
enable_spell_correction=True,
1405+
locked=True,
13991406
)
14001407
)
14011408
response = await client.create_agent(request)
@@ -1418,6 +1425,7 @@ async def test_create_agent_async(
14181425
assert response.security_settings == "security_settings_value"
14191426
assert response.enable_stackdriver_logging is True
14201427
assert response.enable_spell_correction is True
1428+
assert response.locked is True
14211429

14221430

14231431
@pytest.mark.asyncio
@@ -1606,6 +1614,7 @@ def test_update_agent(request_type, transport: str = "grpc"):
16061614
security_settings="security_settings_value",
16071615
enable_stackdriver_logging=True,
16081616
enable_spell_correction=True,
1617+
locked=True,
16091618
)
16101619
response = client.update_agent(request)
16111620

@@ -1627,6 +1636,7 @@ def test_update_agent(request_type, transport: str = "grpc"):
16271636
assert response.security_settings == "security_settings_value"
16281637
assert response.enable_stackdriver_logging is True
16291638
assert response.enable_spell_correction is True
1639+
assert response.locked is True
16301640

16311641

16321642
def test_update_agent_empty_call():
@@ -1674,6 +1684,7 @@ async def test_update_agent_async(
16741684
security_settings="security_settings_value",
16751685
enable_stackdriver_logging=True,
16761686
enable_spell_correction=True,
1687+
locked=True,
16771688
)
16781689
)
16791690
response = await client.update_agent(request)
@@ -1696,6 +1707,7 @@ async def test_update_agent_async(
16961707
assert response.security_settings == "security_settings_value"
16971708
assert response.enable_stackdriver_logging is True
16981709
assert response.enable_spell_correction is True
1710+
assert response.locked is True
16991711

17001712

17011713
@pytest.mark.asyncio

0 commit comments

Comments
 (0)