diff --git a/.kokoro/continuous/recommender.cfg b/.kokoro/continuous/recommender.cfg new file mode 100644 index 000000000000..7d65909e6343 --- /dev/null +++ b/.kokoro/continuous/recommender.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell the trampoline which build file to use. +env_vars: { + key: "PACKAGE" + value: "recommender" +} diff --git a/.kokoro/docs/recommender.cfg b/.kokoro/docs/recommender.cfg new file mode 100644 index 000000000000..7d65909e6343 --- /dev/null +++ b/.kokoro/docs/recommender.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell the trampoline which build file to use. +env_vars: { + key: "PACKAGE" + value: "recommender" +} diff --git a/.kokoro/presubmit/recommender.cfg b/.kokoro/presubmit/recommender.cfg new file mode 100644 index 000000000000..7d65909e6343 --- /dev/null +++ b/.kokoro/presubmit/recommender.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell the trampoline which build file to use. +env_vars: { + key: "PACKAGE" + value: "recommender" +} diff --git a/.kokoro/release/recommender.cfg b/.kokoro/release/recommender.cfg new file mode 100644 index 000000000000..7d65909e6343 --- /dev/null +++ b/.kokoro/release/recommender.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell the trampoline which build file to use. +env_vars: { + key: "PACKAGE" + value: "recommender" +} diff --git a/recommender/.coveragerc b/recommender/.coveragerc new file mode 100644 index 000000000000..b178b094aa1d --- /dev/null +++ b/recommender/.coveragerc @@ -0,0 +1,19 @@ +# Generated by synthtool. DO NOT EDIT! +[run] +branch = True + +[report] +fail_under = 100 +show_missing = True +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore abstract methods + raise NotImplementedError +omit = + */gapic/*.py + */proto/*.py + */core/*.py + */site-packages/*.py \ No newline at end of file diff --git a/recommender/.flake8 b/recommender/.flake8 new file mode 100644 index 000000000000..0268ecc9c55c --- /dev/null +++ b/recommender/.flake8 @@ -0,0 +1,14 @@ +# Generated by synthtool. DO NOT EDIT! +[flake8] +ignore = E203, E266, E501, W503 +exclude = + # Exclude generated code. + **/proto/** + **/gapic/** + *_pb2.py + + # Standard linting exemptions. + __pycache__, + .git, + *.pyc, + conf.py diff --git a/recommender/.repo-metadata.json b/recommender/.repo-metadata.json new file mode 100644 index 000000000000..b3598c302da7 --- /dev/null +++ b/recommender/.repo-metadata.json @@ -0,0 +1,13 @@ +{ + "name": "recommender", + "name_pretty": "Cloud Recommender API", + "product_documentation": "https://cloud.google.com/recommender", + "client_documentation": "https://googleapis.dev/python/recommender/latest", + "issue_tracker": "", + "release_level": "alpha", + "language": "python", + "repo": "googleapis/google-cloud-python", + "distribution_name": "google-cloud-recommender", + "api_id": "recommender.googleapis.com", + "requires_billing": true +} \ No newline at end of file diff --git a/recommender/LICENSE b/recommender/LICENSE new file mode 100644 index 000000000000..a8ee855de2aa --- /dev/null +++ b/recommender/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/recommender/MANIFEST.in b/recommender/MANIFEST.in new file mode 100644 index 000000000000..9cbf175afe6b --- /dev/null +++ b/recommender/MANIFEST.in @@ -0,0 +1,5 @@ +include README.rst LICENSE +recursive-include google *.json *.proto +recursive-include tests * +global-exclude *.py[co] +global-exclude __pycache__ diff --git a/recommender/README.rst b/recommender/README.rst new file mode 100644 index 000000000000..bfa5e7bfd58d --- /dev/null +++ b/recommender/README.rst @@ -0,0 +1,80 @@ +Python Client for Recommender API (`Alpha`_) +============================================ + +`Recommender API`_: + +- `Client Library Documentation`_ +- `Product Documentation`_ + +.. _Alpha: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _Recommender API: https://cloud.google.com/recommender +.. _Client Library Documentation: https://googleapis.github.io/google-cloud-python/latest/recommender/usage.html +.. _Product Documentation: https://cloud.google.com/recommender/docs + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. `Enable the Recommender API.`_ +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Enable the Recommender API.: https://cloud.google.com/recommender +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Supported Python Versions +^^^^^^^^^^^^^^^^^^^^^^^^^ +Python >= 3.5 + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + source /bin/activate + /bin/pip install google-cloud-recommender + + +Windows +^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + \Scripts\activate + \Scripts\pip.exe install google-cloud-recommender + +Next Steps +~~~~~~~~~~ + +- Read the `Client Library Documentation`_ for Recommender API + API to see other available methods on the client. +- Read the `Recommender API Product documentation`_ to learn + more about the product and see How-to Guides. +- View this `repository’s main README`_ to see the full list of Cloud + APIs that we cover. + +.. _Recommender API Product documentation: https://cloud.google.com/recommender +.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst \ No newline at end of file diff --git a/recommender/docs/README.rst b/recommender/docs/README.rst new file mode 120000 index 000000000000..89a0106941ff --- /dev/null +++ b/recommender/docs/README.rst @@ -0,0 +1 @@ +../README.rst \ No newline at end of file diff --git a/recommender/docs/conf.py b/recommender/docs/conf.py new file mode 100644 index 000000000000..ba1f5d62862c --- /dev/null +++ b/recommender/docs/conf.py @@ -0,0 +1,363 @@ +# -*- coding: utf-8 -*- +# +# google-cloud-recommender documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "1.6.3" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = u"google-cloud-recommender" +copyright = u"2017, Google" +author = u"Google APIs" + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# 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 +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = [] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-recommender-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', + # Latex figure (float) alignment + #'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "google-cloud-recommender.tex", + u"google-cloud-recommender Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "google-cloud-recommender", + u"google-cloud-recommender Documentation", + [author], + 1, + ) +] + +# 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 +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "google-cloud-recommender", + u"google-cloud-recommender Documentation", + author, + "google-cloud-recommender", + "GAPIC library for the {metadata.shortName} v1beta1 service", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# 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), + "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 +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/recommender/docs/gapic/v1beta1/api.rst b/recommender/docs/gapic/v1beta1/api.rst new file mode 100644 index 000000000000..d9458d258e2a --- /dev/null +++ b/recommender/docs/gapic/v1beta1/api.rst @@ -0,0 +1,6 @@ +Client for Recommender API +========================== + +.. automodule:: google.cloud.recommender_v1beta1 + :members: + :inherited-members: \ No newline at end of file diff --git a/recommender/docs/gapic/v1beta1/types.rst b/recommender/docs/gapic/v1beta1/types.rst new file mode 100644 index 000000000000..3771da42e95f --- /dev/null +++ b/recommender/docs/gapic/v1beta1/types.rst @@ -0,0 +1,5 @@ +Types for Recommender API Client +================================ + +.. automodule:: google.cloud.recommender_v1beta1.types + :members: \ No newline at end of file diff --git a/recommender/docs/index.rst b/recommender/docs/index.rst new file mode 100644 index 000000000000..37c319bfaffe --- /dev/null +++ b/recommender/docs/index.rst @@ -0,0 +1,9 @@ +.. include:: README.rst + +Api Reference +------------- +.. toctree:: + :maxdepth: 2 + + gapic/v1beta1/api + gapic/v1beta1/types \ No newline at end of file diff --git a/recommender/google/__init__.py b/recommender/google/__init__.py new file mode 100644 index 000000000000..8fcc60e2b9c6 --- /dev/null +++ b/recommender/google/__init__.py @@ -0,0 +1,24 @@ +# -*- 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. + +try: + import pkg_resources + + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/recommender/google/cloud/__init__.py b/recommender/google/cloud/__init__.py new file mode 100644 index 000000000000..8fcc60e2b9c6 --- /dev/null +++ b/recommender/google/cloud/__init__.py @@ -0,0 +1,24 @@ +# -*- 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. + +try: + import pkg_resources + + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/recommender/google/cloud/recommender.py b/recommender/google/cloud/recommender.py new file mode 100644 index 000000000000..3caae5792568 --- /dev/null +++ b/recommender/google/cloud/recommender.py @@ -0,0 +1,25 @@ +# -*- 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. + + +from __future__ import absolute_import + +from google.cloud.recommender_v1beta1 import RecommenderClient +from google.cloud.recommender_v1beta1 import enums +from google.cloud.recommender_v1beta1 import types + + +__all__ = ("enums", "types", "RecommenderClient") diff --git a/recommender/google/cloud/recommender_v1beta1/__init__.py b/recommender/google/cloud/recommender_v1beta1/__init__.py new file mode 100644 index 000000000000..2ea08cfa4d18 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/__init__.py @@ -0,0 +1,30 @@ +# -*- 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. + + +from __future__ import absolute_import + +from google.cloud.recommender_v1beta1 import types +from google.cloud.recommender_v1beta1.gapic import enums +from google.cloud.recommender_v1beta1.gapic import recommender_client + + +class RecommenderClient(recommender_client.RecommenderClient): + __doc__ = recommender_client.RecommenderClient.__doc__ + enums = enums + + +__all__ = ("enums", "types", "RecommenderClient") diff --git a/recommender/google/cloud/recommender_v1beta1/gapic/__init__.py b/recommender/google/cloud/recommender_v1beta1/gapic/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/recommender/google/cloud/recommender_v1beta1/gapic/enums.py b/recommender/google/cloud/recommender_v1beta1/gapic/enums.py new file mode 100644 index 000000000000..5d7fbb6b7a31 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/gapic/enums.py @@ -0,0 +1,88 @@ +# -*- 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. + +"""Wrappers for protocol buffer enum types.""" + +import enum + + +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 + + +class Impact(object): + class Category(enum.IntEnum): + """ + The category of the impact. + + Attributes: + CATEGORY_UNSPECIFIED (int): Default unspecified category. Don't use directly. + COST (int): Indicates a potential increase or decrease in cost. + SECURITY (int): Indicates a potential increase or decrease in security. + PERFORMANCE (int): Indicates a potential increase or decrease in performance. + """ + + CATEGORY_UNSPECIFIED = 0 + COST = 1 + SECURITY = 2 + PERFORMANCE = 3 + + +class RecommendationStateInfo(object): + class State(enum.IntEnum): + """ + Represents Recommendation State + + Attributes: + STATE_UNSPECIFIED (int): Default state. Don't use directly. + ACTIVE (int): Recommendation is active and can be applied. Recommendations content can + be updated by Google. + + ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + CLAIMED (int): Recommendation is in claimed state. Recommendations content is + immutable and cannot be updated by Google. + + CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + SUCCEEDED (int): Recommendation is in succeeded state. Recommendations content is + immutable and cannot be updated by Google. + + SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. + FAILED (int): Recommendation is in failed state. Recommendations content is immutable + and cannot be updated by Google. + + FAILED recommendations can be marked as SUCCEEDED, or FAILED. + DISMISSED (int): Recommendation is in dismissed state. Recommendation content can be + updated by Google. + + DISMISSED recommendations can be marked as ACTIVE. + """ + + STATE_UNSPECIFIED = 0 + ACTIVE = 1 + CLAIMED = 6 + SUCCEEDED = 3 + FAILED = 4 + DISMISSED = 5 diff --git a/recommender/google/cloud/recommender_v1beta1/gapic/recommender_client.py b/recommender/google/cloud/recommender_v1beta1/gapic/recommender_client.py new file mode 100644 index 000000000000..deb485bb83f3 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/gapic/recommender_client.py @@ -0,0 +1,670 @@ +# -*- 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. + +"""Accesses the google.cloud.recommender.v1beta1 Recommender API.""" + +import functools +import pkg_resources +import warnings + +from google.oauth2 import service_account +import google.api_core.client_options +import google.api_core.gapic_v1.client_info +import google.api_core.gapic_v1.config +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.page_iterator +import google.api_core.path_template +import grpc + +from google.cloud.recommender_v1beta1.gapic import enums +from google.cloud.recommender_v1beta1.gapic import recommender_client_config +from google.cloud.recommender_v1beta1.gapic.transports import recommender_grpc_transport +from google.cloud.recommender_v1beta1.proto import recommendation_pb2 +from google.cloud.recommender_v1beta1.proto import recommender_service_pb2 +from google.cloud.recommender_v1beta1.proto import recommender_service_pb2_grpc + + +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( + "google-cloud-recommender" +).version + + +class RecommenderClient(object): + """ + Provides recommendations for cloud customers for various categories like + performance optimization, cost savings, reliability, feature discovery, etc. + These recommendations are generated automatically based on analysis of user + resources, configuration and monitoring metrics. + """ + + SERVICE_ADDRESS = "recommender.googleapis.com:443" + """The default address of the service.""" + + # The name of the interface for this client. This is the key used to + # find the method configuration in the client_config dictionary. + _INTERFACE_NAME = "google.cloud.recommender.v1beta1.Recommender" + + @classmethod + def from_service_account_file(cls, filename, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + RecommenderClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @classmethod + def recommendation_path(cls, project, location, recommender, recommendation): + """Return a fully-qualified recommendation string.""" + return google.api_core.path_template.expand( + "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}", + project=project, + location=location, + recommender=recommender, + recommendation=recommendation, + ) + + @classmethod + def recommender_path(cls, project, location, recommender): + """Return a fully-qualified recommender string.""" + return google.api_core.path_template.expand( + "projects/{project}/locations/{location}/recommenders/{recommender}", + project=project, + location=location, + recommender=recommender, + ) + + def __init__( + self, + transport=None, + channel=None, + credentials=None, + client_config=None, + client_info=None, + client_options=None, + ): + """Constructor. + + Args: + transport (Union[~.RecommenderGrpcTransport, + Callable[[~.Credentials, type], ~.RecommenderGrpcTransport]): A transport + instance, responsible for actually making the API calls. + The default transport uses the gRPC protocol. + This argument may also be a callable which returns a + transport instance. Callables will be sent the credentials + as the first argument and the default transport class as + the second argument. + channel (grpc.Channel): DEPRECATED. A ``Channel`` instance + through which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is mutually exclusive with providing a + transport instance to ``transport``; doing so will raise + an exception. + client_config (dict): DEPRECATED. A dictionary of call options for + each method. If not specified, the default configuration is used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + client_options (Union[dict, google.api_core.client_options.ClientOptions]): + Client options used to set user options on the client. API Endpoint + should be set through client_options. + """ + # Raise deprecation warnings for things we want to go away. + if client_config is not None: + warnings.warn( + "The `client_config` argument is deprecated.", + PendingDeprecationWarning, + stacklevel=2, + ) + else: + client_config = recommender_client_config.config + + if channel: + warnings.warn( + "The `channel` argument is deprecated; use " "`transport` instead.", + PendingDeprecationWarning, + stacklevel=2, + ) + + api_endpoint = self.SERVICE_ADDRESS + if client_options: + if type(client_options) == dict: + client_options = google.api_core.client_options.from_dict( + client_options + ) + if client_options.api_endpoint: + api_endpoint = client_options.api_endpoint + + # Instantiate the transport. + # The transport is responsible for handling serialization and + # deserialization and actually sending data to the service. + if transport: + if callable(transport): + self.transport = transport( + credentials=credentials, + default_class=recommender_grpc_transport.RecommenderGrpcTransport, + address=api_endpoint, + ) + else: + if credentials: + raise ValueError( + "Received both a transport instance and " + "credentials; these are mutually exclusive." + ) + self.transport = transport + else: + self.transport = recommender_grpc_transport.RecommenderGrpcTransport( + address=api_endpoint, channel=channel, credentials=credentials + ) + + if client_info is None: + client_info = google.api_core.gapic_v1.client_info.ClientInfo( + gapic_version=_GAPIC_LIBRARY_VERSION + ) + else: + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + self._client_info = client_info + + # Parse out the default settings for retry and timeout for each RPC + # from the client configuration. + # (Ordinarily, these are the defaults specified in the `*_config.py` + # file next to this one.) + self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config["interfaces"][self._INTERFACE_NAME] + ) + + # Save a dictionary of cached API call functions. + # These are the actual callables which invoke the proper + # transport methods, wrapped with `wrap_method` to add retry, + # timeout, and the like. + self._inner_api_calls = {} + + # Service calls + def list_recommendations( + self, + parent, + page_size=None, + filter_=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists recommendations for a Cloud project. Requires the + recommender.\*.list IAM permission for the specified recommender. + + Example: + >>> from google.cloud import recommender_v1beta1 + >>> + >>> client = recommender_v1beta1.RecommenderClient() + >>> + >>> parent = client.recommender_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]') + >>> + >>> # Iterate over all results + >>> for element in client.list_recommendations(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_recommendations(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. The container resource on which to execute the request. + Acceptable formats: + + 1. + + "projects/[PROJECT\_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER\_ID]", + + LOCATION here refers to GCP Locations: + https://cloud.google.com/about/locations/ + 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. + filter_ (str): Filter expression to restrict the recommendations returned. Supported + filter fields: state\_info.state Eg: \`state\_info.state:"DISMISSED" or + state\_info.state:"FAILED" + 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.recommender_v1beta1.types.Recommendation` 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 "list_recommendations" not in self._inner_api_calls: + self._inner_api_calls[ + "list_recommendations" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_recommendations, + default_retry=self._method_configs["ListRecommendations"].retry, + default_timeout=self._method_configs["ListRecommendations"].timeout, + client_info=self._client_info, + ) + + request = recommender_service_pb2.ListRecommendationsRequest( + parent=parent, page_size=page_size, filter=filter_ + ) + 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) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_recommendations"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="recommendations", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + + def get_recommendation( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Gets the requested recommendation. Requires the recommender.\*.get IAM + permission for the specified recommender. + + Example: + >>> from google.cloud import recommender_v1beta1 + >>> + >>> client = recommender_v1beta1.RecommenderClient() + >>> + >>> name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]') + >>> + >>> response = client.get_recommendation(name) + + Args: + name (str): Name of the recommendation. + 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.recommender_v1beta1.types.Recommendation` 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 "get_recommendation" not in self._inner_api_calls: + self._inner_api_calls[ + "get_recommendation" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_recommendation, + default_retry=self._method_configs["GetRecommendation"].retry, + default_timeout=self._method_configs["GetRecommendation"].timeout, + client_info=self._client_info, + ) + + request = recommender_service_pb2.GetRecommendationRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + 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["get_recommendation"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def mark_recommendation_claimed( + self, + name, + etag, + state_metadata=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Mark the Recommendation State as Claimed. Users can use this method to + indicate to the Recommender API that they are starting to apply the + recommendation themselves. This stops the recommendation content from + being updated. + + MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + SUCCEEDED, FAILED, or ACTIVE state. + + Requires the recommender.\*.update IAM permission for the specified + recommender. + + Example: + >>> from google.cloud import recommender_v1beta1 + >>> + >>> client = recommender_v1beta1.RecommenderClient() + >>> + >>> name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]') + >>> + >>> # TODO: Initialize `etag`: + >>> etag = '' + >>> + >>> response = client.mark_recommendation_claimed(name, etag) + + Args: + name (str): Name of the recommendation. + etag (str): Fingerprint of the Recommendation. Provides optimistic locking. + state_metadata (dict[str -> str]): State properties to include with this state. Overwrites any existing + ``state_metadata``. + 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.recommender_v1beta1.types.Recommendation` 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 "mark_recommendation_claimed" not in self._inner_api_calls: + self._inner_api_calls[ + "mark_recommendation_claimed" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.mark_recommendation_claimed, + default_retry=self._method_configs["MarkRecommendationClaimed"].retry, + default_timeout=self._method_configs[ + "MarkRecommendationClaimed" + ].timeout, + client_info=self._client_info, + ) + + request = recommender_service_pb2.MarkRecommendationClaimedRequest( + name=name, etag=etag, state_metadata=state_metadata + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + 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["mark_recommendation_claimed"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def mark_recommendation_succeeded( + self, + name, + etag, + state_metadata=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Mark the Recommendation State as Succeeded. Users can use this method to + indicate to the Recommender API that they have applied the + recommendation themselves, and the operation was successful. This stops + the recommendation content from being updated. + + MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + CLAIMED, SUCCEEDED, or FAILED state. + + Requires the recommender.\*.update IAM permission for the specified + recommender. + + Example: + >>> from google.cloud import recommender_v1beta1 + >>> + >>> client = recommender_v1beta1.RecommenderClient() + >>> + >>> name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]') + >>> + >>> # TODO: Initialize `etag`: + >>> etag = '' + >>> + >>> response = client.mark_recommendation_succeeded(name, etag) + + Args: + name (str): Name of the recommendation. + etag (str): Fingerprint of the Recommendation. Provides optimistic locking. + state_metadata (dict[str -> str]): State properties to include with this state. Overwrites any existing + ``state_metadata``. + 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.recommender_v1beta1.types.Recommendation` 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 "mark_recommendation_succeeded" not in self._inner_api_calls: + self._inner_api_calls[ + "mark_recommendation_succeeded" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.mark_recommendation_succeeded, + default_retry=self._method_configs["MarkRecommendationSucceeded"].retry, + default_timeout=self._method_configs[ + "MarkRecommendationSucceeded" + ].timeout, + client_info=self._client_info, + ) + + request = recommender_service_pb2.MarkRecommendationSucceededRequest( + name=name, etag=etag, state_metadata=state_metadata + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + 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["mark_recommendation_succeeded"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def mark_recommendation_failed( + self, + name, + etag, + state_metadata=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Mark the Recommendation State as Failed. Users can use this method to + indicate to the Recommender API that they have applied the + recommendation themselves, and the operation failed. This stops the + recommendation content from being updated. + + MarkRecommendationFailed can be applied to recommendations in ACTIVE, + CLAIMED, SUCCEEDED, or FAILED state. + + Requires the recommender.\*.update IAM permission for the specified + recommender. + + Example: + >>> from google.cloud import recommender_v1beta1 + >>> + >>> client = recommender_v1beta1.RecommenderClient() + >>> + >>> name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]') + >>> + >>> # TODO: Initialize `etag`: + >>> etag = '' + >>> + >>> response = client.mark_recommendation_failed(name, etag) + + Args: + name (str): Name of the recommendation. + etag (str): Fingerprint of the Recommendation. Provides optimistic locking. + state_metadata (dict[str -> str]): State properties to include with this state. Overwrites any existing + ``state_metadata``. + 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.recommender_v1beta1.types.Recommendation` 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 "mark_recommendation_failed" not in self._inner_api_calls: + self._inner_api_calls[ + "mark_recommendation_failed" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.mark_recommendation_failed, + default_retry=self._method_configs["MarkRecommendationFailed"].retry, + default_timeout=self._method_configs[ + "MarkRecommendationFailed" + ].timeout, + client_info=self._client_info, + ) + + request = recommender_service_pb2.MarkRecommendationFailedRequest( + name=name, etag=etag, state_metadata=state_metadata + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + 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["mark_recommendation_failed"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) diff --git a/recommender/google/cloud/recommender_v1beta1/gapic/recommender_client_config.py b/recommender/google/cloud/recommender_v1beta1/gapic/recommender_client_config.py new file mode 100644 index 000000000000..a1a36482eecd --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/gapic/recommender_client_config.py @@ -0,0 +1,48 @@ +config = { + "interfaces": { + "google.cloud.recommender.v1beta1.Recommender": { + "retry_codes": { + "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], + "non_idempotent": [], + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000, + } + }, + "methods": { + "ListRecommendations": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "GetRecommendation": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "MarkRecommendationClaimed": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "MarkRecommendationSucceeded": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "MarkRecommendationFailed": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + }, + } + } +} diff --git a/recommender/google/cloud/recommender_v1beta1/gapic/transports/__init__.py b/recommender/google/cloud/recommender_v1beta1/gapic/transports/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/recommender/google/cloud/recommender_v1beta1/gapic/transports/recommender_grpc_transport.py b/recommender/google/cloud/recommender_v1beta1/gapic/transports/recommender_grpc_transport.py new file mode 100644 index 000000000000..cc3af3d44211 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/gapic/transports/recommender_grpc_transport.py @@ -0,0 +1,202 @@ +# -*- 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 google.api_core.grpc_helpers + +from google.cloud.recommender_v1beta1.proto import recommender_service_pb2_grpc + + +class RecommenderGrpcTransport(object): + """gRPC transport class providing stubs for + google.cloud.recommender.v1beta1 Recommender API. + + The transport provides access to the raw gRPC stubs, + which can be used to take advantage of advanced + features of gRPC. + """ + + # The scopes needed to make gRPC calls to all of the methods defined + # in this service. + _OAUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + def __init__( + self, channel=None, credentials=None, address="recommender.googleapis.com:443" + ): + """Instantiate the transport class. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + address (str): The address where the service is hosted. + """ + # If both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). + if channel is not None and credentials is not None: + raise ValueError( + "The `channel` and `credentials` arguments are mutually " "exclusive." + ) + + # Create the channel. + if channel is None: + channel = self.create_channel( + address=address, + credentials=credentials, + options={ + "grpc.max_send_message_length": -1, + "grpc.max_receive_message_length": -1, + }.items(), + ) + + self._channel = channel + + # gRPC uses objects called "stubs" that are bound to the + # channel and provide a basic method for each RPC. + self._stubs = { + "recommender_stub": recommender_service_pb2_grpc.RecommenderStub(channel) + } + + @classmethod + def create_channel( + cls, address="recommender.googleapis.com:443", credentials=None, **kwargs + ): + """Create and return a gRPC channel object. + + Args: + address (str): The host for the channel to use. + credentials (~.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + kwargs (dict): Keyword arguments, which are passed to the + channel creation. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return google.api_core.grpc_helpers.create_channel( + address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs + ) + + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + + @property + def list_recommendations(self): + """Return the gRPC stub for :meth:`RecommenderClient.list_recommendations`. + + Lists recommendations for a Cloud project. Requires the + recommender.\*.list IAM permission for the specified recommender. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["recommender_stub"].ListRecommendations + + @property + def get_recommendation(self): + """Return the gRPC stub for :meth:`RecommenderClient.get_recommendation`. + + Gets the requested recommendation. Requires the recommender.\*.get IAM + permission for the specified recommender. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["recommender_stub"].GetRecommendation + + @property + def mark_recommendation_claimed(self): + """Return the gRPC stub for :meth:`RecommenderClient.mark_recommendation_claimed`. + + Mark the Recommendation State as Claimed. Users can use this method to + indicate to the Recommender API that they are starting to apply the + recommendation themselves. This stops the recommendation content from + being updated. + + MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + SUCCEEDED, FAILED, or ACTIVE state. + + Requires the recommender.\*.update IAM permission for the specified + recommender. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["recommender_stub"].MarkRecommendationClaimed + + @property + def mark_recommendation_succeeded(self): + """Return the gRPC stub for :meth:`RecommenderClient.mark_recommendation_succeeded`. + + Mark the Recommendation State as Succeeded. Users can use this method to + indicate to the Recommender API that they have applied the + recommendation themselves, and the operation was successful. This stops + the recommendation content from being updated. + + MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + CLAIMED, SUCCEEDED, or FAILED state. + + Requires the recommender.\*.update IAM permission for the specified + recommender. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["recommender_stub"].MarkRecommendationSucceeded + + @property + def mark_recommendation_failed(self): + """Return the gRPC stub for :meth:`RecommenderClient.mark_recommendation_failed`. + + Mark the Recommendation State as Failed. Users can use this method to + indicate to the Recommender API that they have applied the + recommendation themselves, and the operation failed. This stops the + recommendation content from being updated. + + MarkRecommendationFailed can be applied to recommendations in ACTIVE, + CLAIMED, SUCCEEDED, or FAILED state. + + Requires the recommender.\*.update IAM permission for the specified + recommender. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["recommender_stub"].MarkRecommendationFailed diff --git a/recommender/google/cloud/recommender_v1beta1/proto/__init__.py b/recommender/google/cloud/recommender_v1beta1/proto/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/recommender/google/cloud/recommender_v1beta1/proto/recommendation.proto b/recommender/google/cloud/recommender_v1beta1/proto/recommendation.proto new file mode 100644 index 000000000000..8980de0c4274 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/proto/recommendation.proto @@ -0,0 +1,234 @@ +// 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. +// + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/money.proto"; + +option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender"; +option java_multiple_files = true; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; + +// A recommendation along with a suggested action. E.g., a rightsizing +// recommendation for an underutilized VM, IAM role recommendations, etc +message Recommendation { + // Name of recommendation. + // + // A project recommendation is represented as + // projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID] + string name = 1; + + // Free-form human readable summary in English. The maximum length is 500 + // characters. + string description = 2; + + // Contains an identifier for a subtype of recommendations produced for the + // same recommender. Subtype is a function of content and impact, meaning a + // new subtype will be added when either content or primary impact category + // changes. + // + // Examples: + // For recommender = "google.iam.policy.RoleRecommender", + // recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE" + string recommender_subtype = 12; + + // Last time this recommendation was refreshed by the system that created it + // in the first place. + google.protobuf.Timestamp last_refresh_time = 4; + + // The primary impact that this recommendation can have while trying to + // optimize for one category. + Impact primary_impact = 5; + + // Optional set of additional impact that this recommendation may have when + // trying to optimize for the primary category. These may be positive + // or negative. + repeated Impact additional_impact = 6; + + // Content of the recommendation describing recommended changes to resources. + RecommendationContent content = 7; + + // Information for state. Contains state and metadata. + RecommendationStateInfo state_info = 10; + + // Fingerprint of the Recommendation. Provides optimistic locking when + // updating states. + string etag = 11; +} + +// Contains what resources are changing and how they are changing. +message RecommendationContent { + // Operations to one or more Google Cloud resources grouped in such a way + // that, all operations within one group are expected to be performed + // atomically and in an order. + repeated OperationGroup operation_groups = 2; +} + +// Group of operations that need to be performed atomically. +message OperationGroup { + // List of operations across one or more resources that belong to this group. + // Loosely based on RFC6902 and should be performed in the order they appear. + repeated Operation operations = 1; +} + +// Contains an operation for a resource inspired by the JSON-PATCH format with +// support for: +// * Custom filters for describing partial array patch. +// * Extended path values for describing nested arrays. +// * Custom fields for describing the resource for which the operation is being +// described. +// * Allows extension to custom operations not natively supported by RFC6902. +// See https://tools.ietf.org/html/rfc6902 for details on the original RFC. +message Operation { + // Type of this operation. Contains one of 'and', 'remove', 'replace', 'move', + // 'copy', 'test' and custom operations. This field is case-insensitive and + // always populated. + string action = 1; + + // Type of GCP resource being modified/tested. This field is always populated. + // Example: cloudresourcemanager.googleapis.com/Project, + // compute.googleapis.com/Instance + string resource_type = 2; + + // Contains the fully qualified resource name. This field is always populated. + // ex: //cloudresourcemanager.googleapis.com/projects/foo. + string resource = 3; + + // Path to the target field being operated on. If the operation is at the + // resource level, then path should be "/". This field is always populated. + string path = 4; + + // Can be set with action 'copy' to copy resource configuration across + // different resources of the same type. Example: A resource clone can be + // done via action = 'copy', path = "/", from = "/", + // source_resource = and resource_name = . + // This field is empty for all other values of `action`. + string source_resource = 5; + + // Can be set with action 'copy' or 'move' to indicate the source field within + // resource or source_resource, ignored if provided for other operation types. + string source_path = 6; + + // Value for the `path` field. Set if action is 'add'/'replace'/'test'. + google.protobuf.Value value = 7; + + // Set of filters to apply if `path` refers to array elements or nested array + // elements in order to narrow down to a single unique element that is being + // tested/modified. + // Note that this is intended to be an exact match per filter. + // Example: { + // "/versions/*/name" : "it-123" + // "/versions/*/targetSize/percent": 20 + // } + // Example: { + // "/bindings/*/role": "roles/admin" + // "/bindings/*/condition" : null + // } + // Example: { + // "/bindings/*/role": "roles/admin" + // "/bindings/*/members/*" : ["x@google.com", "y@google.com"] + // } + map path_filters = 8; +} + +// Contains metadata about how much money a recommendation can save or incur. +message CostProjection { + // An approximate projection on amount saved or amount incurred. Negative cost + // units indicate cost savings and positive cost units indicate increase. + // See google.type.Money documentation for positive/negative units. + google.type.Money cost = 1; + + // Duration for which this cost applies. + google.protobuf.Duration duration = 2; +} + +// Contains the impact a recommendation can have for a given category. +message Impact { + // The category of the impact. + enum Category { + // Default unspecified category. Don't use directly. + CATEGORY_UNSPECIFIED = 0; + + // Indicates a potential increase or decrease in cost. + COST = 1; + + // Indicates a potential increase or decrease in security. + SECURITY = 2; + + // Indicates a potential increase or decrease in performance. + PERFORMANCE = 3; + } + + // Category that is being targeted. + Category category = 1; + + // Contains projections (if any) for this category. + oneof projection { + // Use with CategoryType.COST + CostProjection cost_projection = 100; + } +} + +// Information for state. Contains state and metadata. +message RecommendationStateInfo { + // Represents Recommendation State + enum State { + // Default state. Don't use directly. + STATE_UNSPECIFIED = 0; + + // Recommendation is active and can be applied. Recommendations content can + // be updated by Google. + // + // ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + ACTIVE = 1; + + // Recommendation is in claimed state. Recommendations content is + // immutable and cannot be updated by Google. + // + // CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. + CLAIMED = 6; + + // Recommendation is in succeeded state. Recommendations content is + // immutable and cannot be updated by Google. + // + // SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. + SUCCEEDED = 3; + + // Recommendation is in failed state. Recommendations content is immutable + // and cannot be updated by Google. + // + // FAILED recommendations can be marked as SUCCEEDED, or FAILED. + FAILED = 4; + + // Recommendation is in dismissed state. Recommendation content can be + // updated by Google. + // + // DISMISSED recommendations can be marked as ACTIVE. + DISMISSED = 5; + } + + // The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. + State state = 1; + + // A map of metadata for the state, provided by user or automations systems. + map state_metadata = 2; +} diff --git a/recommender/google/cloud/recommender_v1beta1/proto/recommendation_pb2.py b/recommender/google/cloud/recommender_v1beta1/proto/recommendation_pb2.py new file mode 100644 index 000000000000..e7d5913a69a3 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/proto/recommendation_pb2.py @@ -0,0 +1,1119 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/recommender_v1beta1/proto/recommendation.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.type import money_pb2 as google_dot_type_dot_money__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/recommender_v1beta1/proto/recommendation.proto", + package="google.cloud.recommender.v1beta1", + syntax="proto3", + serialized_options=_b( + "\n$com.google.cloud.recommender.v1beta1P\001ZKgoogle.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender\242\002\004CREC\252\002 Google.Cloud.Recommender.V1Beta1" + ), + serialized_pb=_b( + '\n;google/cloud/recommender_v1beta1/proto/recommendation.proto\x12 google.cloud.recommender.v1beta1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x17google/type/money.proto"\xb5\x03\n\x0eRecommendation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x1b\n\x13recommender_subtype\x18\x0c \x01(\t\x12\x35\n\x11last_refresh_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\x0eprimary_impact\x18\x05 \x01(\x0b\x32(.google.cloud.recommender.v1beta1.Impact\x12\x43\n\x11\x61\x64\x64itional_impact\x18\x06 \x03(\x0b\x32(.google.cloud.recommender.v1beta1.Impact\x12H\n\x07\x63ontent\x18\x07 \x01(\x0b\x32\x37.google.cloud.recommender.v1beta1.RecommendationContent\x12M\n\nstate_info\x18\n \x01(\x0b\x32\x39.google.cloud.recommender.v1beta1.RecommendationStateInfo\x12\x0c\n\x04\x65tag\x18\x0b \x01(\t"c\n\x15RecommendationContent\x12J\n\x10operation_groups\x18\x02 \x03(\x0b\x32\x30.google.cloud.recommender.v1beta1.OperationGroup"Q\n\x0eOperationGroup\x12?\n\noperations\x18\x01 \x03(\x0b\x32+.google.cloud.recommender.v1beta1.Operation"\xc7\x02\n\tOperation\x12\x0e\n\x06\x61\x63tion\x18\x01 \x01(\t\x12\x15\n\rresource_type\x18\x02 \x01(\t\x12\x10\n\x08resource\x18\x03 \x01(\t\x12\x0c\n\x04path\x18\x04 \x01(\t\x12\x17\n\x0fsource_resource\x18\x05 \x01(\t\x12\x13\n\x0bsource_path\x18\x06 \x01(\t\x12%\n\x05value\x18\x07 \x01(\x0b\x32\x16.google.protobuf.Value\x12R\n\x0cpath_filters\x18\x08 \x03(\x0b\x32<.google.cloud.recommender.v1beta1.Operation.PathFiltersEntry\x1aJ\n\x10PathFiltersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12%\n\x05value\x18\x02 \x01(\x0b\x32\x16.google.protobuf.Value:\x02\x38\x01"_\n\x0e\x43ostProjection\x12 \n\x04\x63ost\x18\x01 \x01(\x0b\x32\x12.google.type.Money\x12+\n\x08\x64uration\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\xf7\x01\n\x06Impact\x12\x43\n\x08\x63\x61tegory\x18\x01 \x01(\x0e\x32\x31.google.cloud.recommender.v1beta1.Impact.Category\x12K\n\x0f\x63ost_projection\x18\x64 \x01(\x0b\x32\x30.google.cloud.recommender.v1beta1.CostProjectionH\x00"M\n\x08\x43\x61tegory\x12\x18\n\x14\x43\x41TEGORY_UNSPECIFIED\x10\x00\x12\x08\n\x04\x43OST\x10\x01\x12\x0c\n\x08SECURITY\x10\x02\x12\x0f\n\x0bPERFORMANCE\x10\x03\x42\x0c\n\nprojection"\xe8\x02\n\x17RecommendationStateInfo\x12N\n\x05state\x18\x01 \x01(\x0e\x32?.google.cloud.recommender.v1beta1.RecommendationStateInfo.State\x12\x64\n\x0estate_metadata\x18\x02 \x03(\x0b\x32L.google.cloud.recommender.v1beta1.RecommendationStateInfo.StateMetadataEntry\x1a\x34\n\x12StateMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"a\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\n\n\x06\x41\x43TIVE\x10\x01\x12\x0b\n\x07\x43LAIMED\x10\x06\x12\r\n\tSUCCEEDED\x10\x03\x12\n\n\x06\x46\x41ILED\x10\x04\x12\r\n\tDISMISSED\x10\x05\x42\x9f\x01\n$com.google.cloud.recommender.v1beta1P\x01ZKgoogle.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender\xa2\x02\x04\x43REC\xaa\x02 Google.Cloud.Recommender.V1Beta1b\x06proto3' + ), + dependencies=[ + google_dot_protobuf_dot_duration__pb2.DESCRIPTOR, + google_dot_protobuf_dot_struct__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + google_dot_type_dot_money__pb2.DESCRIPTOR, + ], +) + + +_IMPACT_CATEGORY = _descriptor.EnumDescriptor( + name="Category", + full_name="google.cloud.recommender.v1beta1.Impact.Category", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="CATEGORY_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="COST", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="SECURITY", index=2, number=2, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="PERFORMANCE", index=3, number=3, serialized_options=None, type=None + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=1425, + serialized_end=1502, +) +_sym_db.RegisterEnumDescriptor(_IMPACT_CATEGORY) + +_RECOMMENDATIONSTATEINFO_STATE = _descriptor.EnumDescriptor( + name="State", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo.State", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="STATE_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="ACTIVE", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="CLAIMED", index=2, number=6, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="SUCCEEDED", index=3, number=3, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="FAILED", index=4, number=4, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="DISMISSED", index=5, number=5, serialized_options=None, type=None + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=1782, + serialized_end=1879, +) +_sym_db.RegisterEnumDescriptor(_RECOMMENDATIONSTATEINFO_STATE) + + +_RECOMMENDATION = _descriptor.Descriptor( + name="Recommendation", + full_name="google.cloud.recommender.v1beta1.Recommendation", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.recommender.v1beta1.Recommendation.name", + 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="description", + full_name="google.cloud.recommender.v1beta1.Recommendation.description", + 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="recommender_subtype", + full_name="google.cloud.recommender.v1beta1.Recommendation.recommender_subtype", + index=2, + number=12, + 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="last_refresh_time", + full_name="google.cloud.recommender.v1beta1.Recommendation.last_refresh_time", + 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, + ), + _descriptor.FieldDescriptor( + name="primary_impact", + full_name="google.cloud.recommender.v1beta1.Recommendation.primary_impact", + 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, + ), + _descriptor.FieldDescriptor( + name="additional_impact", + full_name="google.cloud.recommender.v1beta1.Recommendation.additional_impact", + index=5, + number=6, + 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="content", + full_name="google.cloud.recommender.v1beta1.Recommendation.content", + 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, + ), + _descriptor.FieldDescriptor( + name="state_info", + full_name="google.cloud.recommender.v1beta1.Recommendation.state_info", + index=7, + number=10, + 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="etag", + full_name="google.cloud.recommender.v1beta1.Recommendation.etag", + index=8, + number=11, + 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=218, + serialized_end=655, +) + + +_RECOMMENDATIONCONTENT = _descriptor.Descriptor( + name="RecommendationContent", + full_name="google.cloud.recommender.v1beta1.RecommendationContent", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="operation_groups", + full_name="google.cloud.recommender.v1beta1.RecommendationContent.operation_groups", + index=0, + number=2, + 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=657, + serialized_end=756, +) + + +_OPERATIONGROUP = _descriptor.Descriptor( + name="OperationGroup", + full_name="google.cloud.recommender.v1beta1.OperationGroup", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="operations", + full_name="google.cloud.recommender.v1beta1.OperationGroup.operations", + 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=758, + serialized_end=839, +) + + +_OPERATION_PATHFILTERSENTRY = _descriptor.Descriptor( + name="PathFiltersEntry", + full_name="google.cloud.recommender.v1beta1.Operation.PathFiltersEntry", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="key", + full_name="google.cloud.recommender.v1beta1.Operation.PathFiltersEntry.key", + 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="value", + full_name="google.cloud.recommender.v1beta1.Operation.PathFiltersEntry.value", + 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=_b("8\001"), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1095, + serialized_end=1169, +) + +_OPERATION = _descriptor.Descriptor( + name="Operation", + full_name="google.cloud.recommender.v1beta1.Operation", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="action", + full_name="google.cloud.recommender.v1beta1.Operation.action", + 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="resource_type", + full_name="google.cloud.recommender.v1beta1.Operation.resource_type", + 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="resource", + full_name="google.cloud.recommender.v1beta1.Operation.resource", + index=2, + 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=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="path", + full_name="google.cloud.recommender.v1beta1.Operation.path", + index=3, + 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=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="source_resource", + full_name="google.cloud.recommender.v1beta1.Operation.source_resource", + 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=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="source_path", + full_name="google.cloud.recommender.v1beta1.Operation.source_path", + index=5, + number=6, + 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="value", + full_name="google.cloud.recommender.v1beta1.Operation.value", + 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, + ), + _descriptor.FieldDescriptor( + name="path_filters", + full_name="google.cloud.recommender.v1beta1.Operation.path_filters", + index=7, + number=8, + 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=[_OPERATION_PATHFILTERSENTRY], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=842, + serialized_end=1169, +) + + +_COSTPROJECTION = _descriptor.Descriptor( + name="CostProjection", + full_name="google.cloud.recommender.v1beta1.CostProjection", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="cost", + full_name="google.cloud.recommender.v1beta1.CostProjection.cost", + 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="duration", + full_name="google.cloud.recommender.v1beta1.CostProjection.duration", + 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=1171, + serialized_end=1266, +) + + +_IMPACT = _descriptor.Descriptor( + name="Impact", + full_name="google.cloud.recommender.v1beta1.Impact", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="category", + full_name="google.cloud.recommender.v1beta1.Impact.category", + index=0, + number=1, + 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="cost_projection", + full_name="google.cloud.recommender.v1beta1.Impact.cost_projection", + index=1, + number=100, + 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=[_IMPACT_CATEGORY], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name="projection", + full_name="google.cloud.recommender.v1beta1.Impact.projection", + index=0, + containing_type=None, + fields=[], + ) + ], + serialized_start=1269, + serialized_end=1516, +) + + +_RECOMMENDATIONSTATEINFO_STATEMETADATAENTRY = _descriptor.Descriptor( + name="StateMetadataEntry", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo.StateMetadataEntry", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="key", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo.StateMetadataEntry.key", + 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="value", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo.StateMetadataEntry.value", + 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=_b("8\001"), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1728, + serialized_end=1780, +) + +_RECOMMENDATIONSTATEINFO = _descriptor.Descriptor( + name="RecommendationStateInfo", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="state", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo.state", + index=0, + number=1, + 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="state_metadata", + full_name="google.cloud.recommender.v1beta1.RecommendationStateInfo.state_metadata", + index=1, + number=2, + 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=[_RECOMMENDATIONSTATEINFO_STATEMETADATAENTRY], + enum_types=[_RECOMMENDATIONSTATEINFO_STATE], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1519, + serialized_end=1879, +) + +_RECOMMENDATION.fields_by_name[ + "last_refresh_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_RECOMMENDATION.fields_by_name["primary_impact"].message_type = _IMPACT +_RECOMMENDATION.fields_by_name["additional_impact"].message_type = _IMPACT +_RECOMMENDATION.fields_by_name["content"].message_type = _RECOMMENDATIONCONTENT +_RECOMMENDATION.fields_by_name["state_info"].message_type = _RECOMMENDATIONSTATEINFO +_RECOMMENDATIONCONTENT.fields_by_name["operation_groups"].message_type = _OPERATIONGROUP +_OPERATIONGROUP.fields_by_name["operations"].message_type = _OPERATION +_OPERATION_PATHFILTERSENTRY.fields_by_name[ + "value" +].message_type = google_dot_protobuf_dot_struct__pb2._VALUE +_OPERATION_PATHFILTERSENTRY.containing_type = _OPERATION +_OPERATION.fields_by_name[ + "value" +].message_type = google_dot_protobuf_dot_struct__pb2._VALUE +_OPERATION.fields_by_name["path_filters"].message_type = _OPERATION_PATHFILTERSENTRY +_COSTPROJECTION.fields_by_name[ + "cost" +].message_type = google_dot_type_dot_money__pb2._MONEY +_COSTPROJECTION.fields_by_name[ + "duration" +].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_IMPACT.fields_by_name["category"].enum_type = _IMPACT_CATEGORY +_IMPACT.fields_by_name["cost_projection"].message_type = _COSTPROJECTION +_IMPACT_CATEGORY.containing_type = _IMPACT +_IMPACT.oneofs_by_name["projection"].fields.append( + _IMPACT.fields_by_name["cost_projection"] +) +_IMPACT.fields_by_name["cost_projection"].containing_oneof = _IMPACT.oneofs_by_name[ + "projection" +] +_RECOMMENDATIONSTATEINFO_STATEMETADATAENTRY.containing_type = _RECOMMENDATIONSTATEINFO +_RECOMMENDATIONSTATEINFO.fields_by_name[ + "state" +].enum_type = _RECOMMENDATIONSTATEINFO_STATE +_RECOMMENDATIONSTATEINFO.fields_by_name[ + "state_metadata" +].message_type = _RECOMMENDATIONSTATEINFO_STATEMETADATAENTRY +_RECOMMENDATIONSTATEINFO_STATE.containing_type = _RECOMMENDATIONSTATEINFO +DESCRIPTOR.message_types_by_name["Recommendation"] = _RECOMMENDATION +DESCRIPTOR.message_types_by_name["RecommendationContent"] = _RECOMMENDATIONCONTENT +DESCRIPTOR.message_types_by_name["OperationGroup"] = _OPERATIONGROUP +DESCRIPTOR.message_types_by_name["Operation"] = _OPERATION +DESCRIPTOR.message_types_by_name["CostProjection"] = _COSTPROJECTION +DESCRIPTOR.message_types_by_name["Impact"] = _IMPACT +DESCRIPTOR.message_types_by_name["RecommendationStateInfo"] = _RECOMMENDATIONSTATEINFO +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Recommendation = _reflection.GeneratedProtocolMessageType( + "Recommendation", + (_message.Message,), + dict( + DESCRIPTOR=_RECOMMENDATION, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""A recommendation along with a suggested action. E.g., a rightsizing + recommendation for an underutilized VM, IAM role recommendations, etc + + + Attributes: + name: + Name of recommendation. A project recommendation is + represented as projects/[PROJECT\_NUMBER]/locations/[LOCATION] + /recommenders/[RECOMMENDER\_ID]/recommendations/[RECOMMENDATIO + N\_ID] + description: + Free-form human readable summary in English. The maximum + length is 500 characters. + recommender_subtype: + Contains an identifier for a subtype of recommendations + produced for the same recommender. Subtype is a function of + content and impact, meaning a new subtype will be added when + either content or primary impact category changes. Examples: + For recommender = "google.iam.policy.RoleRecommender", + recommender\_subtype can be one of + "REMOVE\_ROLE"/"REPLACE\_ROLE" + last_refresh_time: + Last time this recommendation was refreshed by the system that + created it in the first place. + primary_impact: + The primary impact that this recommendation can have while + trying to optimize for one category. + additional_impact: + Optional set of additional impact that this recommendation may + have when trying to optimize for the primary category. These + may be positive or negative. + content: + Content of the recommendation describing recommended changes + to resources. + state_info: + Information for state. Contains state and metadata. + etag: + Fingerprint of the Recommendation. Provides optimistic locking + when updating states. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.Recommendation) + ), +) +_sym_db.RegisterMessage(Recommendation) + +RecommendationContent = _reflection.GeneratedProtocolMessageType( + "RecommendationContent", + (_message.Message,), + dict( + DESCRIPTOR=_RECOMMENDATIONCONTENT, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""Contains what resources are changing and how they are changing. + + + Attributes: + operation_groups: + Operations to one or more Google Cloud resources grouped in + such a way that, all operations within one group are expected + to be performed atomically and in an order. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.RecommendationContent) + ), +) +_sym_db.RegisterMessage(RecommendationContent) + +OperationGroup = _reflection.GeneratedProtocolMessageType( + "OperationGroup", + (_message.Message,), + dict( + DESCRIPTOR=_OPERATIONGROUP, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""Group of operations that need to be performed atomically. + + + Attributes: + operations: + List of operations across one or more resources that belong to + this group. Loosely based on RFC6902 and should be performed + in the order they appear. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.OperationGroup) + ), +) +_sym_db.RegisterMessage(OperationGroup) + +Operation = _reflection.GeneratedProtocolMessageType( + "Operation", + (_message.Message,), + dict( + PathFiltersEntry=_reflection.GeneratedProtocolMessageType( + "PathFiltersEntry", + (_message.Message,), + dict( + DESCRIPTOR=_OPERATION_PATHFILTERSENTRY, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2" + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.Operation.PathFiltersEntry) + ), + ), + DESCRIPTOR=_OPERATION, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""Contains an operation for a resource inspired by the JSON-PATCH format + with support for: \* Custom filters for describing partial array patch. + \* Extended path values for describing nested arrays. \* Custom fields + for describing the resource for which the operation is being described. + \* Allows extension to custom operations not natively supported by + RFC6902. See https://tools.ietf.org/html/rfc6902 for details on the + original RFC. + + + Attributes: + action: + Type of this operation. Contains one of 'and', 'remove', + 'replace', 'move', 'copy', 'test' and custom operations. This + field is case-insensitive and always populated. + resource_type: + Type of GCP resource being modified/tested. This field is + always populated. Example: + cloudresourcemanager.googleapis.com/Project, + compute.googleapis.com/Instance + resource: + Contains the fully qualified resource name. This field is + always populated. ex: + //cloudresourcemanager.googleapis.com/projects/foo. + path: + Path to the target field being operated on. If the operation + is at the resource level, then path should be "/". This field + is always populated. + source_resource: + Can be set with action 'copy' to copy resource configuration + across different resources of the same type. Example: A + resource clone can be done via action = 'copy', path = "/", + from = "/", source\_resource = and resource\_name = . This + field is empty for all other values of ``action``. + source_path: + Can be set with action 'copy' or 'move' to indicate the source + field within resource or source\_resource, ignored if provided + for other operation types. + value: + Value for the ``path`` field. Set if action is + 'add'/'replace'/'test'. + path_filters: + Set of filters to apply if ``path`` refers to array elements + or nested array elements in order to narrow down to a single + unique element that is being tested/modified. Note that this + is intended to be an exact match per filter. Example: { + "/versions/*/name" : "it-123" + "/versions/*/targetSize/percent": 20 } Example: { + "/bindings/*/role": "roles/admin" "/bindings/*/condition" : + null } Example: { "/bindings/*/role": "roles/admin" + "/bindings/*/members/\*" : ["x@google.com", "y@google.com"] } + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.Operation) + ), +) +_sym_db.RegisterMessage(Operation) +_sym_db.RegisterMessage(Operation.PathFiltersEntry) + +CostProjection = _reflection.GeneratedProtocolMessageType( + "CostProjection", + (_message.Message,), + dict( + DESCRIPTOR=_COSTPROJECTION, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""Contains metadata about how much money a recommendation can save or + incur. + + + Attributes: + cost: + An approximate projection on amount saved or amount incurred. + Negative cost units indicate cost savings and positive cost + units indicate increase. See google.type.Money documentation + for positive/negative units. + duration: + Duration for which this cost applies. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.CostProjection) + ), +) +_sym_db.RegisterMessage(CostProjection) + +Impact = _reflection.GeneratedProtocolMessageType( + "Impact", + (_message.Message,), + dict( + DESCRIPTOR=_IMPACT, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""Contains the impact a recommendation can have for a given category. + + + Attributes: + category: + Category that is being targeted. + projection: + Contains projections (if any) for this category. + cost_projection: + Use with CategoryType.COST + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.Impact) + ), +) +_sym_db.RegisterMessage(Impact) + +RecommendationStateInfo = _reflection.GeneratedProtocolMessageType( + "RecommendationStateInfo", + (_message.Message,), + dict( + StateMetadataEntry=_reflection.GeneratedProtocolMessageType( + "StateMetadataEntry", + (_message.Message,), + dict( + DESCRIPTOR=_RECOMMENDATIONSTATEINFO_STATEMETADATAENTRY, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2" + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.RecommendationStateInfo.StateMetadataEntry) + ), + ), + DESCRIPTOR=_RECOMMENDATIONSTATEINFO, + __module__="google.cloud.recommender_v1beta1.proto.recommendation_pb2", + __doc__="""Information for state. Contains state and metadata. + + + Attributes: + state: + The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. + state_metadata: + A map of metadata for the state, provided by user or + automations systems. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.RecommendationStateInfo) + ), +) +_sym_db.RegisterMessage(RecommendationStateInfo) +_sym_db.RegisterMessage(RecommendationStateInfo.StateMetadataEntry) + + +DESCRIPTOR._options = None +_OPERATION_PATHFILTERSENTRY._options = None +_RECOMMENDATIONSTATEINFO_STATEMETADATAENTRY._options = None +# @@protoc_insertion_point(module_scope) diff --git a/recommender/google/cloud/recommender_v1beta1/proto/recommendation_pb2_grpc.py b/recommender/google/cloud/recommender_v1beta1/proto/recommendation_pb2_grpc.py new file mode 100644 index 000000000000..07cb78fe03a9 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/proto/recommendation_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/recommender/google/cloud/recommender_v1beta1/proto/recommender_service.proto b/recommender/google/cloud/recommender_v1beta1/proto/recommender_service.proto new file mode 100644 index 000000000000..49a076ae74f6 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/proto/recommender_service.proto @@ -0,0 +1,190 @@ +// 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. +// + +syntax = "proto3"; + +package google.cloud.recommender.v1beta1; + +import "google/api/annotations.proto"; +import "google/cloud/recommender/v1beta1/recommendation.proto"; +import "google/longrunning/operations.proto"; +import "google/api/client.proto"; + +option csharp_namespace = "Google.Cloud.Recommmender.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender"; +option java_multiple_files = true; +option java_outer_classname = "RecommenderProto"; +option java_package = "com.google.cloud.recommender.v1beta1"; +option objc_class_prefix = "CREC"; + +// Provides recommendations for cloud customers for various categories like +// performance optimization, cost savings, reliability, feature discovery, etc. +// These recommendations are generated automatically based on analysis of user +// resources, configuration and monitoring metrics. +service Recommender { + option (google.api.default_host) = "recommender.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists recommendations for a Cloud project. Requires the recommender.*.list + // IAM permission for the specified recommender. + rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations" + }; + } + + // Gets the requested recommendation. Requires the recommender.*.get + // IAM permission for the specified recommender. + rpc GetRecommendation(GetRecommendationRequest) returns (Recommendation) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}" + }; + } + + // Mark the Recommendation State as Claimed. Users can use this method to + // indicate to the Recommender API that they are starting to apply the + // recommendation themselves. This stops the recommendation content from being + // updated. + // + // MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + // SUCCEEDED, FAILED, or ACTIVE state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest) returns (Recommendation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed" + body: "*" + }; + } + + // Mark the Recommendation State as Succeeded. Users can use this method to + // indicate to the Recommender API that they have applied the recommendation + // themselves, and the operation was successful. This stops the recommendation + // content from being updated. + // + // MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + // CLAIMED, SUCCEEDED, or FAILED state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest) returns (Recommendation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded" + body: "*" + }; + } + + // Mark the Recommendation State as Failed. Users can use this method to + // indicate to the Recommender API that they have applied the recommendation + // themselves, and the operation failed. This stops the recommendation content + // from being updated. + // + // MarkRecommendationFailed can be applied to recommendations in ACTIVE, + // CLAIMED, SUCCEEDED, or FAILED state. + // + // Requires the recommender.*.update IAM permission for the specified + // recommender. + rpc MarkRecommendationFailed(MarkRecommendationFailedRequest) returns (Recommendation) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed" + body: "*" + }; + } +} + +// Request for the `ListRecommendations` method. +message ListRecommendationsRequest { + // Required. The container resource on which to execute the request. + // Acceptable formats: + // + // 1. + // "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]", + // + // LOCATION here refers to GCP Locations: + // https://cloud.google.com/about/locations/ + string parent = 1; + + // Optional. The maximum number of results to return from this request. + // Non-positive values are ignored. If not specified, the server will + // determine the number of results to return. + int32 page_size = 2; + + // Optional. If present, retrieves 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 other method + // parameters must be identical to those in the previous call. + string page_token = 3; + + // Filter expression to restrict the recommendations returned. Supported + // filter fields: state_info.state + // Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED" + string filter = 5; +} + +// Response to the `ListRecommendations` method. +message ListRecommendationsResponse { + // The set of recommendations for the `parent` resource. + repeated Recommendation recommendations = 1; + + // A token that can be used to request the next page of results. This field is + // empty if there are no additional results. + string next_page_token = 2; +} + +// Request to the `GetRecommendation` method. +message GetRecommendationRequest { + // Name of the recommendation. + string name = 1; +} + +// Request for the `MarkRecommendationClaimed` Method. +message MarkRecommendationClaimedRequest { + // Name of the recommendation. + string name = 1; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + map state_metadata = 2; + + // Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3; +} + +// Request for the `MarkRecommendationSucceeded` Method. +message MarkRecommendationSucceededRequest { + // Name of the recommendation. + string name = 1; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + map state_metadata = 2; + + // Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3; +} + +// Request for the `MarkRecommendationFailed` Method. +message MarkRecommendationFailedRequest { + // Name of the recommendation. + string name = 1; + + // State properties to include with this state. Overwrites any existing + // `state_metadata`. + map state_metadata = 2; + + // Fingerprint of the Recommendation. Provides optimistic locking. + string etag = 3; +} diff --git a/recommender/google/cloud/recommender_v1beta1/proto/recommender_service_pb2.py b/recommender/google/cloud/recommender_v1beta1/proto/recommender_service_pb2.py new file mode 100644 index 000000000000..5e7d8f029fd3 --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/proto/recommender_service_pb2.py @@ -0,0 +1,924 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/recommender_v1beta1/proto/recommender_service.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.cloud.recommender_v1beta1.proto import ( + recommendation_pb2 as google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2, +) +from google.longrunning import ( + operations_pb2 as google_dot_longrunning_dot_operations__pb2, +) +from google.api import client_pb2 as google_dot_api_dot_client__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/recommender_v1beta1/proto/recommender_service.proto", + package="google.cloud.recommender.v1beta1", + syntax="proto3", + serialized_options=_b( + "\n$com.google.cloud.recommender.v1beta1B\020RecommenderProtoP\001ZKgoogle.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender\242\002\004CREC\252\002!Google.Cloud.Recommmender.V1Beta1" + ), + serialized_pb=_b( + '\n@google/cloud/recommender_v1beta1/proto/recommender_service.proto\x12 google.cloud.recommender.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a;google/cloud/recommender_v1beta1/proto/recommendation.proto\x1a#google/longrunning/operations.proto\x1a\x17google/api/client.proto"c\n\x1aListRecommendationsRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x05 \x01(\t"\x81\x01\n\x1bListRecommendationsResponse\x12I\n\x0frecommendations\x18\x01 \x03(\x0b\x32\x30.google.cloud.recommender.v1beta1.Recommendation\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"(\n\x18GetRecommendationRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"\xe3\x01\n MarkRecommendationClaimedRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12m\n\x0estate_metadata\x18\x02 \x03(\x0b\x32U.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.StateMetadataEntry\x12\x0c\n\x04\x65tag\x18\x03 \x01(\t\x1a\x34\n\x12StateMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"\xe7\x01\n"MarkRecommendationSucceededRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12o\n\x0estate_metadata\x18\x02 \x03(\x0b\x32W.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.StateMetadataEntry\x12\x0c\n\x04\x65tag\x18\x03 \x01(\t\x1a\x34\n\x12StateMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"\xe1\x01\n\x1fMarkRecommendationFailedRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12l\n\x0estate_metadata\x18\x02 \x03(\x0b\x32T.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.StateMetadataEntry\x12\x0c\n\x04\x65tag\x18\x03 \x01(\t\x1a\x34\n\x12StateMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x32\xf7\t\n\x0bRecommender\x12\xe3\x01\n\x13ListRecommendations\x12<.google.cloud.recommender.v1beta1.ListRecommendationsRequest\x1a=.google.cloud.recommender.v1beta1.ListRecommendationsResponse"O\x82\xd3\xe4\x93\x02I\x12G/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations\x12\xd2\x01\n\x11GetRecommendation\x12:.google.cloud.recommender.v1beta1.GetRecommendationRequest\x1a\x30.google.cloud.recommender.v1beta1.Recommendation"O\x82\xd3\xe4\x93\x02I\x12G/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}\x12\xf1\x01\n\x19MarkRecommendationClaimed\x12\x42.google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest\x1a\x30.google.cloud.recommender.v1beta1.Recommendation"^\x82\xd3\xe4\x93\x02X"S/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed:\x01*\x12\xf7\x01\n\x1bMarkRecommendationSucceeded\x12\x44.google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest\x1a\x30.google.cloud.recommender.v1beta1.Recommendation"`\x82\xd3\xe4\x93\x02Z"U/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded:\x01*\x12\xee\x01\n\x18MarkRecommendationFailed\x12\x41.google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest\x1a\x30.google.cloud.recommender.v1beta1.Recommendation"]\x82\xd3\xe4\x93\x02W"R/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed:\x01*\x1aN\xca\x41\x1arecommender.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb2\x01\n$com.google.cloud.recommender.v1beta1B\x10RecommenderProtoP\x01ZKgoogle.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender\xa2\x02\x04\x43REC\xaa\x02!Google.Cloud.Recommmender.V1Beta1b\x06proto3' + ), + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.DESCRIPTOR, + google_dot_longrunning_dot_operations__pb2.DESCRIPTOR, + google_dot_api_dot_client__pb2.DESCRIPTOR, + ], +) + + +_LISTRECOMMENDATIONSREQUEST = _descriptor.Descriptor( + name="ListRecommendationsRequest", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsRequest.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="page_size", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsRequest.page_size", + index=1, + 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=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsRequest.page_token", + index=2, + 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=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="filter", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsRequest.filter", + index=3, + 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=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=255, + serialized_end=354, +) + + +_LISTRECOMMENDATIONSRESPONSE = _descriptor.Descriptor( + name="ListRecommendationsResponse", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="recommendations", + full_name="google.cloud.recommender.v1beta1.ListRecommendationsResponse.recommendations", + 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.recommender.v1beta1.ListRecommendationsResponse.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=357, + serialized_end=486, +) + + +_GETRECOMMENDATIONREQUEST = _descriptor.Descriptor( + name="GetRecommendationRequest", + full_name="google.cloud.recommender.v1beta1.GetRecommendationRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.recommender.v1beta1.GetRecommendationRequest.name", + 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, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=488, + serialized_end=528, +) + + +_MARKRECOMMENDATIONCLAIMEDREQUEST_STATEMETADATAENTRY = _descriptor.Descriptor( + name="StateMetadataEntry", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.StateMetadataEntry", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="key", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.StateMetadataEntry.key", + 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="value", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.StateMetadataEntry.value", + 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=_b("8\001"), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=706, + serialized_end=758, +) + +_MARKRECOMMENDATIONCLAIMEDREQUEST = _descriptor.Descriptor( + name="MarkRecommendationClaimedRequest", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.name", + 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="state_metadata", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.state_metadata", + index=1, + number=2, + 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="etag", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.etag", + index=2, + 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=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[_MARKRECOMMENDATIONCLAIMEDREQUEST_STATEMETADATAENTRY], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=531, + serialized_end=758, +) + + +_MARKRECOMMENDATIONSUCCEEDEDREQUEST_STATEMETADATAENTRY = _descriptor.Descriptor( + name="StateMetadataEntry", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.StateMetadataEntry", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="key", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.StateMetadataEntry.key", + 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="value", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.StateMetadataEntry.value", + 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=_b("8\001"), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=706, + serialized_end=758, +) + +_MARKRECOMMENDATIONSUCCEEDEDREQUEST = _descriptor.Descriptor( + name="MarkRecommendationSucceededRequest", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.name", + 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="state_metadata", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.state_metadata", + index=1, + number=2, + 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="etag", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.etag", + index=2, + 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=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[_MARKRECOMMENDATIONSUCCEEDEDREQUEST_STATEMETADATAENTRY], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=761, + serialized_end=992, +) + + +_MARKRECOMMENDATIONFAILEDREQUEST_STATEMETADATAENTRY = _descriptor.Descriptor( + name="StateMetadataEntry", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.StateMetadataEntry", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="key", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.StateMetadataEntry.key", + 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="value", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.StateMetadataEntry.value", + 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=_b("8\001"), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=706, + serialized_end=758, +) + +_MARKRECOMMENDATIONFAILEDREQUEST = _descriptor.Descriptor( + name="MarkRecommendationFailedRequest", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.name", + 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="state_metadata", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.state_metadata", + index=1, + number=2, + 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="etag", + full_name="google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.etag", + index=2, + 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=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[_MARKRECOMMENDATIONFAILEDREQUEST_STATEMETADATAENTRY], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=995, + serialized_end=1220, +) + +_LISTRECOMMENDATIONSRESPONSE.fields_by_name[ + "recommendations" +].message_type = ( + google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2._RECOMMENDATION +) +_MARKRECOMMENDATIONCLAIMEDREQUEST_STATEMETADATAENTRY.containing_type = ( + _MARKRECOMMENDATIONCLAIMEDREQUEST +) +_MARKRECOMMENDATIONCLAIMEDREQUEST.fields_by_name[ + "state_metadata" +].message_type = _MARKRECOMMENDATIONCLAIMEDREQUEST_STATEMETADATAENTRY +_MARKRECOMMENDATIONSUCCEEDEDREQUEST_STATEMETADATAENTRY.containing_type = ( + _MARKRECOMMENDATIONSUCCEEDEDREQUEST +) +_MARKRECOMMENDATIONSUCCEEDEDREQUEST.fields_by_name[ + "state_metadata" +].message_type = _MARKRECOMMENDATIONSUCCEEDEDREQUEST_STATEMETADATAENTRY +_MARKRECOMMENDATIONFAILEDREQUEST_STATEMETADATAENTRY.containing_type = ( + _MARKRECOMMENDATIONFAILEDREQUEST +) +_MARKRECOMMENDATIONFAILEDREQUEST.fields_by_name[ + "state_metadata" +].message_type = _MARKRECOMMENDATIONFAILEDREQUEST_STATEMETADATAENTRY +DESCRIPTOR.message_types_by_name[ + "ListRecommendationsRequest" +] = _LISTRECOMMENDATIONSREQUEST +DESCRIPTOR.message_types_by_name[ + "ListRecommendationsResponse" +] = _LISTRECOMMENDATIONSRESPONSE +DESCRIPTOR.message_types_by_name["GetRecommendationRequest"] = _GETRECOMMENDATIONREQUEST +DESCRIPTOR.message_types_by_name[ + "MarkRecommendationClaimedRequest" +] = _MARKRECOMMENDATIONCLAIMEDREQUEST +DESCRIPTOR.message_types_by_name[ + "MarkRecommendationSucceededRequest" +] = _MARKRECOMMENDATIONSUCCEEDEDREQUEST +DESCRIPTOR.message_types_by_name[ + "MarkRecommendationFailedRequest" +] = _MARKRECOMMENDATIONFAILEDREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListRecommendationsRequest = _reflection.GeneratedProtocolMessageType( + "ListRecommendationsRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTRECOMMENDATIONSREQUEST, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2", + __doc__="""Request for the ``ListRecommendations`` method. + + + Attributes: + parent: + Required. The container resource on which to execute the + request. Acceptable formats: 1. "projects/[PROJECT\_NUMBER]/l + ocations/[LOCATION]/recommenders/[RECOMMENDER\_ID]", LOCATION + here refers to GCP Locations: + https://cloud.google.com/about/locations/ + page_size: + Optional. The maximum number of results to return from this + request. Non-positive values are ignored. If not specified, + the server will determine the number of results to return. + page_token: + Optional. If present, retrieves 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 other method parameters must be identical to those + in the previous call. + filter: + Filter expression to restrict the recommendations returned. + Supported filter fields: state\_info.state Eg: + \`state\_info.state:"DISMISSED" or state\_info.state:"FAILED" + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.ListRecommendationsRequest) + ), +) +_sym_db.RegisterMessage(ListRecommendationsRequest) + +ListRecommendationsResponse = _reflection.GeneratedProtocolMessageType( + "ListRecommendationsResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTRECOMMENDATIONSRESPONSE, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2", + __doc__="""Response to the ``ListRecommendations`` method. + + + Attributes: + recommendations: + The set of recommendations for the ``parent`` resource. + next_page_token: + A token that can be used to request the next page of results. + This field is empty if there are no additional results. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.ListRecommendationsResponse) + ), +) +_sym_db.RegisterMessage(ListRecommendationsResponse) + +GetRecommendationRequest = _reflection.GeneratedProtocolMessageType( + "GetRecommendationRequest", + (_message.Message,), + dict( + DESCRIPTOR=_GETRECOMMENDATIONREQUEST, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2", + __doc__="""Request to the ``GetRecommendation`` method. + + + Attributes: + name: + Name of the recommendation. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.GetRecommendationRequest) + ), +) +_sym_db.RegisterMessage(GetRecommendationRequest) + +MarkRecommendationClaimedRequest = _reflection.GeneratedProtocolMessageType( + "MarkRecommendationClaimedRequest", + (_message.Message,), + dict( + StateMetadataEntry=_reflection.GeneratedProtocolMessageType( + "StateMetadataEntry", + (_message.Message,), + dict( + DESCRIPTOR=_MARKRECOMMENDATIONCLAIMEDREQUEST_STATEMETADATAENTRY, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2" + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest.StateMetadataEntry) + ), + ), + DESCRIPTOR=_MARKRECOMMENDATIONCLAIMEDREQUEST, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2", + __doc__="""Request for the ``MarkRecommendationClaimed`` Method. + + + Attributes: + name: + Name of the recommendation. + state_metadata: + State properties to include with this state. Overwrites any + existing ``state_metadata``. + etag: + Fingerprint of the Recommendation. Provides optimistic + locking. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.MarkRecommendationClaimedRequest) + ), +) +_sym_db.RegisterMessage(MarkRecommendationClaimedRequest) +_sym_db.RegisterMessage(MarkRecommendationClaimedRequest.StateMetadataEntry) + +MarkRecommendationSucceededRequest = _reflection.GeneratedProtocolMessageType( + "MarkRecommendationSucceededRequest", + (_message.Message,), + dict( + StateMetadataEntry=_reflection.GeneratedProtocolMessageType( + "StateMetadataEntry", + (_message.Message,), + dict( + DESCRIPTOR=_MARKRECOMMENDATIONSUCCEEDEDREQUEST_STATEMETADATAENTRY, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2" + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest.StateMetadataEntry) + ), + ), + DESCRIPTOR=_MARKRECOMMENDATIONSUCCEEDEDREQUEST, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2", + __doc__="""Request for the ``MarkRecommendationSucceeded`` Method. + + + Attributes: + name: + Name of the recommendation. + state_metadata: + State properties to include with this state. Overwrites any + existing ``state_metadata``. + etag: + Fingerprint of the Recommendation. Provides optimistic + locking. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.MarkRecommendationSucceededRequest) + ), +) +_sym_db.RegisterMessage(MarkRecommendationSucceededRequest) +_sym_db.RegisterMessage(MarkRecommendationSucceededRequest.StateMetadataEntry) + +MarkRecommendationFailedRequest = _reflection.GeneratedProtocolMessageType( + "MarkRecommendationFailedRequest", + (_message.Message,), + dict( + StateMetadataEntry=_reflection.GeneratedProtocolMessageType( + "StateMetadataEntry", + (_message.Message,), + dict( + DESCRIPTOR=_MARKRECOMMENDATIONFAILEDREQUEST_STATEMETADATAENTRY, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2" + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest.StateMetadataEntry) + ), + ), + DESCRIPTOR=_MARKRECOMMENDATIONFAILEDREQUEST, + __module__="google.cloud.recommender_v1beta1.proto.recommender_service_pb2", + __doc__="""Request for the ``MarkRecommendationFailed`` Method. + + + Attributes: + name: + Name of the recommendation. + state_metadata: + State properties to include with this state. Overwrites any + existing ``state_metadata``. + etag: + Fingerprint of the Recommendation. Provides optimistic + locking. + """, + # @@protoc_insertion_point(class_scope:google.cloud.recommender.v1beta1.MarkRecommendationFailedRequest) + ), +) +_sym_db.RegisterMessage(MarkRecommendationFailedRequest) +_sym_db.RegisterMessage(MarkRecommendationFailedRequest.StateMetadataEntry) + + +DESCRIPTOR._options = None +_MARKRECOMMENDATIONCLAIMEDREQUEST_STATEMETADATAENTRY._options = None +_MARKRECOMMENDATIONSUCCEEDEDREQUEST_STATEMETADATAENTRY._options = None +_MARKRECOMMENDATIONFAILEDREQUEST_STATEMETADATAENTRY._options = None + +_RECOMMENDER = _descriptor.ServiceDescriptor( + name="Recommender", + full_name="google.cloud.recommender.v1beta1.Recommender", + file=DESCRIPTOR, + index=0, + serialized_options=_b( + "\312A\032recommender.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" + ), + serialized_start=1223, + serialized_end=2494, + methods=[ + _descriptor.MethodDescriptor( + name="ListRecommendations", + full_name="google.cloud.recommender.v1beta1.Recommender.ListRecommendations", + index=0, + containing_service=None, + input_type=_LISTRECOMMENDATIONSREQUEST, + output_type=_LISTRECOMMENDATIONSRESPONSE, + serialized_options=_b( + "\202\323\344\223\002I\022G/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations" + ), + ), + _descriptor.MethodDescriptor( + name="GetRecommendation", + full_name="google.cloud.recommender.v1beta1.Recommender.GetRecommendation", + index=1, + containing_service=None, + input_type=_GETRECOMMENDATIONREQUEST, + output_type=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2._RECOMMENDATION, + serialized_options=_b( + "\202\323\344\223\002I\022G/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}" + ), + ), + _descriptor.MethodDescriptor( + name="MarkRecommendationClaimed", + full_name="google.cloud.recommender.v1beta1.Recommender.MarkRecommendationClaimed", + index=2, + containing_service=None, + input_type=_MARKRECOMMENDATIONCLAIMEDREQUEST, + output_type=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2._RECOMMENDATION, + serialized_options=_b( + '\202\323\344\223\002X"S/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="MarkRecommendationSucceeded", + full_name="google.cloud.recommender.v1beta1.Recommender.MarkRecommendationSucceeded", + index=3, + containing_service=None, + input_type=_MARKRECOMMENDATIONSUCCEEDEDREQUEST, + output_type=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2._RECOMMENDATION, + serialized_options=_b( + '\202\323\344\223\002Z"U/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="MarkRecommendationFailed", + full_name="google.cloud.recommender.v1beta1.Recommender.MarkRecommendationFailed", + index=4, + containing_service=None, + input_type=_MARKRECOMMENDATIONFAILEDREQUEST, + output_type=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2._RECOMMENDATION, + serialized_options=_b( + '\202\323\344\223\002W"R/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed:\001*' + ), + ), + ], +) +_sym_db.RegisterServiceDescriptor(_RECOMMENDER) + +DESCRIPTOR.services_by_name["Recommender"] = _RECOMMENDER + +# @@protoc_insertion_point(module_scope) diff --git a/recommender/google/cloud/recommender_v1beta1/proto/recommender_service_pb2_grpc.py b/recommender/google/cloud/recommender_v1beta1/proto/recommender_service_pb2_grpc.py new file mode 100644 index 000000000000..24ffe1eb40fb --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/proto/recommender_service_pb2_grpc.py @@ -0,0 +1,155 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.recommender_v1beta1.proto import ( + recommendation_pb2 as google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2, +) +from google.cloud.recommender_v1beta1.proto import ( + recommender_service_pb2 as google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2, +) + + +class RecommenderStub(object): + """Provides recommendations for cloud customers for various categories like + performance optimization, cost savings, reliability, feature discovery, etc. + These recommendations are generated automatically based on analysis of user + resources, configuration and monitoring metrics. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListRecommendations = channel.unary_unary( + "/google.cloud.recommender.v1beta1.Recommender/ListRecommendations", + request_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.ListRecommendationsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.ListRecommendationsResponse.FromString, + ) + self.GetRecommendation = channel.unary_unary( + "/google.cloud.recommender.v1beta1.Recommender/GetRecommendation", + request_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.GetRecommendationRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.FromString, + ) + self.MarkRecommendationClaimed = channel.unary_unary( + "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationClaimed", + request_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.MarkRecommendationClaimedRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.FromString, + ) + self.MarkRecommendationSucceeded = channel.unary_unary( + "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationSucceeded", + request_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.MarkRecommendationSucceededRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.FromString, + ) + self.MarkRecommendationFailed = channel.unary_unary( + "/google.cloud.recommender.v1beta1.Recommender/MarkRecommendationFailed", + request_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.MarkRecommendationFailedRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.FromString, + ) + + +class RecommenderServicer(object): + """Provides recommendations for cloud customers for various categories like + performance optimization, cost savings, reliability, feature discovery, etc. + These recommendations are generated automatically based on analysis of user + resources, configuration and monitoring metrics. + """ + + def ListRecommendations(self, request, context): + """Lists recommendations for a Cloud project. Requires the recommender.*.list + IAM permission for the specified recommender. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def GetRecommendation(self, request, context): + """Gets the requested recommendation. Requires the recommender.*.get + IAM permission for the specified recommender. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def MarkRecommendationClaimed(self, request, context): + """Mark the Recommendation State as Claimed. Users can use this method to + indicate to the Recommender API that they are starting to apply the + recommendation themselves. This stops the recommendation content from being + updated. + + MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + SUCCEEDED, FAILED, or ACTIVE state. + + Requires the recommender.*.update IAM permission for the specified + recommender. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def MarkRecommendationSucceeded(self, request, context): + """Mark the Recommendation State as Succeeded. Users can use this method to + indicate to the Recommender API that they have applied the recommendation + themselves, and the operation was successful. This stops the recommendation + content from being updated. + + MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + CLAIMED, SUCCEEDED, or FAILED state. + + Requires the recommender.*.update IAM permission for the specified + recommender. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def MarkRecommendationFailed(self, request, context): + """Mark the Recommendation State as Failed. Users can use this method to + indicate to the Recommender API that they have applied the recommendation + themselves, and the operation failed. This stops the recommendation content + from being updated. + + MarkRecommendationFailed can be applied to recommendations in ACTIVE, + CLAIMED, SUCCEEDED, or FAILED state. + + Requires the recommender.*.update IAM permission for the specified + recommender. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + +def add_RecommenderServicer_to_server(servicer, server): + rpc_method_handlers = { + "ListRecommendations": grpc.unary_unary_rpc_method_handler( + servicer.ListRecommendations, + request_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.ListRecommendationsRequest.FromString, + response_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.ListRecommendationsResponse.SerializeToString, + ), + "GetRecommendation": grpc.unary_unary_rpc_method_handler( + servicer.GetRecommendation, + request_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.GetRecommendationRequest.FromString, + response_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.SerializeToString, + ), + "MarkRecommendationClaimed": grpc.unary_unary_rpc_method_handler( + servicer.MarkRecommendationClaimed, + request_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.MarkRecommendationClaimedRequest.FromString, + response_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.SerializeToString, + ), + "MarkRecommendationSucceeded": grpc.unary_unary_rpc_method_handler( + servicer.MarkRecommendationSucceeded, + request_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.MarkRecommendationSucceededRequest.FromString, + response_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.SerializeToString, + ), + "MarkRecommendationFailed": grpc.unary_unary_rpc_method_handler( + servicer.MarkRecommendationFailed, + request_deserializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommender__service__pb2.MarkRecommendationFailedRequest.FromString, + response_serializer=google_dot_cloud_dot_recommender__v1beta1_dot_proto_dot_recommendation__pb2.Recommendation.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + "google.cloud.recommender.v1beta1.Recommender", rpc_method_handlers + ) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/recommender/google/cloud/recommender_v1beta1/types.py b/recommender/google/cloud/recommender_v1beta1/types.py new file mode 100644 index 000000000000..205bae43ea9c --- /dev/null +++ b/recommender/google/cloud/recommender_v1beta1/types.py @@ -0,0 +1,48 @@ +# -*- 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. + + +from __future__ import absolute_import +import sys + +from google.api_core.protobuf_helpers import get_messages + +from google.cloud.recommender_v1beta1.proto import recommendation_pb2 +from google.cloud.recommender_v1beta1.proto import recommender_service_pb2 +from google.protobuf import duration_pb2 +from google.protobuf import struct_pb2 +from google.protobuf import timestamp_pb2 +from google.type import money_pb2 + + +_shared_modules = [duration_pb2, struct_pb2, timestamp_pb2, money_pb2] + +_local_modules = [recommendation_pb2, recommender_service_pb2] + +names = [] + +for module in _shared_modules: # pragma: NO COVER + for name, message in get_messages(module).items(): + setattr(sys.modules[__name__], name, message) + names.append(name) +for module in _local_modules: + for name, message in get_messages(module).items(): + message.__module__ = "google.cloud.recommender_v1beta1.types" + setattr(sys.modules[__name__], name, message) + names.append(name) + + +__all__ = tuple(sorted(names)) diff --git a/recommender/mypy.ini b/recommender/mypy.ini new file mode 100644 index 000000000000..f23e6b533aad --- /dev/null +++ b/recommender/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.5 +namespace_packages = True diff --git a/recommender/noxfile.py b/recommender/noxfile.py new file mode 100644 index 000000000000..1f6797a2207f --- /dev/null +++ b/recommender/noxfile.py @@ -0,0 +1,160 @@ +# -*- coding: utf-8 -*- +# +# 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. + +# Generated by synthtool. DO NOT EDIT! + +from __future__ import absolute_import +import os +import shutil + +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"] + +if os.path.exists("samples"): + BLACK_PATHS.append("samples") + + +@nox.session(python="3.7") +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION, *LOCAL_DEPS) + session.run("black", "--check", *BLACK_PATHS) + session.run("flake8", "google", "tests") + + +@nox.session(python="3.6") +def blacken(session): + """Run black. + + Format code to uniform standard. + + This currently uses Python 3.6 due to the automated Kokoro run of synthtool. + That run uses an image that doesn't have 3.6 installed. Before updating this + check the state of the `gcp_ubuntu_config` we use for that Kokoro run. + """ + session.install(BLACK_VERSION) + session.run("black", *BLACK_PATHS) + + +@nox.session(python="3.7") +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") + + +def default(session): + # Install all test dependencies, then install this package in-place. + session.install("mock", "pytest", "pytest-cov") + 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", + "--cov=tests.unit", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", + os.path.join("tests", "unit"), + *session.posargs, + ) + + +@nox.session(python=["3.5", "3.6", "3.7"]) +def unit(session): + """Run the unit test suite.""" + default(session) + + +@nox.session(python=["3.7"]) +def system(session): + """Run the system test suite.""" + system_test_path = os.path.join("tests", "system.py") + system_test_folder_path = os.path.join("tests", "system") + # Sanity check: Only run tests if the environment variable is set. + if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): + session.skip("Credentials must be set via environment variable") + + system_test_exists = os.path.exists(system_test_path) + system_test_folder_exists = os.path.exists(system_test_folder_path) + # Sanity check: only run tests if found. + if not system_test_exists and not system_test_folder_exists: + session.skip("System tests were not found") + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + # 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", ".") + + # Run py.test against the system tests. + if system_test_exists: + session.run("py.test", "--quiet", system_test_path, *session.posargs) + if system_test_folder_exists: + session.run("py.test", "--quiet", system_test_folder_path, *session.posargs) + + +@nox.session(python="3.7") +def cover(session): + """Run the final coverage report. + + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python="3.7") +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/recommender/setup.cfg b/recommender/setup.cfg new file mode 100644 index 000000000000..3bd555500e37 --- /dev/null +++ b/recommender/setup.cfg @@ -0,0 +1,3 @@ +# Generated by synthtool. DO NOT EDIT! +[bdist_wheel] +universal = 1 diff --git a/recommender/setup.py b/recommender/setup.py new file mode 100644 index 000000000000..31a46fd840eb --- /dev/null +++ b/recommender/setup.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# +# 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. + +import io +import os + +import setuptools + +name = "google-cloud-recommender" +description = "Cloud Recommender API client library" +version = "0.1.0" +release_status = "Development Status :: 3 - Alpha" +dependencies = ["google-api-core[grpc] >= 1.14.0, < 2.0.0dev"] + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, "README.rst") +with io.open(readme_filename, encoding="utf-8") as readme_file: + readme = readme_file.read() + +packages = [ + package for package in setuptools.find_packages() if package.startswith("google") +] + +namespaces = ["google"] +if "google.cloud" in packages: + namespaces.append("google.cloud") + +setuptools.setup( + name=name, + version=version, + description=description, + long_description=readme, + author="Google LLC", + author_email="googleapis-packages@google.com", + license="Apache 2.0", + url="https://github.com/GoogleCloudPlatform/google-cloud-python", + classifiers=[ + release_status, + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Operating System :: OS Independent", + "Topic :: Internet", + ], + platforms="Posix; MacOS X; Windows", + packages=packages, + namespace_packages=namespaces, + install_requires=dependencies, + python_requires=">=3.5", + include_package_data=True, + zip_safe=False, +) diff --git a/recommender/synth.metadata b/recommender/synth.metadata new file mode 100644 index 000000000000..2de372bf0e0a --- /dev/null +++ b/recommender/synth.metadata @@ -0,0 +1,39 @@ +{ + "updateTime": "2019-09-27T16:39:53.634316Z", + "sources": [ + { + "generator": { + "name": "artman", + "version": "0.37.1", + "dockerImage": "googleapis/artman@sha256:6068f67900a3f0bdece596b97bda8fc70406ca0e137a941f4c81d3217c994a80" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "cd112d8d255e0099df053643d4bd12c228ef7b1b", + "internalRef": "271468707" + } + }, + { + "template": { + "name": "python_library", + "origin": "synthtool.gcp", + "version": "2019.5.2" + } + } + ], + "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "recommender", + "apiVersion": "v1beta1", + "language": "python", + "generator": "gapic", + "config": "google/cloud/recommender/artman_recommender_v1beta1.yaml" + } + } + ] +} \ No newline at end of file diff --git a/recommender/synth.py b/recommender/synth.py new file mode 100644 index 000000000000..93d445f42f11 --- /dev/null +++ b/recommender/synth.py @@ -0,0 +1,42 @@ +# 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. + +"""This script is used to synthesize generated parts of this library.""" +import re + +import synthtool as s +from synthtool import gcp + +gapic = gcp.GAPICGenerator() +versions = ["v1beta1"] +common = gcp.CommonTemplates() + + +# ---------------------------------------------------------------------------- +# Generate Cloud Recommender +# ---------------------------------------------------------------------------- +for version in versions: + library = gapic.py_library( + "recommender", version, + include_protos=True + ) + s.move(library, excludes=['nox.py', 'docs/index.rst', 'README.rst', 'setup.py']) + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- +templated_files = common.py_library(unit_cov_level=97, cov_level=100) +s.move(templated_files, excludes=['noxfile.py']) + +s.shell.run(["nox", "-s", "blacken"], hide_output=False) \ No newline at end of file diff --git a/recommender/tests/unit/gapic/v1beta1/test_recommender_client_v1beta1.py b/recommender/tests/unit/gapic/v1beta1/test_recommender_client_v1beta1.py new file mode 100644 index 000000000000..dafe315484bf --- /dev/null +++ b/recommender/tests/unit/gapic/v1beta1/test_recommender_client_v1beta1.py @@ -0,0 +1,324 @@ +# -*- 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. + +"""Unit tests.""" + +import mock +import pytest + +from google.cloud import recommender_v1beta1 +from google.cloud.recommender_v1beta1.proto import recommendation_pb2 +from google.cloud.recommender_v1beta1.proto import recommender_service_pb2 + + +class MultiCallableStub(object): + """Stub for the grpc.UnaryUnaryMultiCallable interface.""" + + def __init__(self, method, channel_stub): + self.method = method + self.channel_stub = channel_stub + + def __call__(self, request, timeout=None, metadata=None, credentials=None): + self.channel_stub.requests.append((self.method, request)) + + response = None + if self.channel_stub.responses: + response = self.channel_stub.responses.pop() + + if isinstance(response, Exception): + raise response + + if response: + return response + + +class ChannelStub(object): + """Stub for the grpc.Channel interface.""" + + def __init__(self, responses=[]): + self.responses = responses + self.requests = [] + + def unary_unary(self, method, request_serializer=None, response_deserializer=None): + return MultiCallableStub(method, self) + + +class CustomException(Exception): + pass + + +class TestRecommenderClient(object): + def test_list_recommendations(self): + # Setup Expected Response + next_page_token = "" + recommendations_element = {} + recommendations = [recommendations_element] + expected_response = { + "next_page_token": next_page_token, + "recommendations": recommendations, + } + expected_response = recommender_service_pb2.ListRecommendationsResponse( + **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 = recommender_v1beta1.RecommenderClient() + + # Setup Request + parent = client.recommender_path("[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + + paged_list_response = client.list_recommendations(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.recommendations[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = recommender_service_pb2.ListRecommendationsRequest( + parent=parent + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_recommendations_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 = recommender_v1beta1.RecommenderClient() + + # Setup request + parent = client.recommender_path("[PROJECT]", "[LOCATION]", "[RECOMMENDER]") + + paged_list_response = client.list_recommendations(parent) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_get_recommendation(self): + # Setup Expected Response + name_2 = "name2-1052831874" + description = "description-1724546052" + recommender_subtype = "recommenderSubtype-1488504412" + etag = "etag3123477" + expected_response = { + "name": name_2, + "description": description, + "recommender_subtype": recommender_subtype, + "etag": etag, + } + expected_response = recommendation_pb2.Recommendation(**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 = recommender_v1beta1.RecommenderClient() + + # Setup Request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + + response = client.get_recommendation(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = recommender_service_pb2.GetRecommendationRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_recommendation_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 = recommender_v1beta1.RecommenderClient() + + # Setup request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + + with pytest.raises(CustomException): + client.get_recommendation(name) + + def test_mark_recommendation_claimed(self): + # Setup Expected Response + name_2 = "name2-1052831874" + description = "description-1724546052" + recommender_subtype = "recommenderSubtype-1488504412" + etag_2 = "etag2-1293302904" + expected_response = { + "name": name_2, + "description": description, + "recommender_subtype": recommender_subtype, + "etag": etag_2, + } + expected_response = recommendation_pb2.Recommendation(**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 = recommender_v1beta1.RecommenderClient() + + # Setup Request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + etag = "etag3123477" + + response = client.mark_recommendation_claimed(name, etag) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = recommender_service_pb2.MarkRecommendationClaimedRequest( + name=name, etag=etag + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_mark_recommendation_claimed_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 = recommender_v1beta1.RecommenderClient() + + # Setup request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + etag = "etag3123477" + + with pytest.raises(CustomException): + client.mark_recommendation_claimed(name, etag) + + def test_mark_recommendation_succeeded(self): + # Setup Expected Response + name_2 = "name2-1052831874" + description = "description-1724546052" + recommender_subtype = "recommenderSubtype-1488504412" + etag_2 = "etag2-1293302904" + expected_response = { + "name": name_2, + "description": description, + "recommender_subtype": recommender_subtype, + "etag": etag_2, + } + expected_response = recommendation_pb2.Recommendation(**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 = recommender_v1beta1.RecommenderClient() + + # Setup Request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + etag = "etag3123477" + + response = client.mark_recommendation_succeeded(name, etag) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = recommender_service_pb2.MarkRecommendationSucceededRequest( + name=name, etag=etag + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_mark_recommendation_succeeded_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 = recommender_v1beta1.RecommenderClient() + + # Setup request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + etag = "etag3123477" + + with pytest.raises(CustomException): + client.mark_recommendation_succeeded(name, etag) + + def test_mark_recommendation_failed(self): + # Setup Expected Response + name_2 = "name2-1052831874" + description = "description-1724546052" + recommender_subtype = "recommenderSubtype-1488504412" + etag_2 = "etag2-1293302904" + expected_response = { + "name": name_2, + "description": description, + "recommender_subtype": recommender_subtype, + "etag": etag_2, + } + expected_response = recommendation_pb2.Recommendation(**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 = recommender_v1beta1.RecommenderClient() + + # Setup Request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + etag = "etag3123477" + + response = client.mark_recommendation_failed(name, etag) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = recommender_service_pb2.MarkRecommendationFailedRequest( + name=name, etag=etag + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_mark_recommendation_failed_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 = recommender_v1beta1.RecommenderClient() + + # Setup request + name = client.recommendation_path( + "[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]" + ) + etag = "etag3123477" + + with pytest.raises(CustomException): + client.mark_recommendation_failed(name, etag)