diff --git a/packages/google-cloud-billing-budgets/.coveragerc b/packages/google-cloud-billing-budgets/.coveragerc new file mode 100644 index 000000000000..b178b094aa1d --- /dev/null +++ b/packages/google-cloud-billing-budgets/.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/packages/google-cloud-billing-budgets/.flake8 b/packages/google-cloud-billing-budgets/.flake8 new file mode 100644 index 000000000000..0268ecc9c55c --- /dev/null +++ b/packages/google-cloud-billing-budgets/.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/packages/google-cloud-billing-budgets/.repo-metadata.json b/packages/google-cloud-billing-budgets/.repo-metadata.json new file mode 100644 index 000000000000..895c1720ebbf --- /dev/null +++ b/packages/google-cloud-billing-budgets/.repo-metadata.json @@ -0,0 +1,13 @@ +{ + "name": "billingbudgets", + "name_pretty": "Cloud Billing Budget", + "product_documentation": "https://cloud.google.com/billing/docs/how-to/budget-api-overview", + "client_documentation": "https://googleapis.dev/python/billingbudgets/latest", + "issue_tracker": "https://issuetracker.google.com/savedsearches/559770", + "release_level": "alpha", + "language": "python", + "repo": "googleapis/google-cloud-python", + "distribution_name": "google-cloud-billing-budgets", + "api_id": "billingbudgets.googleapis.com", + "requires_billing": true +} \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/CHANGELOG.md b/packages/google-cloud-billing-budgets/CHANGELOG.md new file mode 100644 index 000000000000..825c32f0d03d --- /dev/null +++ b/packages/google-cloud-billing-budgets/CHANGELOG.md @@ -0,0 +1 @@ +# Changelog diff --git a/packages/google-cloud-billing-budgets/LICENSE b/packages/google-cloud-billing-budgets/LICENSE new file mode 100644 index 000000000000..a8ee855de2aa --- /dev/null +++ b/packages/google-cloud-billing-budgets/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/packages/google-cloud-billing-budgets/MANIFEST.in b/packages/google-cloud-billing-budgets/MANIFEST.in new file mode 100644 index 000000000000..9cbf175afe6b --- /dev/null +++ b/packages/google-cloud-billing-budgets/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/packages/google-cloud-billing-budgets/README.rst b/packages/google-cloud-billing-budgets/README.rst new file mode 100644 index 000000000000..344135705e20 --- /dev/null +++ b/packages/google-cloud-billing-budgets/README.rst @@ -0,0 +1,77 @@ +Python Client for Cloud Billing Budget API (`Alpha`_) +===================================================== + +`Cloud Billing Budget API`_: The Cloud Billing Budget API stores Cloud Billing budgets, which define a +budget plan and the rules to execute as spend is tracked against that +plan. + +- `Client Library Documentation`_ +- `Product Documentation`_ + +.. _Alpha: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _Cloud Billing Budget API: https://cloud.google.com/billing/docs/how-to/budget-api-overview +.. _Client Library Documentation: https://googleapis.dev/python/billingbudgets/latest +.. _Product Documentation: https://cloud.google.com/billing/docs/how-to/budget-api-overview + +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 Cloud Billing Budget 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 Cloud Billing Budget API.: https://cloud.google.com/billing/docs/how-to/budget-api-overview +.. _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/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + source /bin/activate + /bin/pip install google-cloud-billing-budgets + + +Windows +^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + \Scripts\activate + \Scripts\pip.exe install google-cloud-billing-budgets + +Next Steps +~~~~~~~~~~ + +- Read the `Client Library Documentation`_ for Cloud Billing Budget API + API to see other available methods on the client. +- Read the `Cloud Billing Budget 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. + +.. _Cloud Billing Budget API Product documentation: https://cloud.google.com/billing/docs/how-to/budget-api-overview +.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/docs/README.rst b/packages/google-cloud-billing-budgets/docs/README.rst new file mode 120000 index 000000000000..89a0106941ff --- /dev/null +++ b/packages/google-cloud-billing-budgets/docs/README.rst @@ -0,0 +1 @@ +../README.rst \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/docs/changelog.md b/packages/google-cloud-billing-budgets/docs/changelog.md new file mode 120000 index 000000000000..04c99a55caae --- /dev/null +++ b/packages/google-cloud-billing-budgets/docs/changelog.md @@ -0,0 +1 @@ +../CHANGELOG.md \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/docs/conf.py b/packages/google-cloud-billing-budgets/docs/conf.py new file mode 100644 index 000000000000..5d7627cf434c --- /dev/null +++ b/packages/google-cloud-billing-budgets/docs/conf.py @@ -0,0 +1,363 @@ +# -*- coding: utf-8 -*- +# +# google-cloud-billing-budgets 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-billing-budgets" +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-billing-budgets-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-billing-budgets.tex", + u"google-cloud-billing-budgets 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-billing-budgets", + u"google-cloud-billing-budgets 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-billing-budgets", + u"google-cloud-billing-budgets Documentation", + author, + "google-cloud-billing-budgets", + "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/master/", 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/packages/google-cloud-billing-budgets/docs/gapic/v1beta1/api.rst b/packages/google-cloud-billing-budgets/docs/gapic/v1beta1/api.rst new file mode 100644 index 000000000000..b1f9f07ec077 --- /dev/null +++ b/packages/google-cloud-billing-budgets/docs/gapic/v1beta1/api.rst @@ -0,0 +1,6 @@ +Client for Cloud Billing Budget API +=================================== + +.. automodule:: google.cloud.billing_budgets_v1beta1 + :members: + :inherited-members: \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/docs/gapic/v1beta1/types.rst b/packages/google-cloud-billing-budgets/docs/gapic/v1beta1/types.rst new file mode 100644 index 000000000000..d25d7a205bc1 --- /dev/null +++ b/packages/google-cloud-billing-budgets/docs/gapic/v1beta1/types.rst @@ -0,0 +1,5 @@ +Types for Cloud Billing Budget API Client +========================================= + +.. automodule:: google.cloud.billing_budgets_v1beta1.types + :members: \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/docs/index.rst b/packages/google-cloud-billing-budgets/docs/index.rst new file mode 100644 index 000000000000..813764f98353 --- /dev/null +++ b/packages/google-cloud-billing-budgets/docs/index.rst @@ -0,0 +1,19 @@ +.. include:: README.rst + +Api Reference +------------- +.. toctree:: + :maxdepth: 2 + + gapic/v1beta1/api + gapic/v1beta1/types + +Changelog +--------- + +For a list of all ``google-cloud-billing-budgets`` releases: + +.. toctree:: + :maxdepth: 2 + + changelog diff --git a/packages/google-cloud-billing-budgets/google/__init__.py b/packages/google-cloud-billing-budgets/google/__init__.py new file mode 100644 index 000000000000..8fcc60e2b9c6 --- /dev/null +++ b/packages/google-cloud-billing-budgets/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/packages/google-cloud-billing-budgets/google/cloud/__init__.py b/packages/google-cloud-billing-budgets/google/cloud/__init__.py new file mode 100644 index 000000000000..8fcc60e2b9c6 --- /dev/null +++ b/packages/google-cloud-billing-budgets/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/packages/google-cloud-billing-budgets/google/cloud/billing_budgets.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets.py new file mode 100644 index 000000000000..25bce5346d64 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets.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.billing_budgets_v1beta1 import BudgetServiceClient +from google.cloud.billing_budgets_v1beta1 import enums +from google.cloud.billing_budgets_v1beta1 import types + + +__all__ = ("enums", "types", "BudgetServiceClient") diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/__init__.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/__init__.py new file mode 100644 index 000000000000..eb8a6be6d65f --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_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.billing_budgets_v1beta1 import types +from google.cloud.billing_budgets_v1beta1.gapic import budget_service_client +from google.cloud.billing_budgets_v1beta1.gapic import enums + + +class BudgetServiceClient(budget_service_client.BudgetServiceClient): + __doc__ = budget_service_client.BudgetServiceClient.__doc__ + enums = enums + + +__all__ = ("enums", "types", "BudgetServiceClient") diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/__init__.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/budget_service_client.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/budget_service_client.py new file mode 100644 index 000000000000..4b813afb49b7 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/budget_service_client.py @@ -0,0 +1,618 @@ +# -*- 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.billing.budgets.v1beta1 BudgetService 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.billing_budgets_v1beta1.gapic import budget_service_client_config +from google.cloud.billing_budgets_v1beta1.gapic import enums +from google.cloud.billing_budgets_v1beta1.gapic.transports import ( + budget_service_grpc_transport, +) +from google.cloud.billing_budgets_v1beta1.proto import budget_model_pb2 +from google.cloud.billing_budgets_v1beta1.proto import budget_service_pb2 +from google.cloud.billing_budgets_v1beta1.proto import budget_service_pb2_grpc +from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 + + +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( + "google-cloud-billing-budgets" +).version + + +class BudgetServiceClient(object): + """ + BudgetService stores Cloud Billing budgets, which define a + budget plan and rules to execute as we track spend against that plan. + """ + + SERVICE_ADDRESS = "billingbudgets.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.billing.budgets.v1beta1.BudgetService" + + @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: + BudgetServiceClient: 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 billing_account_path(cls, billing_account): + """Return a fully-qualified billing_account string.""" + return google.api_core.path_template.expand( + "billingAccounts/{billing_account}", billing_account=billing_account + ) + + @classmethod + def budget_path(cls, billing_account, budget): + """Return a fully-qualified budget string.""" + return google.api_core.path_template.expand( + "billingAccounts/{billing_account}/budgets/{budget}", + billing_account=billing_account, + budget=budget, + ) + + def __init__( + self, + transport=None, + channel=None, + credentials=None, + client_config=None, + client_info=None, + client_options=None, + ): + """Constructor. + + Args: + transport (Union[~.BudgetServiceGrpcTransport, + Callable[[~.Credentials, type], ~.BudgetServiceGrpcTransport]): 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 = budget_service_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=budget_service_grpc_transport.BudgetServiceGrpcTransport, + 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 = budget_service_grpc_transport.BudgetServiceGrpcTransport( + 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 create_budget( + self, + parent, + budget, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Creates a new budget. See + Quotas and limits + for more information on the limits of the number of budgets you can create. + + Example: + >>> from google.cloud import billing_budgets_v1beta1 + >>> + >>> client = billing_budgets_v1beta1.BudgetServiceClient() + >>> + >>> parent = client.billing_account_path('[BILLING_ACCOUNT]') + >>> + >>> # TODO: Initialize `budget`: + >>> budget = {} + >>> + >>> response = client.create_budget(parent, budget) + + Args: + parent (str): Required. The name of the billing account to create the budget in. + Values are of the form ``billingAccounts/{billingAccountId}``. + budget (Union[dict, ~google.cloud.billing_budgets_v1beta1.types.Budget]): Required. Budget to create. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.billing_budgets_v1beta1.types.Budget` + 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.billing_budgets_v1beta1.types.Budget` 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 "create_budget" not in self._inner_api_calls: + self._inner_api_calls[ + "create_budget" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_budget, + default_retry=self._method_configs["CreateBudget"].retry, + default_timeout=self._method_configs["CreateBudget"].timeout, + client_info=self._client_info, + ) + + request = budget_service_pb2.CreateBudgetRequest(parent=parent, budget=budget) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["create_budget"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def update_budget( + self, + budget, + update_mask=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Updates a budget and returns the updated budget. + + Example: + >>> from google.cloud import billing_budgets_v1beta1 + >>> + >>> client = billing_budgets_v1beta1.BudgetServiceClient() + >>> + >>> # TODO: Initialize `budget`: + >>> budget = {} + >>> + >>> response = client.update_budget(budget) + + Args: + budget (Union[dict, ~google.cloud.billing_budgets_v1beta1.types.Budget]): Required. The updated budget object. + The budget to update is specified by the budget name in the budget. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.billing_budgets_v1beta1.types.Budget` + update_mask (Union[dict, ~google.cloud.billing_budgets_v1beta1.types.FieldMask]): Optional. Indicates which fields in the provided budget to update. + Read-only fields (such as ``name``) cannot be changed. If this is not + provided, then only fields with non-default values from the request are + updated. See + https://developers.google.com/protocol-buffers/docs/proto3#default for + more details about default values. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.billing_budgets_v1beta1.types.FieldMask` + 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.billing_budgets_v1beta1.types.Budget` 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 "update_budget" not in self._inner_api_calls: + self._inner_api_calls[ + "update_budget" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.update_budget, + default_retry=self._method_configs["UpdateBudget"].retry, + default_timeout=self._method_configs["UpdateBudget"].timeout, + client_info=self._client_info, + ) + + request = budget_service_pb2.UpdateBudgetRequest( + budget=budget, update_mask=update_mask + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("budget.name", budget.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["update_budget"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def get_budget( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Returns a budget. + + Example: + >>> from google.cloud import billing_budgets_v1beta1 + >>> + >>> client = billing_budgets_v1beta1.BudgetServiceClient() + >>> + >>> name = client.budget_path('[BILLING_ACCOUNT]', '[BUDGET]') + >>> + >>> response = client.get_budget(name) + + Args: + name (str): Required. Name of budget to get. Values are of the form + ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. + 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.billing_budgets_v1beta1.types.Budget` 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_budget" not in self._inner_api_calls: + self._inner_api_calls[ + "get_budget" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_budget, + default_retry=self._method_configs["GetBudget"].retry, + default_timeout=self._method_configs["GetBudget"].timeout, + client_info=self._client_info, + ) + + request = budget_service_pb2.GetBudgetRequest(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_budget"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def list_budgets( + self, + parent, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Returns a list of budgets for a billing account. + + Example: + >>> from google.cloud import billing_budgets_v1beta1 + >>> + >>> client = billing_budgets_v1beta1.BudgetServiceClient() + >>> + >>> parent = client.billing_account_path('[BILLING_ACCOUNT]') + >>> + >>> # Iterate over all results + >>> for element in client.list_budgets(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_budgets(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. Name of billing account to list budgets under. Values are of + the form ``billingAccounts/{billingAccountId}``. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.api_core.page_iterator.PageIterator` instance. + An iterable of :class:`~google.cloud.billing_budgets_v1beta1.types.Budget` 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_budgets" not in self._inner_api_calls: + self._inner_api_calls[ + "list_budgets" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_budgets, + default_retry=self._method_configs["ListBudgets"].retry, + default_timeout=self._method_configs["ListBudgets"].timeout, + client_info=self._client_info, + ) + + request = budget_service_pb2.ListBudgetsRequest( + parent=parent, page_size=page_size + ) + 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_budgets"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="budgets", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + + def delete_budget( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Deletes a budget. Returns successfully if already deleted. + + Example: + >>> from google.cloud import billing_budgets_v1beta1 + >>> + >>> client = billing_budgets_v1beta1.BudgetServiceClient() + >>> + >>> name = client.budget_path('[BILLING_ACCOUNT]', '[BUDGET]') + >>> + >>> client.delete_budget(name) + + Args: + name (str): Required. Name of the budget to delete. Values are of the form + ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. + 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. + + 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 "delete_budget" not in self._inner_api_calls: + self._inner_api_calls[ + "delete_budget" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_budget, + default_retry=self._method_configs["DeleteBudget"].retry, + default_timeout=self._method_configs["DeleteBudget"].timeout, + client_info=self._client_info, + ) + + request = budget_service_pb2.DeleteBudgetRequest(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) + + self._inner_api_calls["delete_budget"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/budget_service_client_config.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/budget_service_client_config.py new file mode 100644 index 000000000000..1987acdea387 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/budget_service_client_config.py @@ -0,0 +1,48 @@ +config = { + "interfaces": { + "google.cloud.billing.budgets.v1beta1.BudgetService": { + "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": { + "CreateBudget": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "UpdateBudget": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "GetBudget": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "ListBudgets": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "DeleteBudget": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + }, + } + } +} diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/enums.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/enums.py new file mode 100644 index 000000000000..bbfc74f58283 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/enums.py @@ -0,0 +1,55 @@ +# -*- 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 Filter(object): + class CreditTypesTreatment(enum.IntEnum): + """ + Specifies how credits should be treated when determining spend for + threshold calculations. + + Attributes: + CREDIT_TYPES_TREATMENT_UNSPECIFIED (int) + INCLUDE_ALL_CREDITS (int): All types of credit are subtracted from the gross cost to determine the + spend for threshold calculations. + EXCLUDE_ALL_CREDITS (int): All types of credit are added to the net cost to determine the spend for + threshold calculations. + """ + + CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0 + INCLUDE_ALL_CREDITS = 1 + EXCLUDE_ALL_CREDITS = 2 + + +class ThresholdRule(object): + class Basis(enum.IntEnum): + """ + The type of basis used to determine if spend has passed the threshold. + + Attributes: + BASIS_UNSPECIFIED (int): Unspecified threshold basis. + CURRENT_SPEND (int): Use current spend as the basis for comparison against the threshold. + FORECASTED_SPEND (int): Use forecasted spend for the period as the basis for comparison against + the threshold. + """ + + BASIS_UNSPECIFIED = 0 + CURRENT_SPEND = 1 + FORECASTED_SPEND = 2 diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/transports/__init__.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/transports/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/transports/budget_service_grpc_transport.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/transports/budget_service_grpc_transport.py new file mode 100644 index 000000000000..33e7cda78532 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/gapic/transports/budget_service_grpc_transport.py @@ -0,0 +1,178 @@ +# -*- 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.billing_budgets_v1beta1.proto import budget_service_pb2_grpc + + +class BudgetServiceGrpcTransport(object): + """gRPC transport class providing stubs for + google.cloud.billing.budgets.v1beta1 BudgetService 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="billingbudgets.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 = { + "budget_service_stub": budget_service_pb2_grpc.BudgetServiceStub(channel) + } + + @classmethod + def create_channel( + cls, address="billingbudgets.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 create_budget(self): + """Return the gRPC stub for :meth:`BudgetServiceClient.create_budget`. + + Creates a new budget. See + Quotas and limits + for more information on the limits of the number of budgets you can create. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["budget_service_stub"].CreateBudget + + @property + def update_budget(self): + """Return the gRPC stub for :meth:`BudgetServiceClient.update_budget`. + + Updates a budget and returns the updated budget. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["budget_service_stub"].UpdateBudget + + @property + def get_budget(self): + """Return the gRPC stub for :meth:`BudgetServiceClient.get_budget`. + + Returns a budget. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["budget_service_stub"].GetBudget + + @property + def list_budgets(self): + """Return the gRPC stub for :meth:`BudgetServiceClient.list_budgets`. + + Returns a list of budgets for a billing account. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["budget_service_stub"].ListBudgets + + @property + def delete_budget(self): + """Return the gRPC stub for :meth:`BudgetServiceClient.delete_budget`. + + Deletes a budget. Returns successfully if already deleted. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["budget_service_stub"].DeleteBudget diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/__init__.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model.proto b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model.proto new file mode 100644 index 000000000000..89e96bea21c4 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model.proto @@ -0,0 +1,180 @@ +// 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.billing.budgets.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/type/money.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgets"; +option java_multiple_files = true; +option java_package = "com.google.cloud.billing.budgets.v1beta1"; + +// A budget is a plan that describes what you expect to spend on Cloud +// projects, plus the rules to execute as spend is tracked against that plan, +// (for example, send an alert when 90% of the target spend is met). +// Currently all plans are monthly budgets so the usage period(s) tracked are +// implied (calendar months of usage back-to-back). +message Budget { + option (google.api.resource) = { + type: "billingbudgets.googleapis.com/Budget" + pattern: "billingAccounts/{billing_account}/budgets/{budget}" + }; + + // Output only. Resource name of the budget. + // The resource name implies the scope of a budget. Values are of the form + // `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // User data for display name in UI. + // Validation: <= 60 chars. + string display_name = 2; + + // Optional. Filters that define which resources are used to compute + // the actual spend against the budget. + Filter budget_filter = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Budgeted amount. + BudgetAmount amount = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. Rules that trigger alerts (notifications of thresholds + // being crossed) when spend exceeds the specified percentages of the budget. + repeated ThresholdRule threshold_rules = 5 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Rules to apply to all updates to the actual spend, regardless + // of the thresholds set in `threshold_rules`. + AllUpdatesRule all_updates_rule = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Etag to validate that the object is unchanged for a + // read-modify-write operation. + // An empty etag will cause an update to overwrite other changes. + string etag = 7 [(google.api.field_behavior) = OPTIONAL]; +} + +// The budgeted amount for each usage period. +message BudgetAmount { + // Specification for what amount to use as the budget. + oneof budget_amount { + // A specified amount to use as the budget. + // `currency_code` is optional. If specified, it must match the + // currency of the billing account. The `currency_code` is provided on + // output. + google.type.Money specified_amount = 1; + + // Use the last period's actual spend as the budget for the present period. + LastPeriodAmount last_period_amount = 2; + } +} + +// Describes a budget amount targeted to last period's spend. +// At this time, the amount is automatically 100% of last period's spend; +// that is, there are no other options yet. +// Future configuration will be described here (for example, configuring a +// percentage of last period's spend). +message LastPeriodAmount { + +} + +// ThresholdRule contains a definition of a threshold which triggers +// an alert (a notification of a threshold being crossed) to be sent when +// spend goes above the specified amount. +// Alerts are automatically e-mailed to users with the Billing Account +// Administrator role or the Billing Account User role. +// The thresholds here have no effect on notifications sent to anything +// configured under `Budget.all_updates_rule`. +message ThresholdRule { + // The type of basis used to determine if spend has passed the threshold. + enum Basis { + // Unspecified threshold basis. + BASIS_UNSPECIFIED = 0; + + // Use current spend as the basis for comparison against the threshold. + CURRENT_SPEND = 1; + + // Use forecasted spend for the period as the basis for comparison against + // the threshold. + FORECASTED_SPEND = 2; + } + + // Required. Send an alert when this threshold is exceeded. + // This is a 1.0-based percentage, so 0.5 = 50%. + // Validation: non-negative number. + double threshold_percent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The type of basis used to determine if spend has passed the + // threshold. Behavior defaults to CURRENT_SPEND if not set. + Basis spend_basis = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// AllUpdatesRule defines notifications that are sent on every update to the +// billing account's spend, regardless of the thresholds defined using +// threshold rules. +message AllUpdatesRule { + // Required. The name of the Cloud Pub/Sub topic where budget related messages will be + // published, in the form `projects/{project_id}/topics/{topic_id}`. Updates + // are sent at regular intervals to the topic. + // The topic needs to be created before the budget is created; see + // https://cloud.google.com/billing/docs/how-to/budgets#manage-notifications + // for more details. + // Caller is expected to have + // `pubsub.topics.setIamPolicy` permission on the topic when it's set for a + // budget, otherwise, the API call will fail with PERMISSION_DENIED. See + // https://cloud.google.com/pubsub/docs/access-control for more details on + // Pub/Sub roles and permissions. + string pubsub_topic = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The schema version of the notification. + // Only "1.0" is accepted. It represents the JSON schema as defined in + // https://cloud.google.com/billing/docs/how-to/budgets#notification_format + string schema_version = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// A filter for a budget, limiting the scope of the cost to calculate. +message Filter { + // Specifies how credits should be treated when determining spend for + // threshold calculations. + enum CreditTypesTreatment { + CREDIT_TYPES_TREATMENT_UNSPECIFIED = 0; + + // All types of credit are subtracted from the gross cost to determine the + // spend for threshold calculations. + INCLUDE_ALL_CREDITS = 1; + + // All types of credit are added to the net cost to determine the spend for + // threshold calculations. + EXCLUDE_ALL_CREDITS = 2; + } + + // Optional. A set of projects of the form `projects/{project_id}`, + // specifying that usage from only this set of projects should be + // included in the budget. If omitted, the report will include all usage for + // the billing account, regardless of which project the usage occurred on. + // Only zero or one project can be specified currently. + repeated string projects = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If not set, default behavior is `INCLUDE_ALL_CREDITS`. + CreditTypesTreatment credit_types_treatment = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A set of services of the form `services/{service_id}`, + // specifying that usage from only this set of services should be + // included in the budget. If omitted, the report will include usage for + // all the services. + // The service names are available through the Catalog API: + // https://cloud.google.com/billing/v1/how-tos/catalog-api. + repeated string services = 3 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model_pb2.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model_pb2.py new file mode 100644 index 000000000000..734d1d2e2ae1 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model_pb2.py @@ -0,0 +1,761 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/billing/budgets_v1beta1/proto/budget_model.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 field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.type import money_pb2 as google_dot_type_dot_money__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/billing/budgets_v1beta1/proto/budget_model.proto", + package="google.cloud.billing.budgets.v1beta1", + syntax="proto3", + serialized_options=_b( + "\n(com.google.cloud.billing.budgets.v1beta1P\001ZKgoogle.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgets" + ), + serialized_pb=_b( + '\n=google/cloud/billing/budgets_v1beta1/proto/budget_model.proto\x12$google.cloud.billing.budgets.v1beta1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x17google/type/money.proto"\xde\x03\n\x06\x42udget\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\x12H\n\rbudget_filter\x18\x03 \x01(\x0b\x32,.google.cloud.billing.budgets.v1beta1.FilterB\x03\xe0\x41\x01\x12G\n\x06\x61mount\x18\x04 \x01(\x0b\x32\x32.google.cloud.billing.budgets.v1beta1.BudgetAmountB\x03\xe0\x41\x02\x12Q\n\x0fthreshold_rules\x18\x05 \x03(\x0b\x32\x33.google.cloud.billing.budgets.v1beta1.ThresholdRuleB\x03\xe0\x41\x02\x12S\n\x10\x61ll_updates_rule\x18\x06 \x01(\x0b\x32\x34.google.cloud.billing.budgets.v1beta1.AllUpdatesRuleB\x03\xe0\x41\x01\x12\x11\n\x04\x65tag\x18\x07 \x01(\tB\x03\xe0\x41\x01:]\xea\x41Z\n$billingbudgets.googleapis.com/Budget\x12\x32\x62illingAccounts/{billing_account}/budgets/{budget}"\xa5\x01\n\x0c\x42udgetAmount\x12.\n\x10specified_amount\x18\x01 \x01(\x0b\x32\x12.google.type.MoneyH\x00\x12T\n\x12last_period_amount\x18\x02 \x01(\x0b\x32\x36.google.cloud.billing.budgets.v1beta1.LastPeriodAmountH\x00\x42\x0f\n\rbudget_amount"\x12\n\x10LastPeriodAmount"\xcd\x01\n\rThresholdRule\x12\x1e\n\x11threshold_percent\x18\x01 \x01(\x01\x42\x03\xe0\x41\x02\x12S\n\x0bspend_basis\x18\x02 \x01(\x0e\x32\x39.google.cloud.billing.budgets.v1beta1.ThresholdRule.BasisB\x03\xe0\x41\x01"G\n\x05\x42\x61sis\x12\x15\n\x11\x42\x41SIS_UNSPECIFIED\x10\x00\x12\x11\n\rCURRENT_SPEND\x10\x01\x12\x14\n\x10\x46ORECASTED_SPEND\x10\x02"H\n\x0e\x41llUpdatesRule\x12\x19\n\x0cpubsub_topic\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x1b\n\x0eschema_version\x18\x02 \x01(\tB\x03\xe0\x41\x02"\x90\x02\n\x06\x46ilter\x12\x15\n\x08projects\x18\x01 \x03(\tB\x03\xe0\x41\x01\x12\x66\n\x16\x63redit_types_treatment\x18\x04 \x01(\x0e\x32\x41.google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatmentB\x03\xe0\x41\x01\x12\x15\n\x08services\x18\x03 \x03(\tB\x03\xe0\x41\x01"p\n\x14\x43reditTypesTreatment\x12&\n"CREDIT_TYPES_TREATMENT_UNSPECIFIED\x10\x00\x12\x17\n\x13INCLUDE_ALL_CREDITS\x10\x01\x12\x17\n\x13\x45XCLUDE_ALL_CREDITS\x10\x02\x42y\n(com.google.cloud.billing.budgets.v1beta1P\x01ZKgoogle.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgetsb\x06proto3' + ), + dependencies=[ + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_type_dot_money__pb2.DESCRIPTOR, + ], +) + + +_THRESHOLDRULE_BASIS = _descriptor.EnumDescriptor( + name="Basis", + full_name="google.cloud.billing.budgets.v1beta1.ThresholdRule.Basis", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="BASIS_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="CURRENT_SPEND", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="FORECASTED_SPEND", + index=2, + number=2, + serialized_options=None, + type=None, + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=992, + serialized_end=1063, +) +_sym_db.RegisterEnumDescriptor(_THRESHOLDRULE_BASIS) + +_FILTER_CREDITTYPESTREATMENT = _descriptor.EnumDescriptor( + name="CreditTypesTreatment", + full_name="google.cloud.billing.budgets.v1beta1.Filter.CreditTypesTreatment", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="CREDIT_TYPES_TREATMENT_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="INCLUDE_ALL_CREDITS", + index=1, + number=1, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="EXCLUDE_ALL_CREDITS", + index=2, + number=2, + serialized_options=None, + type=None, + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=1300, + serialized_end=1412, +) +_sym_db.RegisterEnumDescriptor(_FILTER_CREDITTYPESTREATMENT) + + +_BUDGET = _descriptor.Descriptor( + name="Budget", + full_name="google.cloud.billing.budgets.v1beta1.Budget", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.billing.budgets.v1beta1.Budget.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=_b("\340A\003"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="display_name", + full_name="google.cloud.billing.budgets.v1beta1.Budget.display_name", + 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="budget_filter", + full_name="google.cloud.billing.budgets.v1beta1.Budget.budget_filter", + index=2, + number=3, + 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=_b("\340A\001"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="amount", + full_name="google.cloud.billing.budgets.v1beta1.Budget.amount", + 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=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="threshold_rules", + full_name="google.cloud.billing.budgets.v1beta1.Budget.threshold_rules", + index=4, + number=5, + 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=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="all_updates_rule", + full_name="google.cloud.billing.budgets.v1beta1.Budget.all_updates_rule", + index=5, + number=6, + 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=_b("\340A\001"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="etag", + full_name="google.cloud.billing.budgets.v1beta1.Budget.etag", + index=6, + number=7, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\001"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=_b( + "\352AZ\n$billingbudgets.googleapis.com/Budget\0222billingAccounts/{billing_account}/budgets/{budget}" + ), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=189, + serialized_end=667, +) + + +_BUDGETAMOUNT = _descriptor.Descriptor( + name="BudgetAmount", + full_name="google.cloud.billing.budgets.v1beta1.BudgetAmount", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="specified_amount", + full_name="google.cloud.billing.budgets.v1beta1.BudgetAmount.specified_amount", + 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="last_period_amount", + full_name="google.cloud.billing.budgets.v1beta1.BudgetAmount.last_period_amount", + 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=[ + _descriptor.OneofDescriptor( + name="budget_amount", + full_name="google.cloud.billing.budgets.v1beta1.BudgetAmount.budget_amount", + index=0, + containing_type=None, + fields=[], + ) + ], + serialized_start=670, + serialized_end=835, +) + + +_LASTPERIODAMOUNT = _descriptor.Descriptor( + name="LastPeriodAmount", + full_name="google.cloud.billing.budgets.v1beta1.LastPeriodAmount", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=837, + serialized_end=855, +) + + +_THRESHOLDRULE = _descriptor.Descriptor( + name="ThresholdRule", + full_name="google.cloud.billing.budgets.v1beta1.ThresholdRule", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="threshold_percent", + full_name="google.cloud.billing.budgets.v1beta1.ThresholdRule.threshold_percent", + index=0, + number=1, + type=1, + cpp_type=5, + label=1, + has_default_value=False, + default_value=float(0), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="spend_basis", + full_name="google.cloud.billing.budgets.v1beta1.ThresholdRule.spend_basis", + index=1, + number=2, + 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=_b("\340A\001"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[_THRESHOLDRULE_BASIS], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=858, + serialized_end=1063, +) + + +_ALLUPDATESRULE = _descriptor.Descriptor( + name="AllUpdatesRule", + full_name="google.cloud.billing.budgets.v1beta1.AllUpdatesRule", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="pubsub_topic", + full_name="google.cloud.billing.budgets.v1beta1.AllUpdatesRule.pubsub_topic", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="schema_version", + full_name="google.cloud.billing.budgets.v1beta1.AllUpdatesRule.schema_version", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1065, + serialized_end=1137, +) + + +_FILTER = _descriptor.Descriptor( + name="Filter", + full_name="google.cloud.billing.budgets.v1beta1.Filter", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="projects", + full_name="google.cloud.billing.budgets.v1beta1.Filter.projects", + index=0, + number=1, + type=9, + cpp_type=9, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\001"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="credit_types_treatment", + full_name="google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment", + index=1, + number=4, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\001"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="services", + full_name="google.cloud.billing.budgets.v1beta1.Filter.services", + index=2, + number=3, + type=9, + cpp_type=9, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\001"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[_FILTER_CREDITTYPESTREATMENT], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1140, + serialized_end=1412, +) + +_BUDGET.fields_by_name["budget_filter"].message_type = _FILTER +_BUDGET.fields_by_name["amount"].message_type = _BUDGETAMOUNT +_BUDGET.fields_by_name["threshold_rules"].message_type = _THRESHOLDRULE +_BUDGET.fields_by_name["all_updates_rule"].message_type = _ALLUPDATESRULE +_BUDGETAMOUNT.fields_by_name[ + "specified_amount" +].message_type = google_dot_type_dot_money__pb2._MONEY +_BUDGETAMOUNT.fields_by_name["last_period_amount"].message_type = _LASTPERIODAMOUNT +_BUDGETAMOUNT.oneofs_by_name["budget_amount"].fields.append( + _BUDGETAMOUNT.fields_by_name["specified_amount"] +) +_BUDGETAMOUNT.fields_by_name[ + "specified_amount" +].containing_oneof = _BUDGETAMOUNT.oneofs_by_name["budget_amount"] +_BUDGETAMOUNT.oneofs_by_name["budget_amount"].fields.append( + _BUDGETAMOUNT.fields_by_name["last_period_amount"] +) +_BUDGETAMOUNT.fields_by_name[ + "last_period_amount" +].containing_oneof = _BUDGETAMOUNT.oneofs_by_name["budget_amount"] +_THRESHOLDRULE.fields_by_name["spend_basis"].enum_type = _THRESHOLDRULE_BASIS +_THRESHOLDRULE_BASIS.containing_type = _THRESHOLDRULE +_FILTER.fields_by_name[ + "credit_types_treatment" +].enum_type = _FILTER_CREDITTYPESTREATMENT +_FILTER_CREDITTYPESTREATMENT.containing_type = _FILTER +DESCRIPTOR.message_types_by_name["Budget"] = _BUDGET +DESCRIPTOR.message_types_by_name["BudgetAmount"] = _BUDGETAMOUNT +DESCRIPTOR.message_types_by_name["LastPeriodAmount"] = _LASTPERIODAMOUNT +DESCRIPTOR.message_types_by_name["ThresholdRule"] = _THRESHOLDRULE +DESCRIPTOR.message_types_by_name["AllUpdatesRule"] = _ALLUPDATESRULE +DESCRIPTOR.message_types_by_name["Filter"] = _FILTER +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Budget = _reflection.GeneratedProtocolMessageType( + "Budget", + (_message.Message,), + dict( + DESCRIPTOR=_BUDGET, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_model_pb2", + __doc__="""A budget is a plan that describes what you expect to spend on Cloud + projects, plus the rules to execute as spend is tracked against that + plan, (for example, send an alert when 90% of the target spend is met). + Currently all plans are monthly budgets so the usage period(s) tracked + are implied (calendar months of usage back-to-back). + + + Attributes: + name: + Output only. Resource name of the budget. The resource name + implies the scope of a budget. Values are of the form + ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. + display_name: + User data for display name in UI. Validation: <= 60 chars. + budget_filter: + Optional. Filters that define which resources are used to + compute the actual spend against the budget. + amount: + Required. Budgeted amount. + threshold_rules: + Required. Rules that trigger alerts (notifications of + thresholds being crossed) when spend exceeds the specified + percentages of the budget. + all_updates_rule: + Optional. Rules to apply to all updates to the actual spend, + regardless of the thresholds set in ``threshold_rules``. + etag: + Optional. Etag to validate that the object is unchanged for a + read-modify-write operation. An empty etag will cause an + update to overwrite other changes. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.Budget) + ), +) +_sym_db.RegisterMessage(Budget) + +BudgetAmount = _reflection.GeneratedProtocolMessageType( + "BudgetAmount", + (_message.Message,), + dict( + DESCRIPTOR=_BUDGETAMOUNT, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_model_pb2", + __doc__="""The budgeted amount for each usage period. + + + Attributes: + budget_amount: + Specification for what amount to use as the budget. + specified_amount: + A specified amount to use as the budget. ``currency_code`` is + optional. If specified, it must match the currency of the + billing account. The ``currency_code`` is provided on output. + last_period_amount: + Use the last period's actual spend as the budget for the + present period. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.BudgetAmount) + ), +) +_sym_db.RegisterMessage(BudgetAmount) + +LastPeriodAmount = _reflection.GeneratedProtocolMessageType( + "LastPeriodAmount", + (_message.Message,), + dict( + DESCRIPTOR=_LASTPERIODAMOUNT, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_model_pb2", + __doc__="""Describes a budget amount targeted to last period's spend. At this time, + the amount is automatically 100% of last period's spend; that is, there + are no other options yet. Future configuration will be described here + (for example, configuring a percentage of last period's spend). + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.LastPeriodAmount) + ), +) +_sym_db.RegisterMessage(LastPeriodAmount) + +ThresholdRule = _reflection.GeneratedProtocolMessageType( + "ThresholdRule", + (_message.Message,), + dict( + DESCRIPTOR=_THRESHOLDRULE, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_model_pb2", + __doc__="""ThresholdRule contains a definition of a threshold which triggers an + alert (a notification of a threshold being crossed) to be sent when + spend goes above the specified amount. Alerts are automatically e-mailed + to users with the Billing Account Administrator role or the Billing + Account User role. The thresholds here have no effect on notifications + sent to anything configured under ``Budget.all_updates_rule``. + + + Attributes: + threshold_percent: + Required. Send an alert when this threshold is exceeded. This + is a 1.0-based percentage, so 0.5 = 50%. Validation: non- + negative number. + spend_basis: + Optional. The type of basis used to determine if spend has + passed the threshold. Behavior defaults to CURRENT\_SPEND if + not set. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.ThresholdRule) + ), +) +_sym_db.RegisterMessage(ThresholdRule) + +AllUpdatesRule = _reflection.GeneratedProtocolMessageType( + "AllUpdatesRule", + (_message.Message,), + dict( + DESCRIPTOR=_ALLUPDATESRULE, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_model_pb2", + __doc__="""AllUpdatesRule defines notifications that are sent on every update to + the billing account's spend, regardless of the thresholds defined using + threshold rules. + + + Attributes: + pubsub_topic: + Required. The name of the Cloud Pub/Sub topic where budget + related messages will be published, in the form + ``projects/{project_id}/topics/{topic_id}``. Updates are sent + at regular intervals to the topic. The topic needs to be + created before the budget is created; see + https://cloud.google.com/billing/docs/how-to/budgets#manage- + notifications for more details. Caller is expected to have + ``pubsub.topics.setIamPolicy`` permission on the topic when + it's set for a budget, otherwise, the API call will fail with + PERMISSION\_DENIED. See + https://cloud.google.com/pubsub/docs/access-control for more + details on Pub/Sub roles and permissions. + schema_version: + Required. The schema version of the notification. Only "1.0" + is accepted. It represents the JSON schema as defined in + https://cloud.google.com/billing/docs/how- + to/budgets#notification\_format + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.AllUpdatesRule) + ), +) +_sym_db.RegisterMessage(AllUpdatesRule) + +Filter = _reflection.GeneratedProtocolMessageType( + "Filter", + (_message.Message,), + dict( + DESCRIPTOR=_FILTER, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_model_pb2", + __doc__="""A filter for a budget, limiting the scope of the cost to calculate. + + + Attributes: + projects: + Optional. A set of projects of the form + ``projects/{project_id}``, specifying that usage from only + this set of projects should be included in the budget. If + omitted, the report will include all usage for the billing + account, regardless of which project the usage occurred on. + Only zero or one project can be specified currently. + credit_types_treatment: + Optional. If not set, default behavior is + ``INCLUDE_ALL_CREDITS``. + services: + Optional. A set of services of the form + ``services/{service_id}``, specifying that usage from only + this set of services should be included in the budget. If + omitted, the report will include usage for all the services. + The service names are available through the Catalog API: + https://cloud.google.com/billing/v1/how-tos/catalog-api. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.Filter) + ), +) +_sym_db.RegisterMessage(Filter) + + +DESCRIPTOR._options = None +_BUDGET.fields_by_name["name"]._options = None +_BUDGET.fields_by_name["budget_filter"]._options = None +_BUDGET.fields_by_name["amount"]._options = None +_BUDGET.fields_by_name["threshold_rules"]._options = None +_BUDGET.fields_by_name["all_updates_rule"]._options = None +_BUDGET.fields_by_name["etag"]._options = None +_BUDGET._options = None +_THRESHOLDRULE.fields_by_name["threshold_percent"]._options = None +_THRESHOLDRULE.fields_by_name["spend_basis"]._options = None +_ALLUPDATESRULE.fields_by_name["pubsub_topic"]._options = None +_ALLUPDATESRULE.fields_by_name["schema_version"]._options = None +_FILTER.fields_by_name["projects"]._options = None +_FILTER.fields_by_name["credit_types_treatment"]._options = None +_FILTER.fields_by_name["services"]._options = None +# @@protoc_insertion_point(module_scope) diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model_pb2_grpc.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model_pb2_grpc.py new file mode 100644 index 000000000000..07cb78fe03a9 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_model_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service.proto b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service.proto new file mode 100644 index 000000000000..d5e0f4bc9a5a --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service.proto @@ -0,0 +1,161 @@ +// 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.billing.budgets.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/billing/budgets/v1beta1/budget_model.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgets"; +option java_multiple_files = true; +option java_package = "com.google.cloud.billing.budgets.v1beta1"; + +// BudgetService stores Cloud Billing budgets, which define a +// budget plan and rules to execute as we track spend against that plan. +service BudgetService { + option (google.api.default_host) = "billingbudgets.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new budget. See + // Quotas and limits + // for more information on the limits of the number of budgets you can create. + rpc CreateBudget(CreateBudgetRequest) returns (Budget) { + option (google.api.http) = { + post: "/v1beta1/{parent=billingAccounts/*}/budgets" + body: "*" + }; + } + + // Updates a budget and returns the updated budget. + rpc UpdateBudget(UpdateBudgetRequest) returns (Budget) { + option (google.api.http) = { + patch: "/v1beta1/{budget.name=billingAccounts/*/budgets/*}" + body: "*" + }; + } + + // Returns a budget. + rpc GetBudget(GetBudgetRequest) returns (Budget) { + option (google.api.http) = { + get: "/v1beta1/{name=billingAccounts/*/budgets/*}" + }; + } + + // Returns a list of budgets for a billing account. + rpc ListBudgets(ListBudgetsRequest) returns (ListBudgetsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=billingAccounts/*}/budgets" + }; + } + + // Deletes a budget. Returns successfully if already deleted. + rpc DeleteBudget(DeleteBudgetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=billingAccounts/*/budgets/*}" + }; + } +} + +// Request for CreateBudget +message CreateBudgetRequest { + // Required. The name of the billing account to create the budget in. Values + // are of the form `billingAccounts/{billingAccountId}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "billingbudgets.googleapis.com/Budget" + } + ]; + + // Required. Budget to create. + Budget budget = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateBudget +message UpdateBudgetRequest { + // Required. The updated budget object. + // The budget to update is specified by the budget name in the budget. + Budget budget = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates which fields in the provided budget to update. + // Read-only fields (such as `name`) cannot be changed. If this is not + // provided, then only fields with non-default values from the request are + // updated. See + // https://developers.google.com/protocol-buffers/docs/proto3#default for more + // details about default values. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for GetBudget +message GetBudgetRequest { + // Required. Name of budget to get. Values are of the form + // `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "billingbudgets.googleapis.com/Budget" + } + ]; +} + +// Request for ListBudgets +message ListBudgetsRequest { + // Required. Name of billing account to list budgets under. Values + // are of the form `billingAccounts/{billingAccountId}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "billingbudgets.googleapis.com/Budget" + } + ]; + + // Optional. The maximum number of budgets to return per page. + // The default and maximum value are 100. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The value returned by the last `ListBudgetsResponse` which + // indicates that this is a continuation of a prior `ListBudgets` call, + // and that the system should return the next page of data. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListBudgets +message ListBudgetsResponse { + // List of the budgets owned by the requested billing account. + repeated Budget budgets = 1; + + // If not empty, indicates that there may be more budgets that match the + // request; this value should be passed in a new `ListBudgetsRequest`. + string next_page_token = 2; +} + +// Request for DeleteBudget +message DeleteBudgetRequest { + // Required. Name of the budget to delete. Values are of the form + // `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "billingbudgets.googleapis.com/Budget" + } + ]; +} diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service_pb2.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service_pb2.py new file mode 100644 index 000000000000..37b30941031a --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service_pb2.py @@ -0,0 +1,628 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/billing/budgets_v1beta1/proto/budget_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.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.cloud.billing_budgets_v1beta1.proto import ( + budget_model_pb2 as google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2, +) +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/billing/budgets_v1beta1/proto/budget_service.proto", + package="google.cloud.billing.budgets.v1beta1", + syntax="proto3", + serialized_options=_b( + "\n(com.google.cloud.billing.budgets.v1beta1P\001ZKgoogle.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgets" + ), + serialized_pb=_b( + '\n?google/cloud/billing/budgets_v1beta1/proto/budget_service.proto\x12$google.cloud.billing.budgets.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a=google/cloud/billing/budgets_v1beta1/proto/budget_model.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto"\x96\x01\n\x13\x43reateBudgetRequest\x12<\n\x06parent\x18\x01 \x01(\tB,\xe0\x41\x02\xfa\x41&\x12$billingbudgets.googleapis.com/Budget\x12\x41\n\x06\x62udget\x18\x02 \x01(\x0b\x32,.google.cloud.billing.budgets.v1beta1.BudgetB\x03\xe0\x41\x02"\x8e\x01\n\x13UpdateBudgetRequest\x12\x41\n\x06\x62udget\x18\x01 \x01(\x0b\x32,.google.cloud.billing.budgets.v1beta1.BudgetB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x01"N\n\x10GetBudgetRequest\x12:\n\x04name\x18\x01 \x01(\tB,\xe0\x41\x02\xfa\x41&\n$billingbudgets.googleapis.com/Budget"\x83\x01\n\x12ListBudgetsRequest\x12<\n\x06parent\x18\x01 \x01(\tB,\xe0\x41\x02\xfa\x41&\x12$billingbudgets.googleapis.com/Budget\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01"m\n\x13ListBudgetsResponse\x12=\n\x07\x62udgets\x18\x01 \x03(\x0b\x32,.google.cloud.billing.budgets.v1beta1.Budget\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"Q\n\x13\x44\x65leteBudgetRequest\x12:\n\x04name\x18\x01 \x01(\tB,\xe0\x41\x02\xfa\x41&\n$billingbudgets.googleapis.com/Budget2\xc9\x07\n\rBudgetService\x12\xaf\x01\n\x0c\x43reateBudget\x12\x39.google.cloud.billing.budgets.v1beta1.CreateBudgetRequest\x1a,.google.cloud.billing.budgets.v1beta1.Budget"6\x82\xd3\xe4\x93\x02\x30"+/v1beta1/{parent=billingAccounts/*}/budgets:\x01*\x12\xb6\x01\n\x0cUpdateBudget\x12\x39.google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest\x1a,.google.cloud.billing.budgets.v1beta1.Budget"=\x82\xd3\xe4\x93\x02\x37\x32\x32/v1beta1/{budget.name=billingAccounts/*/budgets/*}:\x01*\x12\xa6\x01\n\tGetBudget\x12\x36.google.cloud.billing.budgets.v1beta1.GetBudgetRequest\x1a,.google.cloud.billing.budgets.v1beta1.Budget"3\x82\xd3\xe4\x93\x02-\x12+/v1beta1/{name=billingAccounts/*/budgets/*}\x12\xb7\x01\n\x0bListBudgets\x12\x38.google.cloud.billing.budgets.v1beta1.ListBudgetsRequest\x1a\x39.google.cloud.billing.budgets.v1beta1.ListBudgetsResponse"3\x82\xd3\xe4\x93\x02-\x12+/v1beta1/{parent=billingAccounts/*}/budgets\x12\x96\x01\n\x0c\x44\x65leteBudget\x12\x39.google.cloud.billing.budgets.v1beta1.DeleteBudgetRequest\x1a\x16.google.protobuf.Empty"3\x82\xd3\xe4\x93\x02-*+/v1beta1/{name=billingAccounts/*/budgets/*}\x1aQ\xca\x41\x1d\x62illingbudgets.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformBy\n(com.google.cloud.billing.budgets.v1beta1P\x01ZKgoogle.golang.org/genproto/googleapis/cloud/billing/budgets/v1beta1;budgetsb\x06proto3' + ), + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_client__pb2.DESCRIPTOR, + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.DESCRIPTOR, + google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, + google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR, + ], +) + + +_CREATEBUDGETREQUEST = _descriptor.Descriptor( + name="CreateBudgetRequest", + full_name="google.cloud.billing.budgets.v1beta1.CreateBudgetRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.billing.budgets.v1beta1.CreateBudgetRequest.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=_b( + "\340A\002\372A&\022$billingbudgets.googleapis.com/Budget" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="budget", + full_name="google.cloud.billing.budgets.v1beta1.CreateBudgetRequest.budget", + 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=_b("\340A\002"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=347, + serialized_end=497, +) + + +_UPDATEBUDGETREQUEST = _descriptor.Descriptor( + name="UpdateBudgetRequest", + full_name="google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="budget", + full_name="google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest.budget", + 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=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="update_mask", + full_name="google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest.update_mask", + 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=_b("\340A\001"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=500, + serialized_end=642, +) + + +_GETBUDGETREQUEST = _descriptor.Descriptor( + name="GetBudgetRequest", + full_name="google.cloud.billing.budgets.v1beta1.GetBudgetRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.billing.budgets.v1beta1.GetBudgetRequest.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=_b( + "\340A\002\372A&\n$billingbudgets.googleapis.com/Budget" + ), + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=644, + serialized_end=722, +) + + +_LISTBUDGETSREQUEST = _descriptor.Descriptor( + name="ListBudgetsRequest", + full_name="google.cloud.billing.budgets.v1beta1.ListBudgetsRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.billing.budgets.v1beta1.ListBudgetsRequest.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=_b( + "\340A\002\372A&\022$billingbudgets.googleapis.com/Budget" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.cloud.billing.budgets.v1beta1.ListBudgetsRequest.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=_b("\340A\001"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.cloud.billing.budgets.v1beta1.ListBudgetsRequest.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=_b("\340A\001"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=725, + serialized_end=856, +) + + +_LISTBUDGETSRESPONSE = _descriptor.Descriptor( + name="ListBudgetsResponse", + full_name="google.cloud.billing.budgets.v1beta1.ListBudgetsResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="budgets", + full_name="google.cloud.billing.budgets.v1beta1.ListBudgetsResponse.budgets", + 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.billing.budgets.v1beta1.ListBudgetsResponse.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=858, + serialized_end=967, +) + + +_DELETEBUDGETREQUEST = _descriptor.Descriptor( + name="DeleteBudgetRequest", + full_name="google.cloud.billing.budgets.v1beta1.DeleteBudgetRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.billing.budgets.v1beta1.DeleteBudgetRequest.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=_b( + "\340A\002\372A&\n$billingbudgets.googleapis.com/Budget" + ), + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=969, + serialized_end=1050, +) + +_CREATEBUDGETREQUEST.fields_by_name[ + "budget" +].message_type = ( + google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2._BUDGET +) +_UPDATEBUDGETREQUEST.fields_by_name[ + "budget" +].message_type = ( + google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2._BUDGET +) +_UPDATEBUDGETREQUEST.fields_by_name[ + "update_mask" +].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK +_LISTBUDGETSRESPONSE.fields_by_name[ + "budgets" +].message_type = ( + google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2._BUDGET +) +DESCRIPTOR.message_types_by_name["CreateBudgetRequest"] = _CREATEBUDGETREQUEST +DESCRIPTOR.message_types_by_name["UpdateBudgetRequest"] = _UPDATEBUDGETREQUEST +DESCRIPTOR.message_types_by_name["GetBudgetRequest"] = _GETBUDGETREQUEST +DESCRIPTOR.message_types_by_name["ListBudgetsRequest"] = _LISTBUDGETSREQUEST +DESCRIPTOR.message_types_by_name["ListBudgetsResponse"] = _LISTBUDGETSRESPONSE +DESCRIPTOR.message_types_by_name["DeleteBudgetRequest"] = _DELETEBUDGETREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +CreateBudgetRequest = _reflection.GeneratedProtocolMessageType( + "CreateBudgetRequest", + (_message.Message,), + dict( + DESCRIPTOR=_CREATEBUDGETREQUEST, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_service_pb2", + __doc__="""Request for CreateBudget + + + Attributes: + parent: + Required. The name of the billing account to create the budget + in. Values are of the form + ``billingAccounts/{billingAccountId}``. + budget: + Required. Budget to create. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.CreateBudgetRequest) + ), +) +_sym_db.RegisterMessage(CreateBudgetRequest) + +UpdateBudgetRequest = _reflection.GeneratedProtocolMessageType( + "UpdateBudgetRequest", + (_message.Message,), + dict( + DESCRIPTOR=_UPDATEBUDGETREQUEST, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_service_pb2", + __doc__="""Request for UpdateBudget + + + Attributes: + budget: + Required. The updated budget object. The budget to update is + specified by the budget name in the budget. + update_mask: + Optional. Indicates which fields in the provided budget to + update. Read-only fields (such as ``name``) cannot be changed. + If this is not provided, then only fields with non-default + values from the request are updated. See + https://developers.google.com/protocol- + buffers/docs/proto3#default for more details about default + values. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.UpdateBudgetRequest) + ), +) +_sym_db.RegisterMessage(UpdateBudgetRequest) + +GetBudgetRequest = _reflection.GeneratedProtocolMessageType( + "GetBudgetRequest", + (_message.Message,), + dict( + DESCRIPTOR=_GETBUDGETREQUEST, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_service_pb2", + __doc__="""Request for GetBudget + + + Attributes: + name: + Required. Name of budget to get. Values are of the form + ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.GetBudgetRequest) + ), +) +_sym_db.RegisterMessage(GetBudgetRequest) + +ListBudgetsRequest = _reflection.GeneratedProtocolMessageType( + "ListBudgetsRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTBUDGETSREQUEST, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_service_pb2", + __doc__="""Request for ListBudgets + + + Attributes: + parent: + Required. Name of billing account to list budgets under. + Values are of the form ``billingAccounts/{billingAccountId}``. + page_size: + Optional. The maximum number of budgets to return per page. + The default and maximum value are 100. + page_token: + Optional. The value returned by the last + ``ListBudgetsResponse`` which indicates that this is a + continuation of a prior ``ListBudgets`` call, and that the + system should return the next page of data. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.ListBudgetsRequest) + ), +) +_sym_db.RegisterMessage(ListBudgetsRequest) + +ListBudgetsResponse = _reflection.GeneratedProtocolMessageType( + "ListBudgetsResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTBUDGETSRESPONSE, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_service_pb2", + __doc__="""Response for ListBudgets + + + Attributes: + budgets: + List of the budgets owned by the requested billing account. + next_page_token: + If not empty, indicates that there may be more budgets that + match the request; this value should be passed in a new + ``ListBudgetsRequest``. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.ListBudgetsResponse) + ), +) +_sym_db.RegisterMessage(ListBudgetsResponse) + +DeleteBudgetRequest = _reflection.GeneratedProtocolMessageType( + "DeleteBudgetRequest", + (_message.Message,), + dict( + DESCRIPTOR=_DELETEBUDGETREQUEST, + __module__="google.cloud.billing.budgets_v1beta1.proto.budget_service_pb2", + __doc__="""Request for DeleteBudget + + + Attributes: + name: + Required. Name of the budget to delete. Values are of the form + ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. + """, + # @@protoc_insertion_point(class_scope:google.cloud.billing.budgets.v1beta1.DeleteBudgetRequest) + ), +) +_sym_db.RegisterMessage(DeleteBudgetRequest) + + +DESCRIPTOR._options = None +_CREATEBUDGETREQUEST.fields_by_name["parent"]._options = None +_CREATEBUDGETREQUEST.fields_by_name["budget"]._options = None +_UPDATEBUDGETREQUEST.fields_by_name["budget"]._options = None +_UPDATEBUDGETREQUEST.fields_by_name["update_mask"]._options = None +_GETBUDGETREQUEST.fields_by_name["name"]._options = None +_LISTBUDGETSREQUEST.fields_by_name["parent"]._options = None +_LISTBUDGETSREQUEST.fields_by_name["page_size"]._options = None +_LISTBUDGETSREQUEST.fields_by_name["page_token"]._options = None +_DELETEBUDGETREQUEST.fields_by_name["name"]._options = None + +_BUDGETSERVICE = _descriptor.ServiceDescriptor( + name="BudgetService", + full_name="google.cloud.billing.budgets.v1beta1.BudgetService", + file=DESCRIPTOR, + index=0, + serialized_options=_b( + "\312A\035billingbudgets.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" + ), + serialized_start=1053, + serialized_end=2022, + methods=[ + _descriptor.MethodDescriptor( + name="CreateBudget", + full_name="google.cloud.billing.budgets.v1beta1.BudgetService.CreateBudget", + index=0, + containing_service=None, + input_type=_CREATEBUDGETREQUEST, + output_type=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2._BUDGET, + serialized_options=_b( + '\202\323\344\223\0020"+/v1beta1/{parent=billingAccounts/*}/budgets:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="UpdateBudget", + full_name="google.cloud.billing.budgets.v1beta1.BudgetService.UpdateBudget", + index=1, + containing_service=None, + input_type=_UPDATEBUDGETREQUEST, + output_type=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2._BUDGET, + serialized_options=_b( + "\202\323\344\223\002722/v1beta1/{budget.name=billingAccounts/*/budgets/*}:\001*" + ), + ), + _descriptor.MethodDescriptor( + name="GetBudget", + full_name="google.cloud.billing.budgets.v1beta1.BudgetService.GetBudget", + index=2, + containing_service=None, + input_type=_GETBUDGETREQUEST, + output_type=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2._BUDGET, + serialized_options=_b( + "\202\323\344\223\002-\022+/v1beta1/{name=billingAccounts/*/budgets/*}" + ), + ), + _descriptor.MethodDescriptor( + name="ListBudgets", + full_name="google.cloud.billing.budgets.v1beta1.BudgetService.ListBudgets", + index=3, + containing_service=None, + input_type=_LISTBUDGETSREQUEST, + output_type=_LISTBUDGETSRESPONSE, + serialized_options=_b( + "\202\323\344\223\002-\022+/v1beta1/{parent=billingAccounts/*}/budgets" + ), + ), + _descriptor.MethodDescriptor( + name="DeleteBudget", + full_name="google.cloud.billing.budgets.v1beta1.BudgetService.DeleteBudget", + index=4, + containing_service=None, + input_type=_DELETEBUDGETREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + serialized_options=_b( + "\202\323\344\223\002-*+/v1beta1/{name=billingAccounts/*/budgets/*}" + ), + ), + ], +) +_sym_db.RegisterServiceDescriptor(_BUDGETSERVICE) + +DESCRIPTOR.services_by_name["BudgetService"] = _BUDGETSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service_pb2_grpc.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service_pb2_grpc.py new file mode 100644 index 000000000000..3cddb5843873 --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/proto/budget_service_pb2_grpc.py @@ -0,0 +1,125 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.billing_budgets_v1beta1.proto import ( + budget_model_pb2 as google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2, +) +from google.cloud.billing_budgets_v1beta1.proto import ( + budget_service_pb2 as google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2, +) +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class BudgetServiceStub(object): + """BudgetService stores Cloud Billing budgets, which define a + budget plan and rules to execute as we track spend against that plan. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.CreateBudget = channel.unary_unary( + "/google.cloud.billing.budgets.v1beta1.BudgetService/CreateBudget", + request_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.CreateBudgetRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.Budget.FromString, + ) + self.UpdateBudget = channel.unary_unary( + "/google.cloud.billing.budgets.v1beta1.BudgetService/UpdateBudget", + request_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.UpdateBudgetRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.Budget.FromString, + ) + self.GetBudget = channel.unary_unary( + "/google.cloud.billing.budgets.v1beta1.BudgetService/GetBudget", + request_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.GetBudgetRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.Budget.FromString, + ) + self.ListBudgets = channel.unary_unary( + "/google.cloud.billing.budgets.v1beta1.BudgetService/ListBudgets", + request_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.ListBudgetsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.ListBudgetsResponse.FromString, + ) + self.DeleteBudget = channel.unary_unary( + "/google.cloud.billing.budgets.v1beta1.BudgetService/DeleteBudget", + request_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.DeleteBudgetRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + + +class BudgetServiceServicer(object): + """BudgetService stores Cloud Billing budgets, which define a + budget plan and rules to execute as we track spend against that plan. + """ + + def CreateBudget(self, request, context): + """Creates a new budget. See + Quotas and limits + for more information on the limits of the number of budgets you can create. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def UpdateBudget(self, request, context): + """Updates a budget and returns the updated budget. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def GetBudget(self, request, context): + """Returns a budget. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def ListBudgets(self, request, context): + """Returns a list of budgets for a billing account. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def DeleteBudget(self, request, context): + """Deletes a budget. Returns successfully if already deleted. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + +def add_BudgetServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + "CreateBudget": grpc.unary_unary_rpc_method_handler( + servicer.CreateBudget, + request_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.CreateBudgetRequest.FromString, + response_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.Budget.SerializeToString, + ), + "UpdateBudget": grpc.unary_unary_rpc_method_handler( + servicer.UpdateBudget, + request_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.UpdateBudgetRequest.FromString, + response_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.Budget.SerializeToString, + ), + "GetBudget": grpc.unary_unary_rpc_method_handler( + servicer.GetBudget, + request_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.GetBudgetRequest.FromString, + response_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__model__pb2.Budget.SerializeToString, + ), + "ListBudgets": grpc.unary_unary_rpc_method_handler( + servicer.ListBudgets, + request_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.ListBudgetsRequest.FromString, + response_serializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.ListBudgetsResponse.SerializeToString, + ), + "DeleteBudget": grpc.unary_unary_rpc_method_handler( + servicer.DeleteBudget, + request_deserializer=google_dot_cloud_dot_billing_dot_budgets__v1beta1_dot_proto_dot_budget__service__pb2.DeleteBudgetRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + "google.cloud.billing.budgets.v1beta1.BudgetService", rpc_method_handlers + ) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/types.py b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/types.py new file mode 100644 index 000000000000..139bddbfbd9e --- /dev/null +++ b/packages/google-cloud-billing-budgets/google/cloud/billing_budgets_v1beta1/types.py @@ -0,0 +1,47 @@ +# -*- 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.billing_budgets_v1beta1.proto import budget_model_pb2 +from google.cloud.billing_budgets_v1beta1.proto import budget_service_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 +from google.type import money_pb2 + + +_shared_modules = [empty_pb2, field_mask_pb2, money_pb2] + +_local_modules = [budget_model_pb2, budget_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.billing_budgets_v1beta1.types" + setattr(sys.modules[__name__], name, message) + names.append(name) + + +__all__ = tuple(sorted(names)) diff --git a/packages/google-cloud-billing-budgets/noxfile.py b/packages/google-cloud-billing-budgets/noxfile.py new file mode 100644 index 000000000000..88dd771e4879 --- /dev/null +++ b/packages/google-cloud-billing-budgets/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=["2.7", "3.5", "3.6", "3.7"]) +def unit(session): + """Run the unit test suite.""" + default(session) + + +@nox.session(python=["2.7", "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=72") + + session.run("coverage", "erase") + + +@nox.session(python="3.7") +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/packages/google-cloud-billing-budgets/setup.cfg b/packages/google-cloud-billing-budgets/setup.cfg new file mode 100644 index 000000000000..3bd555500e37 --- /dev/null +++ b/packages/google-cloud-billing-budgets/setup.cfg @@ -0,0 +1,3 @@ +# Generated by synthtool. DO NOT EDIT! +[bdist_wheel] +universal = 1 diff --git a/packages/google-cloud-billing-budgets/setup.py b/packages/google-cloud-billing-budgets/setup.py new file mode 100644 index 000000000000..3e2adc62f33d --- /dev/null +++ b/packages/google-cloud-billing-budgets/setup.py @@ -0,0 +1,75 @@ +# -*- 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 io +import os + +import setuptools + + +name = "google-cloud-billing-budgets" +description = "Cloud Billing Budget API API client library" +version = "0.1.0" +release_status = "Development Status :: 3 - Alpha" +dependencies = [ + "google-api-core[grpc] >= 1.14.0, < 2.0.0dev", + 'enum34; python_version < "3.4"', +] + + +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/googleapis/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.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Operating System :: OS Independent", + "Topic :: Internet", + ], + platforms="Posix; MacOS X; Windows", + packages=packages, + namespace_packages=namespaces, + install_requires=dependencies, + include_package_data=True, + zip_safe=False, +) diff --git a/packages/google-cloud-billing-budgets/synth.metadata b/packages/google-cloud-billing-budgets/synth.metadata new file mode 100644 index 000000000000..313c6016e2a7 --- /dev/null +++ b/packages/google-cloud-billing-budgets/synth.metadata @@ -0,0 +1,39 @@ +{ + "updateTime": "2019-11-14T17:31:28.944629Z", + "sources": [ + { + "generator": { + "name": "artman", + "version": "0.41.1", + "dockerImage": "googleapis/artman@sha256:545c758c76c3f779037aa259023ec3d1ef2d57d2c8cd00a222cb187d63ceac5e" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "f8720321aecf4aab42e03602ac2c67f9777d9170", + "internalRef": "280434856" + } + }, + { + "template": { + "name": "python_library", + "origin": "synthtool.gcp", + "version": "2019.10.17" + } + } + ], + "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "billingbudgets", + "apiVersion": "v1beta1", + "language": "python", + "generator": "gapic", + "config": "google/cloud/billing/budgets/artman_billingbudgets_v1beta1.yaml" + } + } + ] +} \ No newline at end of file diff --git a/packages/google-cloud-billing-budgets/synth.py b/packages/google-cloud-billing-budgets/synth.py new file mode 100644 index 000000000000..751501cd8543 --- /dev/null +++ b/packages/google-cloud-billing-budgets/synth.py @@ -0,0 +1,71 @@ +# 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 synthtool as s +import synthtool.gcp as gcp +import logging + +logging.basicConfig(level=logging.DEBUG) + +gapic = gcp.GAPICGenerator() +common = gcp.CommonTemplates() + +# ---------------------------------------------------------------------------- +# Generate billing budgets GAPIC layer +# ---------------------------------------------------------------------------- +library = gapic.py_library( + "billingbudgets", + "v1beta1", + config_path="/google/cloud/billing/budgets/artman_billingbudgets_v1beta1.yaml", + include_protos=True, +) + +excludes = [ + "nox.py", + "setup.py", + "README.rst", + library / "docs/index.rst", + library + / "google/cloud/billingbudgets_v1beta1/proto", # proto files are copied to the wrong place +] + +s.move(library, excludes=excludes) +s.move( + library / "google/cloud/billingbudgets_v1beta1/proto/*.proto", + "google/cloud/billing_budgets_v1beta1/proto", +) + +# Fix namespace +s.replace( + "**/*.py", + "from google\.cloud\.billing\.budgets_v1beta1", + "from google.cloud.billing_budgets_v1beta1", +) + +# Fix package name +s.replace( + ["**/*.rst", "setup.py", "*/**/*.py"], + "google-cloud-billingbudgets", + "google-cloud-billing-budgets", +) + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- +templated_files = common.py_library(unit_cov_level=72, cov_level=72) +s.move(templated_files) + +s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/packages/google-cloud-billing-budgets/tests/unit/gapic/v1beta1/test_budget_service_client_v1beta1.py b/packages/google-cloud-billing-budgets/tests/unit/gapic/v1beta1/test_budget_service_client_v1beta1.py new file mode 100644 index 000000000000..2631222635b3 --- /dev/null +++ b/packages/google-cloud-billing-budgets/tests/unit/gapic/v1beta1/test_budget_service_client_v1beta1.py @@ -0,0 +1,261 @@ +# -*- 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 billing_budgets_v1beta1 +from google.cloud.billing_budgets_v1beta1.proto import budget_model_pb2 +from google.cloud.billing_budgets_v1beta1.proto import budget_service_pb2 +from google.protobuf import empty_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 TestBudgetServiceClient(object): + def test_create_budget(self): + # Setup Expected Response + name = "name3373707" + display_name = "displayName1615086568" + etag = "etag3123477" + expected_response = {"name": name, "display_name": display_name, "etag": etag} + expected_response = budget_model_pb2.Budget(**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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup Request + parent = client.billing_account_path("[BILLING_ACCOUNT]") + budget = {} + + response = client.create_budget(parent, budget) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = budget_service_pb2.CreateBudgetRequest( + parent=parent, budget=budget + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_budget_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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup request + parent = client.billing_account_path("[BILLING_ACCOUNT]") + budget = {} + + with pytest.raises(CustomException): + client.create_budget(parent, budget) + + def test_update_budget(self): + # Setup Expected Response + name = "name3373707" + display_name = "displayName1615086568" + etag = "etag3123477" + expected_response = {"name": name, "display_name": display_name, "etag": etag} + expected_response = budget_model_pb2.Budget(**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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup Request + budget = {} + + response = client.update_budget(budget) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = budget_service_pb2.UpdateBudgetRequest(budget=budget) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_update_budget_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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup request + budget = {} + + with pytest.raises(CustomException): + client.update_budget(budget) + + def test_get_budget(self): + # Setup Expected Response + name_2 = "name2-1052831874" + display_name = "displayName1615086568" + etag = "etag3123477" + expected_response = {"name": name_2, "display_name": display_name, "etag": etag} + expected_response = budget_model_pb2.Budget(**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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup Request + name = client.budget_path("[BILLING_ACCOUNT]", "[BUDGET]") + + response = client.get_budget(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = budget_service_pb2.GetBudgetRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_budget_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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup request + name = client.budget_path("[BILLING_ACCOUNT]", "[BUDGET]") + + with pytest.raises(CustomException): + client.get_budget(name) + + def test_list_budgets(self): + # Setup Expected Response + next_page_token = "" + budgets_element = {} + budgets = [budgets_element] + expected_response = {"next_page_token": next_page_token, "budgets": budgets} + expected_response = budget_service_pb2.ListBudgetsResponse(**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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup Request + parent = client.billing_account_path("[BILLING_ACCOUNT]") + + paged_list_response = client.list_budgets(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.budgets[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = budget_service_pb2.ListBudgetsRequest(parent=parent) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_budgets_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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup request + parent = client.billing_account_path("[BILLING_ACCOUNT]") + + paged_list_response = client.list_budgets(parent) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_delete_budget(self): + channel = ChannelStub() + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup Request + name = client.budget_path("[BILLING_ACCOUNT]", "[BUDGET]") + + client.delete_budget(name) + + assert len(channel.requests) == 1 + expected_request = budget_service_pb2.DeleteBudgetRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_delete_budget_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 = billing_budgets_v1beta1.BudgetServiceClient() + + # Setup request + name = client.budget_path("[BILLING_ACCOUNT]", "[BUDGET]") + + with pytest.raises(CustomException): + client.delete_budget(name)