diff --git a/packages/google-cloud-dialogflow/.circleci/config.yml b/packages/google-cloud-dialogflow/.circleci/config.yml
deleted file mode 100644
index 49f12f6de35e..000000000000
--- a/packages/google-cloud-dialogflow/.circleci/config.yml
+++ /dev/null
@@ -1,186 +0,0 @@
----
-version: 2.0
-workflows:
- version: 2
- tests:
- jobs:
- - 'python 2.7':
- filters:
- tags:
- only: /.*/
- - 'python 3.4':
- filters:
- tags:
- only: /.*/
- - 'python 3.5':
- filters:
- tags:
- only: /.*/
- - 'python 3.6':
- filters:
- tags:
- only: /.*/
- - lint:
- requires:
- - python 2.7
- - python 3.4
- - python 3.5
- - python 3.6
- filters:
- tags:
- only: /.*/
- - docs:
- requires:
- - python 2.7
- - python 3.4
- - python 3.5
- - python 3.6
- filters:
- tags:
- only: /.*/
- - sample_tests:
- requires:
- - lint
- - docs
- filters:
- branches:
- only:
- - master
- - repo-preparation
- tags:
- only: /^v[\d.]+$/
- - publish:
- requires:
- - sample_tests
- filters:
- branches:
- ignore: /.*/
- tags:
- only: /^v[\d.]+$/
-
-jobs:
- 'python 2.7':
- docker:
- - image: python:2.7
- steps:
- - checkout
- - run:
- name: Install nox and codecov.
- command: pip install nox-automation codecov
- - run:
- name: Run unit tests.
- command: nox -s "unit_tests(python_version='2.7')"
- - run:
- name: Submit coverage data to codecov.
- command: codecov
- when: always
- 'python 3.4':
- docker:
- - image: python:3.4
- steps:
- - checkout
- - run:
- name: Install nox and codecov.
- command: pip install nox-automation codecov
- - run:
- name: Run unit tests.
- command: nox -s "unit_tests(python_version='3.4')"
- - run:
- name: Submit coverage data to codecov.
- command: codecov
- when: always
- 'python 3.5':
- docker:
- - image: python:3.5
- steps:
- - checkout
- - run:
- name: Install nox and codecov.
- command: pip install nox-automation codecov
- - run:
- name: Run unit tests.
- command: nox -s "unit_tests(python_version='3.5')"
- - run:
- name: Submit coverage data to codecov.
- command: codecov
- when: always
- 'python 3.6':
- docker:
- - image: python:3.6
- steps:
- - checkout
- - run:
- name: Install nox and codecov.
- command: pip install nox-automation codecov
- - run:
- name: Run unit tests.
- command: nox -s "unit_tests(python_version='3.6')"
- - run:
- name: Submit coverage data to codecov.
- command: codecov
- when: always
-
- lint:
- docker:
- - image: python:3.6
- steps:
- - checkout
- - run:
- name: Install nox.
- command: pip install nox-automation
- - run:
- name: Run linting.
- command: nox -s lint_setup_py
-
- docs:
- docker:
- - image: python:3.6
- steps:
- - checkout
- - run:
- name: Install nox.
- command: pip install nox-automation
- - run:
- name: Build documentation.
- command: nox -s docs
-
- sample_tests:
- docker:
- - image: python:3.6
- steps:
- - checkout
- - run:
- name: Install nox.
- command: pip install nox-automation
- - run:
- name: Decrypt credentials.
- command: |
- openssl aes-256-cbc -d -in .circleci/key.json.enc \
- -out .circleci/key.json \
- -k "${SYSTEM_TESTS_ENCRYPTION_KEY}"
- - run:
- name: Run sample tests.
- command: nox -s sample_tests
- environment:
- GCLOUD_PROJECT: precise-truck-742
- GOOGLE_APPLICATION_CREDENTIALS: /var/dialogflow/.circleci/key.json
- - run:
- name: Remove unencrypted key.
- command: rm .circleci/key.json
- when: always
- working_directory: /var/dialogflow/
-
- publish:
- docker:
- - image: python:3.6
- steps:
- - checkout
- - run:
- name: Set PyPI authentication.
- command: |
- echo "[server-login]" > ~/.pypirc
- echo "username:${PYPI_USERNAME}" >> ~/.pypirc
- echo "password:${PYPI_PASSWORD}" >> ~/.pypirc
- - run:
- name: Publish the module to PyPI.
- command: python setup.py sdist upload
diff --git a/packages/google-cloud-dialogflow/.circleci/key.json.enc b/packages/google-cloud-dialogflow/.circleci/key.json.enc
deleted file mode 100644
index 39f5255faf9b..000000000000
Binary files a/packages/google-cloud-dialogflow/.circleci/key.json.enc and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/.coveragerc b/packages/google-cloud-dialogflow/.coveragerc
index 98e88a275ccc..b178b094aa1d 100644
--- a/packages/google-cloud-dialogflow/.coveragerc
+++ b/packages/google-cloud-dialogflow/.coveragerc
@@ -1,13 +1,19 @@
+# Generated by synthtool. DO NOT EDIT!
[run]
branch = True
-omit =
- */proto/*
[report]
-fail_under = 80
+fail_under = 100
show_missing = True
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
+ # Ignore abstract methods
+ raise NotImplementedError
+omit =
+ */gapic/*.py
+ */proto/*.py
+ */core/*.py
+ */site-packages/*.py
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.flake8 b/packages/google-cloud-dialogflow/.flake8
index 44d549a48a60..0268ecc9c55c 100644
--- a/packages/google-cloud-dialogflow/.flake8
+++ b/packages/google-cloud-dialogflow/.flake8
@@ -1,7 +1,14 @@
+# Generated by synthtool. DO NOT EDIT!
[flake8]
+ignore = E203, E266, E501, W503
exclude =
+ # Exclude generated code.
+ **/proto/**
+ **/gapic/**
+ *_pb2.py
+
+ # Standard linting exemptions.
__pycache__,
- .nox
.git,
*.pyc,
conf.py
diff --git a/packages/google-cloud-dialogflow/.github/ISSUE_TEMPLATE/bug_report.md b/packages/google-cloud-dialogflow/.github/ISSUE_TEMPLATE/bug_report.md
index 360f069ec260..5840956d5e50 100644
--- a/packages/google-cloud-dialogflow/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/packages/google-cloud-dialogflow/.github/ISSUE_TEMPLATE/bug_report.md
@@ -11,20 +11,30 @@ Thanks for stopping by to let us know something could be better!
Please run down the following list and make sure you've tried the usual "quick fixes":
- Search the issues already opened: https://github.com/googleapis/dialogflow-python-client-v2/issues
+ - Check for answers on StackOverflow: http://stackoverflow.com/questions/
If you are still having issues, please be sure to include as much information as possible:
#### Environment details
- - OS:
- - Python version:
- - pip version:
- - `dialogflow` version:
+1. OS type and version
+2. Python version and virtual environment information: `python --version`
+3. dialogflow version: `pip show dialogflow` or `pip freeze`
#### Steps to reproduce
1. ?
- 2. ?
+
+#### Code example
+
+```python
+# example
+```
+
+#### Stack trace
+```
+# example
+```
Making sure to follow these steps will guarantee the quickest resolution possible.
diff --git a/packages/google-cloud-dialogflow/.github/release-please.yml b/packages/google-cloud-dialogflow/.github/release-please.yml
new file mode 100644
index 000000000000..879274e697ea
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.github/release-please.yml
@@ -0,0 +1 @@
+releaseType: python
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.kokoro/build.sh b/packages/google-cloud-dialogflow/.kokoro/build.sh
new file mode 100755
index 000000000000..17e536e9c324
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/build.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Copyright 2018 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.
+
+set -eo pipefail
+
+cd github/dialogflow-python-client-v2
+
+# Disable buffering, so that the logs stream through.
+export PYTHONUNBUFFERED=1
+
+# Debug: show build environment
+env | grep KOKORO
+
+# Setup service account credentials.
+export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
+
+# Setup project id.
+export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
+
+# Remove old nox
+python3.6 -m pip uninstall --yes --quiet nox-automation
+
+# Install nox
+python3.6 -m pip install --upgrade --quiet nox
+python3.6 -m nox --version
+
+python3.6 -m nox
diff --git a/packages/google-cloud-dialogflow/.kokoro/continuous/common.cfg b/packages/google-cloud-dialogflow/.kokoro/continuous/common.cfg
new file mode 100644
index 000000000000..ef672c96ebff
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/continuous/common.cfg
@@ -0,0 +1,27 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Download resources for system tests (service account key, etc.)
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"
+
+# Use the trampoline script to run in docker.
+build_file: "dialogflow-python-client-v2/.kokoro/trampoline.sh"
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
+}
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/dialogflow-python-client-v2/.kokoro/build.sh"
+}
diff --git a/packages/google-cloud-dialogflow/.kokoro/continuous/continuous.cfg b/packages/google-cloud-dialogflow/.kokoro/continuous/continuous.cfg
new file mode 100644
index 000000000000..8f43917d92fe
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/continuous/continuous.cfg
@@ -0,0 +1 @@
+# Format: //devtools/kokoro/config/proto/build.proto
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.kokoro/docs/common.cfg b/packages/google-cloud-dialogflow/.kokoro/docs/common.cfg
new file mode 100644
index 000000000000..14b7c457f82b
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/docs/common.cfg
@@ -0,0 +1,48 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "dialogflow-python-client-v2/.kokoro/trampoline.sh"
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
+}
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/dialogflow-python-client-v2/.kokoro/publish-docs.sh"
+}
+
+env_vars: {
+ key: "STAGING_BUCKET"
+ value: "docs-staging"
+}
+
+# Fetch the token needed for reporting release status to GitHub
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "yoshi-automation-github-key"
+ }
+ }
+}
+
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "docuploader_service_account"
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.kokoro/docs/docs.cfg b/packages/google-cloud-dialogflow/.kokoro/docs/docs.cfg
new file mode 100644
index 000000000000..8f43917d92fe
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/docs/docs.cfg
@@ -0,0 +1 @@
+# Format: //devtools/kokoro/config/proto/build.proto
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.kokoro/presubmit/common.cfg b/packages/google-cloud-dialogflow/.kokoro/presubmit/common.cfg
new file mode 100644
index 000000000000..ef672c96ebff
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/presubmit/common.cfg
@@ -0,0 +1,27 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Download resources for system tests (service account key, etc.)
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"
+
+# Use the trampoline script to run in docker.
+build_file: "dialogflow-python-client-v2/.kokoro/trampoline.sh"
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
+}
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/dialogflow-python-client-v2/.kokoro/build.sh"
+}
diff --git a/packages/google-cloud-dialogflow/.kokoro/presubmit/presubmit.cfg b/packages/google-cloud-dialogflow/.kokoro/presubmit/presubmit.cfg
new file mode 100644
index 000000000000..8f43917d92fe
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/presubmit/presubmit.cfg
@@ -0,0 +1 @@
+# Format: //devtools/kokoro/config/proto/build.proto
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.kokoro/publish-docs.sh b/packages/google-cloud-dialogflow/.kokoro/publish-docs.sh
new file mode 100755
index 000000000000..0b419290c520
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/publish-docs.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+set -eo pipefail
+
+# Disable buffering, so that the logs stream through.
+export PYTHONUNBUFFERED=1
+
+cd github/dialogflow-python-client-v2
+
+# Remove old nox
+python3.6 -m pip uninstall --yes --quiet nox-automation
+
+# Install nox
+python3.6 -m pip install --upgrade --quiet nox
+python3.6 -m nox --version
+
+# build docs
+nox -s docs
+
+python3 -m pip install gcp-docuploader
+
+# install a json parser
+sudo apt-get update
+sudo apt-get -y install software-properties-common
+sudo add-apt-repository universe
+sudo apt-get update
+sudo apt-get -y install jq
+
+# create metadata
+python3 -m docuploader create-metadata \
+ --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
+ --version=$(python3 setup.py --version) \
+ --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
+ --distribution-name=$(python3 setup.py --name) \
+ --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \
+ --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \
+ --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json)
+
+cat docs.metadata
+
+# upload docs
+python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket docs-staging
diff --git a/packages/google-cloud-dialogflow/.kokoro/release.sh b/packages/google-cloud-dialogflow/.kokoro/release.sh
new file mode 100755
index 000000000000..6f113d6c20bf
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/release.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -eo pipefail
+
+# Start the releasetool reporter
+python3 -m pip install gcp-releasetool
+python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
+
+# Ensure that we have the latest versions of Twine, Wheel, and Setuptools.
+python3 -m pip install --upgrade twine wheel setuptools
+
+# Disable buffering, so that the logs stream through.
+export PYTHONUNBUFFERED=1
+
+# Move into the package, build the distribution and upload.
+TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
+cd github/dialogflow-python-client-v2
+python3 setup.py sdist bdist_wheel
+twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
diff --git a/packages/google-cloud-dialogflow/.kokoro/release/common.cfg b/packages/google-cloud-dialogflow/.kokoro/release/common.cfg
new file mode 100644
index 000000000000..b7a3af596c6c
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/release/common.cfg
@@ -0,0 +1,64 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "dialogflow-python-client-v2/.kokoro/trampoline.sh"
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
+}
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/dialogflow-python-client-v2/.kokoro/release.sh"
+}
+
+# Fetch the token needed for reporting release status to GitHub
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "yoshi-automation-github-key"
+ }
+ }
+}
+
+# Fetch PyPI password
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "google_cloud_pypi_password"
+ }
+ }
+}
+
+# Fetch magictoken to use with Magic Github Proxy
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "releasetool-magictoken"
+ }
+ }
+}
+
+# Fetch api key to use with Magic Github Proxy
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "magic-github-proxy-api-key"
+ }
+ }
+}
diff --git a/packages/google-cloud-dialogflow/.kokoro/release/release.cfg b/packages/google-cloud-dialogflow/.kokoro/release/release.cfg
new file mode 100644
index 000000000000..8f43917d92fe
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/release/release.cfg
@@ -0,0 +1 @@
+# Format: //devtools/kokoro/config/proto/build.proto
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/.kokoro/trampoline.sh b/packages/google-cloud-dialogflow/.kokoro/trampoline.sh
new file mode 100755
index 000000000000..e8c4251f3ed4
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.kokoro/trampoline.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Copyright 2017 Google Inc.
+#
+# 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.
+
+set -eo pipefail
+
+python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" || ret_code=$?
+
+chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
+${KOKORO_GFILE_DIR}/trampoline_cleanup.sh || true
+
+exit ${ret_code}
diff --git a/packages/google-cloud-dialogflow/.repo-metadata.json b/packages/google-cloud-dialogflow/.repo-metadata.json
new file mode 100644
index 000000000000..02ebb28e1d2f
--- /dev/null
+++ b/packages/google-cloud-dialogflow/.repo-metadata.json
@@ -0,0 +1,13 @@
+{
+ "name": "dialogflow",
+ "name_pretty": "Dialogflow",
+ "product_documentation": "https://www.dialogflow.com/",
+ "client_documentation": "https://googleapis.dev/python/dialogflow/latest",
+ "issue_tracker": "https://issuetracker.google.com/savedsearches/5300385",
+ "release_level": "beta",
+ "language": "python",
+ "repo": "googleapis/dialogflow-python-client-v2",
+ "distribution_name": "dialogflow",
+ "api_id": "dialogflow.googleapis.com",
+ "requires_billing": true
+}
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/CODE_OF_CONDUCT.md b/packages/google-cloud-dialogflow/CODE_OF_CONDUCT.md
new file mode 100644
index 000000000000..b3d1f6029849
--- /dev/null
+++ b/packages/google-cloud-dialogflow/CODE_OF_CONDUCT.md
@@ -0,0 +1,44 @@
+
+# Contributor Code of Conduct
+
+As contributors and maintainers of this project,
+and in the interest of fostering an open and welcoming community,
+we pledge to respect all people who contribute through reporting issues,
+posting feature requests, updating documentation,
+submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project
+a harassment-free experience for everyone,
+regardless of level of experience, gender, gender identity and expression,
+sexual orientation, disability, personal appearance,
+body size, race, ethnicity, age, religion, or nationality.
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery
+* Personal attacks
+* Trolling or insulting/derogatory comments
+* Public or private harassment
+* Publishing other's private information,
+such as physical or electronic
+addresses, without explicit permission
+* Other unethical or unprofessional conduct.
+
+Project maintainers have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct.
+By adopting this Code of Conduct,
+project maintainers commit themselves to fairly and consistently
+applying these principles to every aspect of managing this project.
+Project maintainers who do not follow or enforce the Code of Conduct
+may be permanently removed from the project team.
+
+This code of conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior
+may be reported by opening an issue
+or contacting one or more of the project maintainers.
+
+This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
+available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
diff --git a/packages/google-cloud-dialogflow/CONTRIBUTING.rst b/packages/google-cloud-dialogflow/CONTRIBUTING.rst
new file mode 100644
index 000000000000..b8d3342a4d18
--- /dev/null
+++ b/packages/google-cloud-dialogflow/CONTRIBUTING.rst
@@ -0,0 +1,219 @@
+############
+Contributing
+############
+
+#. **Please sign one of the contributor license agreements below.**
+#. Fork the repo, develop and test your code changes, add docs.
+#. Make sure that your commit messages clearly describe the changes.
+#. Send a pull request. (Please Read: `Faster Pull Request Reviews`_)
+
+.. _Faster Pull Request Reviews: https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
+
+.. contents:: Here are some guidelines for hacking on the Google Cloud Client libraries.
+
+***************
+Adding Features
+***************
+
+In order to add a feature:
+
+- The feature must be documented in both the API and narrative
+ documentation.
+
+- The feature must work fully on the following CPython versions: 2.7,
+ 3.5, 3.6, and 3.7 on both UNIX and Windows.
+
+- The feature must not add unnecessary dependencies (where
+ "unnecessary" is of course subjective, but new dependencies should
+ be discussed).
+
+****************************
+Using a Development Checkout
+****************************
+
+You'll have to create a development environment using a Git checkout:
+
+- While logged into your GitHub account, navigate to the
+ ``dialogflow-python-client-v2`` `repo`_ on GitHub.
+
+- Fork and clone the ``dialogflow-python-client-v2`` repository to your GitHub account by
+ clicking the "Fork" button.
+
+- Clone your fork of ``dialogflow-python-client-v2`` from your GitHub account to your local
+ computer, substituting your account username and specifying the destination
+ as ``hack-on-dialogflow-python-client-v2``. E.g.::
+
+ $ cd ${HOME}
+ $ git clone git@github.com:USERNAME/dialogflow-python-client-v2.git hack-on-dialogflow-python-client-v2
+ $ cd hack-on-dialogflow-python-client-v2
+ # Configure remotes such that you can pull changes from the googleapis/dialogflow-python-client-v2
+ # repository into your local repository.
+ $ git remote add upstream git@github.com:googleapis/dialogflow-python-client-v2.git
+ # fetch and merge changes from upstream into master
+ $ git fetch upstream
+ $ git merge upstream/master
+
+Now your local repo is set up such that you will push changes to your GitHub
+repo, from which you can submit a pull request.
+
+To work on the codebase and run the tests, we recommend using ``nox``,
+but you can also use a ``virtualenv`` of your own creation.
+
+.. _repo: https://github.com/googleapis/dialogflow-python-client-v2
+
+Using ``nox``
+=============
+
+We use `nox `__ to instrument our tests.
+
+- To test your changes, run unit tests with ``nox``::
+
+ $ nox -s unit-2.7
+ $ nox -s unit-3.7
+ $ ...
+
+ .. note::
+
+ The unit tests and system tests are described in the
+ ``noxfile.py`` files in each directory.
+
+.. nox: https://pypi.org/project/nox/
+
+Note on Editable Installs / Develop Mode
+========================================
+
+- As mentioned previously, using ``setuptools`` in `develop mode`_
+ or a ``pip`` `editable install`_ is not possible with this
+ library. This is because this library uses `namespace packages`_.
+ For context see `Issue #2316`_ and the relevant `PyPA issue`_.
+
+ Since ``editable`` / ``develop`` mode can't be used, packages
+ need to be installed directly. Hence your changes to the source
+ tree don't get incorporated into the **already installed**
+ package.
+
+.. _namespace packages: https://www.python.org/dev/peps/pep-0420/
+.. _Issue #2316: https://github.com/GoogleCloudPlatform/google-cloud-python/issues/2316
+.. _PyPA issue: https://github.com/pypa/packaging-problems/issues/12
+.. _develop mode: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
+.. _editable install: https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs
+
+*****************************************
+I'm getting weird errors... Can you help?
+*****************************************
+
+If the error mentions ``Python.h`` not being found,
+install ``python-dev`` and try again.
+On Debian/Ubuntu::
+
+ $ sudo apt-get install python-dev
+
+************
+Coding Style
+************
+
+- PEP8 compliance, with exceptions defined in the linter configuration.
+ If you have ``nox`` installed, you can test that you have not introduced
+ any non-compliant code via::
+
+ $ nox -s lint
+
+- In order to make ``nox -s lint`` run faster, you can set some environment
+ variables::
+
+ export GOOGLE_CLOUD_TESTING_REMOTE="upstream"
+ export GOOGLE_CLOUD_TESTING_BRANCH="master"
+
+ By doing this, you are specifying the location of the most up-to-date
+ version of ``dialogflow-python-client-v2``. The the suggested remote name ``upstream``
+ should point to the official ``googleapis`` checkout and the
+ the branch should be the main branch on that remote (``master``).
+
+Exceptions to PEP8:
+
+- Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for
+ "Function-Under-Test"), which is PEP8-incompliant, but more readable.
+ Some also use a local variable, ``MUT`` (short for "Module-Under-Test").
+
+*************
+Test Coverage
+*************
+
+- The codebase *must* have 100% test statement coverage after each commit.
+ You can test coverage via ``nox -s cover``.
+
+******************************************************
+Documentation Coverage and Building HTML Documentation
+******************************************************
+
+If you fix a bug, and the bug requires an API or behavior modification, all
+documentation in this package which references that API or behavior must be
+changed to reflect the bug fix, ideally in the same commit that fixes the bug
+or adds the feature.
+
+Build the docs via:
+
+ $ nox -s docs
+
+********************************************
+Note About ``README`` as it pertains to PyPI
+********************************************
+
+The `description on PyPI`_ for the project comes directly from the
+``README``. Due to the reStructuredText (``rst``) parser used by
+PyPI, relative links which will work on GitHub (e.g. ``CONTRIBUTING.rst``
+instead of
+``https://github.com/googleapis/dialogflow-python-client-v2/blob/master/CONTRIBUTING.rst``)
+may cause problems creating links or rendering the description.
+
+.. _description on PyPI: https://pypi.org/project/dialogflow
+
+
+*************************
+Supported Python Versions
+*************************
+
+We support:
+
+- `Python 3.5`_
+- `Python 3.6`_
+- `Python 3.7`_
+
+.. _Python 3.5: https://docs.python.org/3.5/
+.. _Python 3.6: https://docs.python.org/3.6/
+.. _Python 3.7: https://docs.python.org/3.7/
+
+
+Supported versions can be found in our ``noxfile.py`` `config`_.
+
+.. _config: https://github.com/googleapis/dialogflow-python-client-v2/blob/master/noxfile.py
+
+
+**********
+Versioning
+**********
+
+This library follows `Semantic Versioning`_.
+
+.. _Semantic Versioning: http://semver.org/
+
+Some packages are currently in major version zero (``0.y.z``), which means that
+anything may change at any time and the public API should not be considered
+stable.
+
+******************************
+Contributor License Agreements
+******************************
+
+Before we can accept your pull requests you'll need to sign a Contributor
+License Agreement (CLA):
+
+- **If you are an individual writing original source code** and **you own the
+ intellectual property**, then you'll need to sign an
+ `individual CLA `__.
+- **If you work for a company that wants to allow you to contribute your work**,
+ then you'll need to sign a
+ `corporate CLA `__.
+
+You can sign these electronically (just scroll to the bottom). After that,
+we'll be able to accept your pull requests.
diff --git a/packages/google-cloud-dialogflow/MANIFEST.in b/packages/google-cloud-dialogflow/MANIFEST.in
index 9cbf175afe6b..cd011be27a0e 100644
--- a/packages/google-cloud-dialogflow/MANIFEST.in
+++ b/packages/google-cloud-dialogflow/MANIFEST.in
@@ -1,3 +1,4 @@
+# Generated by synthtool. DO NOT EDIT!
include README.rst LICENSE
recursive-include google *.json *.proto
recursive-include tests *
diff --git a/packages/google-cloud-dialogflow/README.rst b/packages/google-cloud-dialogflow/README.rst
index 82d539c89d81..62e1be49602a 100644
--- a/packages/google-cloud-dialogflow/README.rst
+++ b/packages/google-cloud-dialogflow/README.rst
@@ -50,7 +50,7 @@ Installation
Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
-Python >= 3.4
+Python >= 3.5
Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -89,10 +89,4 @@ See `the LICENSE file v documentation".
-#html_title = None
+# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
+# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
-#html_logo = None
+# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
-#html_favicon = None
+# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
@@ -154,78 +169,87 @@
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
-#html_extra_path = []
+# html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
-#html_use_smartypants = True
+# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
-#html_additional_pages = {}
+# html_additional_pages = {}
# If false, no module index is generated.
-#html_domain_indices = True
+# html_domain_indices = True
# If false, no index is generated.
-#html_use_index = True
+# html_use_index = True
# If true, the index is split into individual pages for each letter.
-#html_split_index = False
+# html_split_index = False
# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
+# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
+# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
+# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
+# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
+# html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
-#html_search_language = 'en'
+# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
-#html_search_options = {'type': 'default'}
+# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
-#html_search_scorer = 'scorer.js'
+# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
-htmlhelp_basename = 'dialogflow-doc'
+htmlhelp_basename = "dialogflow-doc"
+
+# -- Options for warnings ------------------------------------------------------
+
+
+suppress_warnings = [
+ # Temporarily suppress this to avoid "more than one target found for
+ # cross-reference" warning, which are intractable for us to avoid while in
+ # a mono-repo.
+ # See https://github.com/sphinx-doc/sphinx/blob
+ # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843
+ "ref.python"
+]
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
-
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
-
# Additional stuff for the LaTeX preamble.
#'preamble': '',
-
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
@@ -234,39 +258,53 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
- (master_doc, 'dialogflow.tex',
- u'dialogflow Documentation', author, 'manual'),
+ (
+ master_doc,
+ "dialogflow.tex",
+ u"dialogflow Documentation",
+ author,
+ "manual",
+ )
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
-#latex_logo = None
+# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
-#latex_use_parts = False
+# latex_use_parts = False
# If true, show page references after internal links.
-#latex_show_pagerefs = False
+# latex_show_pagerefs = False
# If true, show URL addresses after external links.
-#latex_show_urls = False
+# latex_show_urls = False
# Documents to append as an appendix to all manuals.
-#latex_appendices = []
+# latex_appendices = []
# If false, no module index is generated.
-#latex_domain_indices = True
+# latex_domain_indices = True
+
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
-man_pages = [(master_doc, 'dialogflow',
- u'dialogflow Documentation', [author], 1)]
+man_pages = [
+ (
+ master_doc,
+ "dialogflow",
+ u"dialogflow Documentation",
+ [author],
+ 1,
+ )
+]
# If true, show URL addresses after external links.
-#man_show_urls = False
+# man_show_urls = False
+
# -- Options for Texinfo output -------------------------------------------
@@ -274,30 +312,45 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- (master_doc, 'dialogflow',
- u'dialogflow Documentation', author,
- 'dialogflow',
- 'GAPIC library for the {metadata.shortName} v2 service', 'APIs'),
+ (
+ master_doc,
+ "dialogflow",
+ u"dialogflow Documentation",
+ author,
+ "dialogflow",
+ "dialogflow Library",
+ "APIs",
+ )
]
# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
+# texinfo_appendices = []
# If false, no module index is generated.
-#texinfo_domain_indices = True
+# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'
+# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
-#texinfo_no_detailmenu = False
+# texinfo_no_detailmenu = False
+
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
- 'python': ('http://python.readthedocs.org/en/latest/', None),
- 'gax': ('https://gax-python.readthedocs.org/en/latest/', None),
+ "python": ("http://python.readthedocs.org/en/latest/", None),
+ "gax": ("https://gax-python.readthedocs.org/en/latest/", None),
+ "google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
+ "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None),
+ "google.api_core": (
+ "https://googleapis.dev/python/google-api-core/latest",
+ None,
+ ),
+ "grpc": ("https://grpc.io/grpc/python/", None),
+
}
+
# Napoleon settings
napoleon_google_docstring = True
napoleon_numpy_docstring = True
diff --git a/packages/google-cloud-dialogflow/docs/index.rst b/packages/google-cloud-dialogflow/docs/index.rst
index b1c152c6794b..7c62c09a528d 100644
--- a/packages/google-cloud-dialogflow/docs/index.rst
+++ b/packages/google-cloud-dialogflow/docs/index.rst
@@ -1,190 +1,16 @@
-Dialogflow: Python Client
-=========================
-
-|release level| |circleci| |codecov|
-
- Python idiomatic client for `Dialogflow`_
-
-`Dialogflow`_ is an enterprise-grade NLU platform that makes it easy for
-developers to design and integrate conversational user interfaces int
-mobile apps, web applications, devices, and bots.
-
-* `Dialogflow Standard Edition Documentation `_
-* `Dialogflow Enterprise Edition Documentation `_
-
-Read more about the client libraries for Cloud APIs, including the older
-Google APIs Client Libraries, in
-`Client Libraries Explained `_.
-
-.. _Dialogflow: https://dialogflow.com/
-
-
-Before you begin
-----------------
-
-#. Select or create a Cloud Platform `project`_.
-#. `Enable billing`_ for your project.
-#. `Enable the Google Cloud Dialogflow API`_.
-#. `Set up authentication`_ with a service account so you can access the
- API from your local workstation.
-
-.. _project: https://console.cloud.google.com/project
-.. _Enable billing: https://support.google.com/cloud/answer/6293499#enable-billing
-.. _Enable the Google Cloud Dialogflow API: https://console.cloud.google.com/flows/enableapi?apiid=dialogflow.googleapis.com
-.. _Set up authentication: https://cloud.google.com/docs/authentication/getting-started
-
-
-Installation
-------------
-
-.. code-block:: shell
-
- pip install dialogflow
-
-.. note::
-
- We highly recommend that you install this library in a
- `virtualenv `_.
-
-
-Using Dialogflow
-----------------
-
-Importing the Library
-~~~~~~~~~~~~~~~~~~~~~
-
-.. code-block:: python
-
- import dialogflow
-
-Detecting Intent (Texts)
-~~~~~~~~~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to detect the intent from texts:
-
-.. literalinclude:: ../samples/detect_intent_texts.py
- :start-after: # [START dialogflow_detect_intent_text]
- :end-before: # [END dialogflow_detect_intent_text]
-
-Detecting Intent (Audio)
-~~~~~~~~~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to detect the intent of a speaker given an
-audio file:
-
-.. literalinclude:: ../samples/detect_intent_audio.py
- :start-after: # [START dialogflow_detect_intent_audio]
- :end-before: # [END dialogflow_detect_intent_audio]
-
-Detecting Intent (Streaming Audio)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to detect the intent of a speaker given a
-stream of audio:
-
-.. literalinclude:: ../samples/detect_intent_stream.py
- :start-after: # [START dialogflow_detect_intent_streaming]
- :end-before: # [END dialogflow_detect_intent_streaming]
-
-Managing Intents
-~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to create intents:
-
-.. literalinclude:: ../samples/intent_management.py
- :start-after: # [START dialogflow_create_intent]
- :end-before: # [END dialogflow_create_intent]
-
-To delete intents:
-
-.. literalinclude:: ../samples/intent_management.py
- :start-after: # [START dialogflow_delete_intent]
- :end-before: # [END dialogflow_delete_intent]
-
-Managing Entity Types
-~~~~~~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to create entity types:
-
-.. literalinclude:: ../samples/entity_type_management.py
- :start-after: # [START dialogflow_create_entity_type]
- :end-before: # [END dialogflow_create_entity_type]
-
-To delete entity types:
-
-.. literalinclude:: ../samples/entity_type_management.py
- :start-after: # [START dialogflow_delete_entity_type]
- :end-before: # [END dialogflow_delete_entity_type]
-
-Managing Entities
-~~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to create entities:
-
-.. literalinclude:: ../samples/entity_management.py
- :start-after: # [START dialogflow_create_entity]
- :end-before: # [END dialogflow_create_entity]
-
-To delete entities:
-
-.. literalinclude:: ../samples/entity_management.py
- :start-after: # [START dialogflow_delete_entity]
- :end-before: # [END dialogflow_delete_entity]
-
-Managing Session Entity Types
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You can use the Dialogflow API to create session entity types:
-
-.. literalinclude:: ../samples/session_entity_type_management.py
- :start-after: # [START dialogflow_create_session_entity_type]
- :end-before: # [END dialogflow_create_session_entity_type]
-
-To delete session entity types:
-
-.. literalinclude:: ../samples/session_entity_type_management.py
- :start-after: # [START dialogflow_delete_session_entity_type]
- :end-before: # [END dialogflow_delete_session_entity_type]
-
-Versioning
-----------
-
-This library follows `Semantic Versioning `_.
-
-This library is considered to be in **beta**. This means it is expected to be
-mostly stable while we work toward a general availability release; however,
-complete stability is not guaranteed. We will address issues and requests
-against beta libraries with a high priority.
-
-More Information: `Google Cloud Platform Launch Stages `_
-
-Contributing
-------------
-
-Contributions welcome! See the `Contributing Guide `_.
-
-License
--------
-
-Apache Version 2.0
-
-See `the LICENSE file `_ for more information.
-
-
-.. |release level| image:: https://img.shields.io/badge/release%20level-beta-yellow.svg?style=flat
- :target: https://cloud.google.com/terms/launch-stages
-.. |circleci| image:: https://img.shields.io/circleci/project/github/dialogflow/dialogflow-python-client-v2.svg?style=flat)
- :target: https://circleci.com/gh/dialogflow/dialogflow-python-client-v2
-.. |codecov| image:: https://img.shields.io/codecov/c/github/dialogflow/dialogflow-python-client-v2/master.svg?style=flat)
- :target: https://codecov.io/gh/dialogflow/dialogflow-python-client-v2
+.. include:: README.rst
Api Reference
-------------
.. toctree::
:maxdepth: 2
+
+ v2
+ v2beta1
- gapic/v2/api
- gapic/v2/types
+Changelog
+----------
+.. toctree::
+ :maxdepth: 2
- gapic/v2beta1/api
- gapic/v2beta1/types
+ changelog
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/docs/v2.rst b/packages/google-cloud-dialogflow/docs/v2.rst
new file mode 100644
index 000000000000..80ad8e033c7f
--- /dev/null
+++ b/packages/google-cloud-dialogflow/docs/v2.rst
@@ -0,0 +1,7 @@
+v2
+-------------
+.. toctree::
+ :maxdepth: 2
+
+ gapic/v2/api
+ gapic/v2/types
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/docs/v2beta1.rst b/packages/google-cloud-dialogflow/docs/v2beta1.rst
new file mode 100644
index 000000000000..64e77b5b88f4
--- /dev/null
+++ b/packages/google-cloud-dialogflow/docs/v2beta1.rst
@@ -0,0 +1,7 @@
+v2beta1
+-------------
+.. toctree::
+ :maxdepth: 2
+
+ gapic/v2beta1/api
+ gapic/v2beta1/types
\ No newline at end of file
diff --git a/packages/google-cloud-dialogflow/nox.py b/packages/google-cloud-dialogflow/nox.py
deleted file mode 100644
index 5670ffe96d60..000000000000
--- a/packages/google-cloud-dialogflow/nox.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2017, 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.
-
-from __future__ import absolute_import
-import os
-
-import nox
-
-
-@nox.session
-@nox.parametrize('python_version', ['2.7', '3.4', '3.5', '3.6'])
-def unit_tests(session, python_version):
- """Run the unit test suite."""
-
- session.interpreter = 'python{}'.format(python_version)
-
- session.virtualenv_dirname = 'unit-' + python_version
-
- session.install('mock', 'pytest', 'pytest-cov')
- session.install('-e', '.')
-
- session.run(
- 'py.test',
- '--quiet',
- '--cov=dialogflow',
- '--cov=dialogflow_v2beta1',
- '--cov-append',
- '--cov-config=.coveragerc',
- '--cov-report=',
- os.path.join('tests', 'unit'),
- )
-
-
-@nox.session
-def sample_tests(session):
- """Run the sample tests."""
- session.install('mock', 'pytest')
- session.install('-e', '.')
- session.run('py.test', '--quiet', os.path.join('samples', 'tests'))
-
-
-@nox.session
-def lint_setup_py(session):
- """Verify that setup.py is valid (including RST check)."""
- session.install('docutils', 'pygments')
- session.run('python', 'setup.py', 'check', '--restructuredtext',
- '--strict')
-
-
-@nox.session
-def docs(session):
- """Build the docs."""
-
- session.install('sphinx', 'sphinx_rtd_theme')
- session.install('.')
-
- # Build the docs!
- session.run('rm', '-rf', 'docs/_build/')
- session.run('sphinx-build', '-W', '-b', 'html', '-d',
- 'docs/_build/doctrees', 'docs/', 'docs/_build/html/')
-
-
-@nox.session
-def cover(session):
- """Run the final coverage report.
-
- This outputs the coverage report aggregating coverage from the unit
- test runs (not system test runs), and then erases coverage data.
- """
- session.install('coverage', 'pytest-cov')
- session.run('coverage', 'report', '--show-missing')
- session.run('coverage', 'erase')
diff --git a/packages/google-cloud-dialogflow/noxfile.py b/packages/google-cloud-dialogflow/noxfile.py
new file mode 100644
index 000000000000..f7a3c74c354a
--- /dev/null
+++ b/packages/google-cloud-dialogflow/noxfile.py
@@ -0,0 +1,118 @@
+# Copyright 2017, 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.
+
+from __future__ import absolute_import
+import os
+import shutil
+
+import nox
+
+BLACK_VERSION = "black==19.3b0"
+BLACK_PATHS = [
+ "dialogflow",
+ "dialogflow_v2",
+ "dialogflow_v2beta1",
+ "docs",
+ "noxfile.py",
+ "setup.py",
+]
+
+
+@nox.session(python="3.7")
+def lint(session):
+ """Run linters.
+ Returns a failure if the linters find linting errors or sufficiently
+ serious code quality issues.
+ """
+ session.install("flake8", BLACK_VERSION)
+ # session.run("black", "--check", *BLACK_PATHS)
+ session.run("flake8", "dialogflow", "dialogflow_v2", "dialogflow_v2beta1")
+
+
+# @nox.session(python="3.6")
+# def blacken(session):
+# """Run black.
+# Format code to uniform standard.
+# This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
+# That run uses an image that doesn't have 3.6 installed. Before updating this
+# check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
+# """
+# session.install(BLACK_VERSION)
+# session.run("black", *BLACK_PATHS)
+
+
+@nox.session(python="3.7")
+def lint_setup_py(session):
+ """Verify that setup.py is valid (including RST check)."""
+ session.install("docutils", "pygments")
+ session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
+
+
+def default(session):
+ # Install all test dependencies, then install this package in-place.
+ session.install("mock", "pytest", "pytest-cov")
+ session.install("-e", ".")
+
+ # Run py.test against the unit tests.
+ session.run(
+ "py.test",
+ "--quiet",
+ "--cov=dialogflow",
+ "--cov=dialogflow_v2beta1",
+ "--cov=dialogflow_v2" "--cov-append",
+ "--cov-config=.coveragerc",
+ "--cov-report=",
+ os.path.join("tests", "unit"),
+ *session.posargs,
+ )
+
+
+@nox.session(python=["2.7", "3.5", "3.6", "3.7"])
+def unit(session):
+ """Run the unit test suite."""
+ default(session)
+
+
+@nox.session(python="3.7")
+def cover(session):
+ """Run the final coverage report.
+ This outputs the coverage report aggregating coverage from the unit
+ test runs (not system test runs), and then erases coverage data.
+ """
+ session.install("coverage", "pytest-cov")
+ session.run("coverage", "report", "--show-missing", "--fail-under=80")
+
+ session.run("coverage", "erase")
+
+
+@nox.session(python="3.7")
+def docs(session):
+ """Build the docs for this library."""
+
+ session.install("-e", ".")
+ session.install("sphinx", "alabaster", "recommonmark")
+
+ shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
+ session.run(
+ "sphinx-build",
+ "-W", # warnings as errors
+ "-T", # show full traceback on exception
+ "-N", # no colors
+ "-b",
+ "html",
+ "-d",
+ os.path.join("docs", "_build", "doctrees", ""),
+ os.path.join("docs", ""),
+ os.path.join("docs", "_build", "html", ""),
+ )
diff --git a/packages/google-cloud-dialogflow/renovate.json b/packages/google-cloud-dialogflow/renovate.json
new file mode 100644
index 000000000000..4fa949311b20
--- /dev/null
+++ b/packages/google-cloud-dialogflow/renovate.json
@@ -0,0 +1,5 @@
+{
+ "extends": [
+ "config:base", ":preserveSemverRanges"
+ ]
+}
diff --git a/packages/google-cloud-dialogflow/samples/README.rst b/packages/google-cloud-dialogflow/samples/README.rst
deleted file mode 100644
index 5127a0042898..000000000000
--- a/packages/google-cloud-dialogflow/samples/README.rst
+++ /dev/null
@@ -1,633 +0,0 @@
-.. This file is automatically generated. Do not edit this file directly.
-
-Dialogflow Enterprise Edition API Python Samples
-===============================================================================
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/README.rst
-
-
-This directory contains samples for Dialogflow Enterprise Edition API. The `Dialogflow Enterprise Edition API`_ enables you to create conversational experiences across devices and platforms.
-
-
-
-
-.. _Dialogflow Enterprise Edition API: https://cloud.google.com/dialogflow-enterprise/docs/
-
-Setup
--------------------------------------------------------------------------------
-
-
-Authentication
-++++++++++++++
-
-This sample requires you to have authentication setup. Refer to the
-`Authentication Getting Started Guide`_ for instructions on setting up
-credentials for applications.
-
-.. _Authentication Getting Started Guide:
- https://cloud.google.com/docs/authentication/getting-started
-
-Install Dependencies
-++++++++++++++++++++
-
-#. Clone the repository and change directory to the sample directory.
-
- .. code-block:: bash
-
- $ git clone https://github.com/dialogflow/dialogflow-python-client-v2.git
- $ cd dialogflow-python-client-v2/samples
-
-#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.
-
- .. _Python Development Environment Setup Guide:
- https://cloud.google.com/python/setup
-
-#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
-
- .. code-block:: bash
-
- $ virtualenv env
- $ source env/bin/activate
-
-#. Install the dependencies needed to run the samples.
-
- .. code-block:: bash
-
- $ pip install -r requirements.txt
-
-.. _pip: https://pip.pypa.io/
-.. _virtualenv: https://virtualenv.pypa.io/
-
-Samples
--------------------------------------------------------------------------------
-
-Detect Intent Text
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_texts.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_texts.py
-
- usage: detect_intent_texts.py [-h] --project-id PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- texts [texts ...]
-
- DialogFlow API Detect Intent Python sample with text inputs.
-
- Examples:
- python detect_intent_texts.py -h
- python detect_intent_texts.py --project-id PROJECT_ID --session-id SESSION_ID "hello" "book a meeting room" "Mountain View"
- python detect_intent_texts.py --project-id PROJECT_ID --session-id SESSION_ID "tomorrow" "10 AM" "2 hours" "10 people" "A" "yes"
-
- positional arguments:
- texts Text inputs.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- Identifier of the DetectIntent session. Defaults to a
- random UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
-
-
-
-Detect Intent Audio
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_audio.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_audio.py
-
- usage: detect_intent_audio.py [-h] --project-id PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- --audio-file-path AUDIO_FILE_PATH
-
- DialogFlow API Detect Intent Python sample with audio file.
-
- Examples:
- python detect_intent_audio.py -h
- python detect_intent_audio.py --project-id PROJECT_ID --session-id SESSION_ID --audio-file-path resources/book_a_room.wav
- python detect_intent_audio.py --project-id PROJECT_ID --session-id SESSION_ID --audio-file-path resources/mountain_view.wav
- python detect_intent_audio.py --project-id PROJECT_ID --session-id SESSION_ID --audio-file-path resources/today.wav
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- Identifier of the DetectIntent session. Defaults to a
- random UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
- --audio-file-path AUDIO_FILE_PATH
- Path to the audio file.
-
-
-
-Detect Intent Stream
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_stream.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_stream.py
-
- usage: detect_intent_stream.py [-h] --project-id PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- --audio-file-path AUDIO_FILE_PATH
-
- DialogFlow API Detect Intent Python sample with audio files processed
- as an audio stream.
-
- Examples:
- python detect_intent_stream.py -h
- python detect_intent_stream.py --project-id PROJECT_ID --session-id SESSION_ID --audio-file-path resources/book_a_room.wav
- python detect_intent_stream.py --project-id PROJECT_ID --session-id SESSION_ID --audio-file-path resources/mountain_view.wav
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- Identifier of the DetectIntent session. Defaults to a
- random UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
- --audio-file-path AUDIO_FILE_PATH
- Path to the audio file.
-
-
-
-Detect Intent Knowledge Base
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_knowledge.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_knowledge.py
-
- usage: detect_intent_knowledge.py [-h] --project-id PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- --knowledge-base-id KNOWLEDGE_ID
- texts [texts ...]
-
- Dialogflow API Detect Intent Python sample with text inputs.
-
- Examples:
- python detect_intent_knowledge.py -h
- python detect_intent_knowledge.py --project-id PROJECT_ID --session-id SESSION_ID --knowledge-base-id KNOWLEDGE_ID "hello" "how do I reset my password?"
-
- positional arguments:
- texts Text inputs.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- ID of the DetectIntent session. Defaults to a random
- UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
- --knowledge-base-id KNOWLEDGE_ID
- The id of the Knowledge Base to query against, e.g., OTE5NjYzMTkxNDA2NzI2MzQ4OA
-
-
-
-Detect Intent with Model Selection
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_with_model_selection.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_with_model_selection.py
-
- usage: detect_intent_with_model_selection.py [-h] --project-id PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- --audio-file-path AUDIO_FILE_PATH
-
- Dialogflow API Beta Detect Intent Python sample with model selection.
-
- Examples:
- python detect_intent_with_model_selection.py -h
- python detect_intent_with_model_selection.py --project-id PROJECT_ID --session-id SESSION_ID --audio-file-path resources/book_a_room.wav
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- Identifier of the DetectIntent session. Defaults to a
- random UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
- --audio-file-path AUDIO_FILE_PATH
- Path to the audio file.
-
-
-
-Detect Intent with Sentiment Analysis
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_with_sentiment_analysis.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_with_sentiment_analysis.py
-
- usage: detect_intent_with_sentiment_analysis.py [-h] --project-id PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- texts [texts ...]
-
- Dialogflow API Beta Detect Intent Python sample with sentiment analysis.
-
- Examples:
- python detect_intent_with_sentiment_analysis.py -h
- python detect_intent_with_sentiment_analysis.py --project-id PROJECT_ID --session-id SESSION_ID "hello" "book a meeting room" "Mountain View"
-
- positional arguments:
- texts Text inputs.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- Identifier of the DetectIntent session. Defaults to a
- random UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
-
-
-
-Detect Intent with Text to Speech Response
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/detect_intent_with_texttospeech_response.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python detect_intent_with_texttospeech_response.py
-
- usage: detect_intent_with_texttospeech_response.py [-h] --project-id
- PROJECT_ID
- [--session-id SESSION_ID]
- [--language-code LANGUAGE_CODE]
- texts [texts ...]
-
- Dialogflow API Beta Detect Intent Python sample with an audio response.
-
- Examples:
- python detect_intent_with_texttospeech_response.py -h
- python detect_intent_with_texttospeech_response.py --project-id PROJECT_ID --session-id SESSION_ID "hello"
-
- positional arguments:
- texts Text inputs.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
- --session-id SESSION_ID
- Identifier of the DetectIntent session. Defaults to a
- random UUID.
- --language-code LANGUAGE_CODE
- Language code of the query. Defaults to "en-US".
-
-
-
-Intent Management
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/intent_management.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python intent_management.py
-
- usage: intent_management.py [-h] --project-id PROJECT_ID
- {list,create,delete} ...
-
- DialogFlow API Intent Python sample showing how to manage intents.
-
- Examples:
- python intent_management.py -h
- python intent_management.py --project-id PROJECT_ID list
- python intent_management.py --project-id PROJECT_ID create "room.cancellation - yes" --training-phrases-parts "cancel" "cancellation" --message-texts "Are you sure you want to cancel?" "Cancelled."
- python intent_management.py --project-id PROJECT_ID delete 74892d81-7901-496a-bb0a-c769eda5180e
-
- positional arguments:
- {list,create,delete}
- list
- create Create an intent of the given intent type.
- delete Delete intent with the given intent type and intent
- value.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
-
-
-
-Entity Type Management
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/entity_type_management.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python entity_type_management.py
-
- usage: entity_type_management.py [-h] --project-id PROJECT_ID
- {list,create,delete} ...
-
- DialogFlow API EntityType Python sample showing how to manage entity types.
-
- Examples:
- python entity_type_management.py -h
- python entity_type_management.py --project-id PROJECT_ID list
- python entity_type_management.py --project-id PROJECT_ID create employee
- python entity_type_management.py --project-id PROJECT_ID delete e57238e2-e692-44ea-9216-6be1b2332e2a
-
- positional arguments:
- {list,create,delete}
- list
- create Create an entity type with the given display name.
- delete Delete entity type with the given entity type name.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
-
-
-
-Entity Management
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/entity_management.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python entity_management.py
-
- usage: entity_management.py [-h] --project-id PROJECT_ID
- {list,create,delete} ...
-
- DialogFlow API Entity Python sample showing how to manage entities.
-
- Examples:
- python entity_management.py -h
- python entity_management.py --project-id PROJECT_ID list --entity-type-id e57238e2-e692-44ea-9216-6be1b2332e2a
- python entity_management.py --project-id PROJECT_ID create new_room --synonyms basement cellar --entity-type-id e57238e2-e692-44ea-9216-6be1b2332e2a
- python entity_management.py --project-id PROJECT_ID delete new_room --entity-type-id e57238e2-e692-44ea-9216-6be1b2332e2a
-
- positional arguments:
- {list,create,delete}
- list
- create Create an entity of the given entity type.
- delete Delete entity with the given entity type and entity
- value.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
-
-
-
-Session Entity Type Management
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/session_entity_type_management.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python session_entity_type_management.py
-
- usage: session_entity_type_management.py [-h] --project-id PROJECT_ID
- {list,create,delete} ...
-
- DialogFlow API SessionEntityType Python sample showing how to manage
- session entity types.
-
- Examples:
- python session_entity_type_management.py -h
- python session_entity_type_management.py --project-id PROJECT_ID list --session-id SESSION_ID
- python session_entity_type_management.py --project-id PROJECT_ID create --session-id SESSION_ID --entity-type-display-name room --entity-values C D E F
- python session_entity_type_management.py --project-id PROJECT_ID delete --session-id SESSION_ID --entity-type-display-name room
-
- positional arguments:
- {list,create,delete}
- list
- create Create a session entity type with the given display
- name.
- delete Delete session entity type with the given entity type
- display name.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id. Required.
-
-
-
-Knowledge Base Management
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/knowledge_base_management.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python knowledge_base_management.py
-
- usage: knowledge_base_management.py [-h] --project-id PROJECT_ID
- {list,create,get,delete} ...
-
- Dialogflow API Python sample showing how to manage Knowledge bases.
-
- Examples:
- python knowledge_base_management.py -h
- python knowledge_base_management.py --project-id PROJECT_ID list
- python knowledge_base_management.py --project-id PROJECT_ID create --display-name DISPLAY_NAME
- python knowledge_base_management.py --project-id PROJECT_ID get --knowledge-base-id knowledge_base_id
- python knowledge_base_management.py --project-id PROJECT_ID delete --knowledge-base-id knowledge_base_id
-
- positional arguments:
- {list,create,get,delete}
- list List all Knowledge bases that belong to the project.
- create Create a new Knowledge base.
- get Get a Knowledge base by its id.
- delete Delete a Knowledge base by its id.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project/agent id.
-
-
-
-Document Management
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=/document_management.py,/README.rst
-
-
-
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python document_management.py
-
- usage: document_management.py [-h] --project-id PROJECT_ID --knowledge-base-id
- KNOWLEDGE_BASE_ID
- {list,create,get,delete} ...
-
- Dialogflow API Python sample showing how to manage Knowledge Documents.
-
- Examples:
- python document_management.py -h
- python document_management.py --project-id PROJECT_ID --knowledge-base-id knowledge_base_id list
- python document_management.py --project-id PROJECT_ID --knowledge-base-id knowledge_base_id create --display-name DISPLAY_NAME --mime-type MIME_TYPE --knowledge-type KNOWLEDGE_TYPE --content-uri CONTENT_URI
- python document_management.py --project-id PROJECT_ID --knowledge-base-id knowledge_base_id get --document-id DOCUMENT_ID
- python document_management.py --project-id PROJECT_ID --knowledge-base-id knowledge_base_id delete --document-id DOCUMENT_ID
-
- positional arguments:
- {list,create,get,delete}
- list List all Documents that belong to a certain Knowledge
- base.
- create Create a Document for a certain Knowledge base. Please note that it will be initially disabled until you enable it.
- get Get a Document by its id and the Knowledge base id.
- delete Delete a Document by its id and the Knowledge baseid.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-id PROJECT_ID
- Project id. Required.
- --knowledge-base-id KNOWLEDGE_BASE_ID
- The id of the Knowledge Base that the Document belongs
- to, e.g., OTE5NjYzMTkxNDA2NzI2MzQ4OA
- --mime_type The mime_type of the Document. e.g. text/csv, text/html,
- text/plain, text/pdf etc.
-
- --knowledge_type The Knowledge type of the Document. e.g. FAQ, EXTRACTIVE_QA.
-
- --content_uri Uri of the document, e.g. gs://path/mydoc.csv,
- http://mypage.com/faq.html.
-
-
-
-
-
-
-
-
-The client library
--------------------------------------------------------------------------------
-
-This sample uses the `Google Cloud Client Library for Python`_.
-You can read the documentation for more details on API usage and use GitHub
-to `browse the source`_ and `report issues`_.
-
-.. _Google Cloud Client Library for Python:
- https://googlecloudplatform.github.io/google-cloud-python/
-.. _browse the source:
- https://github.com/GoogleCloudPlatform/google-cloud-python
-.. _report issues:
- https://github.com/GoogleCloudPlatform/google-cloud-python/issues
-
-
-.. _Google Cloud SDK: https://cloud.google.com/sdk/
diff --git a/packages/google-cloud-dialogflow/samples/README.rst.in b/packages/google-cloud-dialogflow/samples/README.rst.in
deleted file mode 100644
index 250055c43d69..000000000000
--- a/packages/google-cloud-dialogflow/samples/README.rst.in
+++ /dev/null
@@ -1,55 +0,0 @@
-# This file is used to generate README.rst
-
-product:
- name: Dialogflow Enterprise Edition API
- short_name: Dialogflow API
- url: https://cloud.google.com/dialogflow-enterprise/docs/
- description: >
- The `Dialogflow Enterprise Edition API`_ enables you to create conversational experiences across devices and platforms.
-
-setup:
-- auth
-- install_deps
-
-samples:
-- name: Detect Intent Text
- file: detect_intent_texts.py
- show_help: True
-- name: Detect Intent Audio
- file: detect_intent_audio.py
- show_help: True
-- name: Detect Intent Stream
- file: detect_intent_stream.py
- show_help: True
-- name: Detect Intent Knowledge Base
- file: detect_intent_knowledge.py
- show_help: True
-- name: Detect Intent with Model Selection
- file: detect_intent_with_model_selection.py
- show_help: True
-- name: Detect Intent with Sentiment Analysis
- file: detect_intent_with_sentiment_analysis.py
- show_help: True
-- name: Detect Intent with Text to Speech Response
- file: detect_intent_with_texttospeech_response.py
- show_help: True
-- name: Intent Management
- file: intent_management.py
- show_help: True
-- name: Entity Type Management
- file: entity_type_management.py
- show_help: True
-- name: Entity Management
- file: entity_management.py
- show_help: True
-- name: Session Entity Type Management
- file: session_entity_type_management.py
- show_help: True
-- name: Knowledge Base Management
- file: knowledge_base_management.py
- show_help: True
-- name: Document Management
- file: document_management.py
- show_help: True
-
-cloud_client_library: true
diff --git a/packages/google-cloud-dialogflow/samples/__init__.py b/packages/google-cloud-dialogflow/samples/__init__.py
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/packages/google-cloud-dialogflow/samples/context_management.py b/packages/google-cloud-dialogflow/samples/context_management.py
deleted file mode 100644
index 2567086d653f..000000000000
--- a/packages/google-cloud-dialogflow/samples/context_management.py
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API Context Python sample showing how to manage session
-contexts.
-
-Examples:
- python context_management.py -h
- python context_management.py --project-id PROJECT_ID \
- list --session-id SESSION_ID
- python context_management.py --project-id PROJECT_ID \
- create --session-id SESSION_ID --context-id CONTEXT_ID
- python context_management.py --project-id PROJECT_ID \
- delete --session-id SESSION_ID --context-id CONTEXT_ID
-"""
-
-import argparse
-
-
-def list_contexts(project_id, session_id):
- import dialogflow_v2 as dialogflow
- contexts_client = dialogflow.ContextsClient()
-
- session_path = contexts_client.session_path(project_id, session_id)
-
- contexts = contexts_client.list_contexts(session_path)
-
- print('Contexts for session {}:\n'.format(session_path))
- for context in contexts:
- print('Context name: {}'.format(context.name))
- print('Lifespan count: {}'.format(context.lifespan_count))
- print('Fields:')
- for field, value in context.parameters.fields.items():
- if value.string_value:
- print('\t{}: {}'.format(field, value))
-
-
-# [START dialogflow_create_context]
-def create_context(project_id, session_id, context_id, lifespan_count):
- import dialogflow_v2 as dialogflow
- contexts_client = dialogflow.ContextsClient()
-
- session_path = contexts_client.session_path(project_id, session_id)
- context_name = contexts_client.context_path(
- project_id, session_id, context_id)
-
- context = dialogflow.types.Context(
- name=context_name, lifespan_count=lifespan_count)
-
- response = contexts_client.create_context(session_path, context)
-
- print('Context created: \n{}'.format(response))
-# [END dialogflow_create_context]
-
-
-# [START dialogflow_delete_context]
-def delete_context(project_id, session_id, context_id):
- import dialogflow_v2 as dialogflow
- contexts_client = dialogflow.ContextsClient()
-
- context_name = contexts_client.context_path(
- project_id, session_id, context_id)
-
- contexts_client.delete_context(context_name)
-# [END dialogflow_delete_context]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list', help=list_contexts.__doc__)
- list_parser.add_argument(
- '--session-id',
- required=True)
-
- create_parser = subparsers.add_parser(
- 'create', help=create_context.__doc__)
- create_parser.add_argument(
- '--session-id',
- required=True)
- create_parser.add_argument(
- '--context-id',
- help='The id of the context.',
- required=True)
- create_parser.add_argument(
- '--lifespan-count',
- help='The lifespan_count of the context. Defaults to 1.',
- default=1)
-
- delete_parser = subparsers.add_parser(
- 'delete', help=delete_context.__doc__)
- delete_parser.add_argument(
- '--session-id',
- required=True)
- delete_parser.add_argument(
- '--context-id',
- help='The id of the context.',
- required=True)
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_contexts(args.project_id, args.session_id, )
- elif args.command == 'create':
- create_context(
- args.project_id, args.session_id, args.context_id,
- args.lifespan_count)
- elif args.command == 'delete':
- delete_context(args.project_id, args.session_id, args.context_id)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_audio.py b/packages/google-cloud-dialogflow/samples/detect_intent_audio.py
deleted file mode 100644
index 7dcef341a8a6..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_audio.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API Detect Intent Python sample with audio file.
-
-Examples:
- python detect_intent_audio.py -h
- python detect_intent_audio.py --project-id PROJECT_ID \
- --session-id SESSION_ID --audio-file-path resources/book_a_room.wav
- python detect_intent_audio.py --project-id PROJECT_ID \
- --session-id SESSION_ID --audio-file-path resources/mountain_view.wav
- python detect_intent_audio.py --project-id PROJECT_ID \
- --session-id SESSION_ID --audio-file-path resources/today.wav
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_audio]
-def detect_intent_audio(project_id, session_id, audio_file_path,
- language_code):
- """Returns the result of detect intent with an audio file as input.
-
- Using the same `session_id` between requests allows continuation
- of the conversaion."""
- import dialogflow_v2 as dialogflow
-
- session_client = dialogflow.SessionsClient()
-
- # Note: hard coding audio_encoding and sample_rate_hertz for simplicity.
- audio_encoding = dialogflow.enums.AudioEncoding.AUDIO_ENCODING_LINEAR_16
- sample_rate_hertz = 16000
-
- session = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session))
-
- with open(audio_file_path, 'rb') as audio_file:
- input_audio = audio_file.read()
-
- audio_config = dialogflow.types.InputAudioConfig(
- audio_encoding=audio_encoding, language_code=language_code,
- sample_rate_hertz=sample_rate_hertz)
- query_input = dialogflow.types.QueryInput(audio_config=audio_config)
-
- response = session_client.detect_intent(
- session=session, query_input=query_input,
- input_audio=input_audio)
-
- print('=' * 20)
- print('Query text: {}'.format(response.query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- response.query_result.intent.display_name,
- response.query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- response.query_result.fulfillment_text))
-# [END dialogflow_detect_intent_audio]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
- parser.add_argument(
- '--session-id',
- help='Identifier of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- '--audio-file-path',
- help='Path to the audio file.',
- required=True)
-
- args = parser.parse_args()
-
- detect_intent_audio(
- args.project_id, args.session_id, args.audio_file_path,
- args.language_code)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_knowledge.py b/packages/google-cloud-dialogflow/samples/detect_intent_knowledge.py
deleted file mode 100644
index edfd4b517ec8..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_knowledge.py
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2018 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.
-
-"""Dialogflow API Detect Knowledge Base Intent Python sample with text inputs.
-
-Examples:
- python detect_intent_knowledge.py -h
- python detect_intent_knowledge.py --project-id PROJECT_ID \
- --session-id SESSION_ID --knowledge-base-id KNOWLEDGE_BASE_ID \
- "hello" "how do I reset my password?"
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_knowledge]
-def detect_intent_knowledge(project_id, session_id, language_code,
- knowledge_base_id, texts):
- """Returns the result of detect intent with querying Knowledge Connector.
-
- Args:
- project_id: The GCP project linked with the agent you are going to query.
- session_id: Id of the session, using the same `session_id` between requests
- allows continuation of the conversation.
- language_code: Language of the queries.
- knowledge_base_id: The Knowledge base's id to query against.
- texts: A list of text queries to send.
- """
- import dialogflow_v2beta1 as dialogflow
- session_client = dialogflow.SessionsClient()
-
- session_path = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session_path))
-
- for text in texts:
- text_input = dialogflow.types.TextInput(
- text=text, language_code=language_code)
-
- query_input = dialogflow.types.QueryInput(text=text_input)
-
- knowledge_base_path = dialogflow.knowledge_bases_client \
- .KnowledgeBasesClient \
- .knowledge_base_path(project_id, knowledge_base_id)
-
- query_params = dialogflow.types.QueryParameters(
- knowledge_base_names=[knowledge_base_path])
-
- response = session_client.detect_intent(
- session=session_path, query_input=query_input,
- query_params=query_params)
-
- print('=' * 20)
- print('Query text: {}'.format(response.query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- response.query_result.intent.display_name,
- response.query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- response.query_result.fulfillment_text))
- print('Knowledge results:')
- knowledge_answers = response.query_result.knowledge_answers
- for answers in knowledge_answers.answers:
- print(' - Answer: {}'.format(answers.answer))
- print(' - Confidence: {}'.format(
- answers.match_confidence))
-# [END dialogflow_detect_intent_knowledge]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id', help='Project/agent id. Required.', required=True)
- parser.add_argument(
- '--session-id',
- help='ID of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- '--knowledge-base-id',
- help='The id of the Knowledge Base to query against',
- required=True)
- parser.add_argument('texts', nargs='+', type=str, help='Text inputs.')
-
- args = parser.parse_args()
-
- detect_intent_knowledge(args.project_id, args.session_id,
- args.language_code, args.knowledge_base_id,
- args.texts)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_stream.py b/packages/google-cloud-dialogflow/samples/detect_intent_stream.py
deleted file mode 100644
index e69d46c25bbb..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_stream.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API Detect Intent Python sample with audio files processed
-as an audio stream.
-
-Examples:
- python detect_intent_stream.py -h
- python detect_intent_stream.py --project-id PROJECT_ID \
- --session-id SESSION_ID --audio-file-path resources/book_a_room.wav
- python detect_intent_stream.py --project-id PROJECT_ID \
- --session-id SESSION_ID --audio-file-path resources/mountain_view.wav
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_streaming]
-def detect_intent_stream(project_id, session_id, audio_file_path,
- language_code):
- """Returns the result of detect intent with streaming audio as input.
-
- Using the same `session_id` between requests allows continuation
- of the conversaion."""
- import dialogflow_v2 as dialogflow
- session_client = dialogflow.SessionsClient()
-
- # Note: hard coding audio_encoding and sample_rate_hertz for simplicity.
- audio_encoding = dialogflow.enums.AudioEncoding.AUDIO_ENCODING_LINEAR_16
- sample_rate_hertz = 16000
-
- session_path = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session_path))
-
- def request_generator(audio_config, audio_file_path):
- query_input = dialogflow.types.QueryInput(audio_config=audio_config)
-
- # The first request contains the configuration.
- yield dialogflow.types.StreamingDetectIntentRequest(
- session=session_path, query_input=query_input)
-
- # Here we are reading small chunks of audio data from a local
- # audio file. In practice these chunks should come from
- # an audio input device.
- with open(audio_file_path, 'rb') as audio_file:
- while True:
- chunk = audio_file.read(4096)
- if not chunk:
- break
- # The later requests contains audio data.
- yield dialogflow.types.StreamingDetectIntentRequest(
- input_audio=chunk)
-
- audio_config = dialogflow.types.InputAudioConfig(
- audio_encoding=audio_encoding, language_code=language_code,
- sample_rate_hertz=sample_rate_hertz)
-
- requests = request_generator(audio_config, audio_file_path)
- responses = session_client.streaming_detect_intent(requests)
-
- print('=' * 20)
- for response in responses:
- print('Intermediate transcript: "{}".'.format(
- response.recognition_result.transcript))
-
- # Note: The result from the last response is the final transcript along
- # with the detected content.
- query_result = response.query_result
-
- print('=' * 20)
- print('Query text: {}'.format(query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- query_result.intent.display_name,
- query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- query_result.fulfillment_text))
-# [END dialogflow_detect_intent_streaming]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
- parser.add_argument(
- '--session-id',
- help='Identifier of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- '--audio-file-path',
- help='Path to the audio file.',
- required=True)
-
- args = parser.parse_args()
-
- detect_intent_stream(
- args.project_id, args.session_id, args.audio_file_path,
- args.language_code)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_texts.py b/packages/google-cloud-dialogflow/samples/detect_intent_texts.py
deleted file mode 100644
index 6aba714887a5..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_texts.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API Detect Intent Python sample with text inputs.
-
-Examples:
- python detect_intent_texts.py -h
- python detect_intent_texts.py --project-id PROJECT_ID \
- --session-id SESSION_ID \
- "hello" "book a meeting room" "Mountain View"
- python detect_intent_texts.py --project-id PROJECT_ID \
- --session-id SESSION_ID \
- "tomorrow" "10 AM" "2 hours" "10 people" "A" "yes"
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_text]
-def detect_intent_texts(project_id, session_id, texts, language_code):
- """Returns the result of detect intent with texts as inputs.
-
- Using the same `session_id` between requests allows continuation
- of the conversation."""
-
- import dialogflow_v2 as dialogflow
- session_client = dialogflow.SessionsClient()
-
- session = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session))
-
- for text in texts:
- text_input = dialogflow.types.TextInput(
- text=text, language_code=language_code)
-
- query_input = dialogflow.types.QueryInput(text=text_input)
-
- response = session_client.detect_intent(
- session=session, query_input=query_input)
-
- print('=' * 20)
- print('Query text: {}'.format(response.query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- response.query_result.intent.display_name,
- response.query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- response.query_result.fulfillment_text))
-# [END dialogflow_detect_intent_text]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
- parser.add_argument(
- '--session-id',
- help='Identifier of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- 'texts',
- nargs='+',
- type=str,
- help='Text inputs.')
-
- args = parser.parse_args()
-
- detect_intent_texts(
- args.project_id, args.session_id, args.texts, args.language_code)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_with_model_selection.py b/packages/google-cloud-dialogflow/samples/detect_intent_with_model_selection.py
deleted file mode 100644
index 723170ee9fe1..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_with_model_selection.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2018 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.
-
-"""Dialogflow API Beta Detect Intent Python sample with model selection.
-
-Examples:
- python detect_intent_with_model_selection.py -h
- python detect_intent_with_model_selection.py --project-id PROJECT_ID \
- --session-id SESSION_ID --audio-file-path resources/book_a_room.wav
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_with_model_selection]
-def detect_intent_with_model_selection(project_id, session_id, audio_file_path,
- language_code):
- """Returns the result of detect intent with model selection on an audio file
- as input
-
- Using the same `session_id` between requests allows continuation
- of the conversaion."""
- import dialogflow_v2beta1 as dialogflow
- session_client = dialogflow.SessionsClient()
-
- # Note: hard coding audio_encoding and sample_rate_hertz for simplicity.
- audio_encoding = dialogflow.enums.AudioEncoding.AUDIO_ENCODING_LINEAR_16
- sample_rate_hertz = 16000
-
- session_path = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session_path))
-
- with open(audio_file_path, 'rb') as audio_file:
- input_audio = audio_file.read()
-
- # Which Speech model to select for the given request.
- # Possible models: video, phone_call, command_and_search, default
- model = 'phone_call'
-
- audio_config = dialogflow.types.InputAudioConfig(
- audio_encoding=audio_encoding, language_code=language_code,
- sample_rate_hertz=sample_rate_hertz,
- model=model)
- query_input = dialogflow.types.QueryInput(audio_config=audio_config)
-
- response = session_client.detect_intent(
- session=session_path, query_input=query_input,
- input_audio=input_audio)
-
- print('=' * 20)
- print('Query text: {}'.format(response.query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- response.query_result.intent.display_name,
- response.query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- response.query_result.fulfillment_text))
-# [END dialogflow_detect_intent_with_model_selection]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
- parser.add_argument(
- '--session-id',
- help='Identifier of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- '--audio-file-path',
- help='Path to the audio file.',
- required=True)
-
- args = parser.parse_args()
-
- detect_intent_with_model_selection(
- args.project_id, args.session_id, args.audio_file_path,
- args.language_code)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_with_sentiment_analysis.py b/packages/google-cloud-dialogflow/samples/detect_intent_with_sentiment_analysis.py
deleted file mode 100644
index 4eb4babf29f1..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_with_sentiment_analysis.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2018 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.
-
-"""Dialogflow API Beta Detect Intent Python sample with sentiment analysis.
-
-Examples:
- python detect_intent_with_sentiment_analysis.py -h
- python detect_intent_with_sentiment_analysis.py --project-id PROJECT_ID \
- --session-id SESSION_ID \
- "hello" "book a meeting room" "Mountain View"
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_with_sentiment_analysis]
-def detect_intent_with_sentiment_analysis(project_id, session_id, texts,
- language_code):
- """Returns the result of detect intent with texts as inputs and analyzes the
- sentiment of the query text.
-
- Using the same `session_id` between requests allows continuation
- of the conversaion."""
- import dialogflow_v2beta1 as dialogflow
- session_client = dialogflow.SessionsClient()
-
- session_path = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session_path))
-
- for text in texts:
- text_input = dialogflow.types.TextInput(
- text=text, language_code=language_code)
-
- query_input = dialogflow.types.QueryInput(text=text_input)
-
- # Enable sentiment analysis
- sentiment_config = dialogflow.types.SentimentAnalysisRequestConfig(
- analyze_query_text_sentiment=True)
-
- # Set the query parameters with sentiment analysis
- query_params = dialogflow.types.QueryParameters(
- sentiment_analysis_request_config=sentiment_config)
-
- response = session_client.detect_intent(
- session=session_path, query_input=query_input,
- query_params=query_params)
-
- print('=' * 20)
- print('Query text: {}'.format(response.query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- response.query_result.intent.display_name,
- response.query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- response.query_result.fulfillment_text))
- # Score between -1.0 (negative sentiment) and 1.0 (positive sentiment).
- print('Query Text Sentiment Score: {}\n'.format(
- response.query_result.sentiment_analysis_result
- .query_text_sentiment.score))
- print('Query Text Sentiment Magnitude: {}\n'.format(
- response.query_result.sentiment_analysis_result
- .query_text_sentiment.magnitude))
-# [END dialogflow_detect_intent_with_sentiment_analysis]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
- parser.add_argument(
- '--session-id',
- help='Identifier of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- 'texts',
- nargs='+',
- type=str,
- help='Text inputs.')
-
- args = parser.parse_args()
-
- detect_intent_with_sentiment_analysis(
- args.project_id, args.session_id, args.texts, args.language_code)
diff --git a/packages/google-cloud-dialogflow/samples/detect_intent_with_texttospeech_response.py b/packages/google-cloud-dialogflow/samples/detect_intent_with_texttospeech_response.py
deleted file mode 100644
index 2cad6a9b047f..000000000000
--- a/packages/google-cloud-dialogflow/samples/detect_intent_with_texttospeech_response.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2018 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.
-
-"""Dialogflow API Beta Detect Intent Python sample with an audio response.
-
-Examples:
- python detect_intent_with_texttospeech_response.py -h
- python detect_intent_with_texttospeech_response.py --project-id PROJECT_ID \
- --session-id SESSION_ID "hello"
-"""
-
-import argparse
-import uuid
-
-
-# [START dialogflow_detect_intent_with_texttospeech_response]
-def detect_intent_with_texttospeech_response(project_id, session_id, texts,
- language_code):
- """Returns the result of detect intent with texts as inputs and includes
- the response in an audio format.
-
- Using the same `session_id` between requests allows continuation
- of the conversaion."""
- import dialogflow_v2beta1 as dialogflow
- session_client = dialogflow.SessionsClient()
-
- session_path = session_client.session_path(project_id, session_id)
- print('Session path: {}\n'.format(session_path))
-
- for text in texts:
- text_input = dialogflow.types.TextInput(
- text=text, language_code=language_code)
-
- query_input = dialogflow.types.QueryInput(text=text_input)
-
- # Set the query parameters with sentiment analysis
- output_audio_config = dialogflow.types.OutputAudioConfig(
- audio_encoding=dialogflow.enums.OutputAudioEncoding
- .OUTPUT_AUDIO_ENCODING_LINEAR_16)
-
- response = session_client.detect_intent(
- session=session_path, query_input=query_input,
- output_audio_config=output_audio_config)
-
- print('=' * 20)
- print('Query text: {}'.format(response.query_result.query_text))
- print('Detected intent: {} (confidence: {})\n'.format(
- response.query_result.intent.display_name,
- response.query_result.intent_detection_confidence))
- print('Fulfillment text: {}\n'.format(
- response.query_result.fulfillment_text))
- # The response's audio_content is binary.
- with open('output.wav', 'wb') as out:
- out.write(response.output_audio)
- print('Audio content written to file "output.wav"')
-# [END dialogflow_detect_intent_with_texttospeech_response]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
- parser.add_argument(
- '--session-id',
- help='Identifier of the DetectIntent session. '
- 'Defaults to a random UUID.',
- default=str(uuid.uuid4()))
- parser.add_argument(
- '--language-code',
- help='Language code of the query. Defaults to "en-US".',
- default='en-US')
- parser.add_argument(
- 'texts',
- nargs='+',
- type=str,
- help='Text inputs.')
-
- args = parser.parse_args()
-
- detect_intent_with_texttospeech_response(
- args.project_id, args.session_id, args.texts, args.language_code)
diff --git a/packages/google-cloud-dialogflow/samples/document_management.py b/packages/google-cloud-dialogflow/samples/document_management.py
deleted file mode 100644
index 6145c9df8a6a..000000000000
--- a/packages/google-cloud-dialogflow/samples/document_management.py
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2018 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.
-
-"""Dialogflow API Python sample showing how to manage Knowledge Documents.
-
-Examples:
- python document_management.py -h
- python document_management.py --project-id PROJECT_ID \
- --knowledge-base-id knowledge_base_id \
- list
- python document_management.py --project-id PROJECT_ID \
- --knowledge-base-id knowledge_base_id \
- create --display-name DISPLAY_NAME --mime-type MIME_TYPE \
- --knowledge-type KNOWLEDGE_TYPE --content-uri CONTENT_URI
- python document_management.py --project-id PROJECT_ID \
- --knowledge-base-id knowledge_base_id \
- get --document-id DOCUMENT_ID
- python document_management.py --project-id PROJECT_ID \
- --knowledge-base-id knowledge_base_id \
- delete --document-id DOCUMENT_ID
-"""
-
-import argparse
-
-
-KNOWLEDGE_TYPES = ['KNOWLEDGE_TYPE_UNSPECIFIED', 'FAQ', 'EXTRACTIVE_QA']
-
-
-# [START dialogflow_list_document]
-def list_documents(project_id, knowledge_base_id):
- """Lists the Documents belonging to a Knowledge base.
-
- Args:
- project_id: The GCP project linked with the agent.
- knowledge_base_id: Id of the Knowledge base."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.DocumentsClient()
- knowledge_base_path = client.knowledge_base_path(project_id,
- knowledge_base_id)
-
- print('Documents for Knowledge Id: {}'.format(knowledge_base_id))
- for document in client.list_documents(knowledge_base_path):
- print(' - Display Name: {}'.format(document.display_name))
- print(' - Knowledge ID: {}'.format(document.name))
- print(' - MIME Type: {}'.format(document.mime_type))
- print(' - Knowledge Types:')
- for knowledge_type in document.knowledge_types:
- print(' - {}'.format(KNOWLEDGE_TYPES[knowledge_type]))
- print(' - Source: {}\n'.format(document.content_uri))
-# [END dialogflow_list_document]
-
-
-# [START dialogflow_create_document]]
-def create_document(project_id, knowledge_base_id, display_name, mime_type,
- knowledge_type, content_uri):
- """Creates a Document.
-
- Args:
- project_id: The GCP project linked with the agent.
- knowledge_base_id: Id of the Knowledge base.
- display_name: The display name of the Document.
- mime_type: The mime_type of the Document. e.g. text/csv, text/html,
- text/plain, text/pdf etc.
- knowledge_type: The Knowledge type of the Document. e.g. FAQ,
- EXTRACTIVE_QA.
- content_uri: Uri of the document, e.g. gs://path/mydoc.csv,
- http://mypage.com/faq.html."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.DocumentsClient()
- knowledge_base_path = client.knowledge_base_path(project_id,
- knowledge_base_id)
-
- document = dialogflow.types.Document(
- display_name=display_name, mime_type=mime_type,
- content_uri=content_uri)
-
- document.knowledge_types.append(
- dialogflow.types.Document.KnowledgeType.Value(knowledge_type))
-
- response = client.create_document(knowledge_base_path, document)
- print('Waiting for results...')
- document = response.result(timeout=90)
- print('Created Document:')
- print(' - Display Name: {}'.format(document.display_name))
- print(' - Knowledge ID: {}'.format(document.name))
- print(' - MIME Type: {}'.format(document.mime_type))
- print(' - Knowledge Types:')
- for knowledge_type in document.knowledge_types:
- print(' - {}'.format(KNOWLEDGE_TYPES[knowledge_type]))
- print(' - Source: {}\n'.format(document.content_uri))
-# [END dialogflow_create_document]]
-
-
-# [START dialogflow_get_document]]
-def get_document(project_id, knowledge_base_id, document_id):
- """Gets a Document.
-
- Args:
- project_id: The GCP project linked with the agent.
- knowledge_base_id: Id of the Knowledge base.
- document_id: Id of the Document."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.DocumentsClient()
- document_path = client.document_path(project_id, knowledge_base_id,
- document_id)
-
- response = client.get_document(document_path)
- print('Got Document:')
- print(' - Display Name: {}'.format(response.display_name))
- print(' - Knowledge ID: {}'.format(response.name))
- print(' - MIME Type: {}'.format(response.mime_type))
- print(' - Knowledge Types:')
- for knowledge_type in response.knowledge_types:
- print(' - {}'.format(KNOWLEDGE_TYPES[knowledge_type]))
- print(' - Source: {}\n'.format(response.content_uri))
-# [END dialogflow_get_document]]
-
-
-# [START dialogflow_delete_document]]
-def delete_document(project_id, knowledge_base_id, document_id):
- """Deletes a Document.
-
- Args:
- project_id: The GCP project linked with the agent.
- knowledge_base_id: Id of the Knowledge base.
- document_id: Id of the Document."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.DocumentsClient()
- document_path = client.document_path(project_id, knowledge_base_id,
- document_id)
-
- response = client.delete_document(document_path)
- print('operation running:\n {}'.format(response.operation))
- print('Waiting for results...')
- print('Done.\n {}'.format(response.result()))
-# [END dialogflow_delete_document]]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id', help='Project id. Required.', required=True)
- parser.add_argument(
- '--knowledge-base-id',
- help='The id of the Knowledge Base that the Document belongs to',
- required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list',
- help='List all Documents that belong to a certain Knowledge base.')
-
- create_parser = subparsers.add_parser(
- 'create', help='Create a Document for a certain Knowledge base.')
- create_parser.add_argument(
- '--display-name',
- help='A name of the Document, mainly used for display purpose, '
- 'can not be used to identify the Document.',
- default=str(''))
- create_parser.add_argument(
- '--mime-type',
- help='The mime-type of the Document, e.g. text/csv, text/html, '
- 'text/plain, text/pdf etc. ',
- required=True)
- create_parser.add_argument(
- '--knowledge-type',
- help='The knowledge-type of the Document, e.g. FAQ, EXTRACTIVE_QA.',
- required=True)
- create_parser.add_argument(
- '--content-uri',
- help='The uri of the Document, e.g. gs://path/mydoc.csv, '
- 'http://mypage.com/faq.html',
- required=True)
-
- get_parser = subparsers.add_parser(
- 'get', help='Get a Document by its id and the Knowledge base id.')
- get_parser.add_argument(
- '--document-id', help='The id of the Document', required=True)
-
- delete_parser = subparsers.add_parser(
- 'delete', help='Delete a Document by its id and the Knowledge base'
- 'id.')
- delete_parser.add_argument(
- '--document-id',
- help='The id of the Document you want to delete',
- required=True)
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_documents(args.project_id, args.knowledge_base_id)
- elif args.command == 'create':
- create_document(args.project_id, args.knowledge_base_id,
- args.display_name, args.mime_type, args.knowledge_type,
- args.content_uri)
- elif args.command == 'get':
- get_document(args.project_id, args.knowledge_base_id, args.document_id)
- elif args.command == 'delete':
- delete_document(args.project_id, args.knowledge_base_id,
- args.document_id)
diff --git a/packages/google-cloud-dialogflow/samples/entity_management.py b/packages/google-cloud-dialogflow/samples/entity_management.py
deleted file mode 100644
index dc29012448d2..000000000000
--- a/packages/google-cloud-dialogflow/samples/entity_management.py
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API Entity Python sample showing how to manage entities.
-
-Examples:
- python entity_management.py -h
- python entity_management.py --project-id PROJECT_ID \
- list --entity-type-id e57238e2-e692-44ea-9216-6be1b2332e2a
- python entity_management.py --project-id PROJECT_ID \
- create new_room --synonyms basement cellar \
- --entity-type-id e57238e2-e692-44ea-9216-6be1b2332e2a
- python entity_management.py --project-id PROJECT_ID \
- delete new_room \
- --entity-type-id e57238e2-e692-44ea-9216-6be1b2332e2a
-"""
-
-import argparse
-
-
-def list_entities(project_id, entity_type_id):
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- parent = entity_types_client.entity_type_path(
- project_id, entity_type_id)
-
- entities = entity_types_client.get_entity_type(parent).entities
-
- for entity in entities:
- print('Entity value: {}'.format(entity.value))
- print('Entity synonyms: {}\n'.format(entity.synonyms))
-
-
-# [START dialogflow_create_entity]
-def create_entity(project_id, entity_type_id, entity_value, synonyms):
- """Create an entity of the given entity type."""
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- # Note: synonyms must be exactly [entity_value] if the
- # entity_type's kind is KIND_LIST
- synonyms = synonyms or [entity_value]
-
- entity_type_path = entity_types_client.entity_type_path(
- project_id, entity_type_id)
-
- entity = dialogflow.types.EntityType.Entity()
- entity.value = entity_value
- entity.synonyms.extend(synonyms)
-
- response = entity_types_client.batch_create_entities(
- entity_type_path, [entity])
-
- print('Entity created: {}'.format(response))
-# [END dialogflow_create_entity]
-
-
-# [START dialogflow_delete_entity]
-def delete_entity(project_id, entity_type_id, entity_value):
- """Delete entity with the given entity type and entity value."""
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- entity_type_path = entity_types_client.entity_type_path(
- project_id, entity_type_id)
-
- entity_types_client.batch_delete_entities(
- entity_type_path, [entity_value])
-# [END dialogflow_delete_entity]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list', help=list_entities.__doc__)
- list_parser.add_argument(
- '--entity-type-id',
- help='The id of the entity_type.')
-
- create_parser = subparsers.add_parser(
- 'create', help=create_entity.__doc__)
- create_parser.add_argument(
- 'entity_value',
- help='The entity value to be added.')
- create_parser.add_argument(
- '--entity-type-id',
- help='The id of the entity_type to which to add an entity.',
- required=True)
- create_parser.add_argument(
- '--synonyms',
- nargs='*',
- help='The synonyms that will map to the provided entity value.',
- default=[])
-
- delete_parser = subparsers.add_parser(
- 'delete', help=delete_entity.__doc__)
- delete_parser.add_argument(
- '--entity-type-id',
- help='The id of the entity_type.',
- required=True)
- delete_parser.add_argument(
- 'entity_value',
- help='The value of the entity to delete.')
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_entities(args.project_id, args.entity_type_id)
- elif args.command == 'create':
- create_entity(
- args.project_id, args.entity_type_id, args.entity_value,
- args.synonyms)
- elif args.command == 'delete':
- delete_entity(
- args.project_id, args.entity_type_id, args.entity_value)
diff --git a/packages/google-cloud-dialogflow/samples/entity_type_management.py b/packages/google-cloud-dialogflow/samples/entity_type_management.py
deleted file mode 100644
index 065088661cf5..000000000000
--- a/packages/google-cloud-dialogflow/samples/entity_type_management.py
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API EntityType Python sample showing how to manage entity types.
-
-Examples:
- python entity_type_management.py -h
- python entity_type_management.py --project-id PROJECT_ID list
- python entity_type_management.py --project-id PROJECT_ID create employee
- python entity_type_management.py --project-id PROJECT_ID delete \
- e57238e2-e692-44ea-9216-6be1b2332e2a
-"""
-
-import argparse
-
-
-def list_entity_types(project_id):
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- parent = entity_types_client.project_agent_path(project_id)
-
- entity_types = entity_types_client.list_entity_types(parent)
-
- for entity_type in entity_types:
- print('Entity type name: {}'.format(entity_type.name))
- print('Entity type display name: {}'.format(entity_type.display_name))
- print('Number of entities: {}\n'.format(len(entity_type.entities)))
-
-
-# [START dialogflow_create_entity_type]
-def create_entity_type(project_id, display_name, kind):
- """Create an entity type with the given display name."""
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- parent = entity_types_client.project_agent_path(project_id)
- entity_type = dialogflow.types.EntityType(
- display_name=display_name, kind=kind)
-
- response = entity_types_client.create_entity_type(parent, entity_type)
-
- print('Entity type created: \n{}'.format(response))
-# [END dialogflow_create_entity_type]
-
-
-# [START dialogflow_delete_entity_type]
-def delete_entity_type(project_id, entity_type_id):
- """Delete entity type with the given entity type name."""
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- entity_type_path = entity_types_client.entity_type_path(
- project_id, entity_type_id)
-
- entity_types_client.delete_entity_type(entity_type_path)
-# [END dialogflow_delete_entity_type]
-
-
-# Helper to get entity_type_id from display name.
-def _get_entity_type_ids(project_id, display_name):
- import dialogflow_v2 as dialogflow
- entity_types_client = dialogflow.EntityTypesClient()
-
- parent = entity_types_client.project_agent_path(project_id)
- entity_types = entity_types_client.list_entity_types(parent)
- entity_type_names = [
- entity_type.name for entity_type in entity_types
- if entity_type.display_name == display_name]
-
- entity_type_ids = [
- entity_type_name.split('/')[-1] for entity_type_name
- in entity_type_names]
-
- return entity_type_ids
-
-
-if __name__ == '__main__':
- import dialogflow_v2
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list', help=list_entity_types.__doc__)
-
- create_parser = subparsers.add_parser(
- 'create', help=create_entity_type.__doc__)
- create_parser.add_argument(
- 'display_name',
- help='The display name of the entity.')
- create_parser.add_argument(
- '--kind',
- help='The kind of entity. KIND_MAP (default) or KIND_LIST.',
- default=dialogflow_v2.enums.EntityType.Kind.KIND_MAP)
-
- delete_parser = subparsers.add_parser(
- 'delete', help=delete_entity_type.__doc__)
- delete_parser.add_argument(
- 'entity_type_id',
- help='The id of the entity_type.')
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_entity_types(args.project_id)
- elif args.command == 'create':
- create_entity_type(args.project_id, args.display_name, args.kind)
- elif args.command == 'delete':
- delete_entity_type(args.project_id, args.entity_type_id)
diff --git a/packages/google-cloud-dialogflow/samples/intent_management.py b/packages/google-cloud-dialogflow/samples/intent_management.py
deleted file mode 100644
index 853e191c1a18..000000000000
--- a/packages/google-cloud-dialogflow/samples/intent_management.py
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API Intent Python sample showing how to manage intents.
-
-Examples:
- python intent_management.py -h
- python intent_management.py --project-id PROJECT_ID list
- python intent_management.py --project-id PROJECT_ID create \
- "room.cancellation - yes" \
- --training-phrases-parts "cancel" "cancellation" \
- --message-texts "Are you sure you want to cancel?" "Cancelled."
- python intent_management.py --project-id PROJECT_ID delete \
- 74892d81-7901-496a-bb0a-c769eda5180e
-"""
-
-import argparse
-
-
-# [START dialogflow_list_intents]
-def list_intents(project_id):
- import dialogflow_v2 as dialogflow
- intents_client = dialogflow.IntentsClient()
-
- parent = intents_client.project_agent_path(project_id)
-
- intents = intents_client.list_intents(parent)
-
- for intent in intents:
- print('=' * 20)
- print('Intent name: {}'.format(intent.name))
- print('Intent display_name: {}'.format(intent.display_name))
- print('Action: {}\n'.format(intent.action))
- print('Root followup intent: {}'.format(
- intent.root_followup_intent_name))
- print('Parent followup intent: {}\n'.format(
- intent.parent_followup_intent_name))
-
- print('Input contexts:')
- for input_context_name in intent.input_context_names:
- print('\tName: {}'.format(input_context_name))
-
- print('Output contexts:')
- for output_context in intent.output_contexts:
- print('\tName: {}'.format(output_context.name))
-# [END dialogflow_list_intents]
-
-
-# [START dialogflow_create_intent]
-def create_intent(project_id, display_name, training_phrases_parts,
- message_texts):
- """Create an intent of the given intent type."""
- import dialogflow_v2 as dialogflow
- intents_client = dialogflow.IntentsClient()
-
- parent = intents_client.project_agent_path(project_id)
- training_phrases = []
- for training_phrases_part in training_phrases_parts:
- part = dialogflow.types.Intent.TrainingPhrase.Part(
- text=training_phrases_part)
- # Here we create a new training phrase for each provided part.
- training_phrase = dialogflow.types.Intent.TrainingPhrase(parts=[part])
- training_phrases.append(training_phrase)
-
- text = dialogflow.types.Intent.Message.Text(text=message_texts)
- message = dialogflow.types.Intent.Message(text=text)
-
- intent = dialogflow.types.Intent(
- display_name=display_name,
- training_phrases=training_phrases,
- messages=[message])
-
- response = intents_client.create_intent(parent, intent)
-
- print('Intent created: {}'.format(response))
-# [END dialogflow_create_intent]
-
-
-# [START dialogflow_delete_intent]
-def delete_intent(project_id, intent_id):
- """Delete intent with the given intent type and intent value."""
- import dialogflow_v2 as dialogflow
- intents_client = dialogflow.IntentsClient()
-
- intent_path = intents_client.intent_path(project_id, intent_id)
-
- intents_client.delete_intent(intent_path)
-# [END dialogflow_delete_intent]
-
-
-# Helper to get intent from display name.
-def _get_intent_ids(project_id, display_name):
- import dialogflow_v2 as dialogflow
- intents_client = dialogflow.IntentsClient()
-
- parent = intents_client.project_agent_path(project_id)
- intents = intents_client.list_intents(parent)
- intent_names = [
- intent.name for intent in intents
- if intent.display_name == display_name]
-
- intent_ids = [
- intent_name.split('/')[-1] for intent_name
- in intent_names]
-
- return intent_ids
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list', help=list_intents.__doc__)
-
- create_parser = subparsers.add_parser(
- 'create', help=create_intent.__doc__)
- create_parser.add_argument(
- 'display_name')
- create_parser.add_argument(
- '--training-phrases-parts',
- nargs='*',
- type=str,
- help='Training phrases.',
- default=[])
- create_parser.add_argument(
- '--message-texts',
- nargs='*',
- type=str,
- help='Message texts for the agent\'s response when the intent '
- 'is detected.',
- default=[])
-
- delete_parser = subparsers.add_parser(
- 'delete', help=delete_intent.__doc__)
- delete_parser.add_argument(
- 'intent_id',
- help='The id of the intent.')
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_intents(args.project_id)
- elif args.command == 'create':
- create_intent(
- args.project_id, args.display_name, args.training_phrases_parts,
- args.message_texts, )
- elif args.command == 'delete':
- delete_intent(args.project_id, args.intent_id)
diff --git a/packages/google-cloud-dialogflow/samples/knowledge_base_management.py b/packages/google-cloud-dialogflow/samples/knowledge_base_management.py
deleted file mode 100644
index b5ceab786ccf..000000000000
--- a/packages/google-cloud-dialogflow/samples/knowledge_base_management.py
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2018 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.
-
-"""Dialogflow API Python sample showing how to manage Knowledge bases.
-
-Examples:
- python knowledge_base_management.py -h
- python knowledge_base_management.py --project-id PROJECT_ID \
- list
- python knowledge_base_management.py --project-id PROJECT_ID \
- create --display-name DISPLAY_NAME
- python knowledge_base_management.py --project-id PROJECT_ID \
- get --knowledge-base-id knowledge_base_id
- python knowledge_base_management.py --project-id PROJECT_ID \
- delete --knowledge-base-id knowledge_base_id
-"""
-
-import argparse
-
-
-# [START dialogflow_list_knowledge_base]
-def list_knowledge_bases(project_id):
- """Lists the Knowledge bases belonging to a project.
-
- Args:
- project_id: The GCP project linked with the agent."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.KnowledgeBasesClient()
- project_path = client.project_path(project_id)
-
- print('Knowledge Bases for: {}'.format(project_id))
- for knowledge_base in client.list_knowledge_bases(project_path):
- print(' - Display Name: {}'.format(knowledge_base.display_name))
- print(' - Knowledge ID: {}\n'.format(knowledge_base.name))
-# [END dialogflow_list_knowledge_base]
-
-
-# [START dialogflow_create_knowledge_base]
-def create_knowledge_base(project_id, display_name):
- """Creates a Knowledge base.
-
- Args:
- project_id: The GCP project linked with the agent.
- display_name: The display name of the Knowledge base."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.KnowledgeBasesClient()
- project_path = client.project_path(project_id)
-
- knowledge_base = dialogflow.types.KnowledgeBase(
- display_name=display_name)
-
- response = client.create_knowledge_base(project_path, knowledge_base)
-
- print('Knowledge Base created:\n')
- print('Display Name: {}\n'.format(response.display_name))
- print('Knowledge ID: {}\n'.format(response.name))
-# [END dialogflow_create_knowledge_base]
-
-
-# [START dialogflow_get_knowledge_base]
-def get_knowledge_base(project_id, knowledge_base_id):
- """Gets a specific Knowledge base.
-
- Args:
- project_id: The GCP project linked with the agent.
- knowledge_base_id: Id of the Knowledge base."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.KnowledgeBasesClient()
- knowledge_base_path = client.knowledge_base_path(
- project_id, knowledge_base_id)
-
- response = client.get_knowledge_base(knowledge_base_path)
-
- print('Got Knowledge Base:')
- print(' - Display Name: {}'.format(response.display_name))
- print(' - Knowledge ID: {}'.format(response.name))
-# [END dialogflow_get_knowledge_base]
-
-
-# [START dialogflow_delete_knowledge_base]
-def delete_knowledge_base(project_id, knowledge_base_id):
- """Deletes a specific Knowledge base.
-
- Args:
- project_id: The GCP project linked with the agent.
- knowledge_base_id: Id of the Knowledge base."""
- import dialogflow_v2beta1 as dialogflow
- client = dialogflow.KnowledgeBasesClient()
- knowledge_base_path = client.knowledge_base_path(
- project_id, knowledge_base_id)
-
- response = client.delete_knowledge_base(knowledge_base_path)
-
- print('Knowledge Base deleted.'.format(response))
-# [END dialogflow_delete_knowledge_base]
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id', help='Project/agent id.', required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list', help='List all Knowledge bases that belong to the project.')
-
- create_parser = subparsers.add_parser(
- 'create', help='Create a new Knowledge base.')
- create_parser.add_argument(
- '--display-name',
- help='A name of the Knowledge base, used for display purpose, '
- 'can not be used to identify the Knowledge base.',
- default=str(''))
-
- get_parser = subparsers.add_parser(
- 'get', help='Get a Knowledge base by its id.')
- get_parser.add_argument(
- '--knowledge-base-id', help='The id of the Knowledge base.',
- required=True)
-
- delete_parser = subparsers.add_parser(
- 'delete', help='Delete a Knowledge base by its id.')
- delete_parser.add_argument(
- '--knowledge-base-id',
- help='The id of the Knowledge base you want to delete.',
- required=True)
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_knowledge_bases(args.project_id)
- elif args.command == 'create':
- create_knowledge_base(args.project_id, args.display_name)
- elif args.command == 'get':
- get_knowledge_base(args.project_id, args.knowledge_base_id)
- elif args.command == 'delete':
- delete_knowledge_base(args.project_id, args.knowledge_base_id)
diff --git a/packages/google-cloud-dialogflow/samples/requirements.txt b/packages/google-cloud-dialogflow/samples/requirements.txt
deleted file mode 100644
index 6b1de5689d25..000000000000
--- a/packages/google-cloud-dialogflow/samples/requirements.txt
+++ /dev/null
@@ -1 +0,0 @@
-dialogflow==0.5.1
diff --git a/packages/google-cloud-dialogflow/samples/resources/230pm.wav b/packages/google-cloud-dialogflow/samples/resources/230pm.wav
deleted file mode 100644
index 7509eca784dc..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/230pm.wav and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/resources/RoomReservation.zip b/packages/google-cloud-dialogflow/samples/resources/RoomReservation.zip
deleted file mode 100644
index 7873fb628c89..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/RoomReservation.zip and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/resources/book_a_room.wav b/packages/google-cloud-dialogflow/samples/resources/book_a_room.wav
deleted file mode 100644
index 9124e9279460..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/book_a_room.wav and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/resources/half_an_hour.wav b/packages/google-cloud-dialogflow/samples/resources/half_an_hour.wav
deleted file mode 100644
index 71010a871bbb..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/half_an_hour.wav and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/resources/mountain_view.wav b/packages/google-cloud-dialogflow/samples/resources/mountain_view.wav
deleted file mode 100644
index 1c5437f7cb5b..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/mountain_view.wav and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/resources/today.wav b/packages/google-cloud-dialogflow/samples/resources/today.wav
deleted file mode 100644
index d47ed78b3516..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/today.wav and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/resources/two_people.wav b/packages/google-cloud-dialogflow/samples/resources/two_people.wav
deleted file mode 100644
index 5114ebbd3105..000000000000
Binary files a/packages/google-cloud-dialogflow/samples/resources/two_people.wav and /dev/null differ
diff --git a/packages/google-cloud-dialogflow/samples/session_entity_type_management.py b/packages/google-cloud-dialogflow/samples/session_entity_type_management.py
deleted file mode 100644
index 2c9861f80778..000000000000
--- a/packages/google-cloud-dialogflow/samples/session_entity_type_management.py
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 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.
-
-"""DialogFlow API SessionEntityType Python sample showing how to manage
-session entity types.
-
-Examples:
- python session_entity_type_management.py -h
- python session_entity_type_management.py --project-id PROJECT_ID list \
- --session-id SESSION_ID
- python session_entity_type_management.py --project-id PROJECT_ID create \
- --session-id SESSION_ID \
- --entity-type-display-name room --entity-values C D E F
- python session_entity_type_management.py --project-id PROJECT_ID delete \
- --session-id SESSION_ID \
- --entity-type-display-name room
-"""
-
-import argparse
-
-
-def list_session_entity_types(project_id, session_id):
- import dialogflow_v2 as dialogflow
- session_entity_types_client = dialogflow.SessionEntityTypesClient()
-
- session_path = session_entity_types_client.session_path(
- project_id, session_id)
-
- session_entity_types = (
- session_entity_types_client.
- list_session_entity_types(session_path))
-
- print('SessionEntityTypes for session {}:\n'.format(session_path))
- for session_entity_type in session_entity_types:
- print('\tSessionEntityType name: {}'.format(session_entity_type.name))
- print('\tNumber of entities: {}\n'.format(
- len(session_entity_type.entities)))
-
-
-# [START dialogflow_create_session_entity_type]
-def create_session_entity_type(project_id, session_id, entity_values,
- entity_type_display_name, entity_override_mode):
- """Create a session entity type with the given display name."""
- import dialogflow_v2 as dialogflow
- session_entity_types_client = dialogflow.SessionEntityTypesClient()
-
- session_path = session_entity_types_client.session_path(
- project_id, session_id)
- session_entity_type_name = (
- session_entity_types_client.session_entity_type_path(
- project_id, session_id, entity_type_display_name))
-
- # Here we use the entity value as the only synonym.
- entities = [
- dialogflow.types.EntityType.Entity(value=value, synonyms=[value])
- for value in entity_values]
- session_entity_type = dialogflow.types.SessionEntityType(
- name=session_entity_type_name,
- entity_override_mode=entity_override_mode,
- entities=entities)
-
- response = session_entity_types_client.create_session_entity_type(
- session_path, session_entity_type)
-
- print('SessionEntityType created: \n\n{}'.format(response))
-# [END dialogflow_create_session_entity_type]
-
-
-# [START dialogflow_delete_session_entity_type]
-def delete_session_entity_type(project_id, session_id,
- entity_type_display_name):
- """Delete session entity type with the given entity type display name."""
- import dialogflow_v2 as dialogflow
- session_entity_types_client = dialogflow.SessionEntityTypesClient()
-
- session_entity_type_name = (
- session_entity_types_client.session_entity_type_path(
- project_id, session_id, entity_type_display_name))
-
- session_entity_types_client.delete_session_entity_type(
- session_entity_type_name)
-# [END dialogflow_delete_session_entity_type]
-
-
-if __name__ == '__main__':
- import dialogflow_v2
- parser = argparse.ArgumentParser(
- description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument(
- '--project-id',
- help='Project/agent id. Required.',
- required=True)
-
- subparsers = parser.add_subparsers(dest='command')
-
- list_parser = subparsers.add_parser(
- 'list', help=list_session_entity_types.__doc__)
- list_parser.add_argument(
- '--session-id',
- required=True)
-
- create_parser = subparsers.add_parser(
- 'create', help=create_session_entity_type.__doc__)
- create_parser.add_argument(
- '--session-id',
- required=True)
- create_parser.add_argument(
- '--entity-type-display-name',
- help='The DISPLAY NAME of the entity type to be overridden '
- 'in the session.',
- required=True)
- create_parser.add_argument(
- '--entity-values',
- nargs='*',
- help='The entity values of the session entity type.',
- required=True)
- create_parser.add_argument(
- '--entity-override-mode',
- help='ENTITY_OVERRIDE_MODE_OVERRIDE (default) or '
- 'ENTITY_OVERRIDE_MODE_SUPPLEMENT',
- default=(dialogflow_v2.enums.SessionEntityType.EntityOverrideMode.
- ENTITY_OVERRIDE_MODE_OVERRIDE))
-
- delete_parser = subparsers.add_parser(
- 'delete', help=delete_session_entity_type.__doc__)
- delete_parser.add_argument(
- '--session-id',
- required=True)
- delete_parser.add_argument(
- '--entity-type-display-name',
- help='The DISPLAY NAME of the entity type.',
- required=True)
-
- args = parser.parse_args()
-
- if args.command == 'list':
- list_session_entity_types(args.project_id, args.session_id)
- elif args.command == 'create':
- create_session_entity_type(
- args.project_id, args.session_id, args.entity_values,
- args.entity_type_display_name, args.entity_override_mode)
- elif args.command == 'delete':
- delete_session_entity_type(
- args.project_id, args.session_id, args.entity_type_display_name)
diff --git a/packages/google-cloud-dialogflow/samples/tests/__init__.py b/packages/google-cloud-dialogflow/samples/tests/__init__.py
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/packages/google-cloud-dialogflow/samples/tests/context_test.py b/packages/google-cloud-dialogflow/samples/tests/context_test.py
deleted file mode 100644
index d66477aaee06..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/context_test.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2017 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.
-
-from __future__ import absolute_import
-import os
-
-from .. import detect_intent_texts
-from .. import context_management
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-CONTEXT_ID = 'fake_context_for_testing'
-
-
-def test_create_context(capsys):
- # Calling detect intent to create a session.
- detect_intent_texts.detect_intent_texts(
- PROJECT_ID, SESSION_ID, ['hi'], 'en-US')
-
- context_management.create_context(PROJECT_ID, SESSION_ID, CONTEXT_ID, 1)
- context_management.list_contexts(PROJECT_ID, SESSION_ID)
-
- out, _ = capsys.readouterr()
- assert CONTEXT_ID in out
-
-
-def test_delete_context(capsys):
- context_management.delete_context(PROJECT_ID, SESSION_ID, CONTEXT_ID)
- context_management.list_contexts(PROJECT_ID, SESSION_ID)
-
- out, _ = capsys.readouterr()
- assert CONTEXT_ID not in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/create_delete_entity_test.py b/packages/google-cloud-dialogflow/samples/tests/create_delete_entity_test.py
deleted file mode 100644
index 208dadb6a8e4..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/create_delete_entity_test.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2017 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.
-
-from __future__ import absolute_import
-import os
-
-from .. import entity_type_management
-from .. import entity_management
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-ENTITY_TYPE_DISPLAY_NAME = 'fake_entity_type_for_testing'
-ENTITY_VALUE_1 = 'fake_entity_for_testing_1'
-ENTITY_VALUE_2 = 'fake_entity_for_testing_2'
-SYNONYMS = ['fake_synonym_for_testing_1', 'fake_synonym_for_testing_2']
-
-
-def test_create_entity_type(capsys):
- entity_type_ids = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)
-
- assert len(entity_type_ids) == 0
-
- entity_type_management.create_entity_type(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME, 'KIND_MAP')
- out, _ = capsys.readouterr()
-
- assert 'display_name: "{}"'.format(ENTITY_TYPE_DISPLAY_NAME) in out
-
- entity_type_ids = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)
-
- assert len(entity_type_ids) == 1
-
-
-def test_create_entity(capsys):
- entity_type_id = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)[0]
-
- entity_management.create_entity(
- PROJECT_ID, entity_type_id, ENTITY_VALUE_1, [])
- entity_management.create_entity(
- PROJECT_ID, entity_type_id, ENTITY_VALUE_2, SYNONYMS)
-
- entity_management.list_entities(PROJECT_ID, entity_type_id)
- out, _ = capsys.readouterr()
-
- assert 'Entity value: {}'.format(ENTITY_VALUE_1) in out
- assert 'Entity value: {}'.format(ENTITY_VALUE_2) in out
- for synonym in SYNONYMS:
- assert synonym in out
-
-
-def test_delete_entity(capsys):
- entity_type_id = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)[0]
-
- entity_management.delete_entity(
- PROJECT_ID, entity_type_id, ENTITY_VALUE_1)
- entity_management.delete_entity(
- PROJECT_ID, entity_type_id, ENTITY_VALUE_2)
-
- entity_management.list_entities(PROJECT_ID, entity_type_id)
- out, _ = capsys.readouterr()
-
- assert out == ''
-
-
-def test_delete_entity_type(capsys):
- entity_type_ids = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)
-
- for entity_type_id in entity_type_ids:
- entity_type_management.delete_entity_type(PROJECT_ID, entity_type_id)
-
- entity_type_ids = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)
-
- assert len(entity_type_ids) == 0
diff --git a/packages/google-cloud-dialogflow/samples/tests/detect_intent_audio_test.py b/packages/google-cloud-dialogflow/samples/tests/detect_intent_audio_test.py
deleted file mode 100644
index 64dde1fc16d2..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/detect_intent_audio_test.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2017, 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.
-
-from __future__ import absolute_import
-import os
-
-from ..detect_intent_audio import detect_intent_audio
-
-DIRNAME = os.path.realpath(os.path.dirname(__file__))
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-AUDIOS = [
- '{0}/../resources/book_a_room.wav'.format(DIRNAME),
- '{0}/../resources/mountain_view.wav'.format(DIRNAME),
- '{0}/../resources/today.wav'.format(DIRNAME),
-]
-
-
-def test_detect_intent_audio(capsys):
- for audio_file_path in AUDIOS:
- detect_intent_audio(PROJECT_ID, SESSION_ID, audio_file_path, 'en-US')
- out, _ = capsys.readouterr()
-
- assert 'Fulfillment text: What time will the meeting start?' in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/detect_intent_stream_test.py b/packages/google-cloud-dialogflow/samples/tests/detect_intent_stream_test.py
deleted file mode 100644
index 610a7f3309f6..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/detect_intent_stream_test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2017, 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.
-
-from __future__ import absolute_import
-import os
-
-from ..detect_intent_stream import detect_intent_stream
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-AUDIO_FILE_PATH = '{0}/../resources/book_a_room.wav'.format(
- os.path.realpath(os.path.dirname(__file__)),
-)
-
-
-def test_detect_intent_stream(capsys):
- detect_intent_stream(PROJECT_ID, SESSION_ID, AUDIO_FILE_PATH, 'en-US')
- out, _ = capsys.readouterr()
-
- assert 'Intermediate transcript: "book"' in out
- assert 'Fulfillment text: What time will the meeting start?' in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/detect_intent_texts_test.py b/packages/google-cloud-dialogflow/samples/tests/detect_intent_texts_test.py
deleted file mode 100644
index aab6c14b5c41..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/detect_intent_texts_test.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2017, 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.
-
-from __future__ import absolute_import
-import os
-
-from ..detect_intent_texts import detect_intent_texts
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-TEXTS = ["hello", "book a meeting room", "Mountain View",
- "tomorrow", "10 AM", "2 hours", "10 people", "A", "yes"]
-
-
-def test_detect_intent_texts(capsys):
- detect_intent_texts(PROJECT_ID, SESSION_ID, TEXTS, 'en-US')
- out, _ = capsys.readouterr()
-
- assert 'Fulfillment text: All set!' in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_model_selection_test.py b/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_model_selection_test.py
deleted file mode 100644
index b1c65bcfe442..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_model_selection_test.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2018, 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.
-
-from __future__ import absolute_import
-import os
-
-from ..detect_intent_with_model_selection import \
- detect_intent_with_model_selection
-
-DIRNAME = os.path.realpath(os.path.dirname(__file__))
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-AUDIOS = [
- '{0}/../resources/book_a_room.wav'.format(DIRNAME),
- '{0}/../resources/mountain_view.wav'.format(DIRNAME),
- '{0}/../resources/today.wav'.format(DIRNAME),
-]
-
-
-def test_detect_intent_audio(capsys):
- for audio_file_path in AUDIOS:
- detect_intent_with_model_selection(PROJECT_ID, SESSION_ID,
- audio_file_path, 'en-US')
- out, _ = capsys.readouterr()
-
- assert 'Fulfillment text: What time will the meeting start?' in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_sentiment_analysis_test.py b/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_sentiment_analysis_test.py
deleted file mode 100644
index ac320737557e..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_sentiment_analysis_test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2018, 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.
-
-from __future__ import absolute_import
-import os
-
-from ..detect_intent_with_sentiment_analysis import \
- detect_intent_with_sentiment_analysis
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-TEXTS = ["hello", "book a meeting room", "Mountain View",
- "tomorrow", "10 AM", "2 hours", "10 people", "A", "yes"]
-
-
-def test_detect_intent_with_sentiment_analysis(capsys):
- detect_intent_with_sentiment_analysis(PROJECT_ID, SESSION_ID, TEXTS,
- 'en-US')
- out, _ = capsys.readouterr()
-
- assert 'Query Text Sentiment Score' in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_texttospeech_response.py b/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_texttospeech_response.py
deleted file mode 100644
index eedf4a3cd858..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/detect_intent_with_texttospeech_response.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2018, 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.
-
-from __future__ import absolute_import
-import os
-
-from ..detect_intent_with_texttospeech_response import \
- detect_intent_with_texttospeech_response
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-TEXTS = ["hello"]
-
-
-def test_detect_intent_with_sentiment_analysis(capsys):
- detect_intent_with_texttospeech_response(PROJECT_ID, SESSION_ID, TEXTS,
- 'en-US')
- out, _ = capsys.readouterr()
-
- assert 'Audio content written to file' in out
- statinfo = os.stat('output.wav')
- assert statinfo.st_size > 0
- os.remove('output.wav')
- assert not os.path.isfile('output.wav')
diff --git a/packages/google-cloud-dialogflow/samples/tests/intent_test.py b/packages/google-cloud-dialogflow/samples/tests/intent_test.py
deleted file mode 100644
index c4bd664bcb66..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/intent_test.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2017 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.
-
-from __future__ import absolute_import
-import os
-
-from .. import intent_management
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-INTENT_DISPLAY_NAME = 'fake_display_name_for_testing'
-MESSAGE_TEXTS = [
- 'fake_message_text_for_testing_1',
- 'fake_message_text_for_testing_2'
-]
-TRAINING_PHRASE_PARTS = [
- 'fake_training_phrase_part_1',
- 'fake_training_phease_part_2'
-]
-
-
-def test_create_intent(capsys):
- intent_management.create_intent(
- PROJECT_ID, INTENT_DISPLAY_NAME, TRAINING_PHRASE_PARTS,
- MESSAGE_TEXTS)
-
- intent_ids = intent_management._get_intent_ids(
- PROJECT_ID, INTENT_DISPLAY_NAME)
-
- assert len(intent_ids) == 1
-
- intent_management.list_intents(PROJECT_ID)
-
- out, _ = capsys.readouterr()
-
- assert INTENT_DISPLAY_NAME in out
-
- for message_text in MESSAGE_TEXTS:
- assert message_text in out
-
-
-def test_delete_session_entity_type(capsys):
- intent_ids = intent_management._get_intent_ids(
- PROJECT_ID, INTENT_DISPLAY_NAME)
-
- for intent_id in intent_ids:
- intent_management.delete_intent(PROJECT_ID, intent_id)
-
- intent_management.list_intents(PROJECT_ID)
- out, _ = capsys.readouterr()
-
- assert INTENT_DISPLAY_NAME not in out
-
- intent_ids = intent_management._get_intent_ids(
- PROJECT_ID, INTENT_DISPLAY_NAME)
-
- assert len(intent_ids) == 0
diff --git a/packages/google-cloud-dialogflow/samples/tests/knowledge_base_test.py b/packages/google-cloud-dialogflow/samples/tests/knowledge_base_test.py
deleted file mode 100644
index a416986c4ba9..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/knowledge_base_test.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 2018 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.
-
-from __future__ import absolute_import
-import os
-
-from .. import knowledge_base_management
-from .. import document_management
-from .. import detect_intent_knowledge
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-TEXTS = ['Where is my data stored?']
-
-KNOWLEDGE_BASE_NAME = 'fake_knowledge_base_name'
-DOCUMENT_BASE_NAME = 'fake_document_name'
-
-
-def test_create_knowledge_base(capsys):
- # Check the knowledge base does not yet exists
- knowledge_base_management.list_knowledge_bases(PROJECT_ID)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(KNOWLEDGE_BASE_NAME) not in out
-
- # Create a knowledge base
- knowledge_base_management.create_knowledge_base(PROJECT_ID,
- KNOWLEDGE_BASE_NAME)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(KNOWLEDGE_BASE_NAME) in out
-
- # List the knowledge base
- knowledge_base_management.list_knowledge_bases(PROJECT_ID)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(KNOWLEDGE_BASE_NAME) in out
-
- knowledge_base_id = out.split('knowledgeBases/')[1].rstrip()
-
- # Get the knowledge base
- knowledge_base_management.get_knowledge_base(PROJECT_ID, knowledge_base_id)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(KNOWLEDGE_BASE_NAME) in out
-
- # Create a Document
- document_management.create_document(
- PROJECT_ID, knowledge_base_id, DOCUMENT_BASE_NAME, 'text/html', 'FAQ',
- 'https://cloud.google.com/storage/docs/faq')
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(DOCUMENT_BASE_NAME) in out
-
- # List the Document
- document_management.list_documents(PROJECT_ID, knowledge_base_id)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(DOCUMENT_BASE_NAME) in out
-
- document_id = out.split('documents/')[1].split(' - MIME Type:')[0].rstrip()
-
- # Get the Document
- document_management.get_document(PROJECT_ID, knowledge_base_id,
- document_id)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(DOCUMENT_BASE_NAME) in out
-
- # Detect intent with Knowledge Base
- detect_intent_knowledge.detect_intent_knowledge(
- PROJECT_ID, SESSION_ID, 'en-us', knowledge_base_id, TEXTS)
-
- out, _ = capsys.readouterr()
- assert 'Knowledge results' in out
-
- # Delete the Document
- document_management.delete_document(PROJECT_ID, knowledge_base_id,
- document_id)
-
- # List the Document
- document_management.list_documents(PROJECT_ID, knowledge_base_id)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(DOCUMENT_BASE_NAME) not in out
-
- # Delete the Knowledge Base
- knowledge_base_management.delete_knowledge_base(PROJECT_ID,
- knowledge_base_id)
-
- # List the knowledge base
- knowledge_base_management.list_knowledge_bases(PROJECT_ID)
-
- out, _ = capsys.readouterr()
- assert 'Display Name: {}'.format(KNOWLEDGE_BASE_NAME) not in out
diff --git a/packages/google-cloud-dialogflow/samples/tests/session_entity_type_test.py b/packages/google-cloud-dialogflow/samples/tests/session_entity_type_test.py
deleted file mode 100644
index 2871b05e79d1..000000000000
--- a/packages/google-cloud-dialogflow/samples/tests/session_entity_type_test.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2017 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.
-
-from __future__ import absolute_import
-import os
-
-from .. import entity_type_management
-from .. import session_entity_type_management
-
-PROJECT_ID = os.getenv('GCLOUD_PROJECT')
-SESSION_ID = 'fake_session_for_testing'
-ENTITY_TYPE_DISPLAY_NAME = 'fake_display_name_for_testing'
-ENTITY_VALUES = ['fake_entity_value_1', 'fake_entity_value_2']
-
-
-def test_create_session_entity_type(capsys):
- # Create an entity type
- entity_type_management.create_entity_type(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME, 'KIND_MAP')
-
- session_entity_type_management.create_session_entity_type(
- PROJECT_ID, SESSION_ID, ENTITY_VALUES, ENTITY_TYPE_DISPLAY_NAME,
- 'ENTITY_OVERRIDE_MODE_SUPPLEMENT')
- session_entity_type_management.list_session_entity_types(
- PROJECT_ID, SESSION_ID)
-
- out, _ = capsys.readouterr()
-
- assert SESSION_ID in out
- assert ENTITY_TYPE_DISPLAY_NAME in out
- for entity_value in ENTITY_VALUES:
- assert entity_value in out
-
-
-def test_delete_session_entity_type(capsys):
- session_entity_type_management.delete_session_entity_type(
- PROJECT_ID, SESSION_ID, ENTITY_TYPE_DISPLAY_NAME)
- session_entity_type_management.list_session_entity_types(
- PROJECT_ID, SESSION_ID)
-
- out, _ = capsys.readouterr()
- assert ENTITY_TYPE_DISPLAY_NAME not in out
- for entity_value in ENTITY_VALUES:
- assert entity_value not in out
-
- # Clean up entity type
- entity_type_ids = entity_type_management._get_entity_type_ids(
- PROJECT_ID, ENTITY_TYPE_DISPLAY_NAME)
- for entity_type_id in entity_type_ids:
- entity_type_management.delete_entity_type(
- PROJECT_ID, entity_type_id)
diff --git a/packages/google-cloud-dialogflow/setup.cfg b/packages/google-cloud-dialogflow/setup.cfg
index 2a9acf13daa9..3bd555500e37 100644
--- a/packages/google-cloud-dialogflow/setup.cfg
+++ b/packages/google-cloud-dialogflow/setup.cfg
@@ -1,2 +1,3 @@
+# Generated by synthtool. DO NOT EDIT!
[bdist_wheel]
universal = 1
diff --git a/packages/google-cloud-dialogflow/synth.py b/packages/google-cloud-dialogflow/synth.py
index 5a4911e32a05..d0a29709c0cb 100644
--- a/packages/google-cloud-dialogflow/synth.py
+++ b/packages/google-cloud-dialogflow/synth.py
@@ -88,3 +88,5 @@
s.replace('dialogflow_v2/proto/agent_pb2.py', ':math:', '')
s.replace('dialogflow_v2/proto/agent_pb2.py', ':raw-latex:', '')
+
+s.shell.run(["nox", "-s", "blacken"], hide_output=False)
\ No newline at end of file