This repository was archived by the owner on Dec 17, 2023. It is now read-only.
File tree 2 files changed +70
-0
lines changed
2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright 2021 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # [START dialogflow_set_agent_sample]
16
+
17
+ from google .cloud .dialogflow_v2 import Agent
18
+ from google .cloud .dialogflow_v2 import AgentsClient
19
+
20
+
21
+ def set_agent (project_id , display_name ):
22
+
23
+ agents_client = AgentsClient ()
24
+
25
+ parent = agents_client .common_project_path (project_id )
26
+
27
+ agent = Agent (
28
+ parent = parent ,
29
+ display_name = display_name ,
30
+ default_language_code = "en" ,
31
+ time_zone = "America/Los_Angeles" ,
32
+ )
33
+
34
+ response = agents_client .set_agent (request = {"agent" : agent })
35
+
36
+ return response
37
+
38
+
39
+ # [END dialogflow_set_agent_sample]
Original file line number Diff line number Diff line change
1
+ # Copyright 2021 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import os
16
+
17
+ from google .api_core .exceptions import InvalidArgument
18
+
19
+ import pytest
20
+
21
+ from set_agent import set_agent
22
+
23
+ PROJECT_ID = os .getenv ("GOOGLE_CLOUD_PROJECT" )
24
+
25
+
26
+ # We cannot test setAgent because Dialogflow ES can only have one agent
27
+ # and if we create a agent it will delete the exisitng testing agent and
28
+ # would cause all tests to fail
29
+ def test_set_agent ():
30
+ with pytest .raises (InvalidArgument ):
31
+ set_agent (PROJECT_ID , "" )
You can’t perform that action at this time.
0 commit comments