diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..939e5341 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows [Google's Open Source Community +Guidelines](https://opensource.google.com/conduct/). diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..ced4aa04 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,44 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +Thanks for stopping by to let us know something could be better! + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. + +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/python-asset/issues + - Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-python + - Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+python + +If you are still having issues, please be sure to include as much information as possible: + +#### Environment details + + - OS type and version: + - Python version: `python --version` + - pip version: `pip --version` + - `google-cloud-asset` version: `pip show google-cloud-asset` + +#### Steps to reproduce + + 1. ? + 2. ? + +#### Code example + +```python +# example +``` + +#### Stack trace +``` +# example +``` + +Making sure to follow these steps will guarantee the quickest resolution possible. + +Thanks! diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..6365857f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature request +about: Suggest an idea for this library + +--- + +Thanks for stopping by to let us know something could be better! + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. + + **Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + **Describe the solution you'd like** +A clear and concise description of what you want to happen. + **Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + **Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/support_request.md b/.github/ISSUE_TEMPLATE/support_request.md new file mode 100644 index 00000000..99586903 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support_request.md @@ -0,0 +1,7 @@ +--- +name: Support request +about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. + +--- + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..ef9e7889 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: +- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-asset/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea +- [ ] Ensure the tests and linter pass +- [ ] Code coverage does not decrease (if any source code was changed) +- [ ] Appropriate docs were updated (if necessary) + +Fixes # 🦕 diff --git a/.github/release-please.yml b/.github/release-please.yml new file mode 100644 index 00000000..4507ad05 --- /dev/null +++ b/.github/release-please.yml @@ -0,0 +1 @@ +releaseType: python diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3fb06e09 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +*.py[cod] +*.sw[op] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +__pycache__ + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.nox +.cache +.pytest_cache + + +# Mac +.DS_Store + +# JetBrains +.idea + +# VS Code +.vscode + +# emacs +*~ + +# Built documentation +docs/_build +bigquery/docs/generated + +# Virtual environment +env/ +coverage.xml + +# System test environment variables. +system_tests/local_test_setup + +# Make sure a generated file isn't accidentally committed. +pylintrc +pylintrc.test \ No newline at end of file diff --git a/.kokoro/build.sh b/.kokoro/build.sh new file mode 100755 index 00000000..3c1b94a8 --- /dev/null +++ b/.kokoro/build.sh @@ -0,0 +1,39 @@ +#!/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/python-asset + +# 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/.kokoro/continuous/common.cfg b/.kokoro/continuous/common.cfg new file mode 100644 index 00000000..ff92dd85 --- /dev/null +++ b/.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: "python-asset/.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/python-asset/.kokoro/build.sh" +} diff --git a/.kokoro/continuous/continuous.cfg b/.kokoro/continuous/continuous.cfg new file mode 100644 index 00000000..8f43917d --- /dev/null +++ b/.kokoro/continuous/continuous.cfg @@ -0,0 +1 @@ +# Format: //devtools/kokoro/config/proto/build.proto \ No newline at end of file diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg new file mode 100644 index 00000000..24af5cf6 --- /dev/null +++ b/.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: "python-asset/.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/python-asset/.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/.kokoro/docs/docs.cfg b/.kokoro/docs/docs.cfg new file mode 100644 index 00000000..8f43917d --- /dev/null +++ b/.kokoro/docs/docs.cfg @@ -0,0 +1 @@ +# Format: //devtools/kokoro/config/proto/build.proto \ No newline at end of file diff --git a/.kokoro/presubmit/common.cfg b/.kokoro/presubmit/common.cfg new file mode 100644 index 00000000..ff92dd85 --- /dev/null +++ b/.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: "python-asset/.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/python-asset/.kokoro/build.sh" +} diff --git a/.kokoro/presubmit/presubmit.cfg b/.kokoro/presubmit/presubmit.cfg new file mode 100644 index 00000000..8f43917d --- /dev/null +++ b/.kokoro/presubmit/presubmit.cfg @@ -0,0 +1 @@ +# Format: //devtools/kokoro/config/proto/build.proto \ No newline at end of file diff --git a/.kokoro/publish-docs.sh b/.kokoro/publish-docs.sh new file mode 100755 index 00000000..8decfe59 --- /dev/null +++ b/.kokoro/publish-docs.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Copyright 2020 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. + +#!/bin/bash + +set -eo pipefail + +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + +cd github/python-asset + +# 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/.kokoro/release.sh b/.kokoro/release.sh new file mode 100755 index 00000000..b8a150a2 --- /dev/null +++ b/.kokoro/release.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2020 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. + +#!/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/python-asset +python3 setup.py sdist bdist_wheel +twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg new file mode 100644 index 00000000..b17c77f6 --- /dev/null +++ b/.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: "python-asset/.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/python-asset/.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/.kokoro/release/release.cfg b/.kokoro/release/release.cfg new file mode 100644 index 00000000..8f43917d --- /dev/null +++ b/.kokoro/release/release.cfg @@ -0,0 +1 @@ +# Format: //devtools/kokoro/config/proto/build.proto \ No newline at end of file diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh new file mode 100755 index 00000000..e8c4251f --- /dev/null +++ b/.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/.repo-metadata.json b/.repo-metadata.json index 36b7812f..6b63eb88 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -4,9 +4,9 @@ "product_documentation": "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview", "client_documentation": "https://googleapis.dev/python/cloudasset/latest", "issue_tracker": "https://issuetracker.google.com/savedsearches/559757", - "release_level": "beta", + "release_level": "ga", "language": "python", - "repo": "googleapis/google-cloud-python", + "repo": "googleapis/python-asset", "distribution_name": "google-cloud-asset", "api_id": "cloudasset.googleapis.com", "requires_billing": true diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b31835a..47f13989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://pypi.org/project/google-cloud-asset/#history +## [0.8.0](https://www.github.com/googleapis/python-asset/compare/v0.7.0...v0.8.0) (2020-03-07) + + +### Features + +* remove search resources and search iam policies support in v1p1beta1; remove export assets and batch get assets history from v1p2beta1 (via synth) ([#12](https://www.github.com/googleapis/python-asset/issues/12)) ([15b60a3](https://www.github.com/googleapis/python-asset/commit/15b60a349c93c928fe121dc47d44d812a0c14439)) + + +### Bug Fixes + +* **asset:** correct asset synthfile ([#10355](https://www.github.com/googleapis/python-asset/issues/10355)) ([32d9374](https://www.github.com/googleapis/python-asset/commit/32d937433109b55c8f6632d402859a38520ee153)) + ## 0.7.0 01-29-2020 10:53 PST diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..b3d1f602 --- /dev/null +++ b/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/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 00000000..9dc28398 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,279 @@ +.. Generated by synthtool. DO NOT EDIT! +############ +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 + ``python-asset`` `repo`_ on GitHub. + +- Fork and clone the ``python-asset`` repository to your GitHub account by + clicking the "Fork" button. + +- Clone your fork of ``python-asset`` from your GitHub account to your local + computer, substituting your account username and specifying the destination + as ``hack-on-python-asset``. E.g.:: + + $ cd ${HOME} + $ git clone git@github.com:USERNAME/python-asset.git hack-on-python-asset + $ cd hack-on-python-asset + # Configure remotes such that you can pull changes from the googleapis/python-asset + # repository into your local repository. + $ git remote add upstream git@github.com:googleapis/python-asset.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/python-asset + +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 ``python-asset``. 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"). + +******************** +Running System Tests +******************** + +- To run system tests, you can execute:: + + $ nox -s system-3.7 + $ nox -s system-2.7 + + .. note:: + + System tests are only configured to run under Python 2.7 and + Python 3.7. For expediency, we do not run them in older versions + of Python 3. + + This alone will not run the tests. You'll need to change some local + auth settings and change some configuration in your project to + run all the tests. + +- System tests will be run against an actual project and + so you'll need to provide some environment variables to facilitate + authentication to your project: + + - ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file; + Such a file can be downloaded directly from the developer's console by clicking + "Generate new JSON key". See private key + `docs `__ + for more details. + +- Once you have downloaded your json keys, set the environment variable + ``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file:: + + $ export GOOGLE_APPLICATION_CREDENTIALS="/Users//path/to/app_credentials.json" + + +************* +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/python-asset/blob/master/CONTRIBUTING.rst``) +may cause problems creating links or rendering the description. + +.. _description on PyPI: https://pypi.org/project/google-cloud-asset + + +************************* +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/python-asset/blob/master/noxfile.py + +We explicitly decided not to support `Python 2.5`_ due to `decreased usage`_ +and lack of continuous integration `support`_. + +.. _Python 2.5: https://docs.python.org/2.5/ +.. _decreased usage: https://caremad.io/2013/10/a-look-at-pypi-downloads/ +.. _support: https://blog.travis-ci.com/2013-11-18-upcoming-build-environment-updates/ + +We have `dropped 2.6`_ as a supported version as well since Python 2.6 is no +longer supported by the core development team. + +Python 2.7 support is deprecated. All code changes should maintain Python 2.7 compatibility until January 1, 2020. + +We also explicitly decided to support Python 3 beginning with version +3.5. Reasons for this include: + +- Encouraging use of newest versions of Python 3 +- Taking the lead of `prominent`_ open-source `projects`_ +- `Unicode literal support`_ which allows for a cleaner codebase that + works in both Python 2 and Python 3 + +.. _prominent: https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django +.. _projects: http://flask.pocoo.org/docs/0.10/python3/ +.. _Unicode literal support: https://www.python.org/dev/peps/pep-0414/ +.. _dropped 2.6: https://github.com/googleapis/google-cloud-python/issues/995 + +********** +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/MANIFEST.in b/MANIFEST.in index 9cbf175a..cd011be2 100644 --- a/MANIFEST.in +++ b/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/README.rst b/README.rst index 8ef2943e..89dab942 100644 --- a/README.rst +++ b/README.rst @@ -1,15 +1,15 @@ Python Client for Cloud Asset API ================================= -|beta| |pypi| |versions| +|ga| |pypi| |versions| `Cloud Asset API`_: The cloud asset API manages the history and inventory of cloud resources. - `Client Library Documentation`_ - `Product Documentation`_ -.. |beta| image:: https://img.shields.io/badge/support-beta-orange.svg - :target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#beta-support +.. |ga| image:: https://img.shields.io/badge/support-GA-gold.svg + :target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#general-availability .. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-asset.svg :target: https://pypi.org/project/google-cloud-asset/ .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-asset.svg diff --git a/docs/conf.py b/docs/conf.py index 08733912..3b11ec80 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,7 +20,7 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath("..")) -__version__ = "0.1.0" +__version__ = "" # -- General configuration ------------------------------------------------ @@ -45,6 +45,7 @@ autodoc_default_flags = ["members"] autosummary_generate = True + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -65,7 +66,7 @@ # General information about the project. project = u"google-cloud-asset" -copyright = u"2017, Google" +copyright = u"2019, Google" author = u"Google APIs" # The version info for the project you're documenting, acts as replacement for @@ -121,6 +122,7 @@ # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True + # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -131,9 +133,9 @@ # further. For a list of options available for each theme, see the # documentation. html_theme_options = { - "description": "Google Cloud Client Libraries for Python", + "description": "Google Cloud Client Libraries for google-cloud-asset", "github_user": "googleapis", - "github_repo": "google-cloud-python", + "github_repo": "python-asset", "github_banner": True, "font_family": "'Roboto', Georgia, sans", "head_font_family": "'Roboto', Georgia, serif", @@ -229,6 +231,7 @@ # -- 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 @@ -284,6 +287,7 @@ # If false, no module index is generated. # latex_domain_indices = True + # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples @@ -295,6 +299,7 @@ # If true, show URL addresses after external links. # man_show_urls = False + # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples @@ -307,7 +312,7 @@ u"google-cloud-asset Documentation", author, "google-cloud-asset", - "GAPIC library for the {metadata.shortName} v1 service", + "google-cloud-asset Library", "APIs", ) ] @@ -324,19 +329,16 @@ # If true, do not generate a @detailmenu in the "Top" node's menu. # 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), "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), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("https://requests.kennethreitz.org/en/stable/", None), - "fastavro": ("https://fastavro.readthedocs.io/en/stable/", None), - "pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None), } + # Napoleon settings napoleon_google_docstring = True napoleon_numpy_docstring = True diff --git a/google/__init__.py b/google/__init__.py index 8fcc60e2..9a1b64a6 100644 --- a/google/__init__.py +++ b/google/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/__init__.py b/google/cloud/__init__.py index 8fcc60e2..9a1b64a6 100644 --- a/google/cloud/__init__.py +++ b/google/cloud/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset.py b/google/cloud/asset.py index 24c7e7d2..c6c18919 100644 --- a/google/cloud/asset.py +++ b/google/cloud/asset.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1/__init__.py b/google/cloud/asset_v1/__init__.py index 5f6bd2a4..29404194 100644 --- a/google/cloud/asset_v1/__init__.py +++ b/google/cloud/asset_v1/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1/gapic/asset_service_client.py b/google/cloud/asset_v1/gapic/asset_service_client.py index 10bf2942..d8a70733 100644 --- a/google/cloud/asset_v1/gapic/asset_service_client.py +++ b/google/cloud/asset_v1/gapic/asset_service_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1/gapic/enums.py b/google/cloud/asset_v1/gapic/enums.py index 38eb45ae..6c394aab 100644 --- a/google/cloud/asset_v1/gapic/enums.py +++ b/google/cloud/asset_v1/gapic/enums.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1/gapic/transports/asset_service_grpc_transport.py b/google/cloud/asset_v1/gapic/transports/asset_service_grpc_transport.py index 55750559..47301928 100644 --- a/google/cloud/asset_v1/gapic/transports/asset_service_grpc_transport.py +++ b/google/cloud/asset_v1/gapic/transports/asset_service_grpc_transport.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1/proto/asset_service_pb2.py b/google/cloud/asset_v1/proto/asset_service_pb2.py index 075cda63..8c6edb2a 100644 --- a/google/cloud/asset_v1/proto/asset_service_pb2.py +++ b/google/cloud/asset_v1/proto/asset_service_pb2.py @@ -1568,10 +1568,10 @@ dict( DESCRIPTOR=_FEED, __module__="google.cloud.asset_v1.proto.asset_service_pb2", - __doc__="""An asset feed used to export asset updates to a destinations. An asset - feed filter controls what updates are exported. The asset feed must be - created within a project, organization, or folder. Supported - destinations are: Cloud Pub/Sub topics. + __doc__="""An asset feed used to export asset updates to a + destinations. An asset feed filter controls what updates are exported. + The asset feed must be created within a project, organization, or + folder. Supported destinations are: Cloud Pub/Sub topics. Attributes: diff --git a/google/cloud/asset_v1/proto/assets_pb2.py b/google/cloud/asset_v1/proto/assets_pb2.py index 60f1340f..b3f9b943 100644 --- a/google/cloud/asset_v1/proto/assets_pb2.py +++ b/google/cloud/asset_v1/proto/assets_pb2.py @@ -444,8 +444,8 @@ dict( DESCRIPTOR=_TEMPORALASSET, __module__="google.cloud.asset_v1.proto.assets_pb2", - __doc__="""Temporal asset. In addition to the asset, the temporal asset includes - the status of the asset and valid from and to time of it. + __doc__="""Temporal asset. In addition to the asset, the temporal + asset includes the status of the asset and valid from and to time of it. Attributes: @@ -488,8 +488,8 @@ dict( DESCRIPTOR=_ASSET, __module__="google.cloud.asset_v1.proto.assets_pb2", - __doc__="""Cloud asset. This includes all Google Cloud Platform resources, Cloud - IAM policies, and other non-GCP assets. + __doc__="""Cloud asset. This includes all Google Cloud Platform + resources, Cloud IAM policies, and other non-GCP assets. Attributes: diff --git a/google/cloud/asset_v1/types.py b/google/cloud/asset_v1/types.py index 0689ba28..3e71c914 100644 --- a/google/cloud/asset_v1/types.py +++ b/google/cloud/asset_v1/types.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1beta1/__init__.py b/google/cloud/asset_v1beta1/__init__.py index 26b617ac..f1056686 100644 --- a/google/cloud/asset_v1beta1/__init__.py +++ b/google/cloud/asset_v1beta1/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1beta1/gapic/asset_service_client.py b/google/cloud/asset_v1beta1/gapic/asset_service_client.py index 32b796af..3a615892 100644 --- a/google/cloud/asset_v1beta1/gapic/asset_service_client.py +++ b/google/cloud/asset_v1beta1/gapic/asset_service_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -332,7 +332,8 @@ def batch_get_assets_history( RESOURCE content, this API outputs history with asset in both non-delete or deleted status. For IAM\_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create - gaps in the output history. + gaps in the output history. If a specified asset does not exist, this + API returns an INVALID\_ARGUMENT error. Example: >>> from google.cloud import asset_v1beta1 @@ -354,7 +355,7 @@ def batch_get_assets_history( parent (str): Required. The relative name of the root asset. It can only be an organization number (such as "organizations/123"), a project ID (such as "projects/my-project-id")", or a project number (such as "projects/12345"). - content_type (~google.cloud.asset_v1beta1.types.ContentType): Required. The content type. + content_type (~google.cloud.asset_v1beta1.types.ContentType): Optional. The content type. read_time_window (Union[dict, ~google.cloud.asset_v1beta1.types.TimeWindow]): Optional. The time window for the asset history. Both start\_time and end\_time are optional and if set, it must be after 2018-10-02 UTC. If end\_time is not set, it is default to current timestamp. If start\_time diff --git a/google/cloud/asset_v1beta1/gapic/enums.py b/google/cloud/asset_v1beta1/gapic/enums.py index 780beae4..aa17ba4b 100644 --- a/google/cloud/asset_v1beta1/gapic/enums.py +++ b/google/cloud/asset_v1beta1/gapic/enums.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1beta1/gapic/transports/asset_service_grpc_transport.py b/google/cloud/asset_v1beta1/gapic/transports/asset_service_grpc_transport.py index 9e92ba56..abe776b7 100644 --- a/google/cloud/asset_v1beta1/gapic/transports/asset_service_grpc_transport.py +++ b/google/cloud/asset_v1beta1/gapic/transports/asset_service_grpc_transport.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -139,7 +139,8 @@ def batch_get_assets_history(self): RESOURCE content, this API outputs history with asset in both non-delete or deleted status. For IAM\_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create - gaps in the output history. + gaps in the output history. If a specified asset does not exist, this + API returns an INVALID\_ARGUMENT error. Returns: Callable: A callable which accepts the appropriate diff --git a/google/cloud/asset_v1beta1/proto/asset_service.proto b/google/cloud/asset_v1beta1/proto/asset_service.proto index 8e2d1b0a..956c6a76 100644 --- a/google/cloud/asset_v1beta1/proto/asset_service.proto +++ b/google/cloud/asset_v1beta1/proto/asset_service.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,6 +18,9 @@ syntax = "proto3"; package google.cloud.asset.v1beta1; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; import "google/cloud/asset/v1beta1/assets.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/timestamp.proto"; @@ -31,6 +34,10 @@ option php_namespace = "Google\\Cloud\\Asset\\V1beta1"; // Asset service definition. service AssetService { + option (google.api.default_host) = "cloudasset.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + // Exports assets with time and resource types to a given Cloud Storage // location. The output format is newline-delimited JSON. // This API implements the @@ -49,6 +56,10 @@ service AssetService { body: "*" } }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.asset.v1beta1.ExportAssetsResponse" + metadata_type: "google.cloud.asset.v1beta1.ExportAssetsRequest" + }; } // Batch gets the update history of assets that overlap a time window. @@ -56,6 +67,8 @@ service AssetService { // non-delete or deleted status. // For IAM_POLICY content, this API outputs history when the asset and its // attached IAM POLICY both exist. This can create gaps in the output history. + // If a specified asset does not exist, this API returns an INVALID_ARGUMENT + // error. rpc BatchGetAssetsHistory(BatchGetAssetsHistoryRequest) returns (BatchGetAssetsHistoryResponse) { option (google.api.http) = { @@ -73,7 +86,12 @@ message ExportAssetsRequest { // organization number (such as "organizations/123"), a project ID (such as // "projects/my-project-id"), a project number (such as "projects/12345"), or // a folder number (such as "folders/123"). - string parent = 1; + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudasset.googleapis.com/Asset" + } + ]; // Timestamp to take an asset snapshot. This can only be set to a timestamp // between 2018-10-02 UTC (inclusive) and the current time. If not specified, @@ -95,7 +113,7 @@ message ExportAssetsRequest { // Required. Output configuration indicating where the results will be output // to. All results will be in newline delimited JSON format. - OutputConfig output_config = 5; + OutputConfig output_config = 5 [(google.api.field_behavior) = REQUIRED]; } // The export asset response. This message is returned by the @@ -117,7 +135,12 @@ message BatchGetAssetsHistoryRequest { // Required. The relative name of the root asset. It can only be an // organization number (such as "organizations/123"), a project ID (such as // "projects/my-project-id")", or a project number (such as "projects/12345"). - string parent = 1; + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudasset.googleapis.com/Asset" + } + ]; // A list of the full names of the assets. For example: // `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`. @@ -129,8 +152,8 @@ message BatchGetAssetsHistoryRequest { // size of the asset name list is 100 in one request. repeated string asset_names = 2; - // Required. The content type. - ContentType content_type = 3; + // Optional. The content type. + ContentType content_type = 3 [(google.api.field_behavior) = OPTIONAL]; // Optional. The time window for the asset history. Both start_time and // end_time are optional and if set, it must be after 2018-10-02 UTC. If @@ -138,7 +161,7 @@ message BatchGetAssetsHistoryRequest { // not set, the snapshot of the assets at end_time will be returned. The // returned results contain all temporal assets whose time window overlap with // read_time_window. - TimeWindow read_time_window = 4; + TimeWindow read_time_window = 4 [(google.api.field_behavior) = OPTIONAL]; } // Batch get assets history response. @@ -166,6 +189,16 @@ message GcsDestination { // Metadata](https://cloud.google.com/storage/docs/viewing-editing-metadata) // for more information. string uri = 1; + + // The uri prefix of all generated Cloud Storage objects. For example: + // "gs://bucket_name/object_name_prefix". Each object uri is in format: + // "gs://bucket_name/object_name_prefix// and only + // contains assets for that type. starts from 0. For example: + // "gs://bucket_name/object_name_prefix/google.compute.disk/0" is the first + // shard of output objects containing all google.compute.disk assets. + // An INVALID_ARGUMENT error will be returned if file with the same name + // "gs://bucket_name/object_name_prefix" already exists. + string uri_prefix = 2; } } diff --git a/google/cloud/asset_v1beta1/proto/asset_service_pb2.py b/google/cloud/asset_v1beta1/proto/asset_service_pb2.py index bd97c5aa..2d3b457a 100644 --- a/google/cloud/asset_v1beta1/proto/asset_service_pb2.py +++ b/google/cloud/asset_v1beta1/proto/asset_service_pb2.py @@ -17,6 +17,9 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 from google.cloud.asset_v1beta1.proto import ( assets_pb2 as google_dot_cloud_dot_asset__v1beta1_dot_proto_dot_assets__pb2, ) @@ -34,10 +37,13 @@ "\n\036com.google.cloud.asset.v1beta1B\021AssetServiceProtoP\001Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\252\002\032Google.Cloud.Asset.V1Beta1\312\002\032Google\\Cloud\\Asset\\V1beta1" ), serialized_pb=_b( - '\n4google/cloud/asset_v1beta1/proto/asset_service.proto\x12\x1agoogle.cloud.asset.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a-google/cloud/asset_v1beta1/proto/assets.proto\x1a#google/longrunning/operations.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xe9\x01\n\x13\x45xportAssetsRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12-\n\tread_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x13\n\x0b\x61sset_types\x18\x03 \x03(\t\x12=\n\x0c\x63ontent_type\x18\x04 \x01(\x0e\x32\'.google.cloud.asset.v1beta1.ContentType\x12?\n\routput_config\x18\x05 \x01(\x0b\x32(.google.cloud.asset.v1beta1.OutputConfig"\x86\x01\n\x14\x45xportAssetsResponse\x12-\n\tread_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12?\n\routput_config\x18\x02 \x01(\x0b\x32(.google.cloud.asset.v1beta1.OutputConfig"\xc4\x01\n\x1c\x42\x61tchGetAssetsHistoryRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x13\n\x0b\x61sset_names\x18\x02 \x03(\t\x12=\n\x0c\x63ontent_type\x18\x03 \x01(\x0e\x32\'.google.cloud.asset.v1beta1.ContentType\x12@\n\x10read_time_window\x18\x04 \x01(\x0b\x32&.google.cloud.asset.v1beta1.TimeWindow"Z\n\x1d\x42\x61tchGetAssetsHistoryResponse\x12\x39\n\x06\x61ssets\x18\x01 \x03(\x0b\x32).google.cloud.asset.v1beta1.TemporalAsset"d\n\x0cOutputConfig\x12\x45\n\x0fgcs_destination\x18\x01 \x01(\x0b\x32*.google.cloud.asset.v1beta1.GcsDestinationH\x00\x42\r\n\x0b\x64\x65stination"-\n\x0eGcsDestination\x12\r\n\x03uri\x18\x01 \x01(\tH\x00\x42\x0c\n\nobject_uri*I\n\x0b\x43ontentType\x12\x1c\n\x18\x43ONTENT_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08RESOURCE\x10\x01\x12\x0e\n\nIAM_POLICY\x10\x02\x32\x91\x04\n\x0c\x41ssetService\x12\xfa\x01\n\x0c\x45xportAssets\x12/.google.cloud.asset.v1beta1.ExportAssetsRequest\x1a\x1d.google.longrunning.Operation"\x99\x01\x82\xd3\xe4\x93\x02\x92\x01")/v1beta1/{parent=projects/*}:exportAssets:\x01*Z-"(/v1beta1/{parent=folders/*}:exportAssets:\x01*Z3"./v1beta1/{parent=organizations/*}:exportAssets:\x01*\x12\x83\x02\n\x15\x42\x61tchGetAssetsHistory\x12\x38.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest\x1a\x39.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse"u\x82\xd3\xe4\x93\x02o\x12\x32/v1beta1/{parent=projects/*}:batchGetAssetsHistoryZ9\x12\x37/v1beta1/{parent=organizations/*}:batchGetAssetsHistoryB\xb0\x01\n\x1e\x63om.google.cloud.asset.v1beta1B\x11\x41ssetServiceProtoP\x01Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\xaa\x02\x1aGoogle.Cloud.Asset.V1Beta1\xca\x02\x1aGoogle\\Cloud\\Asset\\V1beta1b\x06proto3' + '\n4google/cloud/asset_v1beta1/proto/asset_service.proto\x12\x1agoogle.cloud.asset.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a-google/cloud/asset_v1beta1/proto/assets.proto\x1a#google/longrunning/operations.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x97\x02\n\x13\x45xportAssetsRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\x12\x1f\x63loudasset.googleapis.com/Asset\x12-\n\tread_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x13\n\x0b\x61sset_types\x18\x03 \x03(\t\x12=\n\x0c\x63ontent_type\x18\x04 \x01(\x0e\x32\'.google.cloud.asset.v1beta1.ContentType\x12\x44\n\routput_config\x18\x05 \x01(\x0b\x32(.google.cloud.asset.v1beta1.OutputConfigB\x03\xe0\x41\x02"\x86\x01\n\x14\x45xportAssetsResponse\x12-\n\tread_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12?\n\routput_config\x18\x02 \x01(\x0b\x32(.google.cloud.asset.v1beta1.OutputConfig"\xf7\x01\n\x1c\x42\x61tchGetAssetsHistoryRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\x12\x1f\x63loudasset.googleapis.com/Asset\x12\x13\n\x0b\x61sset_names\x18\x02 \x03(\t\x12\x42\n\x0c\x63ontent_type\x18\x03 \x01(\x0e\x32\'.google.cloud.asset.v1beta1.ContentTypeB\x03\xe0\x41\x01\x12\x45\n\x10read_time_window\x18\x04 \x01(\x0b\x32&.google.cloud.asset.v1beta1.TimeWindowB\x03\xe0\x41\x01"Z\n\x1d\x42\x61tchGetAssetsHistoryResponse\x12\x39\n\x06\x61ssets\x18\x01 \x03(\x0b\x32).google.cloud.asset.v1beta1.TemporalAsset"d\n\x0cOutputConfig\x12\x45\n\x0fgcs_destination\x18\x01 \x01(\x0b\x32*.google.cloud.asset.v1beta1.GcsDestinationH\x00\x42\r\n\x0b\x64\x65stination"C\n\x0eGcsDestination\x12\r\n\x03uri\x18\x01 \x01(\tH\x00\x12\x14\n\nuri_prefix\x18\x02 \x01(\tH\x00\x42\x0c\n\nobject_uri*I\n\x0b\x43ontentType\x12\x1c\n\x18\x43ONTENT_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08RESOURCE\x10\x01\x12\x0e\n\nIAM_POLICY\x10\x02\x32\xc4\x05\n\x0c\x41ssetService\x12\xde\x02\n\x0c\x45xportAssets\x12/.google.cloud.asset.v1beta1.ExportAssetsRequest\x1a\x1d.google.longrunning.Operation"\xfd\x01\x82\xd3\xe4\x93\x02\x92\x01")/v1beta1/{parent=projects/*}:exportAssets:\x01*Z-"(/v1beta1/{parent=folders/*}:exportAssets:\x01*Z3"./v1beta1/{parent=organizations/*}:exportAssets:\x01*\xca\x41\x61\n/google.cloud.asset.v1beta1.ExportAssetsResponse\x12.google.cloud.asset.v1beta1.ExportAssetsRequest\x12\x83\x02\n\x15\x42\x61tchGetAssetsHistory\x12\x38.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest\x1a\x39.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse"u\x82\xd3\xe4\x93\x02o\x12\x32/v1beta1/{parent=projects/*}:batchGetAssetsHistoryZ9\x12\x37/v1beta1/{parent=organizations/*}:batchGetAssetsHistory\x1aM\xca\x41\x19\x63loudasset.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb0\x01\n\x1e\x63om.google.cloud.asset.v1beta1B\x11\x41ssetServiceProtoP\x01Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\xaa\x02\x1aGoogle.Cloud.Asset.V1Beta1\xca\x02\x1aGoogle\\Cloud\\Asset\\V1beta1b\x06proto3' ), dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_client__pb2.DESCRIPTOR, + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, google_dot_cloud_dot_asset__v1beta1_dot_proto_dot_assets__pb2.DESCRIPTOR, google_dot_longrunning_dot_operations__pb2.DESCRIPTOR, google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, @@ -66,8 +72,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=1044, - serialized_end=1117, + serialized_start=1248, + serialized_end=1321, ) _sym_db.RegisterEnumDescriptor(_CONTENTTYPE) @@ -99,7 +105,9 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b( + "\340A\002\372A!\022\037cloudasset.googleapis.com/Asset" + ), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -171,7 +179,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], @@ -183,8 +191,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=232, - serialized_end=465, + serialized_start=317, + serialized_end=596, ) @@ -240,8 +248,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=468, - serialized_end=602, + serialized_start=599, + serialized_end=733, ) @@ -267,7 +275,9 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b( + "\340A\002\372A!\022\037cloudasset.googleapis.com/Asset" + ), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -303,7 +313,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -321,7 +331,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), ], @@ -333,8 +343,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=605, - serialized_end=801, + serialized_start=736, + serialized_end=983, ) @@ -372,8 +382,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=803, - serialized_end=893, + serialized_start=985, + serialized_end=1075, ) @@ -419,8 +429,8 @@ fields=[], ) ], - serialized_start=895, - serialized_end=995, + serialized_start=1077, + serialized_end=1177, ) @@ -448,7 +458,25 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, - ) + ), + _descriptor.FieldDescriptor( + name="uri_prefix", + full_name="google.cloud.asset.v1beta1.GcsDestination.uri_prefix", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), ], extensions=[], nested_types=[], @@ -466,8 +494,8 @@ fields=[], ) ], - serialized_start=997, - serialized_end=1042, + serialized_start=1179, + serialized_end=1246, ) _EXPORTASSETSREQUEST.fields_by_name[ @@ -503,6 +531,12 @@ _GCSDESTINATION.fields_by_name["uri"].containing_oneof = _GCSDESTINATION.oneofs_by_name[ "object_uri" ] +_GCSDESTINATION.oneofs_by_name["object_uri"].fields.append( + _GCSDESTINATION.fields_by_name["uri_prefix"] +) +_GCSDESTINATION.fields_by_name[ + "uri_prefix" +].containing_oneof = _GCSDESTINATION.oneofs_by_name["object_uri"] DESCRIPTOR.message_types_by_name["ExportAssetsRequest"] = _EXPORTASSETSREQUEST DESCRIPTOR.message_types_by_name["ExportAssetsResponse"] = _EXPORTASSETSRESPONSE DESCRIPTOR.message_types_by_name[ @@ -608,7 +642,7 @@ empty, and the max size of the asset name list is 100 in one request. content_type: - Required. The content type. + Optional. The content type. read_time_window: Optional. The time window for the asset history. Both start\_time and end\_time are optional and if set, it must be @@ -679,6 +713,17 @@ See `Viewing and Editing Object Metadata `__ for more information. + uri_prefix: + The uri prefix of all generated Cloud Storage objects. For + example: "gs://bucket\_name/object\_name\_prefix". Each object + uri is in format: "gs://bucket\_name/object\_name\_prefix// + and only contains assets for that type. starts from 0. For + example: + "gs://bucket\_name/object\_name\_prefix/google.compute.disk/0" + is the first shard of output objects containing all + google.compute.disk assets. An INVALID\_ARGUMENT error will be + returned if file with the same name + "gs://bucket\_name/object\_name\_prefix" already exists. """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1beta1.GcsDestination) ), @@ -687,15 +732,22 @@ DESCRIPTOR._options = None +_EXPORTASSETSREQUEST.fields_by_name["parent"]._options = None +_EXPORTASSETSREQUEST.fields_by_name["output_config"]._options = None +_BATCHGETASSETSHISTORYREQUEST.fields_by_name["parent"]._options = None +_BATCHGETASSETSHISTORYREQUEST.fields_by_name["content_type"]._options = None +_BATCHGETASSETSHISTORYREQUEST.fields_by_name["read_time_window"]._options = None _ASSETSERVICE = _descriptor.ServiceDescriptor( name="AssetService", full_name="google.cloud.asset.v1beta1.AssetService", file=DESCRIPTOR, index=0, - serialized_options=None, - serialized_start=1120, - serialized_end=1649, + serialized_options=_b( + "\312A\031cloudasset.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" + ), + serialized_start=1324, + serialized_end=2032, methods=[ _descriptor.MethodDescriptor( name="ExportAssets", @@ -705,7 +757,7 @@ input_type=_EXPORTASSETSREQUEST, output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, serialized_options=_b( - '\202\323\344\223\002\222\001")/v1beta1/{parent=projects/*}:exportAssets:\001*Z-"(/v1beta1/{parent=folders/*}:exportAssets:\001*Z3"./v1beta1/{parent=organizations/*}:exportAssets:\001*' + '\202\323\344\223\002\222\001")/v1beta1/{parent=projects/*}:exportAssets:\001*Z-"(/v1beta1/{parent=folders/*}:exportAssets:\001*Z3"./v1beta1/{parent=organizations/*}:exportAssets:\001*\312Aa\n/google.cloud.asset.v1beta1.ExportAssetsResponse\022.google.cloud.asset.v1beta1.ExportAssetsRequest' ), ), _descriptor.MethodDescriptor( diff --git a/google/cloud/asset_v1beta1/proto/asset_service_pb2_grpc.py b/google/cloud/asset_v1beta1/proto/asset_service_pb2_grpc.py index 35e7c536..24a26e0c 100644 --- a/google/cloud/asset_v1beta1/proto/asset_service_pb2_grpc.py +++ b/google/cloud/asset_v1beta1/proto/asset_service_pb2_grpc.py @@ -52,6 +52,8 @@ def BatchGetAssetsHistory(self, request, context): non-delete or deleted status. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create gaps in the output history. + If a specified asset does not exist, this API returns an INVALID_ARGUMENT + error. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details("Method not implemented!") diff --git a/google/cloud/asset_v1beta1/proto/assets.proto b/google/cloud/asset_v1beta1/proto/assets.proto index 84db977b..4bb1438c 100644 --- a/google/cloud/asset_v1beta1/proto/assets.proto +++ b/google/cloud/asset_v1beta1/proto/assets.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,11 +18,13 @@ syntax = "proto3"; package google.cloud.asset.v1beta1; import "google/api/annotations.proto"; +import "google/api/resource.proto"; import "google/iam/v1/policy.proto"; import "google/protobuf/any.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; +option cc_enable_arenas = true; option csharp_namespace = "Google.Cloud.Asset.V1Beta1"; option go_package = "google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset"; option java_multiple_files = true; @@ -56,6 +58,11 @@ message TimeWindow { // Cloud asset. This includes all Google Cloud Platform resources, // Cloud IAM policies, and other non-GCP assets. message Asset { + option (google.api.resource) = { + type: "cloudasset.googleapis.com/Asset" + pattern: "*" + }; + // The full name of the asset. For example: // `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`. // See [Resource diff --git a/google/cloud/asset_v1beta1/proto/assets_pb2.py b/google/cloud/asset_v1beta1/proto/assets_pb2.py index 6a04ad0a..ad741851 100644 --- a/google/cloud/asset_v1beta1/proto/assets_pb2.py +++ b/google/cloud/asset_v1beta1/proto/assets_pb2.py @@ -16,6 +16,7 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 @@ -27,13 +28,14 @@ package="google.cloud.asset.v1beta1", syntax="proto3", serialized_options=_b( - "\n\036com.google.cloud.asset.v1beta1B\nAssetProtoP\001Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\252\002\032Google.Cloud.Asset.V1Beta1\312\002\032Google\\Cloud\\Asset\\V1beta1" + "\n\036com.google.cloud.asset.v1beta1B\nAssetProtoP\001Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\370\001\001\252\002\032Google.Cloud.Asset.V1Beta1\312\002\032Google\\Cloud\\Asset\\V1beta1" ), serialized_pb=_b( - '\n-google/cloud/asset_v1beta1/proto/assets.proto\x12\x1agoogle.cloud.asset.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x8a\x01\n\rTemporalAsset\x12\x36\n\x06window\x18\x01 \x01(\x0b\x32&.google.cloud.asset.v1beta1.TimeWindow\x12\x0f\n\x07\x64\x65leted\x18\x02 \x01(\x08\x12\x30\n\x05\x61sset\x18\x03 \x01(\x0b\x32!.google.cloud.asset.v1beta1.Asset"j\n\nTimeWindow\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8c\x01\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x36\n\x08resource\x18\x03 \x01(\x0b\x32$.google.cloud.asset.v1beta1.Resource\x12)\n\niam_policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.Policy"\xa0\x01\n\x08Resource\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x1e\n\x16\x64iscovery_document_uri\x18\x02 \x01(\t\x12\x16\n\x0e\x64iscovery_name\x18\x03 \x01(\t\x12\x14\n\x0cresource_url\x18\x04 \x01(\t\x12\x0e\n\x06parent\x18\x05 \x01(\t\x12%\n\x04\x64\x61ta\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructB\xa9\x01\n\x1e\x63om.google.cloud.asset.v1beta1B\nAssetProtoP\x01Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\xaa\x02\x1aGoogle.Cloud.Asset.V1Beta1\xca\x02\x1aGoogle\\Cloud\\Asset\\V1beta1b\x06proto3' + '\n-google/cloud/asset_v1beta1/proto/assets.proto\x12\x1agoogle.cloud.asset.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/api/resource.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x8a\x01\n\rTemporalAsset\x12\x36\n\x06window\x18\x01 \x01(\x0b\x32&.google.cloud.asset.v1beta1.TimeWindow\x12\x0f\n\x07\x64\x65leted\x18\x02 \x01(\x08\x12\x30\n\x05\x61sset\x18\x03 \x01(\x0b\x32!.google.cloud.asset.v1beta1.Asset"j\n\nTimeWindow\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\xb5\x01\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x36\n\x08resource\x18\x03 \x01(\x0b\x32$.google.cloud.asset.v1beta1.Resource\x12)\n\niam_policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.Policy:\'\xea\x41$\n\x1f\x63loudasset.googleapis.com/Asset\x12\x01*"\xa0\x01\n\x08Resource\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x1e\n\x16\x64iscovery_document_uri\x18\x02 \x01(\t\x12\x16\n\x0e\x64iscovery_name\x18\x03 \x01(\t\x12\x14\n\x0cresource_url\x18\x04 \x01(\t\x12\x0e\n\x06parent\x18\x05 \x01(\t\x12%\n\x04\x64\x61ta\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructB\xac\x01\n\x1e\x63om.google.cloud.asset.v1beta1B\nAssetProtoP\x01Z?google.golang.org/genproto/googleapis/cloud/asset/v1beta1;asset\xf8\x01\x01\xaa\x02\x1aGoogle.Cloud.Asset.V1Beta1\xca\x02\x1aGoogle\\Cloud\\Asset\\V1beta1b\x06proto3' ), dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR, google_dot_protobuf_dot_any__pb2.DESCRIPTOR, google_dot_protobuf_dot_struct__pb2.DESCRIPTOR, @@ -112,8 +114,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=226, - serialized_end=364, + serialized_start=253, + serialized_end=391, ) @@ -169,8 +171,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=366, - serialized_end=472, + serialized_start=393, + serialized_end=499, ) @@ -257,13 +259,13 @@ extensions=[], nested_types=[], enum_types=[], - serialized_options=None, + serialized_options=_b("\352A$\n\037cloudasset.googleapis.com/Asset\022\001*"), is_extendable=False, syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=475, - serialized_end=615, + serialized_start=502, + serialized_end=683, ) @@ -391,8 +393,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=618, - serialized_end=778, + serialized_start=686, + serialized_end=846, ) _TEMPORALASSET.fields_by_name["window"].message_type = _TIMEWINDOW @@ -468,8 +470,8 @@ dict( DESCRIPTOR=_ASSET, __module__="google.cloud.asset_v1beta1.proto.assets_pb2", - __doc__="""Cloud asset. This includes all Google Cloud Platform resources, Cloud - IAM policies, and other non-GCP assets. + __doc__="""Cloud asset. This includes all Google Cloud Platform + resources, Cloud IAM policies, and other non-GCP assets. Attributes: @@ -541,4 +543,5 @@ DESCRIPTOR._options = None +_ASSET._options = None # @@protoc_insertion_point(module_scope) diff --git a/google/cloud/asset_v1beta1/types.py b/google/cloud/asset_v1beta1/types.py index cf051722..e1f5fb7d 100644 --- a/google/cloud/asset_v1beta1/types.py +++ b/google/cloud/asset_v1beta1/types.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1p1beta1/__init__.py b/google/cloud/asset_v1p1beta1/__init__.py index d8cba9f9..9c5b3b33 100644 --- a/google/cloud/asset_v1p1beta1/__init__.py +++ b/google/cloud/asset_v1p1beta1/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,11 +16,22 @@ from __future__ import absolute_import +import sys +import warnings from google.cloud.asset_v1p1beta1 import types from google.cloud.asset_v1p1beta1.gapic import asset_service_client +if sys.version_info[:2] == (2, 7): + message = ( + "A future version of this library will drop support for Python 2.7." + "More details about Python 2 support for Google Cloud Client Libraries" + "can be found at https://cloud.google.com/python/docs/python2-sunset/" + ) + warnings.warn(message, DeprecationWarning) + + class AssetServiceClient(asset_service_client.AssetServiceClient): __doc__ = asset_service_client.AssetServiceClient.__doc__ diff --git a/google/cloud/asset_v1p1beta1/gapic/asset_service_client.py b/google/cloud/asset_v1p1beta1/gapic/asset_service_client.py index cb6de100..b4bddc31 100644 --- a/google/cloud/asset_v1p1beta1/gapic/asset_service_client.py +++ b/google/cloud/asset_v1p1beta1/gapic/asset_service_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -182,208 +182,6 @@ def __init__( self._inner_api_calls = {} # Service calls - def search_resources( - self, - scope, - query=None, - asset_types=None, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Searches resources which are accessible with .get permission. - - Example: - >>> from google.cloud import asset_v1p1beta1 - >>> - >>> client = asset_v1p1beta1.AssetServiceClient() - >>> - >>> # TODO: Initialize `scope`: - >>> scope = '' - >>> - >>> # Iterate over all results - >>> for element in client.search_resources(scope): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.search_resources(scope).pages: - ... for element in page: - ... # process element - ... pass - - Args: - scope (str): Required. The relative name of an asset. The search is limited to the - resources within the ``scope``. The allowed value must be: - - - Organization number (such as "organizations/123") - - Folder number(such as "folders/1234") - - Project number (such as "projects/12345") - query (str): Optional. The query statement. - asset_types (list[str]): Optional. A list of asset types that this request searches for. If empty, it will - search all the supported asset types. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.asset_v1p1beta1.types.StandardResourceMetadata` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "search_resources" not in self._inner_api_calls: - self._inner_api_calls[ - "search_resources" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.search_resources, - default_retry=self._method_configs["SearchResources"].retry, - default_timeout=self._method_configs["SearchResources"].timeout, - client_info=self._client_info, - ) - - request = asset_service_pb2.SearchResourcesRequest( - scope=scope, query=query, asset_types=asset_types, page_size=page_size - ) - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["search_resources"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="results", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - - def search_iam_policies( - self, - scope, - query=None, - page_size=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Searches IAM policies which are accessible with .getIamPolicy permission. - - Example: - >>> from google.cloud import asset_v1p1beta1 - >>> - >>> client = asset_v1p1beta1.AssetServiceClient() - >>> - >>> # TODO: Initialize `scope`: - >>> scope = '' - >>> - >>> # Iterate over all results - >>> for element in client.search_iam_policies(scope): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: - >>> - >>> # Iterate over results one page at a time - >>> for page in client.search_iam_policies(scope).pages: - ... for element in page: - ... # process element - ... pass - - Args: - scope (str): Required. The relative name of an asset. The search is limited to the - resources within the ``scope``. The allowed value must be: - - - Organization number (such as "organizations/123") - - Folder number(such as "folders/1234") - - Project number (such as "projects/12345") - query (str): Optional. The query statement. Examples: - - - "policy:myuser@mydomain.com" - - "policy:(myuser@mydomain.com viewer)" - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.asset_v1p1beta1.types.IamPolicySearchResult` instances. - You can also iterate over the pages of the response - using its `pages` property. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "search_iam_policies" not in self._inner_api_calls: - self._inner_api_calls[ - "search_iam_policies" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.search_iam_policies, - default_retry=self._method_configs["SearchIamPolicies"].retry, - default_timeout=self._method_configs["SearchIamPolicies"].timeout, - client_info=self._client_info, - ) - - request = asset_service_pb2.SearchIamPoliciesRequest( - scope=scope, query=query, page_size=page_size - ) - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["search_iam_policies"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="results", - request_token_field="page_token", - response_token_field="next_page_token", - ) - return iterator - def search_all_resources( self, scope, diff --git a/google/cloud/asset_v1p1beta1/gapic/asset_service_client_config.py b/google/cloud/asset_v1p1beta1/gapic/asset_service_client_config.py index b675e69c..9c506cbb 100644 --- a/google/cloud/asset_v1p1beta1/gapic/asset_service_client_config.py +++ b/google/cloud/asset_v1p1beta1/gapic/asset_service_client_config.py @@ -17,23 +17,13 @@ } }, "methods": { - "SearchResources": { - "timeout_millis": 15000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, - "SearchIamPolicies": { - "timeout_millis": 15000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, "SearchAllResources": { - "timeout_millis": 15000, + "timeout_millis": 600000, "retry_codes_name": "idempotent", "retry_params_name": "default", }, "SearchAllIamPolicies": { - "timeout_millis": 15000, + "timeout_millis": 600000, "retry_codes_name": "idempotent", "retry_params_name": "default", }, diff --git a/google/cloud/asset_v1p1beta1/gapic/transports/asset_service_grpc_transport.py b/google/cloud/asset_v1p1beta1/gapic/transports/asset_service_grpc_transport.py index cb3a63cc..8b7027a8 100644 --- a/google/cloud/asset_v1p1beta1/gapic/transports/asset_service_grpc_transport.py +++ b/google/cloud/asset_v1p1beta1/gapic/transports/asset_service_grpc_transport.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -107,32 +107,6 @@ def channel(self): """ return self._channel - @property - def search_resources(self): - """Return the gRPC stub for :meth:`AssetServiceClient.search_resources`. - - Searches resources which are accessible with .get permission. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["asset_service_stub"].SearchResources - - @property - def search_iam_policies(self): - """Return the gRPC stub for :meth:`AssetServiceClient.search_iam_policies`. - - Searches IAM policies which are accessible with .getIamPolicy permission. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["asset_service_stub"].SearchIamPolicies - @property def search_all_resources(self): """Return the gRPC stub for :meth:`AssetServiceClient.search_all_resources`. diff --git a/google/cloud/asset_v1p1beta1/proto/asset_service_pb2.py b/google/cloud/asset_v1p1beta1/proto/asset_service_pb2.py index cdc0f0ba..ac6703ce 100644 --- a/google/cloud/asset_v1p1beta1/proto/asset_service_pb2.py +++ b/google/cloud/asset_v1p1beta1/proto/asset_service_pb2.py @@ -16,11 +16,11 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 from google.cloud.asset_v1p1beta1.proto import ( assets_pb2 as google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_assets__pb2, ) -from google.api import client_pb2 as google_dot_api_dot_client__pb2 DESCRIPTOR = _descriptor.FileDescriptor( @@ -31,332 +31,14 @@ "\n com.google.cloud.asset.v1p1beta1B\021AssetServiceProtoP\001ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p1beta1;asset\252\002\034Google.Cloud.Asset.V1P1Beta1\312\002\034Google\\Cloud\\Asset\\V1p1beta1" ), serialized_pb=_b( - '\n6google/cloud/asset_v1p1beta1/proto/asset_service.proto\x12\x1cgoogle.cloud.asset.v1p1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a/google/cloud/asset_v1p1beta1/proto/assets.proto\x1a\x17google/api/client.proto"\x8b\x01\n\x16SearchResourcesRequest\x12\x12\n\x05scope\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05query\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x18\n\x0b\x61sset_types\x18\x03 \x03(\tB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x04 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x05 \x01(\tB\x03\xe0\x41\x01"{\n\x17SearchResourcesResponse\x12G\n\x07results\x18\x01 \x03(\x0b\x32\x36.google.cloud.asset.v1p1beta1.StandardResourceMetadata\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"s\n\x18SearchIamPoliciesRequest\x12\x12\n\x05scope\x18\x04 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05query\x18\x01 \x01(\tB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01"z\n\x19SearchIamPoliciesResponse\x12\x44\n\x07results\x18\x01 \x03(\x0b\x32\x33.google.cloud.asset.v1p1beta1.IamPolicySearchResult\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"\x8e\x01\n\x19SearchAllResourcesRequest\x12\x12\n\x05scope\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05query\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x18\n\x0b\x61sset_types\x18\x03 \x03(\tB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x04 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x05 \x01(\tB\x03\xe0\x41\x01"~\n\x1aSearchAllResourcesResponse\x12G\n\x07results\x18\x01 \x03(\x0b\x32\x36.google.cloud.asset.v1p1beta1.StandardResourceMetadata\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"v\n\x1bSearchAllIamPoliciesRequest\x12\x12\n\x05scope\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05query\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x03 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x04 \x01(\tB\x03\xe0\x41\x01"}\n\x1cSearchAllIamPoliciesResponse\x12\x44\n\x07results\x18\x01 \x03(\x0b\x32\x33.google.cloud.asset.v1p1beta1.IamPolicySearchResult\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xb5\x06\n\x0c\x41ssetService\x12\xa3\x01\n\x0fSearchResources\x12\x34.google.cloud.asset.v1p1beta1.SearchResourcesRequest\x1a\x35.google.cloud.asset.v1p1beta1.SearchResourcesResponse"#\x82\xd3\xe4\x93\x02\x1d\x12\x1b/v1p1beta1/resources:search\x12\xab\x01\n\x11SearchIamPolicies\x12\x36.google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest\x1a\x37.google.cloud.asset.v1p1beta1.SearchIamPoliciesResponse"%\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1p1beta1/iamPolicies:search\x12\xbb\x01\n\x12SearchAllResources\x12\x37.google.cloud.asset.v1p1beta1.SearchAllResourcesRequest\x1a\x38.google.cloud.asset.v1p1beta1.SearchAllResourcesResponse"2\x82\xd3\xe4\x93\x02,\x12*/v1p1beta1/{scope=*/*}/resources:searchAll\x12\xc3\x01\n\x14SearchAllIamPolicies\x12\x39.google.cloud.asset.v1p1beta1.SearchAllIamPoliciesRequest\x1a:.google.cloud.asset.v1p1beta1.SearchAllIamPoliciesResponse"4\x82\xd3\xe4\x93\x02.\x12,/v1p1beta1/{scope=*/*}/iamPolicies:searchAll\x1aM\xca\x41\x19\x63loudasset.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb8\x01\n com.google.cloud.asset.v1p1beta1B\x11\x41ssetServiceProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p1beta1;asset\xaa\x02\x1cGoogle.Cloud.Asset.V1P1Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p1beta1b\x06proto3' + '\n6google/cloud/asset_v1p1beta1/proto/asset_service.proto\x12\x1cgoogle.cloud.asset.v1p1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a/google/cloud/asset_v1p1beta1/proto/assets.proto"\x8e\x01\n\x19SearchAllResourcesRequest\x12\x12\n\x05scope\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05query\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x18\n\x0b\x61sset_types\x18\x03 \x03(\tB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x04 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x05 \x01(\tB\x03\xe0\x41\x01"~\n\x1aSearchAllResourcesResponse\x12G\n\x07results\x18\x01 \x03(\x0b\x32\x36.google.cloud.asset.v1p1beta1.StandardResourceMetadata\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"v\n\x1bSearchAllIamPoliciesRequest\x12\x12\n\x05scope\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05query\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x03 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x04 \x01(\tB\x03\xe0\x41\x01"}\n\x1cSearchAllIamPoliciesResponse\x12\x44\n\x07results\x18\x01 \x03(\x0b\x32\x33.google.cloud.asset.v1p1beta1.IamPolicySearchResult\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\x89\x04\n\x0c\x41ssetService\x12\xd5\x01\n\x12SearchAllResources\x12\x37.google.cloud.asset.v1p1beta1.SearchAllResourcesRequest\x1a\x38.google.cloud.asset.v1p1beta1.SearchAllResourcesResponse"L\x82\xd3\xe4\x93\x02,\x12*/v1p1beta1/{scope=*/*}/resources:searchAll\xda\x41\x17scope,query,asset_types\x12\xd1\x01\n\x14SearchAllIamPolicies\x12\x39.google.cloud.asset.v1p1beta1.SearchAllIamPoliciesRequest\x1a:.google.cloud.asset.v1p1beta1.SearchAllIamPoliciesResponse"B\x82\xd3\xe4\x93\x02.\x12,/v1p1beta1/{scope=*/*}/iamPolicies:searchAll\xda\x41\x0bscope,query\x1aM\xca\x41\x19\x63loudasset.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb8\x01\n com.google.cloud.asset.v1p1beta1B\x11\x41ssetServiceProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p1beta1;asset\xaa\x02\x1cGoogle.Cloud.Asset.V1P1Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p1beta1b\x06proto3' ), dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_client__pb2.DESCRIPTOR, google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_assets__pb2.DESCRIPTOR, - google_dot_api_dot_client__pb2.DESCRIPTOR, - ], -) - - -_SEARCHRESOURCESREQUEST = _descriptor.Descriptor( - name="SearchResourcesRequest", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scope", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesRequest.scope", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="query", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesRequest.query", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="asset_types", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesRequest.asset_types", - index=2, - number=3, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesRequest.page_size", - index=3, - number=4, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesRequest.page_token", - index=4, - number=5, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=226, - serialized_end=365, -) - - -_SEARCHRESOURCESRESPONSE = _descriptor.Descriptor( - name="SearchResourcesResponse", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="results", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesResponse.results", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.asset.v1p1beta1.SearchResourcesResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=367, - serialized_end=490, -) - - -_SEARCHIAMPOLICIESREQUEST = _descriptor.Descriptor( - name="SearchIamPoliciesRequest", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="scope", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest.scope", - index=0, - number=4, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\002"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="query", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest.query", - index=1, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_size", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest.page_size", - index=2, - number=2, - type=5, - cpp_type=1, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="page_token", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest.page_token", - index=3, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=_b("\340A\001"), - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=492, - serialized_end=607, -) - - -_SEARCHIAMPOLICIESRESPONSE = _descriptor.Descriptor( - name="SearchIamPoliciesResponse", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="results", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesResponse.results", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="next_page_token", - full_name="google.cloud.asset.v1p1beta1.SearchIamPoliciesResponse.next_page_token", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=609, - serialized_end=731, ) @@ -466,8 +148,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=734, - serialized_end=876, + serialized_start=226, + serialized_end=368, ) @@ -523,8 +205,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=878, - serialized_end=1004, + serialized_start=370, + serialized_end=496, ) @@ -616,8 +298,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1006, - serialized_end=1124, + serialized_start=498, + serialized_end=616, ) @@ -673,20 +355,10 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1126, - serialized_end=1251, + serialized_start=618, + serialized_end=743, ) -_SEARCHRESOURCESRESPONSE.fields_by_name[ - "results" -].message_type = ( - google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_assets__pb2._STANDARDRESOURCEMETADATA -) -_SEARCHIAMPOLICIESRESPONSE.fields_by_name[ - "results" -].message_type = ( - google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_assets__pb2._IAMPOLICYSEARCHRESULT -) _SEARCHALLRESOURCESRESPONSE.fields_by_name[ "results" ].message_type = ( @@ -697,12 +369,6 @@ ].message_type = ( google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_assets__pb2._IAMPOLICYSEARCHRESULT ) -DESCRIPTOR.message_types_by_name["SearchResourcesRequest"] = _SEARCHRESOURCESREQUEST -DESCRIPTOR.message_types_by_name["SearchResourcesResponse"] = _SEARCHRESOURCESRESPONSE -DESCRIPTOR.message_types_by_name["SearchIamPoliciesRequest"] = _SEARCHIAMPOLICIESREQUEST -DESCRIPTOR.message_types_by_name[ - "SearchIamPoliciesResponse" -] = _SEARCHIAMPOLICIESRESPONSE DESCRIPTOR.message_types_by_name[ "SearchAllResourcesRequest" ] = _SEARCHALLRESOURCESREQUEST @@ -717,128 +383,6 @@ ] = _SEARCHALLIAMPOLICIESRESPONSE _sym_db.RegisterFileDescriptor(DESCRIPTOR) -SearchResourcesRequest = _reflection.GeneratedProtocolMessageType( - "SearchResourcesRequest", - (_message.Message,), - dict( - DESCRIPTOR=_SEARCHRESOURCESREQUEST, - __module__="google.cloud.asset_v1p1beta1.proto.asset_service_pb2", - __doc__="""Search resource request. - - - Attributes: - scope: - Required. The relative name of an asset. The search is limited - to the resources within the ``scope``. The allowed value must - be: \* Organization number (such as "organizations/123") \* - Folder number(such as "folders/1234") \* Project number (such - as "projects/12345") - query: - Optional. The query statement. - asset_types: - Optional. A list of asset types that this request searches - for. If empty, it will search all the supported asset types. - page_size: - Optional. The page size for search result pagination. Returned - results may be fewer than requested. The value of this field - is capped at 2000. If set to the zero value, server will pick - an appropriate default. - page_token: - Optional. If present, then retrieve the next batch of results - from the preceding call to this method. ``page_token`` must be - the value of ``next_page_token`` from the previous response. - The values of all other method parameters, must be identical - to those in the previous call. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p1beta1.SearchResourcesRequest) - ), -) -_sym_db.RegisterMessage(SearchResourcesRequest) - -SearchResourcesResponse = _reflection.GeneratedProtocolMessageType( - "SearchResourcesResponse", - (_message.Message,), - dict( - DESCRIPTOR=_SEARCHRESOURCESRESPONSE, - __module__="google.cloud.asset_v1p1beta1.proto.asset_service_pb2", - __doc__="""Search resource response. - - - Attributes: - results: - A list of resource that match the search query. - next_page_token: - If there are more results than those appearing in this - response, then ``next_page_token`` is included. To get the - next set of results, call this method again using the value of - ``next_page_token`` as ``page_token``. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p1beta1.SearchResourcesResponse) - ), -) -_sym_db.RegisterMessage(SearchResourcesResponse) - -SearchIamPoliciesRequest = _reflection.GeneratedProtocolMessageType( - "SearchIamPoliciesRequest", - (_message.Message,), - dict( - DESCRIPTOR=_SEARCHIAMPOLICIESREQUEST, - __module__="google.cloud.asset_v1p1beta1.proto.asset_service_pb2", - __doc__="""Search IAM policies request. - - - Attributes: - scope: - Required. The relative name of an asset. The search is limited - to the resources within the ``scope``. The allowed value must - be: \* Organization number (such as "organizations/123") \* - Folder number(such as "folders/1234") \* Project number (such - as "projects/12345") - query: - Optional. The query statement. Examples: \* - "policy:myuser@mydomain.com" \* "policy:(myuser@mydomain.com - viewer)" - page_size: - Optional. The page size for search result pagination. Returned - results may be fewer than requested. The maximum is 2000. If - set to the zero value, the server will pick an appropriate - default. - page_token: - Optional. If present, retrieve the next batch of results from - the preceding call to this method. ``page_token`` must be the - value of ``next_page_token`` from the previous response. The - values of all other method parameters must be identical to - those in the previous call. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p1beta1.SearchIamPoliciesRequest) - ), -) -_sym_db.RegisterMessage(SearchIamPoliciesRequest) - -SearchIamPoliciesResponse = _reflection.GeneratedProtocolMessageType( - "SearchIamPoliciesResponse", - (_message.Message,), - dict( - DESCRIPTOR=_SEARCHIAMPOLICIESRESPONSE, - __module__="google.cloud.asset_v1p1beta1.proto.asset_service_pb2", - __doc__="""Search IAM policies response. - - - Attributes: - results: - A list of IamPolicy that match the search query. Related - information such as the associated resource is returned along - with the policy. - next_page_token: - Set if there are more results than those appearing in this - response; to get the next set of results, call this method - again, using this value as the ``page_token``. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p1beta1.SearchIamPoliciesResponse) - ), -) -_sym_db.RegisterMessage(SearchIamPoliciesResponse) - SearchAllResourcesRequest = _reflection.GeneratedProtocolMessageType( "SearchAllResourcesRequest", (_message.Message,), @@ -861,10 +405,12 @@ Optional. A list of asset types that this request searches for. If empty, it will search all the supported asset types. page_size: - Optional. The page size for search result pagination. Returned - results may be fewer than requested. The value of this field - is capped at 2000. If set to the zero value, server will pick - an appropriate default. + Optional. The page size for search result pagination. Page + size is capped at 500 even if a larger value is given. If set + to zero, server will pick an appropriate default. Returned + results may be fewer than requested. When this happens, there + could be more results as long as ``next_page_token`` is + returned. page_token: Optional. If present, then retrieve the next batch of results from the preceding call to this method. ``page_token`` must be @@ -921,10 +467,12 @@ "policy:myuser@mydomain.com" \* "policy:(myuser@mydomain.com viewer)" page_size: - Optional. The page size for search result pagination. Returned - results may be fewer than requested. The maximum is 2000. If - set to the zero value, the server will pick an appropriate - default. + Optional. The page size for search result pagination. Page + size is capped at 500 even if a larger value is given. If set + to zero, server will pick an appropriate default. Returned + results may be fewer than requested. When this happens, there + could be more results as long as ``next_page_token`` is + returned. page_token: Optional. If present, retrieve the next batch of results from the preceding call to this method. ``page_token`` must be the @@ -963,15 +511,6 @@ DESCRIPTOR._options = None -_SEARCHRESOURCESREQUEST.fields_by_name["scope"]._options = None -_SEARCHRESOURCESREQUEST.fields_by_name["query"]._options = None -_SEARCHRESOURCESREQUEST.fields_by_name["asset_types"]._options = None -_SEARCHRESOURCESREQUEST.fields_by_name["page_size"]._options = None -_SEARCHRESOURCESREQUEST.fields_by_name["page_token"]._options = None -_SEARCHIAMPOLICIESREQUEST.fields_by_name["scope"]._options = None -_SEARCHIAMPOLICIESREQUEST.fields_by_name["query"]._options = None -_SEARCHIAMPOLICIESREQUEST.fields_by_name["page_size"]._options = None -_SEARCHIAMPOLICIESREQUEST.fields_by_name["page_token"]._options = None _SEARCHALLRESOURCESREQUEST.fields_by_name["scope"]._options = None _SEARCHALLRESOURCESREQUEST.fields_by_name["query"]._options = None _SEARCHALLRESOURCESREQUEST.fields_by_name["asset_types"]._options = None @@ -990,51 +529,29 @@ serialized_options=_b( "\312A\031cloudasset.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" ), - serialized_start=1254, - serialized_end=2075, + serialized_start=746, + serialized_end=1267, methods=[ - _descriptor.MethodDescriptor( - name="SearchResources", - full_name="google.cloud.asset.v1p1beta1.AssetService.SearchResources", - index=0, - containing_service=None, - input_type=_SEARCHRESOURCESREQUEST, - output_type=_SEARCHRESOURCESRESPONSE, - serialized_options=_b( - "\202\323\344\223\002\035\022\033/v1p1beta1/resources:search" - ), - ), - _descriptor.MethodDescriptor( - name="SearchIamPolicies", - full_name="google.cloud.asset.v1p1beta1.AssetService.SearchIamPolicies", - index=1, - containing_service=None, - input_type=_SEARCHIAMPOLICIESREQUEST, - output_type=_SEARCHIAMPOLICIESRESPONSE, - serialized_options=_b( - "\202\323\344\223\002\037\022\035/v1p1beta1/iamPolicies:search" - ), - ), _descriptor.MethodDescriptor( name="SearchAllResources", full_name="google.cloud.asset.v1p1beta1.AssetService.SearchAllResources", - index=2, + index=0, containing_service=None, input_type=_SEARCHALLRESOURCESREQUEST, output_type=_SEARCHALLRESOURCESRESPONSE, serialized_options=_b( - "\202\323\344\223\002,\022*/v1p1beta1/{scope=*/*}/resources:searchAll" + "\202\323\344\223\002,\022*/v1p1beta1/{scope=*/*}/resources:searchAll\332A\027scope,query,asset_types" ), ), _descriptor.MethodDescriptor( name="SearchAllIamPolicies", full_name="google.cloud.asset.v1p1beta1.AssetService.SearchAllIamPolicies", - index=3, + index=1, containing_service=None, input_type=_SEARCHALLIAMPOLICIESREQUEST, output_type=_SEARCHALLIAMPOLICIESRESPONSE, serialized_options=_b( - "\202\323\344\223\002.\022,/v1p1beta1/{scope=*/*}/iamPolicies:searchAll" + "\202\323\344\223\002.\022,/v1p1beta1/{scope=*/*}/iamPolicies:searchAll\332A\013scope,query" ), ), ], diff --git a/google/cloud/asset_v1p1beta1/proto/asset_service_pb2_grpc.py b/google/cloud/asset_v1p1beta1/proto/asset_service_pb2_grpc.py index bf01e16c..034b538b 100644 --- a/google/cloud/asset_v1p1beta1/proto/asset_service_pb2_grpc.py +++ b/google/cloud/asset_v1p1beta1/proto/asset_service_pb2_grpc.py @@ -16,16 +16,6 @@ def __init__(self, channel): Args: channel: A grpc.Channel. """ - self.SearchResources = channel.unary_unary( - "/google.cloud.asset.v1p1beta1.AssetService/SearchResources", - request_serializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchResourcesRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchResourcesResponse.FromString, - ) - self.SearchIamPolicies = channel.unary_unary( - "/google.cloud.asset.v1p1beta1.AssetService/SearchIamPolicies", - request_serializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchIamPoliciesRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchIamPoliciesResponse.FromString, - ) self.SearchAllResources = channel.unary_unary( "/google.cloud.asset.v1p1beta1.AssetService/SearchAllResources", request_serializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchAllResourcesRequest.SerializeToString, @@ -42,20 +32,6 @@ class AssetServiceServicer(object): """Asset service definition. """ - def SearchResources(self, request, context): - """Searches resources which are accessible with .get permission. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def SearchIamPolicies(self, request, context): - """Searches IAM policies which are accessible with .getIamPolicy permission. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - def SearchAllResources(self, request, context): """Searches all the resources under a given accessible CRM scope (project/folder/organization). This RPC gives callers @@ -83,16 +59,6 @@ def SearchAllIamPolicies(self, request, context): def add_AssetServiceServicer_to_server(servicer, server): rpc_method_handlers = { - "SearchResources": grpc.unary_unary_rpc_method_handler( - servicer.SearchResources, - request_deserializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchResourcesRequest.FromString, - response_serializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchResourcesResponse.SerializeToString, - ), - "SearchIamPolicies": grpc.unary_unary_rpc_method_handler( - servicer.SearchIamPolicies, - request_deserializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchIamPoliciesRequest.FromString, - response_serializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchIamPoliciesResponse.SerializeToString, - ), "SearchAllResources": grpc.unary_unary_rpc_method_handler( servicer.SearchAllResources, request_deserializer=google_dot_cloud_dot_asset__v1p1beta1_dot_proto_dot_asset__service__pb2.SearchAllResourcesRequest.FromString, diff --git a/google/cloud/asset_v1p1beta1/proto/assets_pb2.py b/google/cloud/asset_v1p1beta1/proto/assets_pb2.py index ef68efd0..e8cfb8d7 100644 --- a/google/cloud/asset_v1p1beta1/proto/assets_pb2.py +++ b/google/cloud/asset_v1p1beta1/proto/assets_pb2.py @@ -27,7 +27,7 @@ "\n com.google.cloud.asset.v1p1beta1B\nAssetProtoP\001ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p1beta1;asset\370\001\001\252\002\034Google.Cloud.Asset.V1P1Beta1\312\002\034Google\\Cloud\\Asset\\V1p1beta1" ), serialized_pb=_b( - '\n/google/cloud/asset_v1p1beta1/proto/assets.proto\x12\x1cgoogle.cloud.asset.v1p1beta1\x1a\x1agoogle/iam/v1/policy.proto\x1a\x1cgoogle/api/annotations.proto"x\n\x18StandardResourceMetadata\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x0f\n\x07project\x18\x03 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t"a\n\x15IamPolicySearchResult\x12\x10\n\x08resource\x18\x01 \x01(\t\x12\x0f\n\x07project\x18\x03 \x01(\t\x12%\n\x06policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.PolicyB\xb4\x01\n com.google.cloud.asset.v1p1beta1B\nAssetProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p1beta1;asset\xf8\x01\x01\xaa\x02\x1cGoogle.Cloud.Asset.V1P1Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p1beta1b\x06proto3' + '\n/google/cloud/asset_v1p1beta1/proto/assets.proto\x12\x1cgoogle.cloud.asset.v1p1beta1\x1a\x1agoogle/iam/v1/policy.proto\x1a\x1cgoogle/api/annotations.proto"\x97\x01\n\x18StandardResourceMetadata\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x0f\n\x07project\x18\x03 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x04 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x05 \x01(\t\x12\x1d\n\x15\x61\x64\x64itional_attributes\x18\n \x03(\t"a\n\x15IamPolicySearchResult\x12\x10\n\x08resource\x18\x01 \x01(\t\x12\x0f\n\x07project\x18\x03 \x01(\t\x12%\n\x06policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.PolicyB\xb4\x01\n com.google.cloud.asset.v1p1beta1B\nAssetProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p1beta1;asset\xf8\x01\x01\xaa\x02\x1cGoogle.Cloud.Asset.V1P1Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p1beta1b\x06proto3' ), dependencies=[ google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR, @@ -133,6 +133,24 @@ serialized_options=None, file=DESCRIPTOR, ), + _descriptor.FieldDescriptor( + name="additional_attributes", + full_name="google.cloud.asset.v1p1beta1.StandardResourceMetadata.additional_attributes", + index=5, + number=10, + type=9, + cpp_type=9, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), ], extensions=[], nested_types=[], @@ -142,8 +160,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=139, - serialized_end=259, + serialized_start=140, + serialized_end=291, ) @@ -217,8 +235,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=261, - serialized_end=358, + serialized_start=293, + serialized_end=390, ) _IAMPOLICYSEARCHRESULT.fields_by_name[ @@ -256,6 +274,10 @@ description: One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes. + additional_attributes: + Additional searchable attributes of this resource. + Informational only. The exact set of attributes is subject to + change. For example: project id, DNS name etc. """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p1beta1.StandardResourceMetadata) ), diff --git a/google/cloud/asset_v1p1beta1/types.py b/google/cloud/asset_v1p1beta1/types.py index 7d5c6640..68b91edf 100644 --- a/google/cloud/asset_v1p1beta1/types.py +++ b/google/cloud/asset_v1p1beta1/types.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1p2beta1/__init__.py b/google/cloud/asset_v1p2beta1/__init__.py index 39ca5599..59d13256 100644 --- a/google/cloud/asset_v1p2beta1/__init__.py +++ b/google/cloud/asset_v1p2beta1/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/asset_v1p2beta1/gapic/asset_service_client.py b/google/cloud/asset_v1p2beta1/gapic/asset_service_client.py index b4cdc2b0..452566f1 100644 --- a/google/cloud/asset_v1p2beta1/gapic/asset_service_client.py +++ b/google/cloud/asset_v1p2beta1/gapic/asset_service_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,8 +26,6 @@ import google.api_core.gapic_v1.method import google.api_core.gapic_v1.routing_header import google.api_core.grpc_helpers -import google.api_core.operation -import google.api_core.operations_v1 import google.api_core.path_template import grpc @@ -36,11 +34,8 @@ from google.cloud.asset_v1p2beta1.gapic.transports import asset_service_grpc_transport from google.cloud.asset_v1p2beta1.proto import asset_service_pb2 from google.cloud.asset_v1p2beta1.proto import asset_service_pb2_grpc -from google.cloud.asset_v1p2beta1.proto import assets_pb2 -from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 from google.protobuf import field_mask_pb2 -from google.protobuf import timestamp_pb2 _GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-asset").version @@ -196,240 +191,6 @@ def __init__( self._inner_api_calls = {} # Service calls - def export_assets( - self, - parent, - output_config, - read_time=None, - asset_types=None, - content_type=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Exports assets with time and resource types to a given Cloud Storage - location. The output format is newline-delimited JSON. This API - implements the ``google.longrunning.Operation`` API allowing you to keep - track of the export. - - Example: - >>> from google.cloud import asset_v1p2beta1 - >>> - >>> client = asset_v1p2beta1.AssetServiceClient() - >>> - >>> # TODO: Initialize `parent`: - >>> parent = '' - >>> - >>> # TODO: Initialize `output_config`: - >>> output_config = {} - >>> - >>> response = client.export_assets(parent, output_config) - >>> - >>> def callback(operation_future): - ... # Handle result. - ... result = operation_future.result() - >>> - >>> response.add_done_callback(callback) - >>> - >>> # Handle metadata. - >>> metadata = response.metadata() - - Args: - parent (str): Required. The relative name of the root asset. This can only be an - organization number (such as "organizations/123"), a project ID (such as - "projects/my-project-id"), or a project number (such as "projects/12345"). - output_config (Union[dict, ~google.cloud.asset_v1p2beta1.types.OutputConfig]): Required. Output configuration indicating where the results will be output - to. All results will be in newline delimited JSON format. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.asset_v1p2beta1.types.OutputConfig` - read_time (Union[dict, ~google.cloud.asset_v1p2beta1.types.Timestamp]): Timestamp to take an asset snapshot. This can only be set to a timestamp - between 2018-10-02 UTC (inclusive) and the current time. If not specified, - the current time will be used. Due to delays in resource data collection - and indexing, there is a volatile window during which running the same - query may get different results. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.asset_v1p2beta1.types.Timestamp` - asset_types (list[str]): A list of asset types of which to take a snapshot for. For example: - "compute.googleapis.com/Disk". If specified, only matching assets will - be returned. See `Introduction to Cloud Asset - Inventory `__ - for all supported asset types. - content_type (~google.cloud.asset_v1p2beta1.types.ContentType): Asset content type. If not specified, no content but the asset name will be - returned. - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.asset_v1p2beta1.types._OperationFuture` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "export_assets" not in self._inner_api_calls: - self._inner_api_calls[ - "export_assets" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.export_assets, - default_retry=self._method_configs["ExportAssets"].retry, - default_timeout=self._method_configs["ExportAssets"].timeout, - client_info=self._client_info, - ) - - request = asset_service_pb2.ExportAssetsRequest( - parent=parent, - output_config=output_config, - read_time=read_time, - asset_types=asset_types, - content_type=content_type, - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - operation = self._inner_api_calls["export_assets"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - return google.api_core.operation.from_gapic( - operation, - self.transport._operations_client, - asset_service_pb2.ExportAssetsResponse, - metadata_type=asset_service_pb2.ExportAssetsRequest, - ) - - def batch_get_assets_history( - self, - parent, - asset_names, - content_type, - read_time_window=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None, - ): - """ - Batch gets the update history of assets that overlap a time window. For - RESOURCE content, this API outputs history with asset in both non-delete - or deleted status. For IAM\_POLICY content, this API outputs history - when the asset and its attached IAM POLICY both exist. This can create - gaps in the output history. - - Example: - >>> from google.cloud import asset_v1p2beta1 - >>> from google.cloud.asset_v1p2beta1 import enums - >>> - >>> client = asset_v1p2beta1.AssetServiceClient() - >>> - >>> # TODO: Initialize `parent`: - >>> parent = '' - >>> - >>> # TODO: Initialize `asset_names`: - >>> asset_names = [] - >>> - >>> # TODO: Initialize `content_type`: - >>> content_type = enums.ContentType.CONTENT_TYPE_UNSPECIFIED - >>> - >>> response = client.batch_get_assets_history(parent, asset_names, content_type) - - Args: - parent (str): Required. The relative name of the root asset. It can only be an - organization number (such as "organizations/123"), a project ID (such as - "projects/my-project-id")", or a project number (such as "projects/12345"). - asset_names (list[str]): A list of the full names of the assets. For example: - ``//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1``. - See `Resource - Names `__ - and `Resource Name - Format `__ - for more info. - - The request becomes a no-op if the asset name list is empty, and the max - size of the asset name list is 100 in one request. - content_type (~google.cloud.asset_v1p2beta1.types.ContentType): Required. The content type. - read_time_window (Union[dict, ~google.cloud.asset_v1p2beta1.types.TimeWindow]): Optional. The time window for the asset history. Both start\_time and - end\_time are optional and if set, it must be after 2018-10-02 UTC. If - end\_time is not set, it is default to current timestamp. If start\_time - is not set, the snapshot of the assets at end\_time will be returned. - The returned results contain all temporal assets whose time window - overlap with read\_time\_window. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.asset_v1p2beta1.types.TimeWindow` - retry (Optional[google.api_core.retry.Retry]): A retry object used - to retry requests. If ``None`` is specified, requests will - be retried using a default configuration. - timeout (Optional[float]): The amount of time, in seconds, to wait - for the request to complete. Note that if ``retry`` is - specified, the timeout applies to each individual attempt. - metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata - that is provided to the method. - - Returns: - A :class:`~google.cloud.asset_v1p2beta1.types.BatchGetAssetsHistoryResponse` instance. - - Raises: - google.api_core.exceptions.GoogleAPICallError: If the request - failed for any reason. - google.api_core.exceptions.RetryError: If the request failed due - to a retryable error and retry attempts failed. - ValueError: If the parameters are invalid. - """ - # Wrap the transport method to add retry and timeout logic. - if "batch_get_assets_history" not in self._inner_api_calls: - self._inner_api_calls[ - "batch_get_assets_history" - ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.batch_get_assets_history, - default_retry=self._method_configs["BatchGetAssetsHistory"].retry, - default_timeout=self._method_configs["BatchGetAssetsHistory"].timeout, - client_info=self._client_info, - ) - - request = asset_service_pb2.BatchGetAssetsHistoryRequest( - parent=parent, - asset_names=asset_names, - content_type=content_type, - read_time_window=read_time_window, - ) - if metadata is None: - metadata = [] - metadata = list(metadata) - try: - routing_header = [("parent", parent)] - except AttributeError: - pass - else: - routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( - routing_header - ) - metadata.append(routing_metadata) - - return self._inner_api_calls["batch_get_assets_history"]( - request, retry=retry, timeout=timeout, metadata=metadata - ) - def create_feed( self, parent, @@ -467,8 +228,8 @@ def create_feed( "projects/12345"). feed_id (str): Required. This is the client-assigned asset feed identifier and it needs to be unique under a specific parent project/folder/organization. - feed (Union[dict, ~google.cloud.asset_v1p2beta1.types.Feed]): The feed details. The field ``name`` must be empty and it will be - generated in the format of: projects/project\_number/feeds/feed\_id + feed (Union[dict, ~google.cloud.asset_v1p2beta1.types.Feed]): Required. The feed details. The field ``name`` must be empty and it will + be generated in the format of: projects/project\_number/feeds/feed\_id folders/folder\_number/feeds/feed\_id organizations/organization\_number/feeds/feed\_id @@ -544,7 +305,7 @@ def get_feed( >>> response = client.get_feed(name) Args: - name (str): The name of the Feed and it must be in the format of: + name (str): Required. The name of the Feed and it must be in the format of: projects/project\_number/feeds/feed\_id folders/folder\_number/feeds/feed\_id organizations/organization\_number/feeds/feed\_id @@ -693,17 +454,17 @@ def update_feed( >>> response = client.update_feed(feed, update_mask) Args: - feed (Union[dict, ~google.cloud.asset_v1p2beta1.types.Feed]): The new values of feed details. It must match an existing feed and the - field ``name`` must be in the format of: + feed (Union[dict, ~google.cloud.asset_v1p2beta1.types.Feed]): Required. The new values of feed details. It must match an existing feed + and the field ``name`` must be in the format of: projects/project\_number/feeds/feed\_id or folders/folder\_number/feeds/feed\_id or organizations/organization\_number/feeds/feed\_id. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.asset_v1p2beta1.types.Feed` - update_mask (Union[dict, ~google.cloud.asset_v1p2beta1.types.FieldMask]): Only updates the ``feed`` fields indicated by this mask. The field mask - must not be empty, and it must not contain fields that are immutable or - only set by the server. + update_mask (Union[dict, ~google.cloud.asset_v1p2beta1.types.FieldMask]): Required. Only updates the ``feed`` fields indicated by this mask. The + field mask must not be empty, and it must not contain fields that are + immutable or only set by the server. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.asset_v1p2beta1.types.FieldMask` @@ -777,7 +538,7 @@ def delete_feed( >>> client.delete_feed(name) Args: - name (str): The name of the feed and it must be in the format of: + name (str): Required. The name of the feed and it must be in the format of: projects/project\_number/feeds/feed\_id folders/folder\_number/feeds/feed\_id organizations/organization\_number/feeds/feed\_id diff --git a/google/cloud/asset_v1p2beta1/gapic/asset_service_client_config.py b/google/cloud/asset_v1p2beta1/gapic/asset_service_client_config.py index f3eab9e2..d5bb6775 100644 --- a/google/cloud/asset_v1p2beta1/gapic/asset_service_client_config.py +++ b/google/cloud/asset_v1p2beta1/gapic/asset_service_client_config.py @@ -17,16 +17,6 @@ } }, "methods": { - "ExportAssets": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default", - }, - "BatchGetAssetsHistory": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", - }, "CreateFeed": { "timeout_millis": 30000, "retry_codes_name": "non_idempotent", diff --git a/google/cloud/asset_v1p2beta1/gapic/enums.py b/google/cloud/asset_v1p2beta1/gapic/enums.py index a9541ab2..2b6e94ce 100644 --- a/google/cloud/asset_v1p2beta1/gapic/enums.py +++ b/google/cloud/asset_v1p2beta1/gapic/enums.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,28 +27,8 @@ class ContentType(enum.IntEnum): CONTENT_TYPE_UNSPECIFIED (int): Unspecified content type. RESOURCE (int): Resource metadata. IAM_POLICY (int): The actual IAM policy set on a resource. - IAM_POLICY_NAME (int): The IAM policy name for the IAM policy set on a resource. - ORG_POLICY (int) - ACCESS_POLICY (int): The Cloud Access context mananger Policy set on an asset. """ CONTENT_TYPE_UNSPECIFIED = 0 RESOURCE = 1 IAM_POLICY = 2 - IAM_POLICY_NAME = 3 - ORG_POLICY = 4 - ACCESS_POLICY = 5 - - -class NullValue(enum.IntEnum): - """ - ``NullValue`` is a singleton enumeration to represent the null value for - the ``Value`` type union. - - The JSON representation for ``NullValue`` is JSON ``null``. - - Attributes: - NULL_VALUE (int): Null value. - """ - - NULL_VALUE = 0 diff --git a/google/cloud/asset_v1p2beta1/gapic/transports/asset_service_grpc_transport.py b/google/cloud/asset_v1p2beta1/gapic/transports/asset_service_grpc_transport.py index d7c33e9f..1e81783b 100644 --- a/google/cloud/asset_v1p2beta1/gapic/transports/asset_service_grpc_transport.py +++ b/google/cloud/asset_v1p2beta1/gapic/transports/asset_service_grpc_transport.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ import google.api_core.grpc_helpers -import google.api_core.operations_v1 from google.cloud.asset_v1p2beta1.proto import asset_service_pb2_grpc @@ -76,13 +75,6 @@ def __init__( "asset_service_stub": asset_service_pb2_grpc.AssetServiceStub(channel) } - # Because this API includes a method that returns a - # long-running operation (proto: google.longrunning.Operation), - # instantiate an LRO client. - self._operations_client = google.api_core.operations_v1.OperationsClient( - channel - ) - @classmethod def create_channel( cls, address="cloudasset.googleapis.com:443", credentials=None, **kwargs @@ -115,39 +107,6 @@ def channel(self): """ return self._channel - @property - def export_assets(self): - """Return the gRPC stub for :meth:`AssetServiceClient.export_assets`. - - Exports assets with time and resource types to a given Cloud Storage - location. The output format is newline-delimited JSON. This API - implements the ``google.longrunning.Operation`` API allowing you to keep - track of the export. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["asset_service_stub"].ExportAssets - - @property - def batch_get_assets_history(self): - """Return the gRPC stub for :meth:`AssetServiceClient.batch_get_assets_history`. - - Batch gets the update history of assets that overlap a time window. For - RESOURCE content, this API outputs history with asset in both non-delete - or deleted status. For IAM\_POLICY content, this API outputs history - when the asset and its attached IAM POLICY both exist. This can create - gaps in the output history. - - Returns: - Callable: A callable which accepts the appropriate - deserialized request object and returns a - deserialized response object. - """ - return self._stubs["asset_service_stub"].BatchGetAssetsHistory - @property def create_feed(self): """Return the gRPC stub for :meth:`AssetServiceClient.create_feed`. diff --git a/google/cloud/asset_v1p2beta1/proto/asset_service.proto b/google/cloud/asset_v1p2beta1/proto/asset_service.proto index 0d461d0f..7925bba6 100644 --- a/google/cloud/asset_v1p2beta1/proto/asset_service.proto +++ b/google/cloud/asset_v1p2beta1/proto/asset_service.proto @@ -18,12 +18,14 @@ syntax = "proto3"; package google.cloud.asset.v1p2beta1; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; import "google/cloud/asset/v1p2beta1/assets.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; -import "google/api/client.proto"; option csharp_namespace = "Google.Cloud.Asset.V1p2Beta1"; option go_package = "google.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset"; @@ -37,28 +39,6 @@ service AssetService { option (google.api.default_host) = "cloudasset.googleapis.com"; option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - // Exports assets with time and resource types to a given Cloud Storage - // location. The output format is newline-delimited JSON. - // This API implements the [google.longrunning.Operation][google.longrunning.Operation] API allowing you - // to keep track of the export. - rpc ExportAssets(ExportAssetsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p2beta1/{parent=*/*}:exportAssets" - body: "*" - }; - } - - // Batch gets the update history of assets that overlap a time window. - // For RESOURCE content, this API outputs history with asset in both - // non-delete or deleted status. - // For IAM_POLICY content, this API outputs history when the asset and its - // attached IAM POLICY both exist. This can create gaps in the output history. - rpc BatchGetAssetsHistory(BatchGetAssetsHistoryRequest) returns (BatchGetAssetsHistoryResponse) { - option (google.api.http) = { - get: "/v1p2beta1/{parent=*/*}:batchGetAssetsHistory" - }; - } - // Creates a feed in a parent project/folder/organization to listen to its // asset updates. rpc CreateFeed(CreateFeedRequest) returns (Feed) { @@ -66,6 +46,7 @@ service AssetService { post: "/v1p2beta1/{parent=*/*}/feeds" body: "*" }; + option (google.api.method_signature) = "parent"; } // Gets details about an asset feed. @@ -73,6 +54,7 @@ service AssetService { option (google.api.http) = { get: "/v1p2beta1/{name=*/*/feeds/*}" }; + option (google.api.method_signature) = "name"; } // Lists all asset feeds in a parent project/folder/organization. @@ -80,6 +62,7 @@ service AssetService { option (google.api.http) = { get: "/v1p2beta1/{parent=*/*}/feeds" }; + option (google.api.method_signature) = "parent"; } // Updates an asset feed configuration. @@ -88,6 +71,7 @@ service AssetService { patch: "/v1p2beta1/{feed.name=*/*/feeds/*}" body: "*" }; + option (google.api.method_signature) = "feed"; } // Deletes an asset feed. @@ -95,88 +79,10 @@ service AssetService { option (google.api.http) = { delete: "/v1p2beta1/{name=*/*/feeds/*}" }; + option (google.api.method_signature) = "name"; } } -// Export asset request. -message ExportAssetsRequest { - // Required. The relative name of the root asset. This can only be an - // organization number (such as "organizations/123"), a project ID (such as - // "projects/my-project-id"), or a project number (such as "projects/12345"). - string parent = 1; - - // Timestamp to take an asset snapshot. This can only be set to a timestamp - // between 2018-10-02 UTC (inclusive) and the current time. If not specified, - // the current time will be used. Due to delays in resource data collection - // and indexing, there is a volatile window during which running the same - // query may get different results. - google.protobuf.Timestamp read_time = 2; - - // A list of asset types of which to take a snapshot for. For example: - // "compute.googleapis.com/Disk". If specified, only matching assets will be - // returned. See [Introduction to Cloud Asset - // Inventory](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview) - // for all supported asset types. - repeated string asset_types = 3; - - // Asset content type. If not specified, no content but the asset name will be - // returned. - ContentType content_type = 4; - - // Required. Output configuration indicating where the results will be output - // to. All results will be in newline delimited JSON format. - OutputConfig output_config = 5; -} - -// The export asset response. This message is returned by the -// [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] method in the returned -// [google.longrunning.Operation.response][google.longrunning.Operation.response] field. -message ExportAssetsResponse { - // Time the snapshot was taken. - google.protobuf.Timestamp read_time = 1; - - // Output configuration indicating where the results were output to. - // All results are in JSON format. - OutputConfig output_config = 2; -} - -// Batch get assets history request. -message BatchGetAssetsHistoryRequest { - // Required. The relative name of the root asset. It can only be an - // organization number (such as "organizations/123"), a project ID (such as - // "projects/my-project-id")", or a project number (such as "projects/12345"). - string parent = 1; - - // A list of the full names of the assets. For example: - // `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`. - // See [Resource - // Names](https://cloud.google.com/apis/design/resource_names#full_resource_name) - // and [Resource Name - // Format](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/resource-name-format) - // for more info. - // - // The request becomes a no-op if the asset name list is empty, and the max - // size of the asset name list is 100 in one request. - repeated string asset_names = 2; - - // Required. The content type. - ContentType content_type = 3; - - // Optional. The time window for the asset history. Both start_time and - // end_time are optional and if set, it must be after 2018-10-02 UTC. If - // end_time is not set, it is default to current timestamp. If start_time is - // not set, the snapshot of the assets at end_time will be returned. The - // returned results contain all temporal assets whose time window overlap with - // read_time_window. - TimeWindow read_time_window = 4; -} - -// Batch get assets history response. -message BatchGetAssetsHistoryResponse { - // A list of assets with valid time windows. - repeated TemporalAsset assets = 1; -} - // Create asset feed request. message CreateFeedRequest { // Required. The name of the project/folder/organization where this feed @@ -184,27 +90,32 @@ message CreateFeedRequest { // "organizations/123"), a folder number (such as "folders/123"), a project ID // (such as "projects/my-project-id")", or a project number (such as // "projects/12345"). - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; // Required. This is the client-assigned asset feed identifier and it needs to // be unique under a specific parent project/folder/organization. - string feed_id = 2; + string feed_id = 2 [(google.api.field_behavior) = REQUIRED]; - // The feed details. The field `name` must be empty and it will be generated + // Required. The feed details. The field `name` must be empty and it will be generated // in the format of: // projects/project_number/feeds/feed_id // folders/folder_number/feeds/feed_id // organizations/organization_number/feeds/feed_id - Feed feed = 3; + Feed feed = 3 [(google.api.field_behavior) = REQUIRED]; } // Get asset feed request. message GetFeedRequest { - // The name of the Feed and it must be in the format of: + // Required. The name of the Feed and it must be in the format of: // projects/project_number/feeds/feed_id // folders/folder_number/feeds/feed_id // organizations/organization_number/feeds/feed_id - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudasset.googleapis.com/Feed" + } + ]; } // List asset feeds request. @@ -212,10 +123,9 @@ message ListFeedsRequest { // Required. The parent project/folder/organization whose feeds are to be // listed. It can only be using project/folder/organization number (such as // "folders/12345")", or a project ID (such as "projects/my-project-id"). - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; } -// List asset feeds response. message ListFeedsResponse { // A list of feeds. repeated Feed feeds = 1; @@ -223,26 +133,30 @@ message ListFeedsResponse { // Update asset feed request. message UpdateFeedRequest { - // The new values of feed details. It must match an existing feed and the + // Required. The new values of feed details. It must match an existing feed and the // field `name` must be in the format of: // projects/project_number/feeds/feed_id or // folders/folder_number/feeds/feed_id or // organizations/organization_number/feeds/feed_id. - Feed feed = 1; + Feed feed = 1 [(google.api.field_behavior) = REQUIRED]; - // Only updates the `feed` fields indicated by this mask. + // Required. Only updates the `feed` fields indicated by this mask. // The field mask must not be empty, and it must not contain fields that // are immutable or only set by the server. - google.protobuf.FieldMask update_mask = 2; + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; } -// Delete asset feed request. message DeleteFeedRequest { - // The name of the feed and it must be in the format of: + // Required. The name of the feed and it must be in the format of: // projects/project_number/feeds/feed_id // folders/folder_number/feeds/feed_id // organizations/organization_number/feeds/feed_id - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudasset.googleapis.com/Feed" + } + ]; } // Output configuration for export assets destination. @@ -251,12 +165,6 @@ message OutputConfig { oneof destination { // Destination on Cloud Storage. GcsDestination gcs_destination = 1; - - // Destination on Bigquery. The output table stores the fields in asset - // proto as columns in BigQuery. The resource/iam_policy field is converted - // to a record with each field to a column, except metadata to a single JSON - // string. - BigQueryDestination bigquery_destination = 2; } } @@ -270,40 +178,9 @@ message GcsDestination { // Metadata](https://cloud.google.com/storage/docs/viewing-editing-metadata) // for more information. string uri = 1; - - // The uri prefix of all generated Cloud Storage objects. For example: - // "gs://bucket_name/object_name_prefix". Each object uri is in format: - // "gs://bucket_name/object_name_prefix// and only - // contains assets for that type. starts from 0. For example: - // "gs://bucket_name/object_name_prefix/compute.googleapis.com/Disk/0" is - // the first shard of output objects containing all - // compute.googleapis.com/Disk assets. An INVALID_ARGUMENT error will be - // returned if file with the same name "gs://bucket_name/object_name_prefix" - // already exists. - string uri_prefix = 2; } } -// A Bigquery destination. -message BigQueryDestination { - // Required. The BigQuery dataset in format - // "projects/projectId/datasets/datasetId", to which the snapshot result - // should be exported. If this dataset does not exist, the export call returns - // an error. - string dataset = 1; - - // Required. The BigQuery table to which the snapshot result should be - // written. If this table does not exist, a new table with the given name - // will be created. - string table = 2; - - // If the destination table already exists and this flag is `TRUE`, the - // table will be overwritten by the contents of assets snapshot. If the flag - // is not set and the destination table already exists, the export call - // returns an error. - bool force = 3; -} - // A Cloud Pubsub destination. message PubsubDestination { // The name of the Cloud Pub/Sub topic to publish to. @@ -311,26 +188,6 @@ message PubsubDestination { string topic = 1; } -// Asset content type. -enum ContentType { - // Unspecified content type. - CONTENT_TYPE_UNSPECIFIED = 0; - - // Resource metadata. - RESOURCE = 1; - - // The actual IAM policy set on a resource. - IAM_POLICY = 2; - - // The IAM policy name for the IAM policy set on a resource. - IAM_POLICY_NAME = 3; - - ORG_POLICY = 4; - - // The Cloud Access context mananger Policy set on an asset. - ACCESS_POLICY = 5; -} - // Output configuration for asset feed destination. message FeedOutputConfig { // Asset feed destination. @@ -346,6 +203,14 @@ message FeedOutputConfig { // folder. Supported destinations are: // Cloud Pub/Sub topics. message Feed { + option (google.api.resource) = { + type: "cloudasset.googleapis.com/Feed" + pattern: "projects/{project}/feeds/{feed}" + pattern: "folders/{folder}/feeds/{feed}" + pattern: "organizations/{organization}/feeds/{feed}" + history: ORIGINALLY_SINGLE_PATTERN + }; + // Required. The format will be // projects/{project_number}/feeds/{client-assigned_feed_identifier} or // folders/{folder_number}/feeds/{client-assigned_feed_identifier} or @@ -353,7 +218,7 @@ message Feed { // // The client-assigned feed identifier must be unique within the parent // project/folder/organization. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // A list of the full names of the assets to receive updates. You must specify // either or both of asset_names and asset_types. Only asset updates matching @@ -380,5 +245,17 @@ message Feed { // Required. Feed output configuration defining where the asset updates are // published to. - FeedOutputConfig feed_output_config = 5; + FeedOutputConfig feed_output_config = 5 [(google.api.field_behavior) = REQUIRED]; +} + +// Asset content type. +enum ContentType { + // Unspecified content type. + CONTENT_TYPE_UNSPECIFIED = 0; + + // Resource metadata. + RESOURCE = 1; + + // The actual IAM policy set on a resource. + IAM_POLICY = 2; } diff --git a/google/cloud/asset_v1p2beta1/proto/asset_service_pb2.py b/google/cloud/asset_v1p2beta1/proto/asset_service_pb2.py index 0275b673..4a97fd76 100644 --- a/google/cloud/asset_v1p2beta1/proto/asset_service_pb2.py +++ b/google/cloud/asset_v1p2beta1/proto/asset_service_pb2.py @@ -17,6 +17,9 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 from google.cloud.asset_v1p2beta1.proto import ( assets_pb2 as google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_assets__pb2, ) @@ -26,7 +29,6 @@ from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 -from google.api import client_pb2 as google_dot_api_dot_client__pb2 DESCRIPTOR = _descriptor.FileDescriptor( @@ -37,16 +39,18 @@ "\n com.google.cloud.asset.v1p2beta1B\021AssetServiceProtoP\001ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset\252\002\034Google.Cloud.Asset.V1p2Beta1\312\002\034Google\\Cloud\\Asset\\V1p2Beta1" ), serialized_pb=_b( - '\n6google/cloud/asset_v1p2beta1/proto/asset_service.proto\x12\x1cgoogle.cloud.asset.v1p2beta1\x1a\x1cgoogle/api/annotations.proto\x1a/google/cloud/asset_v1p2beta1/proto/assets.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x17google/api/client.proto"\xed\x01\n\x13\x45xportAssetsRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12-\n\tread_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x13\n\x0b\x61sset_types\x18\x03 \x03(\t\x12?\n\x0c\x63ontent_type\x18\x04 \x01(\x0e\x32).google.cloud.asset.v1p2beta1.ContentType\x12\x41\n\routput_config\x18\x05 \x01(\x0b\x32*.google.cloud.asset.v1p2beta1.OutputConfig"\x88\x01\n\x14\x45xportAssetsResponse\x12-\n\tread_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x41\n\routput_config\x18\x02 \x01(\x0b\x32*.google.cloud.asset.v1p2beta1.OutputConfig"\xc8\x01\n\x1c\x42\x61tchGetAssetsHistoryRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x13\n\x0b\x61sset_names\x18\x02 \x03(\t\x12?\n\x0c\x63ontent_type\x18\x03 \x01(\x0e\x32).google.cloud.asset.v1p2beta1.ContentType\x12\x42\n\x10read_time_window\x18\x04 \x01(\x0b\x32(.google.cloud.asset.v1p2beta1.TimeWindow"\\\n\x1d\x42\x61tchGetAssetsHistoryResponse\x12;\n\x06\x61ssets\x18\x01 \x03(\x0b\x32+.google.cloud.asset.v1p2beta1.TemporalAsset"f\n\x11\x43reateFeedRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x0f\n\x07\x66\x65\x65\x64_id\x18\x02 \x01(\t\x12\x30\n\x04\x66\x65\x65\x64\x18\x03 \x01(\x0b\x32".google.cloud.asset.v1p2beta1.Feed"\x1e\n\x0eGetFeedRequest\x12\x0c\n\x04name\x18\x01 \x01(\t""\n\x10ListFeedsRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t"F\n\x11ListFeedsResponse\x12\x31\n\x05\x66\x65\x65\x64s\x18\x01 \x03(\x0b\x32".google.cloud.asset.v1p2beta1.Feed"v\n\x11UpdateFeedRequest\x12\x30\n\x04\x66\x65\x65\x64\x18\x01 \x01(\x0b\x32".google.cloud.asset.v1p2beta1.Feed\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask"!\n\x11\x44\x65leteFeedRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"\xb9\x01\n\x0cOutputConfig\x12G\n\x0fgcs_destination\x18\x01 \x01(\x0b\x32,.google.cloud.asset.v1p2beta1.GcsDestinationH\x00\x12Q\n\x14\x62igquery_destination\x18\x02 \x01(\x0b\x32\x31.google.cloud.asset.v1p2beta1.BigQueryDestinationH\x00\x42\r\n\x0b\x64\x65stination"C\n\x0eGcsDestination\x12\r\n\x03uri\x18\x01 \x01(\tH\x00\x12\x14\n\nuri_prefix\x18\x02 \x01(\tH\x00\x42\x0c\n\nobject_uri"D\n\x13\x42igQueryDestination\x12\x0f\n\x07\x64\x61taset\x18\x01 \x01(\t\x12\r\n\x05table\x18\x02 \x01(\t\x12\r\n\x05\x66orce\x18\x03 \x01(\x08""\n\x11PubsubDestination\x12\r\n\x05topic\x18\x01 \x01(\t"p\n\x10\x46\x65\x65\x64OutputConfig\x12M\n\x12pubsub_destination\x18\x01 \x01(\x0b\x32/.google.cloud.asset.v1p2beta1.PubsubDestinationH\x00\x42\r\n\x0b\x64\x65stination"\xcb\x01\n\x04\x46\x65\x65\x64\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x61sset_names\x18\x02 \x03(\t\x12\x13\n\x0b\x61sset_types\x18\x03 \x03(\t\x12?\n\x0c\x63ontent_type\x18\x04 \x01(\x0e\x32).google.cloud.asset.v1p2beta1.ContentType\x12J\n\x12\x66\x65\x65\x64_output_config\x18\x05 \x01(\x0b\x32..google.cloud.asset.v1p2beta1.FeedOutputConfig*\x81\x01\n\x0b\x43ontentType\x12\x1c\n\x18\x43ONTENT_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08RESOURCE\x10\x01\x12\x0e\n\nIAM_POLICY\x10\x02\x12\x13\n\x0fIAM_POLICY_NAME\x10\x03\x12\x0e\n\nORG_POLICY\x10\x04\x12\x11\n\rACCESS_POLICY\x10\x05\x32\xf5\x08\n\x0c\x41ssetService\x12\x91\x01\n\x0c\x45xportAssets\x12\x31.google.cloud.asset.v1p2beta1.ExportAssetsRequest\x1a\x1d.google.longrunning.Operation"/\x82\xd3\xe4\x93\x02)"$/v1p2beta1/{parent=*/*}:exportAssets:\x01*\x12\xc7\x01\n\x15\x42\x61tchGetAssetsHistory\x12:.google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest\x1a;.google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryResponse"5\x82\xd3\xe4\x93\x02/\x12-/v1p2beta1/{parent=*/*}:batchGetAssetsHistory\x12\x8b\x01\n\nCreateFeed\x12/.google.cloud.asset.v1p2beta1.CreateFeedRequest\x1a".google.cloud.asset.v1p2beta1.Feed"(\x82\xd3\xe4\x93\x02""\x1d/v1p2beta1/{parent=*/*}/feeds:\x01*\x12\x82\x01\n\x07GetFeed\x12,.google.cloud.asset.v1p2beta1.GetFeedRequest\x1a".google.cloud.asset.v1p2beta1.Feed"%\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1p2beta1/{name=*/*/feeds/*}\x12\x93\x01\n\tListFeeds\x12..google.cloud.asset.v1p2beta1.ListFeedsRequest\x1a/.google.cloud.asset.v1p2beta1.ListFeedsResponse"%\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1p2beta1/{parent=*/*}/feeds\x12\x90\x01\n\nUpdateFeed\x12/.google.cloud.asset.v1p2beta1.UpdateFeedRequest\x1a".google.cloud.asset.v1p2beta1.Feed"-\x82\xd3\xe4\x93\x02\'2"/v1p2beta1/{feed.name=*/*/feeds/*}:\x01*\x12|\n\nDeleteFeed\x12/.google.cloud.asset.v1p2beta1.DeleteFeedRequest\x1a\x16.google.protobuf.Empty"%\x82\xd3\xe4\x93\x02\x1f*\x1d/v1p2beta1/{name=*/*/feeds/*}\x1aM\xca\x41\x19\x63loudasset.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb8\x01\n com.google.cloud.asset.v1p2beta1B\x11\x41ssetServiceProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset\xaa\x02\x1cGoogle.Cloud.Asset.V1p2Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p2Beta1b\x06proto3' + '\n6google/cloud/asset_v1p2beta1/proto/asset_service.proto\x12\x1cgoogle.cloud.asset.v1p2beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a/google/cloud/asset_v1p2beta1/proto/assets.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto"u\n\x11\x43reateFeedRequest\x12\x13\n\x06parent\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x14\n\x07\x66\x65\x65\x64_id\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x35\n\x04\x66\x65\x65\x64\x18\x03 \x01(\x0b\x32".google.cloud.asset.v1p2beta1.FeedB\x03\xe0\x41\x02"F\n\x0eGetFeedRequest\x12\x34\n\x04name\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1e\x63loudasset.googleapis.com/Feed"\'\n\x10ListFeedsRequest\x12\x13\n\x06parent\x18\x01 \x01(\tB\x03\xe0\x41\x02"F\n\x11ListFeedsResponse\x12\x31\n\x05\x66\x65\x65\x64s\x18\x01 \x03(\x0b\x32".google.cloud.asset.v1p2beta1.Feed"\x80\x01\n\x11UpdateFeedRequest\x12\x35\n\x04\x66\x65\x65\x64\x18\x01 \x01(\x0b\x32".google.cloud.asset.v1p2beta1.FeedB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02"I\n\x11\x44\x65leteFeedRequest\x12\x34\n\x04name\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1e\x63loudasset.googleapis.com/Feed"f\n\x0cOutputConfig\x12G\n\x0fgcs_destination\x18\x01 \x01(\x0b\x32,.google.cloud.asset.v1p2beta1.GcsDestinationH\x00\x42\r\n\x0b\x64\x65stination"-\n\x0eGcsDestination\x12\r\n\x03uri\x18\x01 \x01(\tH\x00\x42\x0c\n\nobject_uri""\n\x11PubsubDestination\x12\r\n\x05topic\x18\x01 \x01(\t"p\n\x10\x46\x65\x65\x64OutputConfig\x12M\n\x12pubsub_destination\x18\x01 \x01(\x0b\x32/.google.cloud.asset.v1p2beta1.PubsubDestinationH\x00\x42\r\n\x0b\x64\x65stination"\xe9\x02\n\x04\x46\x65\x65\x64\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x13\n\x0b\x61sset_names\x18\x02 \x03(\t\x12\x13\n\x0b\x61sset_types\x18\x03 \x03(\t\x12?\n\x0c\x63ontent_type\x18\x04 \x01(\x0e\x32).google.cloud.asset.v1p2beta1.ContentType\x12O\n\x12\x66\x65\x65\x64_output_config\x18\x05 \x01(\x0b\x32..google.cloud.asset.v1p2beta1.FeedOutputConfigB\x03\xe0\x41\x02:\x91\x01\xea\x41\x8d\x01\n\x1e\x63loudasset.googleapis.com/Feed\x12\x1fprojects/{project}/feeds/{feed}\x12\x1d\x66olders/{folder}/feeds/{feed}\x12)organizations/{organization}/feeds/{feed} \x01*I\n\x0b\x43ontentType\x12\x1c\n\x18\x43ONTENT_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08RESOURCE\x10\x01\x12\x0e\n\nIAM_POLICY\x10\x02\x32\xbf\x06\n\x0c\x41ssetService\x12\x94\x01\n\nCreateFeed\x12/.google.cloud.asset.v1p2beta1.CreateFeedRequest\x1a".google.cloud.asset.v1p2beta1.Feed"1\x82\xd3\xe4\x93\x02""\x1d/v1p2beta1/{parent=*/*}/feeds:\x01*\xda\x41\x06parent\x12\x89\x01\n\x07GetFeed\x12,.google.cloud.asset.v1p2beta1.GetFeedRequest\x1a".google.cloud.asset.v1p2beta1.Feed",\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1p2beta1/{name=*/*/feeds/*}\xda\x41\x04name\x12\x9c\x01\n\tListFeeds\x12..google.cloud.asset.v1p2beta1.ListFeedsRequest\x1a/.google.cloud.asset.v1p2beta1.ListFeedsResponse".\x82\xd3\xe4\x93\x02\x1f\x12\x1d/v1p2beta1/{parent=*/*}/feeds\xda\x41\x06parent\x12\x97\x01\n\nUpdateFeed\x12/.google.cloud.asset.v1p2beta1.UpdateFeedRequest\x1a".google.cloud.asset.v1p2beta1.Feed"4\x82\xd3\xe4\x93\x02\'2"/v1p2beta1/{feed.name=*/*/feeds/*}:\x01*\xda\x41\x04\x66\x65\x65\x64\x12\x83\x01\n\nDeleteFeed\x12/.google.cloud.asset.v1p2beta1.DeleteFeedRequest\x1a\x16.google.protobuf.Empty",\x82\xd3\xe4\x93\x02\x1f*\x1d/v1p2beta1/{name=*/*/feeds/*}\xda\x41\x04name\x1aM\xca\x41\x19\x63loudasset.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb8\x01\n com.google.cloud.asset.v1p2beta1B\x11\x41ssetServiceProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset\xaa\x02\x1cGoogle.Cloud.Asset.V1p2Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p2Beta1b\x06proto3' ), dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_client__pb2.DESCRIPTOR, + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_assets__pb2.DESCRIPTOR, google_dot_longrunning_dot_operations__pb2.DESCRIPTOR, google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR, google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, - google_dot_api_dot_client__pb2.DESCRIPTOR, ], ) @@ -69,24 +73,11 @@ _descriptor.EnumValueDescriptor( name="IAM_POLICY", index=2, number=2, serialized_options=None, type=None ), - _descriptor.EnumValueDescriptor( - name="IAM_POLICY_NAME", - index=3, - number=3, - serialized_options=None, - type=None, - ), - _descriptor.EnumValueDescriptor( - name="ORG_POLICY", index=4, number=4, serialized_options=None, type=None - ), - _descriptor.EnumValueDescriptor( - name="ACCESS_POLICY", index=5, number=5, serialized_options=None, type=None - ), ], containing_type=None, serialized_options=None, - serialized_start=2084, - serialized_end=2213, + serialized_start=1560, + serialized_end=1633, ) _sym_db.RegisterEnumDescriptor(_CONTENTTYPE) @@ -94,309 +85,6 @@ CONTENT_TYPE_UNSPECIFIED = 0 RESOURCE = 1 IAM_POLICY = 2 -IAM_POLICY_NAME = 3 -ORG_POLICY = 4 -ACCESS_POLICY = 5 - - -_EXPORTASSETSREQUEST = _descriptor.Descriptor( - name="ExportAssetsRequest", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="read_time", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsRequest.read_time", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="asset_types", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsRequest.asset_types", - index=2, - number=3, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="content_type", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsRequest.content_type", - index=3, - number=4, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="output_config", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsRequest.output_config", - index=4, - number=5, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=326, - serialized_end=563, -) - - -_EXPORTASSETSRESPONSE = _descriptor.Descriptor( - name="ExportAssetsResponse", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="read_time", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsResponse.read_time", - index=0, - number=1, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="output_config", - full_name="google.cloud.asset.v1p2beta1.ExportAssetsResponse.output_config", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=566, - serialized_end=702, -) - - -_BATCHGETASSETSHISTORYREQUEST = _descriptor.Descriptor( - name="BatchGetAssetsHistoryRequest", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="parent", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest.parent", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="asset_names", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest.asset_names", - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="content_type", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest.content_type", - index=2, - number=3, - type=14, - cpp_type=8, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="read_time_window", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest.read_time_window", - index=3, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=705, - serialized_end=905, -) - - -_BATCHGETASSETSHISTORYRESPONSE = _descriptor.Descriptor( - name="BatchGetAssetsHistoryResponse", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="assets", - full_name="google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryResponse.assets", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ) - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=907, - serialized_end=999, -) _CREATEFEEDREQUEST = _descriptor.Descriptor( @@ -421,7 +109,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -439,7 +127,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -457,7 +145,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], @@ -469,8 +157,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1001, - serialized_end=1103, + serialized_start=385, + serialized_end=502, ) @@ -496,7 +184,9 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b( + "\340A\002\372A \n\036cloudasset.googleapis.com/Feed" + ), file=DESCRIPTOR, ) ], @@ -508,8 +198,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1105, - serialized_end=1135, + serialized_start=504, + serialized_end=574, ) @@ -535,7 +225,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ) ], @@ -547,8 +237,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1137, - serialized_end=1171, + serialized_start=576, + serialized_end=615, ) @@ -586,8 +276,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1173, - serialized_end=1243, + serialized_start=617, + serialized_end=687, ) @@ -613,7 +303,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -631,7 +321,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], @@ -643,8 +333,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1245, - serialized_end=1363, + serialized_start=690, + serialized_end=818, ) @@ -670,7 +360,9 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b( + "\340A\002\372A \n\036cloudasset.googleapis.com/Feed" + ), file=DESCRIPTOR, ) ], @@ -682,8 +374,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1365, - serialized_end=1398, + serialized_start=820, + serialized_end=893, ) @@ -711,25 +403,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="bigquery_destination", - full_name="google.cloud.asset.v1p2beta1.OutputConfig.bigquery_destination", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), + ) ], extensions=[], nested_types=[], @@ -747,8 +421,8 @@ fields=[], ) ], - serialized_start=1401, - serialized_end=1586, + serialized_start=895, + serialized_end=997, ) @@ -776,25 +450,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="uri_prefix", - full_name="google.cloud.asset.v1p2beta1.GcsDestination.uri_prefix", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), + ) ], extensions=[], nested_types=[], @@ -812,83 +468,8 @@ fields=[], ) ], - serialized_start=1588, - serialized_end=1655, -) - - -_BIGQUERYDESTINATION = _descriptor.Descriptor( - name="BigQueryDestination", - full_name="google.cloud.asset.v1p2beta1.BigQueryDestination", - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name="dataset", - full_name="google.cloud.asset.v1p2beta1.BigQueryDestination.dataset", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="table", - full_name="google.cloud.asset.v1p2beta1.BigQueryDestination.table", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b("").decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name="force", - full_name="google.cloud.asset.v1p2beta1.BigQueryDestination.force", - index=2, - number=3, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1657, - serialized_end=1725, + serialized_start=999, + serialized_end=1044, ) @@ -926,8 +507,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1727, - serialized_end=1761, + serialized_start=1046, + serialized_end=1080, ) @@ -973,8 +554,8 @@ fields=[], ) ], - serialized_start=1763, - serialized_end=1875, + serialized_start=1082, + serialized_end=1194, ) @@ -1000,7 +581,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -1072,42 +653,24 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], extensions=[], nested_types=[], enum_types=[], - serialized_options=None, + serialized_options=_b( + "\352A\215\001\n\036cloudasset.googleapis.com/Feed\022\037projects/{project}/feeds/{feed}\022\035folders/{folder}/feeds/{feed}\022)organizations/{organization}/feeds/{feed} \001" + ), is_extendable=False, syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1878, - serialized_end=2081, + serialized_start=1197, + serialized_end=1558, ) -_EXPORTASSETSREQUEST.fields_by_name[ - "read_time" -].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_EXPORTASSETSREQUEST.fields_by_name["content_type"].enum_type = _CONTENTTYPE -_EXPORTASSETSREQUEST.fields_by_name["output_config"].message_type = _OUTPUTCONFIG -_EXPORTASSETSRESPONSE.fields_by_name[ - "read_time" -].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_EXPORTASSETSRESPONSE.fields_by_name["output_config"].message_type = _OUTPUTCONFIG -_BATCHGETASSETSHISTORYREQUEST.fields_by_name["content_type"].enum_type = _CONTENTTYPE -_BATCHGETASSETSHISTORYREQUEST.fields_by_name[ - "read_time_window" -].message_type = ( - google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_assets__pb2._TIMEWINDOW -) -_BATCHGETASSETSHISTORYRESPONSE.fields_by_name[ - "assets" -].message_type = ( - google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_assets__pb2._TEMPORALASSET -) _CREATEFEEDREQUEST.fields_by_name["feed"].message_type = _FEED _LISTFEEDSRESPONSE.fields_by_name["feeds"].message_type = _FEED _UPDATEFEEDREQUEST.fields_by_name["feed"].message_type = _FEED @@ -1115,31 +678,18 @@ "update_mask" ].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK _OUTPUTCONFIG.fields_by_name["gcs_destination"].message_type = _GCSDESTINATION -_OUTPUTCONFIG.fields_by_name["bigquery_destination"].message_type = _BIGQUERYDESTINATION _OUTPUTCONFIG.oneofs_by_name["destination"].fields.append( _OUTPUTCONFIG.fields_by_name["gcs_destination"] ) _OUTPUTCONFIG.fields_by_name[ "gcs_destination" ].containing_oneof = _OUTPUTCONFIG.oneofs_by_name["destination"] -_OUTPUTCONFIG.oneofs_by_name["destination"].fields.append( - _OUTPUTCONFIG.fields_by_name["bigquery_destination"] -) -_OUTPUTCONFIG.fields_by_name[ - "bigquery_destination" -].containing_oneof = _OUTPUTCONFIG.oneofs_by_name["destination"] _GCSDESTINATION.oneofs_by_name["object_uri"].fields.append( _GCSDESTINATION.fields_by_name["uri"] ) _GCSDESTINATION.fields_by_name["uri"].containing_oneof = _GCSDESTINATION.oneofs_by_name[ "object_uri" ] -_GCSDESTINATION.oneofs_by_name["object_uri"].fields.append( - _GCSDESTINATION.fields_by_name["uri_prefix"] -) -_GCSDESTINATION.fields_by_name[ - "uri_prefix" -].containing_oneof = _GCSDESTINATION.oneofs_by_name["object_uri"] _FEEDOUTPUTCONFIG.fields_by_name["pubsub_destination"].message_type = _PUBSUBDESTINATION _FEEDOUTPUTCONFIG.oneofs_by_name["destination"].fields.append( _FEEDOUTPUTCONFIG.fields_by_name["pubsub_destination"] @@ -1149,14 +699,6 @@ ].containing_oneof = _FEEDOUTPUTCONFIG.oneofs_by_name["destination"] _FEED.fields_by_name["content_type"].enum_type = _CONTENTTYPE _FEED.fields_by_name["feed_output_config"].message_type = _FEEDOUTPUTCONFIG -DESCRIPTOR.message_types_by_name["ExportAssetsRequest"] = _EXPORTASSETSREQUEST -DESCRIPTOR.message_types_by_name["ExportAssetsResponse"] = _EXPORTASSETSRESPONSE -DESCRIPTOR.message_types_by_name[ - "BatchGetAssetsHistoryRequest" -] = _BATCHGETASSETSHISTORYREQUEST -DESCRIPTOR.message_types_by_name[ - "BatchGetAssetsHistoryResponse" -] = _BATCHGETASSETSHISTORYRESPONSE DESCRIPTOR.message_types_by_name["CreateFeedRequest"] = _CREATEFEEDREQUEST DESCRIPTOR.message_types_by_name["GetFeedRequest"] = _GETFEEDREQUEST DESCRIPTOR.message_types_by_name["ListFeedsRequest"] = _LISTFEEDSREQUEST @@ -1165,139 +707,12 @@ DESCRIPTOR.message_types_by_name["DeleteFeedRequest"] = _DELETEFEEDREQUEST DESCRIPTOR.message_types_by_name["OutputConfig"] = _OUTPUTCONFIG DESCRIPTOR.message_types_by_name["GcsDestination"] = _GCSDESTINATION -DESCRIPTOR.message_types_by_name["BigQueryDestination"] = _BIGQUERYDESTINATION DESCRIPTOR.message_types_by_name["PubsubDestination"] = _PUBSUBDESTINATION DESCRIPTOR.message_types_by_name["FeedOutputConfig"] = _FEEDOUTPUTCONFIG DESCRIPTOR.message_types_by_name["Feed"] = _FEED DESCRIPTOR.enum_types_by_name["ContentType"] = _CONTENTTYPE _sym_db.RegisterFileDescriptor(DESCRIPTOR) -ExportAssetsRequest = _reflection.GeneratedProtocolMessageType( - "ExportAssetsRequest", - (_message.Message,), - dict( - DESCRIPTOR=_EXPORTASSETSREQUEST, - __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""Export asset request. - - - Attributes: - parent: - Required. The relative name of the root asset. This can only - be an organization number (such as "organizations/123"), a - project ID (such as "projects/my-project-id"), or a project - number (such as "projects/12345"). - read_time: - Timestamp to take an asset snapshot. This can only be set to a - timestamp between 2018-10-02 UTC (inclusive) and the current - time. If not specified, the current time will be used. Due to - delays in resource data collection and indexing, there is a - volatile window during which running the same query may get - different results. - asset_types: - A list of asset types of which to take a snapshot for. For - example: "compute.googleapis.com/Disk". If specified, only - matching assets will be returned. See `Introduction to Cloud - Asset Inventory `__ for all - supported asset types. - content_type: - Asset content type. If not specified, no content but the asset - name will be returned. - output_config: - Required. Output configuration indicating where the results - will be output to. All results will be in newline delimited - JSON format. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.ExportAssetsRequest) - ), -) -_sym_db.RegisterMessage(ExportAssetsRequest) - -ExportAssetsResponse = _reflection.GeneratedProtocolMessageType( - "ExportAssetsResponse", - (_message.Message,), - dict( - DESCRIPTOR=_EXPORTASSETSRESPONSE, - __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""The export asset response. This message is returned by the - [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation] - method in the returned - [google.longrunning.Operation.response][google.longrunning.Operation.response] - field. - - - Attributes: - read_time: - Time the snapshot was taken. - output_config: - Output configuration indicating where the results were output - to. All results are in JSON format. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.ExportAssetsResponse) - ), -) -_sym_db.RegisterMessage(ExportAssetsResponse) - -BatchGetAssetsHistoryRequest = _reflection.GeneratedProtocolMessageType( - "BatchGetAssetsHistoryRequest", - (_message.Message,), - dict( - DESCRIPTOR=_BATCHGETASSETSHISTORYREQUEST, - __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""Batch get assets history request. - - - Attributes: - parent: - Required. The relative name of the root asset. It can only be - an organization number (such as "organizations/123"), a - project ID (such as "projects/my-project-id")", or a project - number (such as "projects/12345"). - asset_names: - A list of the full names of the assets. For example: ``//compu - te.googleapis.com/projects/my_project_123/zones/zone1/instance - s/instance1``. See `Resource Names `__ and `Resource - Name Format `__ - for more info. The request becomes a no-op if the asset name - list is empty, and the max size of the asset name list is 100 - in one request. - content_type: - Required. The content type. - read_time_window: - Optional. The time window for the asset history. Both - start\_time and end\_time are optional and if set, it must be - after 2018-10-02 UTC. If end\_time is not set, it is default - to current timestamp. If start\_time is not set, the snapshot - of the assets at end\_time will be returned. The returned - results contain all temporal assets whose time window overlap - with read\_time\_window. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryRequest) - ), -) -_sym_db.RegisterMessage(BatchGetAssetsHistoryRequest) - -BatchGetAssetsHistoryResponse = _reflection.GeneratedProtocolMessageType( - "BatchGetAssetsHistoryResponse", - (_message.Message,), - dict( - DESCRIPTOR=_BATCHGETASSETSHISTORYRESPONSE, - __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""Batch get assets history response. - - - Attributes: - assets: - A list of assets with valid time windows. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.BatchGetAssetsHistoryResponse) - ), -) -_sym_db.RegisterMessage(BatchGetAssetsHistoryResponse) - CreateFeedRequest = _reflection.GeneratedProtocolMessageType( "CreateFeedRequest", (_message.Message,), @@ -1319,8 +734,8 @@ and it needs to be unique under a specific parent project/folder/organization. feed: - The feed details. The field ``name`` must be empty and it will - be generated in the format of: + Required. The feed details. The field ``name`` must be empty + and it will be generated in the format of: projects/project\_number/feeds/feed\_id folders/folder\_number/feeds/feed\_id organizations/organization\_number/feeds/feed\_id @@ -1341,8 +756,8 @@ Attributes: name: - The name of the Feed and it must be in the format of: - projects/project\_number/feeds/feed\_id + Required. The name of the Feed and it must be in the format + of: projects/project\_number/feeds/feed\_id folders/folder\_number/feeds/feed\_id organizations/organization\_number/feeds/feed\_id """, @@ -1378,10 +793,8 @@ dict( DESCRIPTOR=_LISTFEEDSRESPONSE, __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""List asset feeds response. - - - Attributes: + __doc__=""" + Attributes: feeds: A list of feeds. """, @@ -1401,15 +814,15 @@ Attributes: feed: - The new values of feed details. It must match an existing feed - and the field ``name`` must be in the format of: + Required. The new values of feed details. It must match an + existing feed and the field ``name`` must be in the format of: projects/project\_number/feeds/feed\_id or folders/folder\_number/feeds/feed\_id or organizations/organization\_number/feeds/feed\_id. update_mask: - Only updates the ``feed`` fields indicated by this mask. The - field mask must not be empty, and it must not contain fields - that are immutable or only set by the server. + Required. Only updates the ``feed`` fields indicated by this + mask. The field mask must not be empty, and it must not + contain fields that are immutable or only set by the server. """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.UpdateFeedRequest) ), @@ -1422,13 +835,11 @@ dict( DESCRIPTOR=_DELETEFEEDREQUEST, __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""Delete asset feed request. - - - Attributes: + __doc__=""" + Attributes: name: - The name of the feed and it must be in the format of: - projects/project\_number/feeds/feed\_id + Required. The name of the feed and it must be in the format + of: projects/project\_number/feeds/feed\_id folders/folder\_number/feeds/feed\_id organizations/organization\_number/feeds/feed\_id """, @@ -1451,11 +862,6 @@ Asset export destination. gcs_destination: Destination on Cloud Storage. - bigquery_destination: - Destination on Bigquery. The output table stores the fields in - asset proto as columns in BigQuery. The resource/iam\_policy - field is converted to a record with each field to a column, - except metadata to a single JSON string. """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.OutputConfig) ), @@ -1480,52 +886,12 @@ See `Viewing and Editing Object Metadata `__ for more information. - uri_prefix: - The uri prefix of all generated Cloud Storage objects. For - example: "gs://bucket\_name/object\_name\_prefix". Each object - uri is in format: "gs://bucket\_name/object\_name\_prefix// - and only contains assets for that type. starts from 0. For - example: "gs://bucket\_name/object\_name\_prefix/compute.googl - eapis.com/Disk/0" is the first shard of output objects - containing all compute.googleapis.com/Disk assets. An - INVALID\_ARGUMENT error will be returned if file with the same - name "gs://bucket\_name/object\_name\_prefix" already exists. """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.GcsDestination) ), ) _sym_db.RegisterMessage(GcsDestination) -BigQueryDestination = _reflection.GeneratedProtocolMessageType( - "BigQueryDestination", - (_message.Message,), - dict( - DESCRIPTOR=_BIGQUERYDESTINATION, - __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""A Bigquery destination. - - - Attributes: - dataset: - Required. The BigQuery dataset in format - "projects/projectId/datasets/datasetId", to which the snapshot - result should be exported. If this dataset does not exist, the - export call returns an error. - table: - Required. The BigQuery table to which the snapshot result - should be written. If this table does not exist, a new table - with the given name will be created. - force: - If the destination table already exists and this flag is - ``TRUE``, the table will be overwritten by the contents of - assets snapshot. If the flag is not set and the destination - table already exists, the export call returns an error. - """, - # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.BigQueryDestination) - ), -) -_sym_db.RegisterMessage(BigQueryDestination) - PubsubDestination = _reflection.GeneratedProtocolMessageType( "PubsubDestination", (_message.Message,), @@ -1571,10 +937,10 @@ dict( DESCRIPTOR=_FEED, __module__="google.cloud.asset_v1p2beta1.proto.asset_service_pb2", - __doc__="""An asset feed used to export asset updates to a destinations. An asset - feed filter controls what updates are exported. The asset feed must be - created within a project, organization, or folder. Supported - destinations are: Cloud Pub/Sub topics. + __doc__="""An asset feed used to export asset updates to a + destinations. An asset feed filter controls what updates are exported. + The asset feed must be created within a project, organization, or + folder. Supported destinations are: Cloud Pub/Sub topics. Attributes: @@ -1619,6 +985,17 @@ DESCRIPTOR._options = None +_CREATEFEEDREQUEST.fields_by_name["parent"]._options = None +_CREATEFEEDREQUEST.fields_by_name["feed_id"]._options = None +_CREATEFEEDREQUEST.fields_by_name["feed"]._options = None +_GETFEEDREQUEST.fields_by_name["name"]._options = None +_LISTFEEDSREQUEST.fields_by_name["parent"]._options = None +_UPDATEFEEDREQUEST.fields_by_name["feed"]._options = None +_UPDATEFEEDREQUEST.fields_by_name["update_mask"]._options = None +_DELETEFEEDREQUEST.fields_by_name["name"]._options = None +_FEED.fields_by_name["name"]._options = None +_FEED.fields_by_name["feed_output_config"]._options = None +_FEED._options = None _ASSETSERVICE = _descriptor.ServiceDescriptor( name="AssetService", @@ -1628,84 +1005,62 @@ serialized_options=_b( "\312A\031cloudasset.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" ), - serialized_start=2216, - serialized_end=3357, + serialized_start=1636, + serialized_end=2467, methods=[ - _descriptor.MethodDescriptor( - name="ExportAssets", - full_name="google.cloud.asset.v1p2beta1.AssetService.ExportAssets", - index=0, - containing_service=None, - input_type=_EXPORTASSETSREQUEST, - output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, - serialized_options=_b( - '\202\323\344\223\002)"$/v1p2beta1/{parent=*/*}:exportAssets:\001*' - ), - ), - _descriptor.MethodDescriptor( - name="BatchGetAssetsHistory", - full_name="google.cloud.asset.v1p2beta1.AssetService.BatchGetAssetsHistory", - index=1, - containing_service=None, - input_type=_BATCHGETASSETSHISTORYREQUEST, - output_type=_BATCHGETASSETSHISTORYRESPONSE, - serialized_options=_b( - "\202\323\344\223\002/\022-/v1p2beta1/{parent=*/*}:batchGetAssetsHistory" - ), - ), _descriptor.MethodDescriptor( name="CreateFeed", full_name="google.cloud.asset.v1p2beta1.AssetService.CreateFeed", - index=2, + index=0, containing_service=None, input_type=_CREATEFEEDREQUEST, output_type=_FEED, serialized_options=_b( - '\202\323\344\223\002""\035/v1p2beta1/{parent=*/*}/feeds:\001*' + '\202\323\344\223\002""\035/v1p2beta1/{parent=*/*}/feeds:\001*\332A\006parent' ), ), _descriptor.MethodDescriptor( name="GetFeed", full_name="google.cloud.asset.v1p2beta1.AssetService.GetFeed", - index=3, + index=1, containing_service=None, input_type=_GETFEEDREQUEST, output_type=_FEED, serialized_options=_b( - "\202\323\344\223\002\037\022\035/v1p2beta1/{name=*/*/feeds/*}" + "\202\323\344\223\002\037\022\035/v1p2beta1/{name=*/*/feeds/*}\332A\004name" ), ), _descriptor.MethodDescriptor( name="ListFeeds", full_name="google.cloud.asset.v1p2beta1.AssetService.ListFeeds", - index=4, + index=2, containing_service=None, input_type=_LISTFEEDSREQUEST, output_type=_LISTFEEDSRESPONSE, serialized_options=_b( - "\202\323\344\223\002\037\022\035/v1p2beta1/{parent=*/*}/feeds" + "\202\323\344\223\002\037\022\035/v1p2beta1/{parent=*/*}/feeds\332A\006parent" ), ), _descriptor.MethodDescriptor( name="UpdateFeed", full_name="google.cloud.asset.v1p2beta1.AssetService.UpdateFeed", - index=5, + index=3, containing_service=None, input_type=_UPDATEFEEDREQUEST, output_type=_FEED, serialized_options=_b( - "\202\323\344\223\002'2\"/v1p2beta1/{feed.name=*/*/feeds/*}:\001*" + "\202\323\344\223\002'2\"/v1p2beta1/{feed.name=*/*/feeds/*}:\001*\332A\004feed" ), ), _descriptor.MethodDescriptor( name="DeleteFeed", full_name="google.cloud.asset.v1p2beta1.AssetService.DeleteFeed", - index=6, + index=4, containing_service=None, input_type=_DELETEFEEDREQUEST, output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, serialized_options=_b( - "\202\323\344\223\002\037*\035/v1p2beta1/{name=*/*/feeds/*}" + "\202\323\344\223\002\037*\035/v1p2beta1/{name=*/*/feeds/*}\332A\004name" ), ), ], diff --git a/google/cloud/asset_v1p2beta1/proto/asset_service_pb2_grpc.py b/google/cloud/asset_v1p2beta1/proto/asset_service_pb2_grpc.py index 05ec4e44..04493683 100644 --- a/google/cloud/asset_v1p2beta1/proto/asset_service_pb2_grpc.py +++ b/google/cloud/asset_v1p2beta1/proto/asset_service_pb2_grpc.py @@ -4,9 +4,6 @@ from google.cloud.asset_v1p2beta1.proto import ( asset_service_pb2 as google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2, ) -from google.longrunning import ( - operations_pb2 as google_dot_longrunning_dot_operations__pb2, -) from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 @@ -20,16 +17,6 @@ def __init__(self, channel): Args: channel: A grpc.Channel. """ - self.ExportAssets = channel.unary_unary( - "/google.cloud.asset.v1p2beta1.AssetService/ExportAssets", - request_serializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.ExportAssetsRequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ) - self.BatchGetAssetsHistory = channel.unary_unary( - "/google.cloud.asset.v1p2beta1.AssetService/BatchGetAssetsHistory", - request_serializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.BatchGetAssetsHistoryRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.BatchGetAssetsHistoryResponse.FromString, - ) self.CreateFeed = channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/CreateFeed", request_serializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.CreateFeedRequest.SerializeToString, @@ -61,27 +48,6 @@ class AssetServiceServicer(object): """Asset service definition. """ - def ExportAssets(self, request, context): - """Exports assets with time and resource types to a given Cloud Storage - location. The output format is newline-delimited JSON. - This API implements the [google.longrunning.Operation][google.longrunning.Operation] API allowing you - to keep track of the export. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def BatchGetAssetsHistory(self, request, context): - """Batch gets the update history of assets that overlap a time window. - For RESOURCE content, this API outputs history with asset in both - non-delete or deleted status. - For IAM_POLICY content, this API outputs history when the asset and its - attached IAM POLICY both exist. This can create gaps in the output history. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - def CreateFeed(self, request, context): """Creates a feed in a parent project/folder/organization to listen to its asset updates. @@ -121,16 +87,6 @@ def DeleteFeed(self, request, context): def add_AssetServiceServicer_to_server(servicer, server): rpc_method_handlers = { - "ExportAssets": grpc.unary_unary_rpc_method_handler( - servicer.ExportAssets, - request_deserializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.ExportAssetsRequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - "BatchGetAssetsHistory": grpc.unary_unary_rpc_method_handler( - servicer.BatchGetAssetsHistory, - request_deserializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.BatchGetAssetsHistoryRequest.FromString, - response_serializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.BatchGetAssetsHistoryResponse.SerializeToString, - ), "CreateFeed": grpc.unary_unary_rpc_method_handler( servicer.CreateFeed, request_deserializer=google_dot_cloud_dot_asset__v1p2beta1_dot_proto_dot_asset__service__pb2.CreateFeedRequest.FromString, diff --git a/google/cloud/asset_v1p2beta1/proto/assets.proto b/google/cloud/asset_v1p2beta1/proto/assets.proto index a9cda898..8fee229b 100644 --- a/google/cloud/asset_v1p2beta1/proto/assets.proto +++ b/google/cloud/asset_v1p2beta1/proto/assets.proto @@ -74,15 +74,10 @@ message Asset { // each resource, there must be at most one Cloud IAM policy set on it. google.iam.v1.Policy iam_policy = 4; - // Cloud IAM policy name of the Cloud IAM policy set on a cloud resource. For - // each resource, there must be at most one Cloud IAM policy name associated - // with it. - bytes iam_policy_name = 5; - // Asset's ancestry path in Cloud Resource Manager (CRM) hierarchy, // represented as a list of relative resource names. Ancestry path starts with - // the closest CRM ancestor and ending at a visible root. If the asset is a - // CRM project/ folder/organization, this starts from the asset itself. + // the closest CRM ancestor and ends at root. If the asset is a CRM + // project/folder/organization, this starts from the asset itself. // // Example: ["projects/123456789", "folders/5432", "organizations/1234"] repeated string ancestors = 6; @@ -128,8 +123,4 @@ message Resource { // The content of the resource, in which some sensitive fields are scrubbed // away and may not be present. google.protobuf.Struct data = 6; - - // The actual metadata content for the resource, only visible for internal - // users. - google.protobuf.Any internal_data = 7; } diff --git a/google/cloud/asset_v1p2beta1/proto/assets_pb2.py b/google/cloud/asset_v1p2beta1/proto/assets_pb2.py index 0e086f63..24f9eca6 100644 --- a/google/cloud/asset_v1p2beta1/proto/assets_pb2.py +++ b/google/cloud/asset_v1p2beta1/proto/assets_pb2.py @@ -30,7 +30,7 @@ "\n com.google.cloud.asset.v1p2beta1B\nAssetProtoP\001ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset\370\001\001\252\002\034Google.Cloud.Asset.v1p2beta1\312\002\034Google\\Cloud\\Asset\\v1p2beta1" ), serialized_pb=_b( - '\n/google/cloud/asset_v1p2beta1/proto/assets.proto\x12\x1cgoogle.cloud.asset.v1p2beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x8e\x01\n\rTemporalAsset\x12\x38\n\x06window\x18\x01 \x01(\x0b\x32(.google.cloud.asset.v1p2beta1.TimeWindow\x12\x0f\n\x07\x64\x65leted\x18\x02 \x01(\x08\x12\x32\n\x05\x61sset\x18\x03 \x01(\x0b\x32#.google.cloud.asset.v1p2beta1.Asset"j\n\nTimeWindow\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\xba\x01\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x38\n\x08resource\x18\x03 \x01(\x0b\x32&.google.cloud.asset.v1p2beta1.Resource\x12)\n\niam_policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.Policy\x12\x17\n\x0fiam_policy_name\x18\x05 \x01(\x0c\x12\x11\n\tancestors\x18\x06 \x03(\t"\xcd\x01\n\x08Resource\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x1e\n\x16\x64iscovery_document_uri\x18\x02 \x01(\t\x12\x16\n\x0e\x64iscovery_name\x18\x03 \x01(\t\x12\x14\n\x0cresource_url\x18\x04 \x01(\t\x12\x0e\n\x06parent\x18\x05 \x01(\t\x12%\n\x04\x64\x61ta\x18\x06 \x01(\x0b\x32\x17.google.protobuf.Struct\x12+\n\rinternal_data\x18\x07 \x01(\x0b\x32\x14.google.protobuf.AnyB\xb4\x01\n com.google.cloud.asset.v1p2beta1B\nAssetProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset\xf8\x01\x01\xaa\x02\x1cGoogle.Cloud.Asset.v1p2beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\v1p2beta1b\x06proto3' + '\n/google/cloud/asset_v1p2beta1/proto/assets.proto\x12\x1cgoogle.cloud.asset.v1p2beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x8e\x01\n\rTemporalAsset\x12\x38\n\x06window\x18\x01 \x01(\x0b\x32(.google.cloud.asset.v1p2beta1.TimeWindow\x12\x0f\n\x07\x64\x65leted\x18\x02 \x01(\x08\x12\x32\n\x05\x61sset\x18\x03 \x01(\x0b\x32#.google.cloud.asset.v1p2beta1.Asset"j\n\nTimeWindow\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\xa1\x01\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x38\n\x08resource\x18\x03 \x01(\x0b\x32&.google.cloud.asset.v1p2beta1.Resource\x12)\n\niam_policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.Policy\x12\x11\n\tancestors\x18\x06 \x03(\t"\xa0\x01\n\x08Resource\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x1e\n\x16\x64iscovery_document_uri\x18\x02 \x01(\t\x12\x16\n\x0e\x64iscovery_name\x18\x03 \x01(\t\x12\x14\n\x0cresource_url\x18\x04 \x01(\t\x12\x0e\n\x06parent\x18\x05 \x01(\t\x12%\n\x04\x64\x61ta\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructB\xb4\x01\n com.google.cloud.asset.v1p2beta1B\nAssetProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p2beta1;asset\xf8\x01\x01\xaa\x02\x1cGoogle.Cloud.Asset.v1p2beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\v1p2beta1b\x06proto3' ), dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, @@ -253,28 +253,10 @@ serialized_options=None, file=DESCRIPTOR, ), - _descriptor.FieldDescriptor( - name="iam_policy_name", - full_name="google.cloud.asset.v1p2beta1.Asset.iam_policy_name", - index=4, - number=5, - type=12, - cpp_type=9, - label=1, - has_default_value=False, - default_value=_b(""), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), _descriptor.FieldDescriptor( name="ancestors", full_name="google.cloud.asset.v1p2beta1.Asset.ancestors", - index=5, + index=4, number=6, type=9, cpp_type=9, @@ -299,7 +281,7 @@ extension_ranges=[], oneofs=[], serialized_start=483, - serialized_end=669, + serialized_end=644, ) @@ -418,24 +400,6 @@ serialized_options=None, file=DESCRIPTOR, ), - _descriptor.FieldDescriptor( - name="internal_data", - full_name="google.cloud.asset.v1p2beta1.Resource.internal_data", - index=6, - number=7, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), ], extensions=[], nested_types=[], @@ -445,8 +409,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=672, - serialized_end=877, + serialized_start=647, + serialized_end=807, ) _TEMPORALASSET.fields_by_name["window"].message_type = _TIMEWINDOW @@ -466,9 +430,6 @@ _RESOURCE.fields_by_name[ "data" ].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_RESOURCE.fields_by_name[ - "internal_data" -].message_type = google_dot_protobuf_dot_any__pb2._ANY DESCRIPTOR.message_types_by_name["TemporalAsset"] = _TEMPORALASSET DESCRIPTOR.message_types_by_name["TimeWindow"] = _TIMEWINDOW DESCRIPTOR.message_types_by_name["Asset"] = _ASSET @@ -481,8 +442,8 @@ dict( DESCRIPTOR=_TEMPORALASSET, __module__="google.cloud.asset_v1p2beta1.proto.assets_pb2", - __doc__="""Temporal asset. In addition to the asset, the temporal asset includes - the status of the asset and valid from and to time of it. + __doc__="""Temporal asset. In addition to the asset, the temporal + asset includes the status of the asset and valid from and to time of it. Attributes: @@ -525,8 +486,8 @@ dict( DESCRIPTOR=_ASSET, __module__="google.cloud.asset_v1p2beta1.proto.assets_pb2", - __doc__="""Cloud asset. This includes all Google Cloud Platform resources, Cloud - IAM policies, and other non-GCP assets. + __doc__="""Cloud asset. This includes all Google Cloud Platform + resources, Cloud IAM policies, and other non-GCP assets. Attributes: @@ -544,18 +505,13 @@ Representation of the actual Cloud IAM policy set on a cloud resource. For each resource, there must be at most one Cloud IAM policy set on it. - iam_policy_name: - Cloud IAM policy name of the Cloud IAM policy set on a cloud - resource. For each resource, there must be at most one Cloud - IAM policy name associated with it. ancestors: Asset's ancestry path in Cloud Resource Manager (CRM) hierarchy, represented as a list of relative resource names. - Ancestry path starts with the closest CRM ancestor and ending - at a visible root. If the asset is a CRM project/ - folder/organization, this starts from the asset itself. - Example: ["projects/123456789", "folders/5432", - "organizations/1234"] + Ancestry path starts with the closest CRM ancestor and ends at + root. If the asset is a CRM project/folder/organization, this + starts from the asset itself. Example: ["projects/123456789", + "folders/5432", "organizations/1234"] """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.Asset) ), @@ -602,9 +558,6 @@ data: The content of the resource, in which some sensitive fields are scrubbed away and may not be present. - internal_data: - The actual metadata content for the resource, only visible for - internal users. """, # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p2beta1.Resource) ), diff --git a/google/cloud/asset_v1p2beta1/types.py b/google/cloud/asset_v1p2beta1/types.py index adaff8cd..11791870 100644 --- a/google/cloud/asset_v1p2beta1/types.py +++ b/google/cloud/asset_v1p2beta1/types.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,31 +21,13 @@ from google.api_core.protobuf_helpers import get_messages from google.cloud.asset_v1p2beta1.proto import asset_service_pb2 -from google.cloud.asset_v1p2beta1.proto import assets_pb2 -from google.iam.v1 import policy_pb2 -from google.longrunning import operations_pb2 -from google.protobuf import any_pb2 from google.protobuf import empty_pb2 from google.protobuf import field_mask_pb2 -from google.protobuf import struct_pb2 -from google.protobuf import timestamp_pb2 -from google.rpc import status_pb2 -from google.type import expr_pb2 - - -_shared_modules = [ - policy_pb2, - operations_pb2, - any_pb2, - empty_pb2, - field_mask_pb2, - struct_pb2, - timestamp_pb2, - status_pb2, - expr_pb2, -] - -_local_modules = [asset_service_pb2, assets_pb2] + + +_shared_modules = [empty_pb2, field_mask_pb2] + +_local_modules = [asset_service_pb2] names = [] diff --git a/noxfile.py b/noxfile.py index 3d92df19..a83b3723 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,7 +23,6 @@ import nox -LOCAL_DEPS = (os.path.join("..", "api_core"), os.path.join("..", "core")) BLACK_VERSION = "black==19.3b0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] @@ -38,7 +37,7 @@ def lint(session): Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.install("flake8", BLACK_VERSION, *LOCAL_DEPS) + session.install("flake8", BLACK_VERSION) session.run("black", "--check", *BLACK_PATHS) session.run("flake8", "google", "tests") @@ -67,14 +66,13 @@ def lint_setup_py(session): def default(session): # Install all test dependencies, then install this package in-place. session.install("mock", "pytest", "pytest-cov") - for local_dep in LOCAL_DEPS: - session.install("-e", local_dep) session.install("-e", ".") # Run py.test against the unit tests. session.run( "py.test", "--quiet", + "--cov=google.cloud.cloudasset", "--cov=google.cloud", "--cov=tests.unit", "--cov-append", @@ -86,7 +84,7 @@ def default(session): ) -@nox.session(python=["2.7", "3.5", "3.6", "3.7"]) +@nox.session(python=["2.7", "3.5", "3.6", "3.7", "3.8"]) def unit(session): """Run the unit test suite.""" default(session) @@ -113,9 +111,8 @@ def system(session): # Install all test dependencies, then install this package into the # virtualenv's dist-packages. session.install("mock", "pytest") - for local_dep in LOCAL_DEPS: - session.install("-e", local_dep) - session.install("-e", "../test_utils/") + + session.install("-e", "test_utils") session.install("-e", ".") # Run py.test against the system tests. diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..4fa94931 --- /dev/null +++ b/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "config:base", ":preserveSemverRanges" + ] +} diff --git a/setup.py b/setup.py index 278c03b9..67dea464 100644 --- a/setup.py +++ b/setup.py @@ -21,12 +21,12 @@ name = "google-cloud-asset" description = "Cloud Asset API API client library" -version = "0.7.0" +version = "0.8.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' # 'Development Status :: 5 - Production/Stable' -release_status = "Development Status :: 4 - Beta" +release_status = "Development Status :: 5 - Production/Stable" dependencies = [ "google-api-core[grpc] >= 1.14.0, < 2.0.0dev", 'enum34; python_version < "3.4"', @@ -60,7 +60,7 @@ author="Google LLC", author_email="googleapis-packages@google.com", license="Apache 2.0", - url="https://github.com/GoogleCloudPlatform/google-cloud-python", + url="https://github.com/googleapis/python-asset", classifiers=[ release_status, "Intended Audience :: Developers", diff --git a/synth.metadata b/synth.metadata index c71beede..2dcc7ca9 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,26 +1,27 @@ { - "updateTime": "2020-01-24T20:52:19.363395Z", + "updateTime": "2020-03-03T13:13:26.707956Z", "sources": [ { "generator": { "name": "artman", - "version": "0.43.0", - "dockerImage": "googleapis/artman@sha256:264654a37596a44b0668b8ce6ac41082d713f6ee150b3fc6425fa78cc64e4f20" + "version": "0.47.0", + "dockerImage": "googleapis/artman@sha256:b3e50d6b8de03920b9f065bbc3d210e2ca93a043446f1fa16cdf567393c09678" } }, { "git": { "name": "googleapis", - "remote": "git@github.com:googleapis/googleapis.git", - "sha": "3c39a1d6e23c1ef63c7fba4019c25e76c40dfe19", - "internalRef": "291420695" + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "4a180bfff8a21645b3a935c2756e8d6ab18a74e0", + "internalRef": "298484782", + "log": "4a180bfff8a21645b3a935c2756e8d6ab18a74e0\nautoml/v1beta1 publish proto updates\n\nPiperOrigin-RevId: 298484782\n\n6de6e938b7df1cd62396563a067334abeedb9676\nchore: use the latest gapic-generator and protoc-java-resource-name-plugin in Bazel workspace.\n\nPiperOrigin-RevId: 298474513\n\n244ab2b83a82076a1fa7be63b7e0671af73f5c02\nAdds service config definition for bigqueryreservation v1\n\nPiperOrigin-RevId: 298455048\n\n83c6f84035ee0f80eaa44d8b688a010461cc4080\nUpdate google/api/auth.proto to make AuthProvider to have JwtLocation\n\nPiperOrigin-RevId: 297918498\n\ne9e90a787703ec5d388902e2cb796aaed3a385b4\nDialogflow weekly v2/v2beta1 library update:\n - adding get validation result\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297671458\n\n1a2b05cc3541a5f7714529c665aecc3ea042c646\nAdding .yaml and .json config files.\n\nPiperOrigin-RevId: 297570622\n\ndfe1cf7be44dee31d78f78e485d8c95430981d6e\nPublish `QueryOptions` proto.\n\nIntroduced a `query_options` input in `ExecuteSqlRequest`.\n\nPiperOrigin-RevId: 297497710\n\ndafc905f71e5d46f500b41ed715aad585be062c3\npubsub: revert pull init_rpc_timeout & max_rpc_timeout back to 25 seconds and reset multiplier to 1.0\n\nPiperOrigin-RevId: 297486523\n\nf077632ba7fee588922d9e8717ee272039be126d\nfirestore: add update_transform\n\nPiperOrigin-RevId: 297405063\n\n0aba1900ffef672ec5f0da677cf590ee5686e13b\ncluster: use square brace for cross-reference\n\nPiperOrigin-RevId: 297204568\n\n5dac2da18f6325cbaed54603c43f0667ecd50247\nRestore retry params in gapic config because securitycenter has non-standard default retry params.\nRestore a few retry codes for some idempotent methods.\n\nPiperOrigin-RevId: 297196720\n\n1eb61455530252bba8b2c8d4bc9832960e5a56f6\npubsub: v1 replace IAM HTTP rules\n\nPiperOrigin-RevId: 297188590\n\n80b2d25f8d43d9d47024ff06ead7f7166548a7ba\nDialogflow weekly v2/v2beta1 library update:\n - updates to mega agent api\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297187629\n\n0b1876b35e98f560f9c9ca9797955f020238a092\nUse an older version of protoc-docs-plugin that is compatible with the specified gapic-generator and protobuf versions.\n\nprotoc-docs-plugin >=0.4.0 (see commit https://github.com/googleapis/protoc-docs-plugin/commit/979f03ede6678c487337f3d7e88bae58df5207af) is incompatible with protobuf 3.9.1.\n\nPiperOrigin-RevId: 296986742\n\n1e47e676cddbbd8d93f19ba0665af15b5532417e\nFix: Restore a method signature for UpdateCluster\n\nPiperOrigin-RevId: 296901854\n\n7f910bcc4fc4704947ccfd3ceed015d16b9e00c2\nUpdate Dataproc v1beta2 client.\n\nPiperOrigin-RevId: 296451205\n\nde287524405a3dce124d301634731584fc0432d7\nFix: Reinstate method signatures that had been missed off some RPCs\nFix: Correct resource types for two fields\n\nPiperOrigin-RevId: 296435091\n\ne5bc9566ae057fb4c92f8b7e047f1c8958235b53\nDeprecate the endpoint_uris field, as it is unused.\n\nPiperOrigin-RevId: 296357191\n\n8c12e2b4dca94e12bff9f538bdac29524ff7ef7a\nUpdate Dataproc v1 client.\n\nPiperOrigin-RevId: 296336662\n\n17567c4a1ef0a9b50faa87024d66f8acbb561089\nRemoving erroneous comment, a la https://github.com/googleapis/java-speech/pull/103\n\nPiperOrigin-RevId: 296332968\n\n3eaaaf8626ce5b0c0bc7eee05e143beffa373b01\nAdd BUILD.bazel for v1 secretmanager.googleapis.com\n\nPiperOrigin-RevId: 296274723\n\ne76149c3d992337f85eeb45643106aacae7ede82\nMove securitycenter v1 to use generate from annotations.\n\nPiperOrigin-RevId: 296266862\n\n203740c78ac69ee07c3bf6be7408048751f618f8\nAdd StackdriverLoggingConfig field to Cloud Tasks v2 API.\n\nPiperOrigin-RevId: 296256388\n\ne4117d5e9ed8bbca28da4a60a94947ca51cb2083\nCreate a Bazel BUILD file for the google.actions.type export.\n\nPiperOrigin-RevId: 296212567\n\na9639a0a9854fd6e1be08bba1ac3897f4f16cb2f\nAdd secretmanager.googleapis.com v1 protos\n\nPiperOrigin-RevId: 295983266\n\nce4f4c21d9dd2bfab18873a80449b9d9851efde8\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295861722\n\ncb61d6c2d070b589980c779b68ffca617f789116\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295855449\n\nab2685d8d3a0e191dc8aef83df36773c07cb3d06\nfix: Dataproc v1 - AutoscalingPolicy annotation\n\nThis adds the second resource name pattern to the\nAutoscalingPolicy resource.\n\nCommitter: @lukesneeringer\nPiperOrigin-RevId: 295738415\n\n8a1020bf6828f6e3c84c3014f2c51cb62b739140\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295286165\n\n5cfa105206e77670369e4b2225597386aba32985\nAdd service control related proto build rule.\n\nPiperOrigin-RevId: 295262088\n\nee4dddf805072004ab19ac94df2ce669046eec26\nmonitoring v3: Add prefix \"https://cloud.google.com/\" into the link for global access\ncl 295167522, get ride of synth.py hacks\n\nPiperOrigin-RevId: 295238095\n\nd9835e922ea79eed8497db270d2f9f85099a519c\nUpdate some minor docs changes about user event proto\n\nPiperOrigin-RevId: 295185610\n\n5f311e416e69c170243de722023b22f3df89ec1c\nfix: use correct PHP package name in gapic configuration\n\nPiperOrigin-RevId: 295161330\n\n6cdd74dcdb071694da6a6b5a206e3a320b62dd11\npubsub: v1 add client config annotations and retry config\n\nPiperOrigin-RevId: 295158776\n\n5169f46d9f792e2934d9fa25c36d0515b4fd0024\nAdded cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295026522\n\n56b55aa8818cd0a532a7d779f6ef337ba809ccbd\nFix: Resource annotations for CreateTimeSeriesRequest and ListTimeSeriesRequest should refer to valid resources. TimeSeries is not a named resource.\n\nPiperOrigin-RevId: 294931650\n\n0646bc775203077226c2c34d3e4d50cc4ec53660\nRemove unnecessary languages from bigquery-related artman configuration files.\n\nPiperOrigin-RevId: 294809380\n\n8b78aa04382e3d4147112ad6d344666771bb1909\nUpdate backend.proto for schemes and protocol\n\nPiperOrigin-RevId: 294788800\n\n80b8f8b3de2359831295e24e5238641a38d8488f\nAdds artman config files for bigquerystorage endpoints v1beta2, v1alpha2, v1\n\nPiperOrigin-RevId: 294763931\n\n2c17ac33b226194041155bb5340c3f34733f1b3a\nAdd parameter to sample generated for UpdateInstance. Related to https://github.com/googleapis/python-redis/issues/4\n\nPiperOrigin-RevId: 294734008\n\nd5e8a8953f2acdfe96fb15e85eb2f33739623957\nMove bigquery datatransfer to gapic v2.\n\nPiperOrigin-RevId: 294703703\n\nefd36705972cfcd7d00ab4c6dfa1135bafacd4ae\nfix: Add two annotations that we missed.\n\nPiperOrigin-RevId: 294664231\n\n8a36b928873ff9c05b43859b9d4ea14cd205df57\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1beta2).\n\nPiperOrigin-RevId: 294459768\n\nc7a3caa2c40c49f034a3c11079dd90eb24987047\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1).\n\nPiperOrigin-RevId: 294456889\n\n5006247aa157e59118833658084345ee59af7c09\nFix: Make deprecated fields optional\nFix: Deprecate SetLoggingServiceRequest.zone in line with the comments\nFeature: Add resource name method signatures where appropriate\n\nPiperOrigin-RevId: 294383128\n\neabba40dac05c5cbe0fca3a35761b17e372036c4\nFix: C# and PHP package/namespace capitalization for BigQuery Storage v1.\n\nPiperOrigin-RevId: 294382444\n\nf8d9a858a7a55eba8009a23aa3f5cc5fe5e88dde\nfix: artman configuration file for bigtable-admin\n\nPiperOrigin-RevId: 294322616\n\n0f29555d1cfcf96add5c0b16b089235afbe9b1a9\nAPI definition for (not-yet-launched) GCS gRPC.\n\nPiperOrigin-RevId: 294321472\n\nfcc86bee0e84dc11e9abbff8d7c3529c0626f390\nfix: Bigtable Admin v2\n\nChange LRO metadata from PartialUpdateInstanceMetadata\nto UpdateInstanceMetadata. (Otherwise, it will not build.)\n\nPiperOrigin-RevId: 294264582\n\n6d9361eae2ebb3f42d8c7ce5baf4bab966fee7c0\nrefactor: Add annotations to Bigtable Admin v2.\n\nPiperOrigin-RevId: 294243406\n\nad7616f3fc8e123451c8b3a7987bc91cea9e6913\nFix: Resource type in CreateLogMetricRequest should use logging.googleapis.com.\nFix: ListLogEntries should have a method signature for convenience of calling it.\n\nPiperOrigin-RevId: 294222165\n\n63796fcbb08712676069e20a3e455c9f7aa21026\nFix: Remove extraneous resource definition for cloudkms.googleapis.com/CryptoKey.\n\nPiperOrigin-RevId: 294176658\n\ne7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\n" } }, { "template": { "name": "python_library", "origin": "synthtool.gcp", - "version": "2019.10.17" + "version": "2020.2.4" } } ], @@ -65,229 +66,5 @@ "config": "google/cloud/asset/artman_cloudasset_v1.yaml" } } - ], - "newFiles": [ - { - "path": "MANIFEST.in" - }, - { - "path": ".flake8" - }, - { - "path": ".coveragerc" - }, - { - "path": "setup.cfg" - }, - { - "path": "LICENSE" - }, - { - "path": "docs/_static/custom.css" - }, - { - "path": "docs/gapic/v1/api.rst" - }, - { - "path": "docs/gapic/v1/types.rst" - }, - { - "path": "docs/gapic/v1p2beta1/api.rst" - }, - { - "path": "docs/gapic/v1p2beta1/types.rst" - }, - { - "path": "docs/gapic/v1beta1/api.rst" - }, - { - "path": "docs/gapic/v1beta1/types.rst" - }, - { - "path": "docs/_templates/layout.html" - }, - { - "path": "google/__init__.py" - }, - { - "path": "google/cloud/__init__.py" - }, - { - "path": "google/cloud/asset.py" - }, - { - "path": "google/cloud/asset_v1/types.py" - }, - { - "path": "google/cloud/asset_v1/__init__.py" - }, - { - "path": "google/cloud/asset_v1/gapic/asset_service_client.py" - }, - { - "path": "google/cloud/asset_v1/gapic/__init__.py" - }, - { - "path": "google/cloud/asset_v1/gapic/enums.py" - }, - { - "path": "google/cloud/asset_v1/gapic/asset_service_client_config.py" - }, - { - "path": "google/cloud/asset_v1/gapic/transports/__init__.py" - }, - { - "path": "google/cloud/asset_v1/gapic/transports/asset_service_grpc_transport.py" - }, - { - "path": "google/cloud/asset_v1/proto/__init__.py" - }, - { - "path": "google/cloud/asset_v1/proto/assets.proto" - }, - { - "path": "google/cloud/asset_v1/proto/asset_service.proto" - }, - { - "path": "google/cloud/asset_v1/proto/asset_service_pb2.py" - }, - { - "path": "google/cloud/asset_v1/proto/assets_pb2.py" - }, - { - "path": "google/cloud/asset_v1/proto/assets_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1/proto/asset_service_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/types.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/__init__.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/gapic/asset_service_client.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/gapic/asset_service_client_config.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/gapic/transports/asset_service_grpc_transport.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/proto/asset_service_pb2.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/proto/assets_pb2.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/proto/assets_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1p1beta1/proto/asset_service_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/types.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/__init__.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/gapic/asset_service_client.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/gapic/__init__.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/gapic/enums.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/gapic/asset_service_client_config.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/gapic/transports/__init__.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/gapic/transports/asset_service_grpc_transport.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/__init__.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/assets.proto" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/asset_service.proto" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/asset_service_pb2.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/assets_pb2.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/assets_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1p2beta1/proto/asset_service_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1beta1/types.py" - }, - { - "path": "google/cloud/asset_v1beta1/__init__.py" - }, - { - "path": "google/cloud/asset_v1beta1/gapic/asset_service_client.py" - }, - { - "path": "google/cloud/asset_v1beta1/gapic/__init__.py" - }, - { - "path": "google/cloud/asset_v1beta1/gapic/enums.py" - }, - { - "path": "google/cloud/asset_v1beta1/gapic/asset_service_client_config.py" - }, - { - "path": "google/cloud/asset_v1beta1/gapic/transports/__init__.py" - }, - { - "path": "google/cloud/asset_v1beta1/gapic/transports/asset_service_grpc_transport.py" - }, - { - "path": "google/cloud/asset_v1beta1/proto/__init__.py" - }, - { - "path": "google/cloud/asset_v1beta1/proto/assets.proto" - }, - { - "path": "google/cloud/asset_v1beta1/proto/asset_service.proto" - }, - { - "path": "google/cloud/asset_v1beta1/proto/asset_service_pb2.py" - }, - { - "path": "google/cloud/asset_v1beta1/proto/assets_pb2.py" - }, - { - "path": "google/cloud/asset_v1beta1/proto/assets_pb2_grpc.py" - }, - { - "path": "google/cloud/asset_v1beta1/proto/asset_service_pb2_grpc.py" - }, - { - "path": "tests/unit/gapic/v1/test_asset_service_client_v1.py" - }, - { - "path": "tests/unit/gapic/v1p1beta1/test_asset_service_client_v1p1beta1.py" - }, - { - "path": "tests/unit/gapic/v1p2beta1/test_asset_service_client_v1p2beta1.py" - }, - { - "path": "tests/unit/gapic/v1beta1/test_asset_service_client_v1beta1.py" - } ] } \ No newline at end of file diff --git a/synth.py b/synth.py index e6a0077c..075edeeb 100644 --- a/synth.py +++ b/synth.py @@ -29,15 +29,13 @@ for version in versions: if version == "v1p1beta1": config_path = "/google/cloud/asset/v1p1beta1/artman_cloudasset_v1p1beta1.yaml" - artman_output_name = f"cloudasset-{version}" else: config_path = f"/google/cloud/asset/artman_cloudasset_{version}.yaml" - artman_output_name=f"asset-{version}" library = gapic.py_library( "asset", version, config_path=config_path, - artman_output_name=artman_output_name, + artman_output_name=f"asset-{version}", include_protos=True, ) @@ -111,7 +109,7 @@ # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = gcp.CommonTemplates().py_library(unit_cov_level=79, cov_level=80) -s.move(templated_files, excludes=["noxfile.py"]) +templated_files = gcp.CommonTemplates().py_library(unit_cov_level=79, cov_level=80, system_test_dependencies=["test_utils"]) +s.move(templated_files) s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/test_utils/credentials.json.enc b/test_utils/credentials.json.enc new file mode 100644 index 00000000..f073c7e4 --- /dev/null +++ b/test_utils/credentials.json.enc @@ -0,0 +1,49 @@ +U2FsdGVkX1/vVm/dOEg1DCACYbdOcL+ey6+64A+DZGZVgF8Z/3skK6rpPocu6GOA +UZAqASsBH9QifDf8cKVXQXVYpYq6HSv2O0w7vOmVorZO9GYPo98s9/8XO+4ty/AU +aB6TD68frBAYv4cT/l5m7aYdzfzMTy0EOXoleZT09JYP3B5FV3KCO114FzMXGwrj +HXsR6E5SyUUlUnWPC3eD3aqmovay0gxOKYO3ZwjFK1nlbN/8q6/8nwBCf/Bg6SHV +V93pNxdolRlJev9kgKz4RN1z4jGCy5PAndhSLE82NFIs9LoAiEOU5YeMlN+Ulqus +J92nh+ptUe9a4pJGbAuveUWO7zdS1QyXvTMUcmmSfXCNm/eIQjNuu5+rHtIjWKh8 +Ilwj2w1aTfSptQEhk/kwRgFz/d11vfwJzvwTmCxO6zyOeL0VUWLqdCBGgG5As9He +/RenF8PZ1O0WbTt7fns5oTlTk/MUo+0xJ1xqvu/y45LaqqcBAnEdrWKmtM3dJHWv +ufQku+kD+83F/VwBnQdvgMHu6KZEs6LRrNo58r4QuK6fS7VCACdzxID1RM2cL7kT +6BFRlyGj1aigmjne9g9M9Jx4R+mZDpPU1WDzzG71J4qCUwaX8Dfwutuv4uiFvzwq +NUF0wLJJPtKWmtW+hnZ/fhHQGCRsOpZzFnqp6Zv7J7k6esqxMgIjfal7Djk5Acy8 +j3iVvm6CYmKMVqzL62JHYS9Ye83tzBCaR8hpnJQKgH3FSOFY8HSwrtQSIsl/hSeF +41sgnz0Y+/gkzNeU18qFk+eCZmvljyu+JK0nPYUgpOCJYVBNQpNHz5PUyiAEKhtM +IOSdjPRW1Y+Xf4RroJnLPoF24Ijwrow5LCm9hBRY6TPPMMmnIXCd23xcLJ1rMj6g +x4ZikElans+cwuc9wtbb7w01DcpTwQ1+eIV1qV+KIgpnLjRGLhZD4etobBsrwYu/ +vnIwy2QHCKENPb8sbdgp7x2mF7VSX0/7tf+9+i70EBiMzpOKBkiZhtLzm6hOBkEy +ODaWrx4lTTwbSw8Rmtf58APhPFMsjHoNsjiUoK249Y8Y2Ff4fMfqYsXu6VC1n/At +CuWYHc3EfBwFcLJS+RQB9kFk/4FygFBWq4Kj0MqoRruLbKmoGeJKH9q35W0f0NCD +j+iHt3014kMGiuyJe1UDQ6fvEihFFdHuDivFpPAXDt4PTY/WtpDhaGMx23kb54pK +jkAuxpznAB1lK3u9bGRXDasGeHIrNtIlPvgkrWHXvoBVqM7zry8TGtoxp3E3I42Z +cUfDWfB9GqVdrOwvrTzyZsl2uShRkAJaZFZj5aMyYxiptp4gM8CwWiNtOd2EwtRO +LxZX4M02PQFIqXV3FSDA0q6EwglUrTZdAlYeOEkopaKCtG31dEPOSQG3NGJAEYso +Cxm99H7970dp0OAgpNSgRbcWDbhVbQXnRzvFGqLeH6a9dQ/a8uD3s8Qm9Du/kB6d +XxTRe2OGxzcD0AgI8GClE4rIZHCLbcwuJRp0EYcN+pgY80O4U98fZ5RYpU6OYbU/ +MEiaBYFKtZtGkV6AQD568V7hHJWqc5DDfVHUQ/aeQwnKi2vnU66u+nnV2rZxXxLP ++dqeLRpul+wKa5b/Z5SfQ14Ff8s7aVyxaogGpyggyPL1vyq4KWZ6Or/wEE5hgNO4 +kBh6ht0QT1Hti8XY2JK1M+Jgbjgcg4jkHBGVqegrG1Rvcc2A4TYKwx+QMSBhyxrU +5qhROjS4lTcC42hQslMUkUwc4U/Y91XdFbOOnaAkwzI36NRYL0pmgZnYxGJZeRvr +E5foOhnOEVSFGdOkLfFh+FkWZQf56Lmn8Gg2wHE3dZTxLHibiUYfkgOr1uEosq29 +D1NstvlJURPQ0Q+8QQNWcl9nEZHMAjOmnL1hbx+QfuC6seucp+sXGzdZByMLZbvT +tG8KNL293CmyQowgf9MXToWYnwRkcvqfTaKyor2Ggze3JtoFW4t0j4DI1XPciZFX +XmfApHrzdB/bZadzxyaZ2NE0CuH9zDelwI6rz38xsN5liYnp5qmNKVCZVOHccXa6 +J8x365m5/VaaA2RrtdPqKxn8VaKy7+T690QgMXVGM4PbzQzQxHuSleklocqlP+sB +jSMXCZY+ng/i4UmRO9noiyW3UThYh0hIdMYs12EmmI9cnF/OuYZpl30fmqwV+VNM +td5B2fYvAvvsjiX60SFCn3DATP1GrPMBlZSmhhP3GYS+xrWt3Xxta9qIX2BEF1Gg +twnZZRjoULSRFUYPfJPEOfEH2UQwm84wxx/GezVE+S/RpBlatPOgCiLnNNaLfdTC +mTG9qY9elJv3GGQO8Lqgf4i8blExs05lSPk1BDhzTB6H9TLz+Ge0/l1QxKf3gPXU +aImK1azieXMXHECkdKxrzmehwu1dZ/oYOLc/OFQCETwSRoLPFOFpYUpizwmVVHR6 +uLSfRptte4ZOU3zHfpd/0+J4tkwHwEkGzsmMdqudlm7qME6upuIplyVBH8JiXzUK +n1RIH/OPmVEluAnexWRLZNdk7MrakIO4XACVbICENiYQgAIErP568An6twWEGDbZ +bEN64E3cVDTDRPRAunIhhsEaapcxpFEPWlHorxv36nMUt0R0h0bJlCu5QdzckfcX +ZrRuu1kl76ZfbSE8T0G4/rBb9gsU4Gn3WyvLIO3MgFBuxR68ZwcR8LpEUd8qp38H +NG4cxPmN1nGKo663Z+xI2Gt5up4gpl+fOt4mXqxY386rB7yHaOfElMG5TUYdrS9w +1xbbCVgeJ6zxX+NFlndG33cSAPprhw+C18eUu6ZU63WZcYFo3GfK6rs3lvYtofvE +8DxztdTidQedNVNE+63YCjhxd/cZUI5n/UpgYkr9owp7hNGJiR3tdoNLR2gcoGqL +qWhH928k2aSgF2j97LZ2OqoPCp0tUB7ho4jD2u4Ik3GLVNlCc3dCvWRvpHtDTQDv +tujESMfHUc9I2r4S/PD3bku/ABGwa977Yp1PjzJGr9RajA5is5n6GVpyynwjtKG4 +iyyITpdwpCgr8pueTBLwZnas3slmiMOog/E4PmPgctHzvC+vhQijhUtw5zSsmv0l +bZlw/mVhp5Ta7dTcLBKR8DA3m3vTbaEGkz0xpfQr7GfiSMRbJyvIw88pDK0gyTMD diff --git a/test_utils/scripts/circleci/get_tagged_package.py b/test_utils/scripts/circleci/get_tagged_package.py new file mode 100644 index 00000000..c148b9dc --- /dev/null +++ b/test_utils/scripts/circleci/get_tagged_package.py @@ -0,0 +1,64 @@ +# Copyright 2016 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. + +"""Helper to determine package from tag. +Get the current package directory corresponding to the Circle Tag. +""" + +from __future__ import print_function + +import os +import re +import sys + + +TAG_RE = re.compile(r""" + ^ + (?P + (([a-z]+)[_-])*) # pkg-name-with-hyphens-or-underscores (empty allowed) + ([0-9]+)\.([0-9]+)\.([0-9]+) # Version x.y.z (x, y, z all ints) + $ +""", re.VERBOSE) +TAG_ENV = 'CIRCLE_TAG' +ERROR_MSG = '%s env. var. not set' % (TAG_ENV,) +BAD_TAG_MSG = 'Invalid tag name: %s. Expected pkg-name-x.y.z' +CIRCLE_CI_SCRIPTS_DIR = os.path.dirname(__file__) +ROOT_DIR = os.path.realpath( + os.path.join(CIRCLE_CI_SCRIPTS_DIR, '..', '..', '..')) + + +def main(): + """Get the current package directory. + Prints the package directory out so callers can consume it. + """ + if TAG_ENV not in os.environ: + print(ERROR_MSG, file=sys.stderr) + sys.exit(1) + + tag_name = os.environ[TAG_ENV] + match = TAG_RE.match(tag_name) + if match is None: + print(BAD_TAG_MSG % (tag_name,), file=sys.stderr) + sys.exit(1) + + pkg_name = match.group('pkg') + if pkg_name is None: + print(ROOT_DIR) + else: + pkg_dir = pkg_name.rstrip('-').replace('-', '_') + print(os.path.join(ROOT_DIR, pkg_dir)) + + +if __name__ == '__main__': + main() diff --git a/test_utils/scripts/circleci/twine_upload.sh b/test_utils/scripts/circleci/twine_upload.sh new file mode 100755 index 00000000..23a4738e --- /dev/null +++ b/test_utils/scripts/circleci/twine_upload.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Copyright 2016 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. + +set -ev + +# If this is not a CircleCI tag, no-op. +if [[ -z "$CIRCLE_TAG" ]]; then + echo "This is not a release tag. Doing nothing." + exit 0 +fi + +# H/T: http://stackoverflow.com/a/246128/1068170 +SCRIPT="$(dirname "${BASH_SOURCE[0]}")/get_tagged_package.py" +# Determine the package directory being deploying on this tag. +PKG_DIR="$(python ${SCRIPT})" + +# Ensure that we have the latest versions of Twine, Wheel, and Setuptools. +python3 -m pip install --upgrade twine wheel setuptools + +# Move into the package, build the distribution and upload. +cd ${PKG_DIR} +python3 setup.py sdist bdist_wheel +twine upload dist/* diff --git a/test_utils/scripts/get_target_packages.py b/test_utils/scripts/get_target_packages.py new file mode 100644 index 00000000..1d51830c --- /dev/null +++ b/test_utils/scripts/get_target_packages.py @@ -0,0 +1,268 @@ +# 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. + +"""Print a list of packages which require testing.""" + +import os +import re +import subprocess +import warnings + + +CURRENT_DIR = os.path.realpath(os.path.dirname(__file__)) +BASE_DIR = os.path.realpath(os.path.join(CURRENT_DIR, '..', '..')) +GITHUB_REPO = os.environ.get('GITHUB_REPO', 'google-cloud-python') +CI = os.environ.get('CI', '') +CI_BRANCH = os.environ.get('CIRCLE_BRANCH') +CI_PR = os.environ.get('CIRCLE_PR_NUMBER') +CIRCLE_TAG = os.environ.get('CIRCLE_TAG') +head_hash, head_name = subprocess.check_output(['git', 'show-ref', 'HEAD'] +).strip().decode('ascii').split() +rev_parse = subprocess.check_output( + ['git', 'rev-parse', '--abbrev-ref', 'HEAD'] +).strip().decode('ascii') +MAJOR_DIV = '#' * 78 +MINOR_DIV = '#' + '-' * 77 + +# NOTE: This reg-ex is copied from ``get_tagged_packages``. +TAG_RE = re.compile(r""" + ^ + (?P + (([a-z]+)-)*) # pkg-name-with-hyphens- (empty allowed) + ([0-9]+)\.([0-9]+)\.([0-9]+) # Version x.y.z (x, y, z all ints) + $ +""", re.VERBOSE) + +# This is the current set of dependencies by package. +# As of this writing, the only "real" dependency is that of error_reporting +# (on logging), the rest are just system test dependencies. +PKG_DEPENDENCIES = { + 'logging': {'pubsub'}, +} + + +def get_baseline(): + """Return the baseline commit. + + On a pull request, or on a branch, return the common parent revision + with the master branch. + + Locally, return a value pulled from environment variables, or None if + the environment variables are not set. + + On a push to master, return None. This will effectively cause everything + to be considered to be affected. + """ + + # If this is a pull request or branch, return the tip for master. + # We will test only packages which have changed since that point. + ci_non_master = (CI == 'true') and any([CI_BRANCH != 'master', CI_PR]) + + if ci_non_master: + + repo_url = 'git@github.com:GoogleCloudPlatform/{}'.format(GITHUB_REPO) + subprocess.run(['git', 'remote', 'add', 'baseline', repo_url], + stderr=subprocess.DEVNULL) + subprocess.run(['git', 'pull', 'baseline'], stderr=subprocess.DEVNULL) + + if CI_PR is None and CI_BRANCH is not None: + output = subprocess.check_output([ + 'git', 'merge-base', '--fork-point', + 'baseline/master', CI_BRANCH]) + return output.strip().decode('ascii') + + return 'baseline/master' + + # If environment variables are set identifying what the master tip is, + # use that. + if os.environ.get('GOOGLE_CLOUD_TESTING_REMOTE', ''): + remote = os.environ['GOOGLE_CLOUD_TESTING_REMOTE'] + branch = os.environ.get('GOOGLE_CLOUD_TESTING_BRANCH', 'master') + return '%s/%s' % (remote, branch) + + # If we are not in CI and we got this far, issue a warning. + if not CI: + warnings.warn('No baseline could be determined; this means tests ' + 'will run for every package. If this is local ' + 'development, set the $GOOGLE_CLOUD_TESTING_REMOTE ' + 'environment variable.') + + # That is all we can do; return None. + return None + + +def get_changed_files(): + """Return a list of files that have been changed since the baseline. + + If there is no base, return None. + """ + # Get the baseline, and fail quickly if there is no baseline. + baseline = get_baseline() + print('# Baseline commit: {}'.format(baseline)) + if not baseline: + return None + + # Return a list of altered files. + try: + return subprocess.check_output([ + 'git', 'diff', '--name-only', '{}..HEAD'.format(baseline), + ], stderr=subprocess.DEVNULL).decode('utf8').strip().split('\n') + except subprocess.CalledProcessError: + warnings.warn('Unable to perform git diff; falling back to assuming ' + 'all packages have changed.') + return None + + +def reverse_map(dict_of_sets): + """Reverse a map of one-to-many. + + So the map:: + + { + 'A': {'B', 'C'}, + 'B': {'C'}, + } + + becomes + + { + 'B': {'A'}, + 'C': {'A', 'B'}, + } + + Args: + dict_of_sets (dict[set]): A dictionary of sets, mapping + one value to many. + + Returns: + dict[set]: The reversed map. + """ + result = {} + for key, values in dict_of_sets.items(): + for value in values: + result.setdefault(value, set()).add(key) + + return result + +def get_changed_packages(file_list): + """Return a list of changed packages based on the provided file list. + + If the file list is None, then all packages should be considered to be + altered. + """ + # Determine a complete list of packages. + all_packages = set() + for file_ in os.listdir(BASE_DIR): + abs_file = os.path.realpath(os.path.join(BASE_DIR, file_)) + nox_file = os.path.join(abs_file, 'nox.py') + if os.path.isdir(abs_file) and os.path.isfile(nox_file): + all_packages.add(file_) + + # If ther is no file list, send down the full package set. + if file_list is None: + return all_packages + + # Create a set based on the list of changed files. + answer = set() + reverse_deps = reverse_map(PKG_DEPENDENCIES) + for file_ in file_list: + # Ignore root directory changes (setup.py, .gitignore, etc.). + if os.path.sep not in file_: + continue + + # Ignore changes that are not in a package (usually this will be docs). + package = file_.split(os.path.sep, 1)[0] + if package not in all_packages: + continue + + # If there is a change in core, short-circuit now and return + # everything. + if package in ('core',): + return all_packages + + # Add the package, as well as any dependencies this package has. + # NOTE: For now, dependencies only go down one level. + answer.add(package) + answer = answer.union(reverse_deps.get(package, set())) + + # We got this far without being short-circuited; return the final answer. + return answer + + +def get_tagged_package(): + """Return the package corresponding to the current tag. + + If there is not tag, will return :data:`None`. + """ + if CIRCLE_TAG is None: + return + + match = TAG_RE.match(CIRCLE_TAG) + if match is None: + return + + pkg_name = match.group('pkg') + if pkg_name == '': + # NOTE: This corresponds to the "umbrella" tag. + return + + return pkg_name.rstrip('-').replace('-', '_') + + +def get_target_packages(): + """Return a list of target packages to be run in the current build. + + If in a tag build, will run only the package(s) that are tagged, otherwise + will run the packages that have file changes in them (or packages that + depend on those). + """ + tagged_package = get_tagged_package() + if tagged_package is None: + file_list = get_changed_files() + print(MAJOR_DIV) + print('# Changed files:') + print(MINOR_DIV) + for file_ in file_list or (): + print('# {}'.format(file_)) + for package in sorted(get_changed_packages(file_list)): + yield package + else: + yield tagged_package + + +def main(): + print(MAJOR_DIV) + print('# Environment') + print(MINOR_DIV) + print('# CircleCI: {}'.format(CI)) + print('# CircleCI branch: {}'.format(CI_BRANCH)) + print('# CircleCI pr: {}'.format(CI_PR)) + print('# CircleCI tag: {}'.format(CIRCLE_TAG)) + print('# HEAD ref: {}'.format(head_hash)) + print('# {}'.format(head_name)) + print('# Git branch: {}'.format(rev_parse)) + print(MAJOR_DIV) + + packages = list(get_target_packages()) + + print(MAJOR_DIV) + print('# Target packages:') + print(MINOR_DIV) + for package in packages: + print(package) + print(MAJOR_DIV) + + +if __name__ == '__main__': + main() diff --git a/test_utils/scripts/get_target_packages_kokoro.py b/test_utils/scripts/get_target_packages_kokoro.py new file mode 100644 index 00000000..27d3a0c9 --- /dev/null +++ b/test_utils/scripts/get_target_packages_kokoro.py @@ -0,0 +1,98 @@ +# 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. + +"""Print a list of packages which require testing.""" + +import pathlib +import subprocess + +import ci_diff_helper +import requests + + +def print_environment(environment): + print("-> CI environment:") + print('Branch', environment.branch) + print('PR', environment.pr) + print('In PR', environment.in_pr) + print('Repo URL', environment.repo_url) + if environment.in_pr: + print('PR Base', environment.base) + + +def get_base(environment): + if environment.in_pr: + return environment.base + else: + # If we're not in a PR, just calculate the changes between this commit + # and its parent. + return 'HEAD~1' + + +def get_changed_files_from_base(base): + return subprocess.check_output([ + 'git', 'diff', '--name-only', f'{base}..HEAD', + ], stderr=subprocess.DEVNULL).decode('utf8').strip().split('\n') + + +_URL_TEMPLATE = ( + 'https://api.github.com/repos/googleapis/google-cloud-python/pulls/' + '{}/files' +) + + +def get_changed_files_from_pr(pr): + url = _URL_TEMPLATE.format(pr) + while url is not None: + response = requests.get(url) + for info in response.json(): + yield info['filename'] + url = response.links.get('next', {}).get('url') + + +def determine_changed_packages(changed_files): + packages = [ + path.parent for path in pathlib.Path('.').glob('*/noxfile.py') + ] + + changed_packages = set() + for file in changed_files: + file = pathlib.Path(file) + for package in packages: + if package in file.parents: + changed_packages.add(package) + + return changed_packages + + +def main(): + environment = ci_diff_helper.get_config() + print_environment(environment) + base = get_base(environment) + + if environment.in_pr: + changed_files = list(get_changed_files_from_pr(environment.pr)) + else: + changed_files = get_changed_files_from_base(base) + + packages = determine_changed_packages(changed_files) + + print(f"Comparing against {base}.") + print("-> Changed packages:") + + for package in packages: + print(package) + + +main() diff --git a/test_utils/scripts/run_emulator.py b/test_utils/scripts/run_emulator.py new file mode 100644 index 00000000..287b0864 --- /dev/null +++ b/test_utils/scripts/run_emulator.py @@ -0,0 +1,199 @@ +# Copyright 2016 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. + +"""Run system tests locally with the emulator. + +First makes system calls to spawn the emulator and get the local environment +variable needed for it. Then calls the system tests. +""" + + +import argparse +import os +import subprocess + +import psutil + +from google.cloud.environment_vars import BIGTABLE_EMULATOR +from google.cloud.environment_vars import GCD_DATASET +from google.cloud.environment_vars import GCD_HOST +from google.cloud.environment_vars import PUBSUB_EMULATOR +from run_system_test import run_module_tests + + +BIGTABLE = 'bigtable' +DATASTORE = 'datastore' +PUBSUB = 'pubsub' +PACKAGE_INFO = { + BIGTABLE: (BIGTABLE_EMULATOR,), + DATASTORE: (GCD_DATASET, GCD_HOST), + PUBSUB: (PUBSUB_EMULATOR,), +} +EXTRA = { + DATASTORE: ('--no-legacy',), +} +_DS_READY_LINE = '[datastore] Dev App Server is now running.\n' +_PS_READY_LINE_PREFIX = '[pubsub] INFO: Server started, listening on ' +_BT_READY_LINE_PREFIX = '[bigtable] Cloud Bigtable emulator running on ' + + +def get_parser(): + """Get simple ``argparse`` parser to determine package. + + :rtype: :class:`argparse.ArgumentParser` + :returns: The parser for this script. + """ + parser = argparse.ArgumentParser( + description='Run google-cloud system tests against local emulator.') + parser.add_argument('--package', dest='package', + choices=sorted(PACKAGE_INFO.keys()), + default=DATASTORE, help='Package to be tested.') + return parser + + +def get_start_command(package): + """Get command line arguments for starting emulator. + + :type package: str + :param package: The package to start an emulator for. + + :rtype: tuple + :returns: The arguments to be used, in a tuple. + """ + result = ('gcloud', 'beta', 'emulators', package, 'start') + extra = EXTRA.get(package, ()) + return result + extra + + +def get_env_init_command(package): + """Get command line arguments for getting emulator env. info. + + :type package: str + :param package: The package to get environment info for. + + :rtype: tuple + :returns: The arguments to be used, in a tuple. + """ + result = ('gcloud', 'beta', 'emulators', package, 'env-init') + extra = EXTRA.get(package, ()) + return result + extra + + +def datastore_wait_ready(popen): + """Wait until the datastore emulator is ready to use. + + :type popen: :class:`subprocess.Popen` + :param popen: An open subprocess to interact with. + """ + emulator_ready = False + while not emulator_ready: + emulator_ready = popen.stderr.readline() == _DS_READY_LINE + + +def wait_ready_prefix(popen, prefix): + """Wait until the a process encounters a line with matching prefix. + + :type popen: :class:`subprocess.Popen` + :param popen: An open subprocess to interact with. + + :type prefix: str + :param prefix: The prefix to match + """ + emulator_ready = False + while not emulator_ready: + emulator_ready = popen.stderr.readline().startswith(prefix) + + +def wait_ready(package, popen): + """Wait until the emulator is ready to use. + + :type package: str + :param package: The package to check if ready. + + :type popen: :class:`subprocess.Popen` + :param popen: An open subprocess to interact with. + + :raises: :class:`KeyError` if the ``package`` is not among + ``datastore``, ``pubsub`` or ``bigtable``. + """ + if package == DATASTORE: + datastore_wait_ready(popen) + elif package == PUBSUB: + wait_ready_prefix(popen, _PS_READY_LINE_PREFIX) + elif package == BIGTABLE: + wait_ready_prefix(popen, _BT_READY_LINE_PREFIX) + else: + raise KeyError('Package not supported', package) + + +def cleanup(pid): + """Cleanup a process (including all of its children). + + :type pid: int + :param pid: Process ID. + """ + proc = psutil.Process(pid) + for child_proc in proc.children(recursive=True): + try: + child_proc.kill() + child_proc.terminate() + except psutil.NoSuchProcess: + pass + proc.terminate() + proc.kill() + + +def run_tests_in_emulator(package): + """Spawn an emulator instance and run the system tests. + + :type package: str + :param package: The package to run system tests against. + """ + # Make sure this package has environment vars to replace. + env_vars = PACKAGE_INFO[package] + + start_command = get_start_command(package) + # Ignore stdin and stdout, don't pollute the user's output with them. + proc_start = subprocess.Popen(start_command, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + try: + wait_ready(package, proc_start) + env_init_command = get_env_init_command(package) + proc_env = subprocess.Popen(env_init_command, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + env_status = proc_env.wait() + if env_status != 0: + raise RuntimeError(env_status, proc_env.stderr.read()) + env_lines = proc_env.stdout.read().strip().split('\n') + # Set environment variables before running the system tests. + for env_var in env_vars: + line_prefix = 'export ' + env_var + '=' + value, = [line.split(line_prefix, 1)[1] for line in env_lines + if line.startswith(line_prefix)] + os.environ[env_var] = value + run_module_tests(package, + ignore_requirements=True) + finally: + cleanup(proc_start.pid) + + +def main(): + """Main method to run this script.""" + parser = get_parser() + args = parser.parse_args() + run_tests_in_emulator(args.package) + + +if __name__ == '__main__': + main() diff --git a/test_utils/scripts/update_docs.sh b/test_utils/scripts/update_docs.sh new file mode 100755 index 00000000..8cbab9f0 --- /dev/null +++ b/test_utils/scripts/update_docs.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# Copyright 2016 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. + +set -ev + +GH_OWNER='GoogleCloudPlatform' +GH_PROJECT_NAME='google-cloud-python' + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Function to build the docs. +function build_docs { + rm -rf docs/_build/ + rm -f docs/bigquery/generated/*.rst + # -W -> warnings as errors + # -T -> show full traceback on exception + # -N -> no color + sphinx-build \ + -W -T -N \ + -b html \ + -d docs/_build/doctrees \ + docs/ \ + docs/_build/html/ + return $? +} + +# Only update docs if we are on CircleCI. +if [[ "${CIRCLE_BRANCH}" == "master" ]] && [[ -z "${CIRCLE_PR_NUMBER}" ]]; then + echo "Building new docs on a merged commit." +elif [[ "$1" == "kokoro" ]]; then + echo "Building and publishing docs on Kokoro." +elif [[ -n "${CIRCLE_TAG}" ]]; then + echo "Building new docs on a tag (but will not deploy)." + build_docs + exit $? +else + echo "Not on master nor a release tag." + echo "Building new docs for testing purposes, but not deploying." + build_docs + exit $? +fi + +# Adding GitHub pages branch. `git submodule add` checks it +# out at HEAD. +GH_PAGES_DIR='ghpages' +git submodule add -q -b gh-pages \ + "git@github.com:${GH_OWNER}/${GH_PROJECT_NAME}" ${GH_PAGES_DIR} + +# Determine if we are building a new tag or are building docs +# for master. Then build new docs in docs/_build from master. +if [[ -n "${CIRCLE_TAG}" ]]; then + # Sphinx will use the package version by default. + build_docs +else + SPHINX_RELEASE=$(git log -1 --pretty=%h) build_docs +fi + +# Update gh-pages with the created docs. +cd ${GH_PAGES_DIR} +git rm -fr latest/ +cp -R ../docs/_build/html/ latest/ + +# Update the files push to gh-pages. +git add . +git status + +# If there are no changes, just exit cleanly. +if [[ -z "$(git status --porcelain)" ]]; then + echo "Nothing to commit. Exiting without pushing changes." + exit +fi + +# Commit to gh-pages branch to apply changes. +git config --global user.email "dpebot@google.com" +git config --global user.name "dpebot" +git commit -m "Update docs after merge to master." + +# NOTE: This may fail if two docs updates (on merges to master) +# happen in close proximity. +git push -q origin HEAD:gh-pages diff --git a/test_utils/setup.py b/test_utils/setup.py new file mode 100644 index 00000000..8e9222a7 --- /dev/null +++ b/test_utils/setup.py @@ -0,0 +1,64 @@ +# 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. + +import os + +from setuptools import find_packages +from setuptools import setup + + +PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) + + +# NOTE: This is duplicated throughout and we should try to +# consolidate. +SETUP_BASE = { + 'author': 'Google Cloud Platform', + 'author_email': 'googleapis-publisher@google.com', + 'scripts': [], + 'url': 'https://github.com/GoogleCloudPlatform/google-cloud-python', + 'license': 'Apache 2.0', + 'platforms': 'Posix; MacOS X; Windows', + 'include_package_data': True, + 'zip_safe': False, + 'classifiers': [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Topic :: Internet', + ], +} + + +REQUIREMENTS = [ + 'google-auth >= 0.4.0', + 'six', +] + +setup( + name='google-cloud-testutils', + version='0.24.0', + description='System test utilities for google-cloud-python', + packages=find_packages(), + install_requires=REQUIREMENTS, + python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', + **SETUP_BASE +) diff --git a/test_utils/test_utils/__init__.py b/test_utils/test_utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test_utils/test_utils/imports.py b/test_utils/test_utils/imports.py new file mode 100644 index 00000000..5991af7f --- /dev/null +++ b/test_utils/test_utils/imports.py @@ -0,0 +1,38 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import mock +import six + + +def maybe_fail_import(predicate): + """Create and return a patcher that conditionally makes an import fail. + + Args: + predicate (Callable[[...], bool]): A callable that, if it returns `True`, + triggers an `ImportError`. It must accept the same arguments as the + built-in `__import__` function. + https://docs.python.org/3/library/functions.html#__import__ + + Returns: + A mock patcher object that can be used to enable patched import behavior. + """ + orig_import = six.moves.builtins.__import__ + + def custom_import(name, globals=None, locals=None, fromlist=(), level=0): + if predicate(name, globals, locals, fromlist, level): + raise ImportError + return orig_import(name, globals, locals, fromlist, level) + + return mock.patch.object(six.moves.builtins, "__import__", new=custom_import) diff --git a/test_utils/test_utils/retry.py b/test_utils/test_utils/retry.py new file mode 100644 index 00000000..e61c001a --- /dev/null +++ b/test_utils/test_utils/retry.py @@ -0,0 +1,207 @@ +# Copyright 2016 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import time +from functools import wraps + +import six + +MAX_TRIES = 4 +DELAY = 1 +BACKOFF = 2 + + +def _retry_all(_): + """Retry all caught exceptions.""" + return True + + +class BackoffFailed(Exception): + """Retry w/ backoffs did not complete successfully.""" + + +class RetryBase(object): + """Base for retrying calling a decorated function w/ exponential backoff. + + :type max_tries: int + :param max_tries: Number of times to try (not retry) before giving up. + + :type delay: int + :param delay: Initial delay between retries in seconds. + + :type backoff: int + :param backoff: Backoff multiplier e.g. value of 2 will double the + delay each retry. + + :type logger: logging.Logger instance + :param logger: Logger to use. If None, print. + """ + def __init__(self, max_tries=MAX_TRIES, delay=DELAY, backoff=BACKOFF, + logger=None): + self.max_tries = max_tries + self.delay = delay + self.backoff = backoff + self.logger = logger.warning if logger else six.print_ + + +class RetryErrors(RetryBase): + """Decorator for retrying given exceptions in testing. + + :type exception: Exception or tuple of Exceptions + :param exception: The exception to check or may be a tuple of + exceptions to check. + + :type error_predicate: function, takes caught exception, returns bool + :param error_predicate: Predicate evaluating whether to retry after a + caught exception. + + :type max_tries: int + :param max_tries: Number of times to try (not retry) before giving up. + + :type delay: int + :param delay: Initial delay between retries in seconds. + + :type backoff: int + :param backoff: Backoff multiplier e.g. value of 2 will double the + delay each retry. + + :type logger: logging.Logger instance + :param logger: Logger to use. If None, print. + """ + def __init__(self, exception, error_predicate=_retry_all, + max_tries=MAX_TRIES, delay=DELAY, backoff=BACKOFF, + logger=None): + super(RetryErrors, self).__init__(max_tries, delay, backoff, logger) + self.exception = exception + self.error_predicate = error_predicate + + def __call__(self, to_wrap): + @wraps(to_wrap) + def wrapped_function(*args, **kwargs): + tries = 0 + while tries < self.max_tries: + try: + return to_wrap(*args, **kwargs) + except self.exception as caught_exception: + + if not self.error_predicate(caught_exception): + raise + + delay = self.delay * self.backoff**tries + msg = ("%s, Trying again in %d seconds..." % + (caught_exception, delay)) + self.logger(msg) + + time.sleep(delay) + tries += 1 + return to_wrap(*args, **kwargs) + + return wrapped_function + + +class RetryResult(RetryBase): + """Decorator for retrying based on non-error result. + + :type result_predicate: function, takes result, returns bool + :param result_predicate: Predicate evaluating whether to retry after a + result is returned. + + :type max_tries: int + :param max_tries: Number of times to try (not retry) before giving up. + + :type delay: int + :param delay: Initial delay between retries in seconds. + + :type backoff: int + :param backoff: Backoff multiplier e.g. value of 2 will double the + delay each retry. + + :type logger: logging.Logger instance + :param logger: Logger to use. If None, print. + """ + def __init__(self, result_predicate, + max_tries=MAX_TRIES, delay=DELAY, backoff=BACKOFF, + logger=None): + super(RetryResult, self).__init__(max_tries, delay, backoff, logger) + self.result_predicate = result_predicate + + def __call__(self, to_wrap): + @wraps(to_wrap) + def wrapped_function(*args, **kwargs): + tries = 0 + while tries < self.max_tries: + result = to_wrap(*args, **kwargs) + if self.result_predicate(result): + return result + + delay = self.delay * self.backoff**tries + msg = "%s. Trying again in %d seconds..." % ( + self.result_predicate.__name__, delay,) + self.logger(msg) + + time.sleep(delay) + tries += 1 + raise BackoffFailed() + + return wrapped_function + + +class RetryInstanceState(RetryBase): + """Decorator for retrying based on instance state. + + :type instance_predicate: function, takes instance, returns bool + :param instance_predicate: Predicate evaluating whether to retry after an + API-invoking method is called. + + :type max_tries: int + :param max_tries: Number of times to try (not retry) before giving up. + + :type delay: int + :param delay: Initial delay between retries in seconds. + + :type backoff: int + :param backoff: Backoff multiplier e.g. value of 2 will double the + delay each retry. + + :type logger: logging.Logger instance + :param logger: Logger to use. If None, print. + """ + def __init__(self, instance_predicate, + max_tries=MAX_TRIES, delay=DELAY, backoff=BACKOFF, + logger=None): + super(RetryInstanceState, self).__init__( + max_tries, delay, backoff, logger) + self.instance_predicate = instance_predicate + + def __call__(self, to_wrap): + instance = to_wrap.__self__ # only instance methods allowed + + @wraps(to_wrap) + def wrapped_function(*args, **kwargs): + tries = 0 + while tries < self.max_tries: + result = to_wrap(*args, **kwargs) + if self.instance_predicate(instance): + return result + + delay = self.delay * self.backoff**tries + msg = "%s. Trying again in %d seconds..." % ( + self.instance_predicate.__name__, delay,) + self.logger(msg) + + time.sleep(delay) + tries += 1 + raise BackoffFailed() + + return wrapped_function diff --git a/test_utils/test_utils/system.py b/test_utils/test_utils/system.py new file mode 100644 index 00000000..590dc62a --- /dev/null +++ b/test_utils/test_utils/system.py @@ -0,0 +1,81 @@ +# Copyright 2014 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 print_function +import os +import sys +import time + +import google.auth.credentials +from google.auth.environment_vars import CREDENTIALS as TEST_CREDENTIALS + + +# From shell environ. May be None. +CREDENTIALS = os.getenv(TEST_CREDENTIALS) + +ENVIRON_ERROR_MSG = """\ +To run the system tests, you need to set some environment variables. +Please check the CONTRIBUTING guide for instructions. +""" + + +class EmulatorCreds(google.auth.credentials.Credentials): + """A mock credential object. + + Used to avoid unnecessary token refreshing or reliance on the network + while an emulator is running. + """ + + def __init__(self): # pylint: disable=super-init-not-called + self.token = b'seekrit' + self.expiry = None + + @property + def valid(self): + """Would-be validity check of the credentials. + + Always is :data:`True`. + """ + return True + + def refresh(self, unused_request): # pylint: disable=unused-argument + """Off-limits implementation for abstract method.""" + raise RuntimeError('Should never be refreshed.') + + +def check_environ(): + err_msg = None + if CREDENTIALS is None: + err_msg = '\nMissing variables: ' + TEST_CREDENTIALS + elif not os.path.isfile(CREDENTIALS): + err_msg = '\nThe %s path %r is not a file.' % (TEST_CREDENTIALS, + CREDENTIALS) + + if err_msg is not None: + msg = ENVIRON_ERROR_MSG + err_msg + print(msg, file=sys.stderr) + sys.exit(1) + + +def unique_resource_id(delimiter='_'): + """A unique identifier for a resource. + + Intended to help locate resources created in particular + testing environments and at particular times. + """ + build_id = os.getenv('CIRCLE_BUILD_NUM', '') + if build_id == '': + return '%s%d' % (delimiter, 1000 * time.time()) + else: + return '%s%s%s%d' % (delimiter, build_id, delimiter, time.time()) diff --git a/test_utils/test_utils/vpcsc_config.py b/test_utils/test_utils/vpcsc_config.py new file mode 100644 index 00000000..36b15d6b --- /dev/null +++ b/test_utils/test_utils/vpcsc_config.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 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. + +import os + +import pytest + + +INSIDE_VPCSC_ENVVAR = "GOOGLE_CLOUD_TESTS_IN_VPCSC" +PROJECT_INSIDE_ENVVAR = "PROJECT_ID" +PROJECT_OUTSIDE_ENVVAR = "GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT" +BUCKET_OUTSIDE_ENVVAR = "GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_BUCKET" + + +class VPCSCTestConfig(object): + """System test utility for VPCSC detection. + + See: https://cloud.google.com/vpc-service-controls/docs/ + """ + + @property + def inside_vpcsc(self): + """Test whether the test environment is configured to run inside VPCSC. + + Returns: + bool: + true if the environment is configured to run inside VPCSC, + else false. + """ + return INSIDE_VPCSC_ENVVAR in os.environ + + @property + def project_inside(self): + """Project ID for testing outside access. + + Returns: + str: project ID used for testing outside access; None if undefined. + """ + return os.environ.get(PROJECT_INSIDE_ENVVAR, None) + + @property + def project_outside(self): + """Project ID for testing inside access. + + Returns: + str: project ID used for testing inside access; None if undefined. + """ + return os.environ.get(PROJECT_OUTSIDE_ENVVAR, None) + + @property + def bucket_outside(self): + """GCS bucket for testing inside access. + + Returns: + str: bucket ID used for testing inside access; None if undefined. + """ + return os.environ.get(BUCKET_OUTSIDE_ENVVAR, None) + + def skip_if_inside_vpcsc(self, testcase): + """Test decorator: skip if running inside VPCSC.""" + reason = ( + "Running inside VPCSC. " + "Unset the {} environment variable to enable this test." + ).format(INSIDE_VPCSC_ENVVAR) + skip = pytest.mark.skipif(self.inside_vpcsc, reason=reason) + return skip(testcase) + + def skip_unless_inside_vpcsc(self, testcase): + """Test decorator: skip if running outside VPCSC.""" + reason = ( + "Running outside VPCSC. " + "Set the {} environment variable to enable this test." + ).format(INSIDE_VPCSC_ENVVAR) + skip = pytest.mark.skipif(not self.inside_vpcsc, reason=reason) + return skip(testcase) + + def skip_unless_inside_project(self, testcase): + """Test decorator: skip if inside project env var not set.""" + reason = ( + "Project ID for running inside VPCSC not set. " + "Set the {} environment variable to enable this test." + ).format(PROJECT_INSIDE_ENVVAR) + skip = pytest.mark.skipif(self.project_inside is None, reason=reason) + return skip(testcase) + + def skip_unless_outside_project(self, testcase): + """Test decorator: skip if outside project env var not set.""" + reason = ( + "Project ID for running outside VPCSC not set. " + "Set the {} environment variable to enable this test." + ).format(PROJECT_OUTSIDE_ENVVAR) + skip = pytest.mark.skipif(self.project_outside is None, reason=reason) + return skip(testcase) + + def skip_unless_outside_bucket(self, testcase): + """Test decorator: skip if outside bucket env var not set.""" + reason = ( + "Bucket ID for running outside VPCSC not set. " + "Set the {} environment variable to enable this test." + ).format(BUCKET_OUTSIDE_ENVVAR) + skip = pytest.mark.skipif(self.bucket_outside is None, reason=reason) + return skip(testcase) + + +vpcsc_config = VPCSCTestConfig() diff --git a/tests/unit/gapic/v1/test_asset_service_client_v1.py b/tests/unit/gapic/v1/test_asset_service_client_v1.py index 4f4b981d..582d8935 100644 --- a/tests/unit/gapic/v1/test_asset_service_client_v1.py +++ b/tests/unit/gapic/v1/test_asset_service_client_v1.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/v1beta1/test_asset_service_client_v1beta1.py b/tests/unit/gapic/v1beta1/test_asset_service_client_v1beta1.py index 7ade3e8d..060a0468 100644 --- a/tests/unit/gapic/v1beta1/test_asset_service_client_v1beta1.py +++ b/tests/unit/gapic/v1beta1/test_asset_service_client_v1beta1.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/v1p1beta1/test_asset_service_client_v1p1beta1.py b/tests/unit/gapic/v1p1beta1/test_asset_service_client_v1p1beta1.py index 04a649fd..8cecd6eb 100644 --- a/tests/unit/gapic/v1p1beta1/test_asset_service_client_v1p1beta1.py +++ b/tests/unit/gapic/v1p1beta1/test_asset_service_client_v1p1beta1.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -61,96 +61,6 @@ class CustomException(Exception): class TestAssetServiceClient(object): - def test_search_resources(self): - # Setup Expected Response - next_page_token = "" - results_element = {} - results = [results_element] - expected_response = {"next_page_token": next_page_token, "results": results} - expected_response = asset_service_pb2.SearchResourcesResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p1beta1.AssetServiceClient() - - # Setup Request - scope = "scope109264468" - - paged_list_response = client.search_resources(scope) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.results[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = asset_service_pb2.SearchResourcesRequest(scope=scope) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_search_resources_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p1beta1.AssetServiceClient() - - # Setup request - scope = "scope109264468" - - paged_list_response = client.search_resources(scope) - with pytest.raises(CustomException): - list(paged_list_response) - - def test_search_iam_policies(self): - # Setup Expected Response - next_page_token = "" - results_element = {} - results = [results_element] - expected_response = {"next_page_token": next_page_token, "results": results} - expected_response = asset_service_pb2.SearchIamPoliciesResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p1beta1.AssetServiceClient() - - # Setup Request - scope = "scope109264468" - - paged_list_response = client.search_iam_policies(scope) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.results[0] == resources[0] - - assert len(channel.requests) == 1 - expected_request = asset_service_pb2.SearchIamPoliciesRequest(scope=scope) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_search_iam_policies_exception(self): - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p1beta1.AssetServiceClient() - - # Setup request - scope = "scope109264468" - - paged_list_response = client.search_iam_policies(scope) - with pytest.raises(CustomException): - list(paged_list_response) - def test_search_all_resources(self): # Setup Expected Response next_page_token = "" diff --git a/tests/unit/gapic/v1p2beta1/test_asset_service_client_v1p2beta1.py b/tests/unit/gapic/v1p2beta1/test_asset_service_client_v1p2beta1.py index b893a5d2..539d0fda 100644 --- a/tests/unit/gapic/v1p2beta1/test_asset_service_client_v1p2beta1.py +++ b/tests/unit/gapic/v1p2beta1/test_asset_service_client_v1p2beta1.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,12 +19,8 @@ import mock import pytest -from google.rpc import status_pb2 - from google.cloud import asset_v1p2beta1 -from google.cloud.asset_v1p2beta1 import enums from google.cloud.asset_v1p2beta1.proto import asset_service_pb2 -from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 from google.protobuf import field_mask_pb2 @@ -66,105 +62,6 @@ class CustomException(Exception): class TestAssetServiceClient(object): - def test_export_assets(self): - # Setup Expected Response - expected_response = {} - expected_response = asset_service_pb2.ExportAssetsResponse(**expected_response) - operation = operations_pb2.Operation( - name="operations/test_export_assets", done=True - ) - operation.response.Pack(expected_response) - - # Mock the API response - channel = ChannelStub(responses=[operation]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p2beta1.AssetServiceClient() - - # Setup Request - parent = "parent-995424086" - output_config = {} - - response = client.export_assets(parent, output_config) - result = response.result() - assert expected_response == result - - assert len(channel.requests) == 1 - expected_request = asset_service_pb2.ExportAssetsRequest( - parent=parent, output_config=output_config - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_export_assets_exception(self): - # Setup Response - error = status_pb2.Status() - operation = operations_pb2.Operation( - name="operations/test_export_assets_exception", done=True - ) - operation.error.CopyFrom(error) - - # Mock the API response - channel = ChannelStub(responses=[operation]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p2beta1.AssetServiceClient() - - # Setup Request - parent = "parent-995424086" - output_config = {} - - response = client.export_assets(parent, output_config) - exception = response.exception() - assert exception.errors[0] == error - - def test_batch_get_assets_history(self): - # Setup Expected Response - expected_response = {} - expected_response = asset_service_pb2.BatchGetAssetsHistoryResponse( - **expected_response - ) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p2beta1.AssetServiceClient() - - # Setup Request - parent = "parent-995424086" - asset_names = [] - content_type = enums.ContentType.CONTENT_TYPE_UNSPECIFIED - - response = client.batch_get_assets_history(parent, asset_names, content_type) - assert expected_response == response - - assert len(channel.requests) == 1 - expected_request = asset_service_pb2.BatchGetAssetsHistoryRequest( - parent=parent, asset_names=asset_names, content_type=content_type - ) - actual_request = channel.requests[0][1] - assert expected_request == actual_request - - def test_batch_get_assets_history_exception(self): - # Mock the API response - channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch("google.api_core.grpc_helpers.create_channel") - with patch as create_channel: - create_channel.return_value = channel - client = asset_v1p2beta1.AssetServiceClient() - - # Setup request - parent = "parent-995424086" - asset_names = [] - content_type = enums.ContentType.CONTENT_TYPE_UNSPECIFIED - - with pytest.raises(CustomException): - client.batch_get_assets_history(parent, asset_names, content_type) - def test_create_feed(self): # Setup Expected Response name = "name3373707"