This repository has been archived by the owner on Dec 17, 2023. It is now read-only.
docs(samples): add set agent code sample #370
Merged
Merged
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
568f0ba
Added Update Intent Snippet and Test
galz10 2b278e7
Deleted Setting Env Vars
galz10 4952c45
Fixed Lint Issues
galz10 7852110
Fixed Lint and Build Issue
galz10 8d4999c
Fixed Build Issue
galz10 1259002
Changed tests to pytests
galz10 755a7d1
Removed delete and create agent from test
galz10 b2395e7
Fixed Import Order
galz10 cb6128e
Deleted unused import
galz10 af3377e
Removed Language from update_intent Snippet
galz10 a774718
Added copyright
galz10 c922a4c
Changed intent name to random name
galz10 100af60
delete intent after testing
galz10 7ba7ed4
fix test
galz10 48c9f13
remove contains
galz10 7ad7509
Added Create Intent
galz10 75958c2
fix lint
galz10 2fad4bf
Merge branch 'master' into master
parthea a012f58
Merge branch 'master' into master
galz10 c3eee8b
Merge branch 'master' into master
galz10 c776f7f
docs(samples): add set agent code sample
galz10 8d87b9b
lint fix
galz10 fd6a653
Merge branch 'master' into create-agent
galz10 0556d84
Resolved comments
galz10 09f4ebb
Merge branch 'create-agent' of github.com:galz10/python-dialogflow in…
galz10 5ba68cc
test and lint changes
galz10 799effe
Merge branch 'main' into create-agent
galz10 11b4a63
Merge branch 'main' into create-agent
galz10 d498ee3
Merge branch 'main' into create-agent
galz10 016f8ad
Merge branch 'main' into create-agent
galz10 245e62f
Added Comments
galz10 a98adb3
lint fix
galz10 c7dfd1c
Merge branch 'main' into create-agent
galz10 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START dialogflow_set_agent_sample] | ||
|
||
from google.cloud.dialogflow_v2 import Agent | ||
from google.cloud.dialogflow_v2 import AgentsClient | ||
|
||
|
||
def set_agent(project_id, display_name): | ||
|
||
agents_client = AgentsClient() | ||
|
||
parent = agents_client.common_project_path(project_id) | ||
|
||
agent = Agent( | ||
parent=parent, | ||
display_name=display_name, | ||
default_language_code="en", | ||
time_zone="America/Los_Angeles", | ||
) | ||
|
||
response = agents_client.set_agent(request={"agent": agent}) | ||
|
||
return response | ||
|
||
|
||
# [END dialogflow_set_agent_sample] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
from google.api_core.exceptions import InvalidArgument | ||
|
||
import pytest | ||
|
||
from set_agent import set_agent | ||
|
||
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") | ||
|
||
|
||
def test_set_agent(): | ||
with pytest.raises(InvalidArgument): | ||
set_agent(PROJECT_ID, "") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The test code might confuse the readers. Maybe you can add a comment justifying the compromising test strategy.