diff --git a/docs/index.rst b/docs/index.rst index 998d3c86c326..d0831181e999 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,7 +21,7 @@ spanner/usage speech/index error-reporting/usage - monitoring/usage + monitoring/index logging/usage storage/client texttospeech/index diff --git a/docs/monitoring b/docs/monitoring new file mode 120000 index 000000000000..d7a58517323e --- /dev/null +++ b/docs/monitoring @@ -0,0 +1 @@ +../monitoring/docs \ No newline at end of file diff --git a/docs/monitoring/changelog.md b/docs/monitoring/changelog.md deleted file mode 120000 index 7a9385404ffd..000000000000 --- a/docs/monitoring/changelog.md +++ /dev/null @@ -1 +0,0 @@ -../../monitoring/CHANGELOG.md \ No newline at end of file diff --git a/docs/monitoring/client.rst b/docs/monitoring/client.rst deleted file mode 100644 index adc83974e6b2..000000000000 --- a/docs/monitoring/client.rst +++ /dev/null @@ -1,6 +0,0 @@ -Stackdriver Monitoring Client -============================= - -.. automodule:: google.cloud.monitoring.client - :members: - :show-inheritance: diff --git a/docs/monitoring/group.rst b/docs/monitoring/group.rst deleted file mode 100644 index ff49077008cc..000000000000 --- a/docs/monitoring/group.rst +++ /dev/null @@ -1,6 +0,0 @@ -Groups -====== - -.. automodule:: google.cloud.monitoring.group - :members: - :show-inheritance: diff --git a/docs/monitoring/label.rst b/docs/monitoring/label.rst deleted file mode 100644 index 67b7c16b7689..000000000000 --- a/docs/monitoring/label.rst +++ /dev/null @@ -1,6 +0,0 @@ -Label Descriptors -================= - -.. automodule:: google.cloud.monitoring.label - :members: - :show-inheritance: diff --git a/docs/monitoring/metric.rst b/docs/monitoring/metric.rst deleted file mode 100644 index abb6395f864c..000000000000 --- a/docs/monitoring/metric.rst +++ /dev/null @@ -1,6 +0,0 @@ -Metric Descriptors -================== - -.. automodule:: google.cloud.monitoring.metric - :members: - :show-inheritance: diff --git a/docs/monitoring/resource.rst b/docs/monitoring/resource.rst deleted file mode 100644 index b7faf93e68df..000000000000 --- a/docs/monitoring/resource.rst +++ /dev/null @@ -1,6 +0,0 @@ -Monitored Resource Descriptors -============================== - -.. automodule:: google.cloud.monitoring.resource - :members: - :show-inheritance: diff --git a/docs/monitoring/timeseries.rst b/docs/monitoring/timeseries.rst deleted file mode 100644 index e580f8067d69..000000000000 --- a/docs/monitoring/timeseries.rst +++ /dev/null @@ -1,6 +0,0 @@ -Time Series -=========== - -.. automodule:: google.cloud.monitoring.timeseries - :members: - :show-inheritance: diff --git a/docs/monitoring/usage.rst b/docs/monitoring/usage.rst deleted file mode 100644 index 0fe03a870b48..000000000000 --- a/docs/monitoring/usage.rst +++ /dev/null @@ -1,430 +0,0 @@ -Stackdriver Monitoring -====================== - -.. toctree:: - :maxdepth: 2 - :hidden: - - client - metric - resource - group - query - timeseries - label - -Introduction ------------- - -With the Stackdriver Monitoring API, you can work with Stackdriver metric data -pertaining to monitored resources in Google Cloud Platform (GCP) -or elsewhere. - -Essential concepts: - -- Metric data is associated with a **monitored resource**. A monitored - resource has a *resource type* and a set of *resource labels* — - key-value pairs — that identify the particular resource. -- A **metric** further identifies the particular kind of data that - is being collected. It has a *metric type* and a set of - *metric labels* that, when combined with the resource labels, identify - a particular time series. -- A **time series** is a collection of data points associated with - points or intervals in time. - -Please refer to the documentation for the `Stackdriver Monitoring API`_ for -more information. - -At present, this client library supports the following features -of the API: - -- Querying of time series. -- Querying of metric descriptors and monitored resource descriptors. -- Creation and deletion of metric descriptors for custom metrics. -- Writing of custom metric data. - -.. _Stackdriver Monitoring API: https://cloud.google.com/monitoring/api/v3/ - - -The Stackdriver Monitoring Client Object ----------------------------------------- - -The Stackdriver Monitoring client library generally makes its -functionality available as methods of the monitoring -:class:`~google.cloud.monitoring.client.Client` class. -A :class:`~google.cloud.monitoring.client.Client` instance holds -authentication credentials and the ID of the target project with -which the metric data of interest is associated. This project ID -will often refer to a `Stackdriver account`_ binding multiple -GCP projects and AWS accounts. It can also simply be the ID of -a monitored project. - -Most often the authentication credentials will be determined -implicitly from your environment. See :doc:`/core/auth` for -more information. - -It is thus typical to create a client object as follows: - -.. code-block:: python - - >>> from google.cloud import monitoring - >>> client = monitoring.Client(project='target-project') - -If you are running in Google Compute Engine or Google App Engine, -the current project is the default target project. This default -can be further overridden with the :envvar:`GOOGLE_CLOUD_PROJECT` -environment variable. Using the default target project is -even easier: - -.. code-block:: python - - >>> client = monitoring.Client() - -If necessary, you can pass in ``credentials`` and ``project`` explicitly: - -.. code-block:: python - - >>> client = monitoring.Client(project='target-project', credentials=...) - -.. _Stackdriver account: https://cloud.google.com/monitoring/accounts/ - - -Monitored Resource Descriptors ------------------------------- - -The available monitored resource types are defined by *monitored resource -descriptors*. You can fetch a list of these with the -:meth:`~google.cloud.monitoring.client.Client.list_resource_descriptors` method: - -.. code-block:: python - - >>> for descriptor in client.list_resource_descriptors(): - ... print(descriptor.type) - -Each :class:`~google.cloud.monitoring.resource.ResourceDescriptor` -has a type, a display name, a description, and a list of -:class:`~google.cloud.monitoring.label.LabelDescriptor` instances. -See the documentation about `Monitored Resources`_ -for more information. - -.. _Monitored Resources: - https://cloud.google.com/monitoring/api/v3/monitored-resources - - -Metric Descriptors ------------------- - -The available metric types are defined by *metric descriptors*. -They include `platform metrics`_, `agent metrics`_, and `custom metrics`_. -You can list all of these with the -:meth:`~google.cloud.monitoring.client.Client.list_metric_descriptors` method: - -.. code-block:: python - - >>> for descriptor in client.list_metric_descriptors(): - ... print(descriptor.type) - -See :class:`~google.cloud.monitoring.metric.MetricDescriptor` and the -`Metric Descriptors`_ API documentation for more information. - -You can create new metric descriptors to define custom metrics in -the ``custom.googleapis.com`` namespace. You do this by creating a -:class:`~google.cloud.monitoring.metric.MetricDescriptor` object using the -client's :meth:`~google.cloud.monitoring.client.Client.metric_descriptor` -factory and then calling the object's -:meth:`~google.cloud.monitoring.metric.MetricDescriptor.create` method: - -.. code-block:: python - - >>> from google.cloud.monitoring import MetricKind, ValueType - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_metric', - ... metric_kind=MetricKind.GAUGE, - ... value_type=ValueType.DOUBLE, - ... description='This is a simple example of a custom metric.') - >>> descriptor.create() - -You can delete such a metric descriptor as follows: - -.. code-block:: python - - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_metric') - >>> descriptor.delete() - -To define a custom metric parameterized by one or more labels, -you must build the appropriate -:class:`~google.cloud.monitoring.label.LabelDescriptor` objects -and include them in the -:class:`~google.cloud.monitoring.metric.MetricDescriptor` object -before you call -:meth:`~google.cloud.monitoring.metric.MetricDescriptor.create`: - -.. code-block:: python - - >>> from google.cloud.monitoring import LabelDescriptor, LabelValueType - >>> label = LabelDescriptor('response_code', LabelValueType.INT64, - ... description='HTTP status code') - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_app/response_count', - ... metric_kind=MetricKind.CUMULATIVE, - ... value_type=ValueType.INT64, - ... labels=[label], - ... description='Cumulative count of HTTP responses.') - >>> descriptor.create() - -.. _platform metrics: https://cloud.google.com/monitoring/api/metrics -.. _agent metrics: https://cloud.google.com/monitoring/agent/ -.. _custom metrics: https://cloud.google.com/monitoring/custom-metrics/ -.. _Metric Descriptors: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors - - -Groups ------- - -A group is a dynamic collection of *monitored resources* whose membership is -defined by a `filter`_. These groups are usually created via the -`Stackdriver dashboard`_. You can list all the groups in a project with the -:meth:`~google.cloud.monitoring.client.Client.list_groups` method: - -.. code-block:: python - - >>> for group in client.list_groups(): - ... print(group.id, group.display_name, group.parent_id) - ('a001', 'Production', None) - ('a002', 'Front-end', 'a001') - ('1003', 'Back-end', 'a001') - -See :class:`~google.cloud.monitoring.group.Group` and the API documentation for -`Groups`_ and `Group members`_ for more information. - -You can get a specific group based on it's ID as follows: - -.. code-block:: python - - >>> group = client.fetch_group('a001') - -You can get the current members of this group using the -:meth:`~google.cloud.monitoring.group.Group.list_members` method: - -.. code-block:: python - - >>> for member in group.list_members(): - ... print(member) - -Passing in ``end_time`` and ``start_time`` to the above method will return -historical members based on the current filter of the group. The group -membership changes over time, as *monitored resources* come and go, and as they -change properties. - -You can create new groups to define new collections of *monitored resources*. -You do this by creating a :class:`~google.cloud.monitoring.group.Group` object using -the client's :meth:`~google.cloud.monitoring.client.Client.group` factory and then -calling the object's :meth:`~google.cloud.monitoring.group.Group.create` method: - -.. code-block:: python - - >>> filter_string = 'resource.zone = "us-central1-a"' - >>> group = client.group( - ... display_name='My group', - ... filter_string=filter_string, - ... parent_id='a001', - ... is_cluster=True) - >>> group.create() - >>> group.id - '1234' - -You can further manipulate an existing group by first initializing a Group -object with it's ID or name, and then calling various methods on it. - -Delete a group: - -.. code-block:: python - - >>> group = client.group('1234') - >>> group.exists() - True - >>> group.delete() - - -Update a group: - -.. code-block:: python - - >>> group = client.group('1234') - >>> group.exists() - True - >>> group.reload() - >>> group.display_name = 'New Display Name' - >>> group.update() - -.. _Stackdriver dashboard: - https://support.stackdriver.com/customer/portal/articles/1535145-creating-groups -.. _filter: - https://cloud.google.com/monitoring/api/v3/filters#group-filter -.. _Groups: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.groups -.. _Group members: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.groups.members - - -Time Series Queries -------------------- - -A time series includes a collection of data points and a set of -resource and metric label values. -See :class:`~google.cloud.monitoring.timeseries.TimeSeries` and the -`Time Series`_ API documentation for more information. - -While you can obtain time series objects by iterating over a -:class:`~google.cloud.monitoring.query.Query` object, usually it is -more useful to retrieve time series data in the form of a -:class:`pandas.DataFrame`, where each column corresponds to a -single time series. For this, you must have :mod:`pandas` installed; -it is not a required dependency of ``google-cloud-python``. - -You can display CPU utilization across your GCE instances over a five minute duration ending at -the start of the current minute as follows: - -.. code-block:: python - - >>> METRIC = 'compute.googleapis.com/instance/cpu/utilization' - >>> query = client.query(METRIC, minutes=5) - >>> print(query.as_dataframe()) - -:class:`~google.cloud.monitoring.query.Query` objects provide a variety of -methods for refining the query. You can request temporal alignment -and cross-series reduction, and you can filter by label values. -See the client :meth:`~google.cloud.monitoring.client.Client.query` method -and the :class:`~google.cloud.monitoring.query.Query` class for more -information. - -For example, you can display CPU utilization during the last hour -across GCE instances with names beginning with ``"mycluster-"``, -averaged over five-minute intervals and aggregated per zone, as -follows: - -.. code-block:: python - - >>> from google.cloud.monitoring import Aligner, Reducer - >>> METRIC = 'compute.googleapis.com/instance/cpu/utilization' - >>> query = (client.query(METRIC, hours=1) - ... .select_metrics(instance_name_prefix='mycluster-') - ... .align(Aligner.ALIGN_MEAN, minutes=5) - ... .reduce(Reducer.REDUCE_MEAN, 'resource.zone')) - >>> print(query.as_dataframe()) - -.. _Time Series: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries - - -Writing Custom Metrics ---------------------------- - -The Stackdriver Monitoring API can be used to write data points to custom metrics. Please refer to -the documentation on `Custom Metrics`_ for more information. - -To write a data point to a custom metric, you must provide an instance of -:class:`~google.cloud.monitoring.metric.Metric` specifying the metric type as well as the values for -the metric labels. You will need to have either created the metric descriptor earlier (see the -`Metric Descriptors`_ section) or rely on metric type auto-creation (see `Auto-creation of -custom metrics`_). - -You will also need to provide a :class:`~google.cloud.monitoring.resource.Resource` instance -specifying a monitored resource type as well as values for all of the monitored resource labels, -except for ``project_id``, which is ignored when it's included in writes to the API. A good -choice is to use the underlying physical resource where your application code runs – e.g., a -monitored resource type of ``gce_instance`` or ``aws_ec2_instance``. In some limited -circumstances, such as when only a single process writes to the custom metric, you may choose to -use the ``global`` monitored resource type. - -See `Monitored resource types`_ for more information about particular monitored resource types. - -.. code-block:: python - - >>> from google.cloud import monitoring - >>> # Create a Resource object for the desired monitored resource type. - >>> resource = client.resource( - ... 'gce_instance', - ... labels={ - ... 'instance_id': '1234567890123456789', - ... 'zone': 'us-central1-f' - ... } - ... ) - >>> # Create a Metric object, specifying the metric type as well as values for any metric labels. - >>> metric = client.metric( - ... type_='custom.googleapis.com/my_metric', - ... labels={ - ... 'status': 'successful' - ... } - ... ) - -With a ``Metric`` and ``Resource`` in hand, the :class:`~google.cloud.monitoring.client.Client` -can be used to write :class:`~google.cloud.monitoring.timeseries.Point` values. - -When writing points, the Python type of the value must match the *value type* of the metric -descriptor associated with the metric. For example, a Python float will map to ``ValueType.DOUBLE``. - -Stackdriver Monitoring supports several *metric kinds*: ``GAUGE``, ``CUMULATIVE``, and ``DELTA``. -However, ``DELTA`` is not supported for custom metrics. - -``GAUGE`` metrics represent only a single point in time, so only the ``end_time`` should be -specified: - -.. code-block:: python - - >>> client.write_point(metric=metric, resource=resource, - ... value=3.14, end_time=end_time) # API call - -By default, ``end_time`` defaults to :meth:`~datetime.datetime.utcnow()`, so metrics can be written -to the current time as follows: - -.. code-block:: python - - >>> client.write_point(metric, resource, 3.14) # API call - -``CUMULATIVE`` metrics enable the monitoring system to compute rates of increase on metrics that -sometimes reset, such as after a process restart. Without cumulative metrics, this -reset would otherwise show up as a huge negative spike. For cumulative metrics, the same start -time should be re-used repeatedly as more points are written to the time series. - -In the examples below, the ``end_time`` again defaults to the current time: - -.. code-block:: python - - >>> RESET = datetime.utcnow() - >>> client.write_point(metric, resource, 3, start_time=RESET) # API call - >>> client.write_point(metric, resource, 6, start_time=RESET) # API call - -To write multiple ``TimeSeries`` in a single batch, you can use -:meth:`~google.cloud.monitoring.client.write_time_series`: - -.. code-block:: python - - >>> ts1 = client.time_series(metric1, resource, 3.14, end_time=end_time) - >>> ts2 = client.time_series(metric2, resource, 42, end_time=end_time) - >>> client.write_time_series([ts1, ts2]) # API call - -While multiple time series can be written in a single batch, each ``TimeSeries`` object sent to -the API must only include a single point. - -All timezone-naive Python ``datetime`` objects are assumed to be UTC. - -.. _TimeSeries: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries -.. _Custom Metrics: https://cloud.google.com/monitoring/custom-metrics/ -.. _Auto-creation of custom metrics: - https://cloud.google.com/monitoring/custom-metrics/creating-metrics#auto-creation -.. _Metrics: https://cloud.google.com/monitoring/api/v3/metrics -.. _Monitored resource types: - https://cloud.google.com/monitoring/api/resources - -Changelog ---------- - -For a list of all ``google-cloud-monitoring`` releases: - -.. toctree:: - :maxdepth: 2 - - changelog diff --git a/monitoring/.coveragerc b/monitoring/.coveragerc index a54b99aa14b7..f1315bbcbfad 100644 --- a/monitoring/.coveragerc +++ b/monitoring/.coveragerc @@ -2,10 +2,15 @@ branch = True [report] -fail_under = 100 +omit = + */gapic/* + */proto/* show_missing = True + exclude_lines = # Re-enable the standard pragma pragma: NO COVER # Ignore debug-only repr def __repr__ + # Ignore abstract methods + raise NotImplementedError diff --git a/monitoring/README.rst b/monitoring/README.rst index 405547e514f9..7718db616402 100644 --- a/monitoring/README.rst +++ b/monitoring/README.rst @@ -1,78 +1,103 @@ -Python Client for Stackdriver Monitoring -======================================== +Python Client for Stackdriver Monitoring API (`Alpha`_) +======================================================= - Python idiomatic client for `Stackdriver Monitoring`_ +`Stackdriver Monitoring API`_: Manages your Stackdriver Monitoring data and configurations. Most projects +must be associated with a Stackdriver account, with a few exceptions as +noted on the individual method pages. -.. _Stackdriver Monitoring: https://cloud.google.com/monitoring/ +- `Client Library Documentation`_ +- `Product Documentation`_ -|pypi| |versions| - -- `Documentation`_ - -.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html +.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst +.. _Stackdriver Monitoring API: https://cloud.google.com/monitoring +.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html +.. _Product Documentation: https://cloud.google.com/monitoring Quick Start ----------- -.. code-block:: console +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 Stackdriver Monitoring 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 Stackdriver Monitoring API.: https://cloud.google.com/monitoring +.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/latest/core/auth.html + +Installation +~~~~~~~~~~~~ - $ pip install --upgrade google-cloud-monitoring +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. -For more information on setting up your Python development environment, -such as installing ``pip`` and ``virtualenv`` on your system, please refer -to `Python Development Environment Setup Guide`_ for Google Cloud Platform. +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. -.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ -Authentication --------------- -With ``google-cloud-python`` we try to make authentication as painless as -possible. Check out the `Authentication section`_ in our documentation to -learn more. You may also find the `authentication document`_ shared by all -the ``google-cloud-*`` libraries to be helpful. +Mac/Linux +^^^^^^^^^ -.. _Authentication section: https://google-cloud-python.readthedocs.io/en/latest/core/auth.html -.. _authentication document: https://github.com/GoogleCloudPlatform/google-cloud-common/tree/master/authentication +.. code-block:: console + + pip install virtualenv + virtualenv + source /bin/activate + /bin/pip install google-cloud-monitoring + + +Windows +^^^^^^^ + +.. code-block:: console -Using the API -------------- + pip install virtualenv + virtualenv + \Scripts\activate + \Scripts\pip.exe install google-cloud-monitoring -`Stackdriver Monitoring`_ (`Monitoring API docs`_) collects metrics, -events, and metadata from Google Cloud Platform, Amazon Web Services (AWS), -hosted uptime probes, application instrumentation, and a variety of common -application components including Cassandra, Nginx, Apache Web Server, -Elasticsearch and many others. Stackdriver ingests that data and generates -insights via dashboards, charts, and alerts. +Preview +~~~~~~~ -This package currently supports all Monitoring API operations other than -writing custom metrics. +MetricServiceClient +^^^^^^^^^^^^^^^^^^^ -.. _Monitoring API docs: https://cloud.google.com/monitoring/api/ref_v3/rest/ +.. code:: py -List available metric types: + from google.cloud import monitoring_v3 -.. code:: python + client = monitoring_v3.MetricServiceClient() - from google.cloud import monitoring - client = monitoring.Client() - for descriptor in client.list_metric_descriptors(): - print(descriptor.type) + name = client.project_path('[PROJECT]') -Display CPU utilization across your GCE instances during the last five minutes: -.. code:: python + # Iterate over all results + for element in client.list_monitored_resource_descriptors(name): + # process element + pass - metric = 'compute.googleapis.com/instance/cpu/utilization' - query = client.query(metric, minutes=5) - print(query.as_dataframe()) + # Or iterate over results one page at a time + for page in client.list_monitored_resource_descriptors(name, options=CallOptions(page_token=INITIAL_PAGE)): + for element in page: + # process element + pass -See the ``google-cloud-python`` API `monitoring documentation`_ to learn how -to connect to Stackdriver Monitoring using this Client Library. +Next Steps +~~~~~~~~~~ -.. _monitoring documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html +- Read the `Client Library Documentation`_ for Stackdriver Monitoring API + API to see other available methods on the client. +- Read the `Stackdriver Monitoring 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. -.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-monitoring.svg - :target: https://pypi.org/project/google-cloud-monitoring/ -.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-monitoring.svg - :target: https://pypi.org/project/google-cloud-monitoring/ +.. _Stackdriver Monitoring API Product documentation: https://cloud.google.com/monitoring +.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst diff --git a/monitoring/docs/conf.py b/monitoring/docs/conf.py new file mode 100644 index 000000000000..d2f757ae417b --- /dev/null +++ b/monitoring/docs/conf.py @@ -0,0 +1,311 @@ +# -*- coding: utf-8 -*- +# +# google-cloud-monitoring 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.0' + +# 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.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'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# 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-monitoring' +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 = 'sphinx_rtd_theme' + +# 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 = {} + +# 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-monitoring-doc' + +# -- 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-monitoring.tex', + u'google-cloud-monitoring 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-monitoring', + u'google-cloud-monitoring 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-monitoring', + u'google-cloud-monitoring Documentation', author, + 'google-cloud-monitoring', + 'GAPIC library for the {metadata.shortName} v3 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), +} + +# 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/monitoring/docs/gapic/v3/api.rst b/monitoring/docs/gapic/v3/api.rst new file mode 100644 index 000000000000..615e004633e5 --- /dev/null +++ b/monitoring/docs/gapic/v3/api.rst @@ -0,0 +1,6 @@ +Client for Stackdriver Monitoring API +===================================== + +.. automodule:: google.cloud.monitoring_v3 + :members: + :inherited-members: \ No newline at end of file diff --git a/monitoring/docs/gapic/v3/types.rst b/monitoring/docs/gapic/v3/types.rst new file mode 100644 index 000000000000..9790a948460e --- /dev/null +++ b/monitoring/docs/gapic/v3/types.rst @@ -0,0 +1,5 @@ +Types for Stackdriver Monitoring API Client +=========================================== + +.. automodule:: google.cloud.monitoring_v3.types + :members: \ No newline at end of file diff --git a/monitoring/docs/index.rst b/monitoring/docs/index.rst new file mode 100644 index 000000000000..f21c17535c48 --- /dev/null +++ b/monitoring/docs/index.rst @@ -0,0 +1,112 @@ +Python Client for Stackdriver Monitoring API (`Alpha`_) +======================================================= + +`Stackdriver Monitoring API`_: Manages your Stackdriver Monitoring data and configurations. Most projects +must be associated with a Stackdriver account, with a few exceptions as +noted on the individual method pages. + +- `Client Library Documentation`_ +- `Product Documentation`_ + +.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst +.. _Stackdriver Monitoring API: https://cloud.google.com/monitoring +.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/monitoring/usage.html +.. _Product Documentation: https://cloud.google.com/monitoring + +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 Stackdriver Monitoring 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 Stackdriver Monitoring API.: https://cloud.google.com/monitoring +.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/latest/core/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-monitoring + + +Windows +^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + \Scripts\activate + \Scripts\pip.exe install google-cloud-monitoring + +Preview +~~~~~~~ + +MetricServiceClient +^^^^^^^^^^^^^^^^^^^ + +.. code:: py + + from google.cloud import monitoring_v3 + + client = monitoring_v3.MetricServiceClient() + + name = client.project_path('[PROJECT]') + + + # Iterate over all results + for element in client.list_monitored_resource_descriptors(name): + # process element + pass + + # Or iterate over results one page at a time + for page in client.list_monitored_resource_descriptors(name, options=CallOptions(page_token=INITIAL_PAGE)): + for element in page: + # process element + pass + +Next Steps +~~~~~~~~~~ + +- Read the `Client Library Documentation`_ for Stackdriver Monitoring API + API to see other available methods on the client. +- Read the `Stackdriver Monitoring 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. + +.. _Stackdriver Monitoring API Product documentation: https://cloud.google.com/monitoring +.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst + +Api Reference +------------- +.. toctree:: + :maxdepth: 2 + + query.rst + gapic/v3/api + gapic/v3/types diff --git a/docs/monitoring/query.rst b/monitoring/docs/query.rst similarity index 58% rename from docs/monitoring/query.rst rename to monitoring/docs/query.rst index 28cc2def2522..d52fd7f19077 100644 --- a/docs/monitoring/query.rst +++ b/monitoring/docs/query.rst @@ -1,6 +1,6 @@ Time Series Query ================= -.. automodule:: google.cloud.monitoring.query +.. automodule:: google.cloud.monitoring_v3.query :members: :show-inheritance: diff --git a/monitoring/pylint.config.py b/monitoring/google/cloud/monitoring.py similarity index 54% rename from monitoring/pylint.config.py rename to monitoring/google/cloud/monitoring.py index 5d64b9d2f256..0cf5c570ceb4 100644 --- a/monitoring/pylint.config.py +++ b/monitoring/google/cloud/monitoring.py @@ -1,4 +1,4 @@ -# Copyright 2017 Google LLC +# Copyright 2017, Google LLC All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,14 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""This module is used to configure gcp-devrel-py-tools run-pylint.""" +from __future__ import absolute_import -# Library configuration +from google.cloud.monitoring_v3.query import Query +from google.cloud.monitoring_v3 import GroupServiceClient +from google.cloud.monitoring_v3 import MetricServiceClient +from google.cloud.monitoring_v3 import enums +from google.cloud.monitoring_v3 import types -# library_additions = {} -# library_replacements = {} - -# Test configuration - -# test_additions = copy.deepcopy(library_additions) -# test_replacements = copy.deepcopy(library_replacements) +__all__ = ( + 'enums', + 'types', + 'GroupServiceClient', + 'Query', + 'MetricServiceClient', ) diff --git a/monitoring/google/cloud/monitoring/__init__.py b/monitoring/google/cloud/monitoring/__init__.py deleted file mode 100644 index 143a7ff05a12..000000000000 --- a/monitoring/google/cloud/monitoring/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Google Stackdriver Monitoring API wrapper.""" - - -from pkg_resources import get_distribution -__version__ = get_distribution('google-cloud-monitoring').version - -from google.cloud.monitoring.client import Client -from google.cloud.monitoring.group import Group -from google.cloud.monitoring.label import LabelDescriptor -from google.cloud.monitoring.label import LabelValueType -from google.cloud.monitoring.metric import Metric -from google.cloud.monitoring.metric import MetricDescriptor -from google.cloud.monitoring.metric import MetricKind -from google.cloud.monitoring.metric import ValueType -from google.cloud.monitoring.query import Aligner -from google.cloud.monitoring.query import Query -from google.cloud.monitoring.query import Reducer -from google.cloud.monitoring.resource import Resource -from google.cloud.monitoring.resource import ResourceDescriptor -from google.cloud.monitoring.timeseries import Point -from google.cloud.monitoring.timeseries import TimeSeries - -__all__ = ( - 'Client', - 'Group', - 'LabelDescriptor', 'LabelValueType', - 'Metric', 'MetricDescriptor', 'MetricKind', 'ValueType', - 'Aligner', 'Query', 'Reducer', - 'Resource', 'ResourceDescriptor', - 'Point', 'TimeSeries', - 'SCOPE', -) - - -SCOPE = Client.SCOPE diff --git a/monitoring/google/cloud/monitoring/_http.py b/monitoring/google/cloud/monitoring/_http.py deleted file mode 100644 index bd23a1ad9e8e..000000000000 --- a/monitoring/google/cloud/monitoring/_http.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Create / interact with Stackdriver Monitoring connections.""" - -from google.cloud import _http - -from google.cloud.monitoring import __version__ - - -_CLIENT_INFO = _http.CLIENT_INFO_TEMPLATE.format(__version__) - - -class Connection(_http.JSONConnection): - """A connection to Google Stackdriver Monitoring via the JSON REST API. - - :type client: :class:`~google.cloud.monitoring.client.Client` - :param client: The client that owns the current connection. - """ - - API_BASE_URL = 'https://monitoring.googleapis.com' - """The base of the API call URL.""" - - API_VERSION = 'v3' - """The version of the API, used in building the API call's URL.""" - - API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}' - """A template for the URL of a particular API call.""" - - _EXTRA_HEADERS = { - _http.CLIENT_INFO_HEADER: _CLIENT_INFO, - } diff --git a/monitoring/google/cloud/monitoring/client.py b/monitoring/google/cloud/monitoring/client.py deleted file mode 100644 index 6df6cc60a659..000000000000 --- a/monitoring/google/cloud/monitoring/client.py +++ /dev/null @@ -1,603 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Client for interacting with the `Google Stackdriver Monitoring API (V3)`_. - -Example:: - - >>> from google.cloud import monitoring - >>> client = monitoring.Client() - >>> query = client.query(minutes=5) - >>> print(query.as_dataframe()) # Requires pandas. - -At present, the client supports querying of time series, metric descriptors, -and monitored resource descriptors. - -.. _Google Stackdriver Monitoring API (V3): - https://cloud.google.com/monitoring/api/v3/ -""" - -import datetime -import six - -from google.cloud._helpers import _datetime_to_rfc3339 -from google.cloud.client import ClientWithProject - -from google.cloud.monitoring._http import Connection -from google.cloud.monitoring.group import Group -from google.cloud.monitoring.metric import Metric -from google.cloud.monitoring.metric import MetricDescriptor -from google.cloud.monitoring.metric import MetricKind -from google.cloud.monitoring.metric import ValueType -from google.cloud.monitoring.query import Query -from google.cloud.monitoring.resource import Resource -from google.cloud.monitoring.resource import ResourceDescriptor -from google.cloud.monitoring.timeseries import Point -from google.cloud.monitoring.timeseries import TimeSeries - - -_UTCNOW = datetime.datetime.utcnow # To be replaced by tests. - - -class Client(ClientWithProject): - """Client to bundle configuration needed for API requests. - - :type project: str - :param project: The target project. If not passed, falls back to the - default inferred from the environment. - - :type credentials: :class:`~google.auth.credentials.Credentials` - :param credentials: (Optional) The OAuth2 Credentials to use for this - client. If not passed (and if no ``_http`` object is - passed), falls back to the default inferred from the - environment. - - :type _http: :class:`~requests.Session` - :param _http: (Optional) HTTP object to make requests. Can be any object - that defines ``request()`` with the same interface as - :meth:`requests.Session.request`. If not passed, an - ``_http`` object is created that is bound to the - ``credentials`` for the current object. - This parameter should be considered private, and could - change in the future. - """ - - SCOPE = ('https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/cloud-platform') - """The scopes required for authenticating as a Monitoring consumer.""" - - def __init__(self, project=None, credentials=None, _http=None): - super(Client, self).__init__( - project=project, credentials=credentials, _http=_http) - self._connection = Connection(self) - - def query(self, - metric_type=Query.DEFAULT_METRIC_TYPE, - end_time=None, - days=0, hours=0, minutes=0): - """Construct a query object for retrieving metric data. - - Example:: - - >>> query = client.query(minutes=5) - >>> print(query.as_dataframe()) # Requires pandas. - - :type metric_type: str - :param metric_type: The metric type name. The default value is - :data:`Query.DEFAULT_METRIC_TYPE - `, - but please note that this default value is provided only for - demonstration purposes and is subject to change. See the - `supported metrics`_. - - :type end_time: :class:`datetime.datetime` - :param end_time: - (Optional) The end time (inclusive) of the time interval - for which results should be returned, as a datetime object. - The default is the start of the current minute. - - The start time (exclusive) is determined by combining the - values of ``days``, ``hours``, and ``minutes``, and - subtracting the resulting duration from the end time. - - It is also allowed to omit the end time and duration here, - in which case - :meth:`~google.cloud.monitoring.query.Query.select_interval` - must be called before the query is executed. - - :type days: int - :param days: The number of days in the time interval. - - :type hours: int - :param hours: The number of hours in the time interval. - - :type minutes: int - :param minutes: The number of minutes in the time interval. - - :rtype: :class:`~google.cloud.monitoring.query.Query` - :returns: The query object. - - :raises: :exc:`ValueError` if ``end_time`` is specified but - ``days``, ``hours``, and ``minutes`` are all zero. - If you really want to specify a point in time, use - :meth:`~google.cloud.monitoring.query.Query.select_interval`. - - .. _supported metrics: https://cloud.google.com/monitoring/api/metrics - """ - return Query(self, metric_type, - end_time=end_time, - days=days, hours=hours, minutes=minutes) - - def metric_descriptor(self, type_, - metric_kind=MetricKind.METRIC_KIND_UNSPECIFIED, - value_type=ValueType.VALUE_TYPE_UNSPECIFIED, - labels=(), unit='', description='', display_name=''): - """Construct a metric descriptor object. - - Metric descriptors specify the schema for a particular metric type. - - This factory method is used most often in conjunction with the metric - descriptor - :meth:`~google.cloud.monitoring.metric.MetricDescriptor.create` - method to define custom metrics:: - - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_metric', - ... metric_kind=MetricKind.GAUGE, - ... value_type=ValueType.DOUBLE, - ... description='This is a simple example of a custom metric.') - >>> descriptor.create() - - Here is an example where the custom metric is parameterized by a - metric label:: - - >>> label = LabelDescriptor('response_code', LabelValueType.INT64, - ... description='HTTP status code') - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_app/response_count', - ... metric_kind=MetricKind.CUMULATIVE, - ... value_type=ValueType.INT64, - ... labels=[label], - ... description='Cumulative count of HTTP responses.') - >>> descriptor.create() - - :type type_: str - :param type_: - The metric type including a DNS name prefix. For example: - ``"custom.googleapis.com/my_metric"`` - - :type metric_kind: str - :param metric_kind: - The kind of measurement. It must be one of - :data:`MetricKind.GAUGE`, :data:`MetricKind.DELTA`, - or :data:`MetricKind.CUMULATIVE`. - See :class:`~google.cloud.monitoring.metric.MetricKind`. - - :type value_type: str - :param value_type: - The value type of the metric. It must be one of - :data:`ValueType.BOOL`, :data:`ValueType.INT64`, - :data:`ValueType.DOUBLE`, :data:`ValueType.STRING`, - or :data:`ValueType.DISTRIBUTION`. - See :class:`ValueType`. - - :type labels: - list of :class:`~google.cloud.monitoring.label.LabelDescriptor` - :param labels: - A sequence of zero or more label descriptors specifying the labels - used to identify a specific instance of this metric. - - :type unit: str - :param unit: An optional unit in which the metric value is reported. - - :type description: str - :param description: An optional detailed description of the metric. - - :type display_name: str - :param display_name: An optional concise name for the metric. - - :rtype: :class:`MetricDescriptor` - :returns: The metric descriptor created with the passed-in arguments. - """ - return MetricDescriptor( - self, type_, - metric_kind=metric_kind, - value_type=value_type, - labels=labels, - unit=unit, - description=description, - display_name=display_name, - ) - - @staticmethod - def metric(type_, labels): - """Factory for constructing metric objects. - - :class:`~google.cloud.monitoring.metric.Metric` objects are typically - created to write custom metric values. The type should match the - metric type specified in the - :class:`~google.cloud.monitoring.metric.MetricDescriptor` used to - create the custom metric:: - - >>> metric = client.metric('custom.googleapis.com/my_metric', - ... labels={ - ... 'status': 'successful', - ... }) - - :type type_: str - :param type_: The metric type name. - - :type labels: dict - :param labels: A mapping from label names to values for all labels - enumerated in the associated - :class:`~.metric.MetricDescriptor`. - - :rtype: :class:`~google.cloud.monitoring.metric.Metric` - :returns: The metric object. - """ - labels = {k: str(v) for k, v in six.iteritems(labels)} - return Metric(type=type_, labels=labels) - - @staticmethod - def resource(type_, labels): - """Factory for constructing monitored resource objects. - - A monitored resource object ( - :class:`~google.cloud.monitoring.resource.Resource`) is - typically used to create a - :class:`~google.cloud.monitoring.timeseries.TimeSeries` object. - - For a list of possible monitored resource types and their associated - labels, see: - - https://cloud.google.com/monitoring/api/resources - - :type type_: str - :param type_: The monitored resource type name. - - :type labels: dict - :param labels: A mapping from label names to values for all labels - enumerated in the associated - :class:`~.resource.ResourceDescriptor`, - except that ``project_id`` can and should be omitted - when writing time series data. - - :rtype: :class:`~google.cloud.monitoring.resource.Resource` - :returns: A monitored resource object. - """ - return Resource(type_, labels) - - @staticmethod - def time_series(metric, resource, value, - end_time=None, start_time=None): - """Construct a time series object for a single data point. - - .. note:: - - While :class:`~google.cloud.monitoring.timeseries.TimeSeries` - objects returned by the API typically have multiple data points, - :class:`~google.cloud.monitoring.timeseries.TimeSeries` objects - sent to the API must have at most one point. - - For example:: - - >>> timeseries = client.time_series(metric, resource, 1.23, - ... end_time=end) - - For more information, see: - - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries - - :type metric: :class:`~google.cloud.monitoring.metric.Metric` - :param metric: A :class:`~google.cloud.monitoring.metric.Metric`. - - :type resource: :class:`~google.cloud.monitoring.resource.Resource` - :param resource: A :class:`~google.cloud.monitoring.resource.Resource` - object. - - :type value: bool, int, string, or float - :param value: - The value of the data point to create for the - :class:`~google.cloud.monitoring.timeseries.TimeSeries`. - - .. note:: - - The Python type of the value will determine the - :class:`~ValueType` sent to the API, which must match the value - type specified in the metric descriptor. For example, a Python - float will be sent to the API as a :data:`ValueType.DOUBLE`. - - :type end_time: :class:`~datetime.datetime` - :param end_time: - The end time for the point to be included in the time series. - Assumed to be UTC if no time zone information is present. - Defaults to the current time, as obtained by calling - :meth:`datetime.datetime.utcnow`. - - :type start_time: :class:`~datetime.datetime` - :param start_time: - The start time for the point to be included in the time series. - Assumed to be UTC if no time zone information is present. - Defaults to None. If the start time is unspecified, - the API interprets the start time to be the same as the end time. - - :rtype: :class:`~google.cloud.monitoring.timeseries.TimeSeries` - :returns: A time series object. - """ - if end_time is None: - end_time = _UTCNOW() - - end_time = _datetime_to_rfc3339(end_time, ignore_zone=False) - if start_time: - start_time = _datetime_to_rfc3339(start_time, ignore_zone=False) - - point = Point(value=value, start_time=start_time, end_time=end_time) - return TimeSeries(metric=metric, resource=resource, metric_kind=None, - value_type=None, points=[point]) - - def fetch_metric_descriptor(self, metric_type): - """Look up a metric descriptor by type. - - Example:: - - >>> METRIC = 'compute.googleapis.com/instance/cpu/utilization' - >>> print(client.fetch_metric_descriptor(METRIC)) - - :type metric_type: str - :param metric_type: The metric type name. - - :rtype: :class:`~google.cloud.monitoring.metric.MetricDescriptor` - :returns: The metric descriptor instance. - - :raises: :class:`google.cloud.exceptions.NotFound` if the metric - descriptor is not found. - """ - return MetricDescriptor._fetch(self, metric_type) - - def list_metric_descriptors(self, filter_string=None, type_prefix=None): - """List all metric descriptors for the project. - - Examples:: - - >>> for descriptor in client.list_metric_descriptors(): - ... print(descriptor.type) - - >>> for descriptor in client.list_metric_descriptors( - ... type_prefix='custom.'): - ... print(descriptor.type) - - :type filter_string: str - :param filter_string: - (Optional) An optional filter expression describing the metric - descriptors to be returned. See the `filter documentation`_. - - :type type_prefix: str - :param type_prefix: - (Optional) An optional prefix constraining the selected metric - types. This adds ``metric.type = starts_with("")`` to the - filter. - - :rtype: - list of :class:`~google.cloud.monitoring.metric.MetricDescriptor` - :returns: A list of metric descriptor instances. - - .. _filter documentation: - https://cloud.google.com/monitoring/api/v3/filters - """ - return MetricDescriptor._list(self, filter_string, - type_prefix=type_prefix) - - def fetch_resource_descriptor(self, resource_type): - """Look up a monitored resource descriptor by type. - - Example:: - - >>> print(client.fetch_resource_descriptor('gce_instance')) - - :type resource_type: str - :param resource_type: The resource type name. - - :rtype: :class:`~google.cloud.monitoring.resource.ResourceDescriptor` - :returns: The resource descriptor instance. - - :raises: :class:`google.cloud.exceptions.NotFound` if the resource - descriptor is not found. - """ - return ResourceDescriptor._fetch(self, resource_type) - - def list_resource_descriptors(self, filter_string=None): - """List all monitored resource descriptors for the project. - - Example:: - - >>> for descriptor in client.list_resource_descriptors(): - ... print(descriptor.type) - - :type filter_string: str - :param filter_string: - (Optional) An optional filter expression describing the resource - descriptors to be returned. See the `filter documentation`_. - - :rtype: list of - :class:`~google.cloud.monitoring.resource.ResourceDescriptor` - :returns: A list of resource descriptor instances. - - .. _filter documentation: - https://cloud.google.com/monitoring/api/v3/filters - """ - return ResourceDescriptor._list(self, filter_string) - - def group(self, group_id=None, display_name=None, parent_id=None, - filter_string=None, is_cluster=False): - """Factory constructor for group object. - - .. note:: - This will not make an HTTP request; it simply instantiates - a group object owned by this client. - - :type group_id: str - :param group_id: (Optional) The ID of the group. - - :type display_name: str - :param display_name: - (Optional) A user-assigned name for this group, used only for - display purposes. - - :type parent_id: str - :param parent_id: - (Optional) The ID of the group's parent, if it has one. - - :type filter_string: str - :param filter_string: - (Optional) The filter string used to determine which monitored - resources belong to this group. - - :type is_cluster: bool - :param is_cluster: - If true, the members of this group are considered to be a cluster. - The system can perform additional analysis on groups that are - clusters. - - :rtype: :class:`Group` - :returns: The group created with the passed-in arguments. - - :raises: - :exc:`ValueError` if both ``group_id`` and ``name`` are specified. - """ - return Group( - self, - group_id=group_id, - display_name=display_name, - parent_id=parent_id, - filter_string=filter_string, - is_cluster=is_cluster, - ) - - def fetch_group(self, group_id): - """Fetch a group from the API based on it's ID. - - Example:: - - >>> try: - >>> group = client.fetch_group('1234') - >>> except google.cloud.exceptions.NotFound: - >>> print('That group does not exist!') - - :type group_id: str - :param group_id: The ID of the group. - - :rtype: :class:`~google.cloud.monitoring.group.Group` - :returns: The group instance. - - :raises: :class:`google.cloud.exceptions.NotFound` if the group - is not found. - """ - return Group._fetch(self, group_id) - - def list_groups(self): - """List all groups for the project. - - Example:: - - >>> for group in client.list_groups(): - ... print((group.display_name, group.name)) - - :rtype: list of :class:`~google.cloud.monitoring.group.Group` - :returns: A list of group instances. - """ - return Group._list(self) - - def write_time_series(self, timeseries_list): - """Write a list of time series objects to the API. - - The recommended approach to creating time series objects is using - the :meth:`~google.cloud.monitoring.client.Client.time_series` factory - method. - - Example:: - - >>> client.write_time_series([ts1, ts2]) - - If you only need to write a single time series object, consider using - the :meth:`~google.cloud.monitoring.client.Client.write_point` method - instead. - - :type timeseries_list: - list of :class:`~google.cloud.monitoring.timeseries.TimeSeries` - :param timeseries_list: - A list of time series object to be written - to the API. Each time series must contain exactly one point. - """ - path = '/projects/{project}/timeSeries/'.format( - project=self.project) - timeseries_dict = [timeseries._to_dict() - for timeseries in timeseries_list] - self._connection.api_request(method='POST', path=path, - data={'timeSeries': timeseries_dict}) - - def write_point(self, metric, resource, value, - end_time=None, - start_time=None): - """Write a single point for a metric to the API. - - This is a convenience method to write a single time series object to - the API. To write multiple time series objects to the API as a batch - operation, use the - :meth:`~google.cloud.monitoring.client.Client.time_series` - factory method to create time series objects and the - :meth:`~google.cloud.monitoring.client.Client.write_time_series` - method to write the objects. - - Example:: - - >>> client.write_point(metric, resource, 3.14) - - :type metric: :class:`~google.cloud.monitoring.metric.Metric` - :param metric: A :class:`~google.cloud.monitoring.metric.Metric` - object. - - :type resource: :class:`~google.cloud.monitoring.resource.Resource` - :param resource: A :class:`~google.cloud.monitoring.resource.Resource` - object. - - :type value: bool, int, string, or float - :param value: - The value of the data point to create for the - :class:`~google.cloud.monitoring.timeseries.TimeSeries`. - - .. note:: - - The Python type of the value will determine the - :class:`~ValueType` sent to the API, which must match the value - type specified in the metric descriptor. For example, a Python - float will be sent to the API as a :data:`ValueType.DOUBLE`. - - :type end_time: :class:`~datetime.datetime` - :param end_time: - The end time for the point to be included in the time series. - Assumed to be UTC if no time zone information is present. - Defaults to the current time, as obtained by calling - :meth:`datetime.datetime.utcnow`. - - :type start_time: :class:`~datetime.datetime` - :param start_time: - The start time for the point to be included in the time series. - Assumed to be UTC if no time zone information is present. - Defaults to None. If the start time is unspecified, - the API interprets the start time to be the same as the end time. - """ - timeseries = self.time_series( - metric, resource, value, end_time, start_time) - self.write_time_series([timeseries]) diff --git a/monitoring/google/cloud/monitoring/group.py b/monitoring/google/cloud/monitoring/group.py deleted file mode 100644 index 68f512ad3dbc..000000000000 --- a/monitoring/google/cloud/monitoring/group.py +++ /dev/null @@ -1,501 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Groups for the `Google Stackdriver Monitoring API (V3)`_. - -.. _Google Stackdriver Monitoring API (V3): - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.groups -""" - -import re - -from google.cloud._helpers import _datetime_to_rfc3339 -from google.cloud._helpers import _name_from_project_path -from google.cloud.exceptions import NotFound -from google.cloud.monitoring.resource import Resource - - -_GROUP_TEMPLATE = re.compile(r""" - projects/ # static prefix - (?P[^/]+) # initial letter, wordchars + hyphen - /groups/ # static midfix - (?P[^/]+) # initial letter, wordchars + allowed punc -""", re.VERBOSE) - - -def _group_id_from_name(path, project=None): - """Validate a group URI path and get the group ID. - - :type path: str - :param path: URI path for a group API request. - - :type project: str - :param project: (Optional) The project associated with the request. It is - included for validation purposes. - - :rtype: str - :returns: Group ID parsed from ``path``. - :raises: :class:`ValueError` if the ``path`` is ill-formed or if - the project from the ``path`` does not agree with the - ``project`` passed in. - """ - return _name_from_project_path(path, project, _GROUP_TEMPLATE) - - -def _group_name_from_id(project, group_id): - """Build the group name given the project and group ID. - - :type project: str - :param project: The project associated with the group. - - :type group_id: str - :param group_id: The group ID. - - :rtype: str - :returns: The fully qualified name of the group. - """ - return 'projects/{project}/groups/{group_id}'.format( - project=project, group_id=group_id) - - -class Group(object): - """A dynamic collection of monitored resources. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: A client for operating on the metric descriptor. - - :type group_id: str - :param group_id: (Optional) The ID of the group. - - :type display_name: str - :param display_name: - (Optional) A user-assigned name for this group, used only for display - purposes. - - :type parent_id: str - :param parent_id: - (Optional) The ID of the group's parent, if it has one. - - :type filter_string: str - :param filter_string: - (Optional) The filter string used to determine which monitored - resources belong to this group. - - :type is_cluster: bool - :param is_cluster: - If true, the members of this group are considered to be a cluster. The - system can perform additional analysis on groups that are clusters. - """ - def __init__(self, client, group_id=None, display_name=None, - parent_id=None, filter_string=None, is_cluster=False): - self.client = client - self._id = group_id - self.display_name = display_name - self.parent_id = parent_id - self.filter = filter_string - self.is_cluster = is_cluster - - if group_id: - self._name = _group_name_from_id(client.project, group_id) - else: - self._name = None - - @property - def id(self): - """Returns the group ID. - - :rtype: str or None - :returns: the ID of the group based on it's name. - """ - return self._id - - @property - def name(self): - """Returns the fully qualified name of the group. - - :rtype: str or None - :returns: - The fully qualified name of the group in the format - "projects//groups/". - """ - return self._name - - @property - def parent_name(self): - """Returns the fully qualified name of the parent group. - - :rtype: str or None - :returns: - The fully qualified name of the parent group. - """ - if not self.parent_id: - return None - return _group_name_from_id(self.client.project, self.parent_id) - - @property - def path(self): - """URL path to this group. - - :rtype: str - :returns: the path based on project and group name. - - :raises: :exc:`ValueError` if :attr:`name` is not specified. - """ - if not self.id: - raise ValueError('Cannot determine path without group ID.') - return '/' + self.name - - def create(self): - """Create a new group based on this object via a ``POST`` request. - - Example:: - - >>> filter_string = 'resource.type = "gce_instance"' - >>> group = client.group( - ... display_name='My group', - ... filter_string=filter_string, - ... parent_id='5678', - ... is_cluster=True) - >>> group.create() - - The ``name`` attribute is ignored in preparing the creation request. - All attributes are overwritten by the values received in the response - (normally affecting only ``name``). - """ - path = '/projects/%s/groups/' % (self.client.project,) - info = self.client._connection.api_request( - method='POST', path=path, data=self._to_dict()) - self._set_properties_from_dict(info) - - def exists(self): - """Test for the existence of the group via a ``GET`` request. - - :rtype: bool - :returns: Boolean indicating existence of the group. - """ - try: - self.client._connection.api_request( - method='GET', path=self.path, query_params={'fields': 'name'}) - except NotFound: - return False - else: - return True - - def reload(self): - """Sync local group information via a ``GET`` request. - - .. warning:: - - This will overwrite any local changes you've made and not saved - via :meth:`update`. - """ - info = self.client._connection.api_request( - method='GET', path=self.path) - self._set_properties_from_dict(info) - - def update(self): - """Update the group via a ``PUT`` request.""" - info = self.client._connection.api_request( - method='PUT', path=self.path, data=self._to_dict()) - self._set_properties_from_dict(info) - - def delete(self): - """Delete the group via a ``DELETE`` request. - - Example:: - - >>> group = client.group('1234') - >>> group.delete() - - Only the ``client`` and ``name`` attributes are used. - - .. warning:: - - This method will fail for groups that have one or more children - groups. - """ - self.client._connection.api_request( - method='DELETE', path=self.path) - - def fetch_parent(self): - """Returns the parent group of this group via a ``GET`` request. - - :rtype: :class:`Group` or None - :returns: The parent of the group. - """ - if not self.parent_id: - return None - return self._fetch(self.client, self.parent_id) - - def list_children(self): - """Lists all children of this group via a ``GET`` request. - - Returns groups whose parent_name field contains the group name. If no - groups have this parent, the results are empty. - - :rtype: list of :class:`~google.cloud.monitoring.group.Group` - :returns: A list of group instances. - """ - return self._list(self.client, children_of_group=self.name) - - def list_ancestors(self): - """Lists all ancestors of this group via a ``GET`` request. - - The groups are returned in order, starting with the immediate parent - and ending with the most distant ancestor. If the specified group has - no immediate parent, the results are empty. - - :rtype: list of :class:`~google.cloud.monitoring.group.Group` - :returns: A list of group instances. - """ - return self._list(self.client, ancestors_of_group=self.name) - - def list_descendants(self): - """Lists all descendants of this group via a ``GET`` request. - - This returns a superset of the results returned by the :meth:`children` - method, and includes children-of-children, and so forth. - - :rtype: list of :class:`~google.cloud.monitoring.group.Group` - :returns: A list of group instances. - """ - return self._list(self.client, descendants_of_group=self.name) - - def list_members(self, filter_string=None, end_time=None, start_time=None): - """Lists all members of this group via a ``GET`` request. - - If no ``end_time`` is provided then the group membership over the last - minute is returned. - - Example:: - - >>> for member in group.list_members(): - ... print(member) - - List members that are Compute Engine VM instances:: - - >>> filter_string = 'resource.type = "gce_instance"' - >>> for member in group.list_members(filter_string=filter_string): - ... print(member) - - List historical members that existed between 4 and 5 hours ago:: - - >>> import datetime - >>> t1 = datetime.datetime.utcnow() - datetime.timedelta(hours=4) - >>> t0 = t1 - datetime.timedelta(hours=1) - >>> for member in group.list_members(end_time=t1, start_time=t0): - ... print(member) - - - :type filter_string: str - :param filter_string: - (Optional) An optional list filter describing the members to be - returned. The filter may reference the type, labels, and metadata - of monitored resources that comprise the group. See the `filter - documentation`_. - - :type end_time: :class:`datetime.datetime` - :param end_time: - (Optional) The end time (inclusive) of the time interval for which - results should be returned, as a datetime object. If ``start_time`` - is specified, then this must also be specified. - - :type start_time: :class:`datetime.datetime` - :param start_time: - (Optional) The start time (exclusive) of the time interval for - which results should be returned, as a datetime object. - - :rtype: list of :class:`~google.cloud.monitoring.resource.Resource` - :returns: A list of resource instances. - - :raises: - :exc:`ValueError` if the ``start_time`` is specified, but the - ``end_time`` is missing. - - .. _filter documentation: - https://cloud.google.com/monitoring/api/v3/filters#group-filter - """ - if start_time is not None and end_time is None: - raise ValueError('If "start_time" is specified, "end_time" must ' - 'also be specified') - - path = '%s/members' % (self.path,) - resources = [] - page_token = None - params = {} - - if filter_string is not None: - params['filter'] = filter_string - - if end_time is not None: - params['interval.endTime'] = _datetime_to_rfc3339( - end_time, ignore_zone=False) - - if start_time is not None: - params['interval.startTime'] = _datetime_to_rfc3339( - start_time, ignore_zone=False) - - while True: - if page_token is not None: - params['pageToken'] = page_token - - response = self.client._connection.api_request( - method='GET', path=path, query_params=params.copy()) - for info in response.get('members', ()): - resources.append(Resource._from_dict(info)) - - page_token = response.get('nextPageToken') - if not page_token: - break - - return resources - - @classmethod - def _fetch(cls, client, group_id): - """Fetch a group from the API based on it's ID. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: The client to use. - - :type group_id: str - :param group_id: The group ID. - - :rtype: :class:`Group` - :returns: The group instance. - - :raises: :class:`google.cloud.exceptions.NotFound` if the group - is not found. - """ - new_group = cls(client, group_id) - new_group.reload() - return new_group - - @classmethod - def _list(cls, client, children_of_group=None, ancestors_of_group=None, - descendants_of_group=None): - """Lists all groups in the project. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: The client to use. - - :type children_of_group: str - :param children_of_group: - (Optional) Returns groups whose parent_name field contains the - group name. If no groups have this parent, the results are empty. - - :type ancestors_of_group: str - :param ancestors_of_group: - (Optional) Returns groups that are ancestors of the specified - group. If the specified group has no immediate parent, the results - are empty. - - :type descendants_of_group: str - :param descendants_of_group: - (Optional) Returns the descendants of the specified group. This is - a superset of the results returned by the children_of_group filter, - and includes children-of-children, and so forth. - - :rtype: list of :class:`~google.cloud.monitoring.group.Group` - :returns: A list of group instances. - """ - path = '/projects/%s/groups/' % (client.project,) - groups = [] - page_token = None - params = {} - - if children_of_group is not None: - params['childrenOfGroup'] = children_of_group - - if ancestors_of_group is not None: - params['ancestorsOfGroup'] = ancestors_of_group - - if descendants_of_group is not None: - params['descendantsOfGroup'] = descendants_of_group - - while True: - if page_token is not None: - params['pageToken'] = page_token - - response = client._connection.api_request( - method='GET', path=path, query_params=params.copy()) - for info in response.get('group', ()): - groups.append(cls._from_dict(client, info)) - - page_token = response.get('nextPageToken') - if not page_token: - break - - return groups - - @classmethod - def _from_dict(cls, client, info): - """Constructs a Group instance from the parsed JSON representation. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: A client to be included in the returned object. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`Group` - :returns: A group. - """ - group = cls(client) - group._set_properties_from_dict(info) - return group - - def _set_properties_from_dict(self, info): - """Update the group properties from its API representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - """ - self._name = info['name'] - self._id = _group_id_from_name(self._name) - self.display_name = info['displayName'] - self.filter = info['filter'] - self.is_cluster = info.get('isCluster', False) - - parent_name = info.get('parentName') - if parent_name is None: - self.parent_id = None - else: - self.parent_id = _group_id_from_name(parent_name) - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON wire format. - - :rtype: dict - :returns: A dictionary. - """ - info = { - 'filter': self.filter, - 'displayName': self.display_name, - 'isCluster': self.is_cluster, - } - - if self.name is not None: - info['name'] = self.name - - parent_name = self.parent_name - if parent_name is not None: - info['parentName'] = parent_name - - return info - - def __repr__(self): - return '' % (self.name,) diff --git a/monitoring/google/cloud/monitoring/label.py b/monitoring/google/cloud/monitoring/label.py deleted file mode 100644 index 896a0a91250f..000000000000 --- a/monitoring/google/cloud/monitoring/label.py +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Label Descriptors for the `Stackdriver Monitoring API (V3)`_. - -.. _Stackdriver Monitoring API (V3): - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/LabelDescriptor -""" - - -class LabelValueType(object): - """Allowed values for the `type of a label`_. - - .. _type of a label: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - LabelDescriptor#ValueType - """ - - STRING = 'STRING' - BOOL = 'BOOL' - INT64 = 'INT64' - - -class LabelDescriptor(object): - """Schema specification and documentation for a single label. - - :type key: str - :param key: The name of the label. - - :type value_type: str - :param value_type: - The type of the label. It must be one of :data:`LabelValueType.STRING`, - :data:`LabelValueType.BOOL`, or :data:`LabelValueType.INT64`. - See :class:`LabelValueType`. - - :type description: str - :param description: A human-readable description for the label. - """ - - def __init__(self, key, value_type=LabelValueType.STRING, description=''): - self.key = key - self.value_type = value_type - self.description = description - - @classmethod - def _from_dict(cls, info): - """Construct a label descriptor from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`LabelDescriptor` - :returns: A label descriptor. - """ - return cls( - info['key'], - info.get('valueType', LabelValueType.STRING), - info.get('description', ''), - ) - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON wire format. - - :rtype: dict - :returns: A dictionary. - """ - info = { - 'key': self.key, - 'valueType': self.value_type, - } - - if self.description: - info['description'] = self.description - - return info - - def __eq__(self, other): - if not isinstance(other, LabelDescriptor): - return NotImplemented - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not self == other - - def __repr__(self): - return ( - 'LabelDescriptor(key={key!r}, value_type={value_type!r},' - ' description={description!r})' - ).format(**self.__dict__) diff --git a/monitoring/google/cloud/monitoring/metric.py b/monitoring/google/cloud/monitoring/metric.py deleted file mode 100644 index b8b5e21861b8..000000000000 --- a/monitoring/google/cloud/monitoring/metric.py +++ /dev/null @@ -1,362 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Metric Descriptors for the `Google Stackdriver Monitoring API (V3)`_. - -.. _Google Stackdriver Monitoring API (V3): - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.metricDescriptors -""" - -import collections - -from google.cloud.monitoring.label import LabelDescriptor - - -class MetricKind(object): - """Choices for the `kind of measurement`_. - - .. _kind of measurement: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.metricDescriptors#MetricKind - """ - - METRIC_KIND_UNSPECIFIED = 'METRIC_KIND_UNSPECIFIED' - """.. note:: An unspecified kind is not allowed in metric descriptors.""" - - GAUGE = 'GAUGE' - DELTA = 'DELTA' - CUMULATIVE = 'CUMULATIVE' - - -class ValueType(object): - """Choices for the `metric value type`_. - - .. _metric value type: - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.metricDescriptors#ValueType - """ - - VALUE_TYPE_UNSPECIFIED = 'VALUE_TYPE_UNSPECIFIED' - """.. note:: An unspecified type is not allowed in metric descriptors.""" - - BOOL = 'BOOL' - INT64 = 'INT64' - DOUBLE = 'DOUBLE' - STRING = 'STRING' - DISTRIBUTION = 'DISTRIBUTION' - - -class MetricDescriptor(object): - """Specification of a metric type and its schema. - - The preferred way to construct a metric descriptor object is using the - :meth:`~google.cloud.monitoring.client.Client.metric_descriptor` factory - method of the :class:`~google.cloud.monitoring.client.Client` class. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: A client for operating on the metric descriptor. - - :type type_: str - :param type_: - The metric type including a DNS name prefix. For example: - ``"compute.googleapis.com/instance/cpu/utilization"`` - - :type metric_kind: str - :param metric_kind: - The kind of measurement. It must be one of - :data:`MetricKind.GAUGE`, :data:`MetricKind.DELTA`, - or :data:`MetricKind.CUMULATIVE`. See :class:`MetricKind`. - - :type value_type: str - :param value_type: - The value type of the metric. It must be one of - :data:`ValueType.BOOL`, :data:`ValueType.INT64`, - :data:`ValueType.DOUBLE`, :data:`ValueType.STRING`, - or :data:`ValueType.DISTRIBUTION`. - See :class:`ValueType`. - - :type labels: - list of :class:`~google.cloud.monitoring.label.LabelDescriptor` - :param labels: - A sequence of zero or more label descriptors specifying the labels - used to identify a specific instance of this metric. - - :type unit: str - :param unit: An optional unit in which the metric value is reported. - - :type description: str - :param description: An optional detailed description of the metric. - - :type display_name: str - :param display_name: An optional concise name for the metric. - - :type name: str - :param name: - (Optional) The "resource name" of the metric descriptor. For example: - ``"projects//metricDescriptors/"``. As - retrieved from the service, this will always be specified. - You can and should omit it when constructing an instance for - the purpose of creating a new metric descriptor. - """ - - def __init__(self, client, type_, - metric_kind=MetricKind.METRIC_KIND_UNSPECIFIED, - value_type=ValueType.VALUE_TYPE_UNSPECIFIED, - labels=(), - unit='', description='', display_name='', - name=None): - self.client = client - self.name = name - self.type = type_ - self.labels = labels - self.metric_kind = metric_kind - self.value_type = value_type - self.unit = unit - self.description = description - self.display_name = display_name - - def create(self): - """Create a new metric descriptor based on this object. - - Example:: - - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_metric', - ... metric_kind=MetricKind.GAUGE, - ... value_type=ValueType.DOUBLE, - ... description='This is a simple example of a custom metric.') - >>> descriptor.create() - - The metric kind must not be :data:`MetricKind.METRIC_KIND_UNSPECIFIED`, - and the value type must not be - :data:`ValueType.VALUE_TYPE_UNSPECIFIED`. - - The ``name`` attribute is ignored in preparing the creation request. - All attributes are overwritten by the values received in the response - (normally affecting only ``name``). - """ - path = '/projects/{project}/metricDescriptors/'.format( - project=self.client.project) - response = self.client._connection.api_request( - method='POST', path=path, data=self._to_dict()) - self._init_from_dict(response) - - def delete(self): - """Delete the metric descriptor identified by this object. - - Example:: - - >>> descriptor = client.metric_descriptor( - ... 'custom.googleapis.com/my_metric') - >>> descriptor.delete() - - Only the ``client`` and ``type`` attributes are used. - """ - path = '/projects/{project}/metricDescriptors/{type}'.format( - project=self.client.project, - type=self.type) - self.client._connection.api_request(method='DELETE', path=path) - - @classmethod - def _fetch(cls, client, metric_type): - """Look up a metric descriptor by type. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: The client to use. - - :type metric_type: str - :param metric_type: The metric type name. - - :rtype: :class:`MetricDescriptor` - :returns: The metric descriptor instance. - - :raises: :class:`google.cloud.exceptions.NotFound` if the metric - descriptor is not found. - """ - path = '/projects/{project}/metricDescriptors/{type}'.format( - project=client.project, - type=metric_type) - info = client._connection.api_request(method='GET', path=path) - return cls._from_dict(client, info) - - @classmethod - def _list(cls, client, filter_string=None, type_prefix=None): - """List all metric descriptors for the project. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: The client to use. - - :type filter_string: str - :param filter_string: - (Optional) Filter expression describing the metric descriptors to - be returned. See the `filter documentation`_. - - :type type_prefix: str - :param type_prefix: - (Optional) Prefix constraining the selected metric types. This adds - ``metric.type = starts_with("")`` to the filter. - - :rtype: list of :class:`MetricDescriptor` - :returns: A list of metric descriptor instances. - - .. _filter documentation: - https://cloud.google.com/monitoring/api/v3/filters - """ - path = '/projects/{project}/metricDescriptors/'.format( - project=client.project) - - filters = [] - if filter_string is not None: - filters.append(filter_string) - - if type_prefix is not None: - filters.append('metric.type = starts_with("{prefix}")'.format( - prefix=type_prefix)) - - descriptors = [] - page_token = None - while True: - params = {} - - if filters: - params['filter'] = ' AND '.join(filters) - - if page_token is not None: - params['pageToken'] = page_token - - response = client._connection.api_request( - method='GET', path=path, query_params=params) - for info in response.get('metricDescriptors', ()): - descriptors.append(cls._from_dict(client, info)) - - page_token = response.get('nextPageToken') - if not page_token: - break - - return descriptors - - @classmethod - def _from_dict(cls, client, info): - """Construct a metric descriptor from the parsed JSON representation. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: A client to be included in the returned object. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`MetricDescriptor` - :returns: A metric descriptor. - """ - descriptor = cls(client, None) - descriptor._init_from_dict(info) - return descriptor - - def _init_from_dict(self, info): - """Initialize attributes from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - """ - self.name = info['name'] - self.type = info['type'] - self.labels = tuple(LabelDescriptor._from_dict(label) - for label in info.get('labels', [])) - self.metric_kind = info['metricKind'] - self.value_type = info['valueType'] - self.unit = info.get('unit', '') - self.description = info.get('description', '') - self.display_name = info.get('displayName', '') - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON wire format. - - :rtype: dict - :returns: A dictionary. - """ - info = { - 'type': self.type, - 'metricKind': self.metric_kind, - 'valueType': self.value_type, - } - - if self.labels: - info['labels'] = [label._to_dict() for label in self.labels] - if self.unit: - info['unit'] = self.unit - if self.description: - info['description'] = self.description - if self.display_name: - info['displayName'] = self.display_name - - return info - - def __repr__(self): - return ( - '' - ).format(**self.__dict__) - - -class Metric(collections.namedtuple('Metric', 'type labels')): - """A specific metric identified by specifying values for all labels. - - The preferred way to construct a metric object is using the - :meth:`~google.cloud.monitoring.client.Client.metric` factory method - of the :class:`~google.cloud.monitoring.client.Client` class. - - :type type: str - :param type: The metric type name. - - :type labels: dict - :param labels: A mapping from label names to values for all labels - enumerated in the associated :class:`MetricDescriptor`. - """ - __slots__ = () - - @classmethod - def _from_dict(cls, info): - """Construct a metric object from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`Metric` - :returns: A metric object. - """ - return cls( - type=info['type'], - labels=info.get('labels', {}), - ) - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON format. - - :rtype: dict - :returns: A dict representation of the object that can be written to - the API. - """ - return { - 'type': self.type, - 'labels': self.labels, - } diff --git a/monitoring/google/cloud/monitoring/resource.py b/monitoring/google/cloud/monitoring/resource.py deleted file mode 100644 index c77259cfe6dd..000000000000 --- a/monitoring/google/cloud/monitoring/resource.py +++ /dev/null @@ -1,201 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Monitored Resource Descriptors for the -`Google Stackdriver Monitoring API (V3)`_. - -.. _Google Stackdriver Monitoring API (V3): - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.monitoredResourceDescriptors -""" - -import collections - -from google.cloud.monitoring.label import LabelDescriptor - - -class ResourceDescriptor(object): - """Specification of a monitored resource type and its schema. - - :type name: str - :param name: - The "resource name" of the monitored resource descriptor: - ``"projects//monitoredResourceDescriptors/"`` - - :type type_: str - :param type_: - The monitored resource type. For example: ``"gce_instance"`` - - :type display_name: str - :param display_name: - A concise name that might be displayed in user interfaces. - - :type description: str - :param description: - A detailed description that might be used in documentation. - - :type labels: - list of :class:`~google.cloud.monitoring.label.LabelDescriptor` - :param labels: - A sequence of label descriptors specifying the labels used - to identify a specific instance of this monitored resource. - """ - - def __init__(self, name, type_, display_name, description, labels): - self.name = name - self.type = type_ - self.display_name = display_name - self.description = description - self.labels = labels - - @classmethod - def _fetch(cls, client, resource_type): - """Look up a monitored resource descriptor by type. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: The client to use. - - :type resource_type: str - :param resource_type: The resource type name. - - :rtype: :class:`ResourceDescriptor` - :returns: The resource descriptor instance. - - :raises: :class:`google.cloud.exceptions.NotFound` if the resource - descriptor is not found. - """ - path = ('/projects/{project}/monitoredResourceDescriptors/{type}' - .format(project=client.project, - type=resource_type)) - info = client._connection.api_request(method='GET', path=path) - return cls._from_dict(info) - - @classmethod - def _list(cls, client, filter_string=None): - """List all monitored resource descriptors for the project. - - :type client: :class:`google.cloud.monitoring.client.Client` - :param client: The client to use. - - :type filter_string: str - :param filter_string: - (Optional) An optional filter expression describing the resource - descriptors to be returned. See the `filter documentation`_. - - :rtype: list of :class:`ResourceDescriptor` - :returns: A list of resource descriptor instances. - - .. _filter documentation: - https://cloud.google.com/monitoring/api/v3/filters - """ - path = '/projects/{project}/monitoredResourceDescriptors/'.format( - project=client.project) - - descriptors = [] - - page_token = None - while True: - params = {} - - if filter_string is not None: - params['filter'] = filter_string - - if page_token is not None: - params['pageToken'] = page_token - - response = client._connection.api_request( - method='GET', path=path, query_params=params) - for info in response.get('resourceDescriptors', ()): - descriptors.append(cls._from_dict(info)) - - page_token = response.get('nextPageToken') - if not page_token: - break - - return descriptors - - @classmethod - def _from_dict(cls, info): - """Construct a resource descriptor from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`ResourceDescriptor` - :returns: A resource descriptor. - """ - return cls( - name=info['name'], - type_=info['type'], - display_name=info.get('displayName', ''), - description=info.get('description', ''), - labels=tuple(LabelDescriptor._from_dict(label) - for label in info.get('labels', ())), - ) - - def __repr__(self): - return ( - '' - ).format(**self.__dict__) - - -class Resource(collections.namedtuple('Resource', 'type labels')): - """A monitored resource identified by specifying values for all labels. - - The preferred way to construct a resource object is using the - :meth:`~google.cloud.monitoring.client.Client.resource` factory method - of the :class:`~google.cloud.monitoring.client.Client` class. - - :type type: str - :param type: The resource type name. - - :type labels: dict - :param labels: A mapping from label names to values for all labels - enumerated in the associated :class:`ResourceDescriptor`. - """ - __slots__ = () - - @classmethod - def _from_dict(cls, info): - """Construct a resource object from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`Resource` - :returns: A resource object. - """ - return cls( - type=info['type'], - labels=info.get('labels', {}), - ) - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON format. - - :rtype: dict - :returns: A dict representation of the object that can be written to - the API. - """ - return { - 'type': self.type, - 'labels': self.labels, - } diff --git a/monitoring/google/cloud/monitoring/timeseries.py b/monitoring/google/cloud/monitoring/timeseries.py deleted file mode 100644 index 95aa825288d8..000000000000 --- a/monitoring/google/cloud/monitoring/timeseries.py +++ /dev/null @@ -1,228 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Time series for the `Google Stackdriver Monitoring API (V3)`_. - -Features intentionally omitted from this first version of the client library: - * Writing time series. - * Natural representation of distribution values. - -.. _Google Stackdriver Monitoring API (V3): - https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries -""" - -import collections - -from google.cloud.monitoring.metric import Metric -from google.cloud.monitoring.resource import Resource - - -class TimeSeries(collections.namedtuple( - 'TimeSeries', 'metric resource metric_kind value_type points')): - """A single time series of metric values. - - The preferred way to construct a - :class:`~google.cloud.monitoring.timeseries.TimeSeries` object is - using the :meth:`~google.cloud.monitoring.client.Client.time_series` - factory method of the :class:`~google.cloud.monitoring.client.Client` - class. - - :type metric: :class:`~google.cloud.monitoring.metric.Metric` - :param metric: A metric object. - - :type resource: :class:`~google.cloud.monitoring.resource.Resource` - :param resource: A resource object. - - :type metric_kind: str - :param metric_kind: - The kind of measurement: :data:`MetricKind.GAUGE`, - :data:`MetricKind.DELTA`, or :data:`MetricKind.CUMULATIVE`. - See :class:`~google.cloud.monitoring.metric.MetricKind`. - - :type value_type: str - :param value_type: - The value type of the metric: :data:`ValueType.BOOL`, - :data:`ValueType.INT64`, :data:`ValueType.DOUBLE`, - :data:`ValueType.STRING`, or :data:`ValueType.DISTRIBUTION`. - See :class:`~google.cloud.monitoring.metric.ValueType`. - - :type points: list of :class:`Point` - :param points: A list of point objects. - """ - - _labels = None - - @property - def labels(self): - """A single dictionary with values for all the labels. - - This combines ``resource.labels`` and ``metric.labels`` and also - adds ``"resource_type"``. - """ - if self._labels is None: - labels = {'resource_type': self.resource.type} - labels.update(self.resource.labels) - labels.update(self.metric.labels) - self._labels = labels - - return self._labels - - def header(self, points=None): - """Copy everything but the point data. - - :type points: list of :class:`Point`, or None - :param points: An optional point list. - - :rtype: :class:`TimeSeries` - :returns: The new time series object. - """ - points = list(points) if points else [] - return self._replace(points=points) - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON wire format. - - Since this method is used when writing to the API, it excludes - output-only fields. - - :rtype: dict - :returns: The dictionary representation of the time series object. - """ - info = { - 'metric': self.metric._to_dict(), - 'resource': self.resource._to_dict(), - 'points': [point._to_dict() for point in self.points], - } - - return info - - @classmethod - def _from_dict(cls, info): - """Construct a time series from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`TimeSeries` - :returns: A time series object. - """ - metric = Metric._from_dict(info['metric']) - resource = Resource._from_dict(info['resource']) - metric_kind = info['metricKind'] - value_type = info['valueType'] - points = [Point._from_dict(p) for p in info.get('points', ())] - return cls(metric, resource, metric_kind, value_type, points) - - def __repr__(self): - """Return a representation string with the points elided.""" - return ( - '' - ).format( - num=len(self.points), - metric=self.metric, - resource=self.resource, - kind=self.metric_kind, - type=self.value_type, - ) - - -def _make_typed_value(value): - """Create a dict representing a TypedValue API object. - - Typed values are objects with the value itself as the value, keyed by the - type of the value. They are used when writing points to time series. This - method returns the dict representation for the TypedValue. - - This method uses the Python type of the object to infer the correct - type to send to the API. For example, a Python float will be sent to the - API with "doubleValue" as its key. - - See https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TypedValue - - :type value: bool, int, float, str, or dict - :param value: value to infer the typed value of. - - :rtype: dict - :returns: A dict - """ - typed_value_map = { - bool: 'boolValue', - int: 'int64Value', - float: 'doubleValue', - str: 'stringValue', - dict: 'distributionValue', - } - type_ = typed_value_map[type(value)] - if type_ == 'int64Value': - value = str(value) - return {type_: value} - - -class Point(collections.namedtuple('Point', 'end_time start_time value')): - """A single point in a time series. - - :type end_time: str - :param end_time: The end time in RFC3339 UTC "Zulu" format. - - :type start_time: str - :param start_time: (Optional) The start time in RFC3339 UTC "Zulu" format. - - :type value: object - :param value: The metric value. This can be a scalar or a distribution. - """ - __slots__ = () - - @classmethod - def _from_dict(cls, info): - """Construct a Point from the parsed JSON representation. - - :type info: dict - :param info: - A ``dict`` parsed from the JSON wire-format representation. - - :rtype: :class:`Point` - :returns: A point object. - """ - end_time = info['interval']['endTime'] - start_time = info['interval'].get('startTime') - (value_type, value), = info['value'].items() - if value_type == 'int64Value': - value = int(value) # Convert from string. - - return cls(end_time, start_time, value) - - def _to_dict(self): - """Build a dictionary ready to be serialized to the JSON wire format. - - This method serializes a point in JSON format to be written - to the API. - - :rtype: dict - :returns: The dictionary representation of the point object. - """ - info = { - 'interval': { - 'endTime': self.end_time, - }, - 'value': _make_typed_value(self.value), - } - - if self.start_time is not None: - info['interval']['startTime'] = self.start_time - - return info diff --git a/monitoring/google/cloud/monitoring_v3/__init__.py b/monitoring/google/cloud/monitoring_v3/__init__.py new file mode 100644 index 000000000000..946324414d44 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/__init__.py @@ -0,0 +1,64 @@ +# 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. + +from __future__ import absolute_import + +from google.cloud.monitoring_v3 import types +from google.cloud.monitoring_v3.gapic import alert_policy_service_client +from google.cloud.monitoring_v3.gapic import enums +from google.cloud.monitoring_v3.gapic import group_service_client +from google.cloud.monitoring_v3.gapic import metric_service_client +from google.cloud.monitoring_v3.gapic import \ + notification_channel_service_client +from google.cloud.monitoring_v3.gapic import uptime_check_service_client + + +class AlertPolicyServiceClient( + alert_policy_service_client.AlertPolicyServiceClient): + __doc__ = alert_policy_service_client.AlertPolicyServiceClient.__doc__ + enums = enums + + +class GroupServiceClient(group_service_client.GroupServiceClient): + __doc__ = group_service_client.GroupServiceClient.__doc__ + enums = enums + + +class MetricServiceClient(metric_service_client.MetricServiceClient): + __doc__ = metric_service_client.MetricServiceClient.__doc__ + enums = enums + + +class NotificationChannelServiceClient( + notification_channel_service_client.NotificationChannelServiceClient): + __doc__ = notification_channel_service_client.\ + NotificationChannelServiceClient.__doc__ + enums = enums + + +class UptimeCheckServiceClient( + uptime_check_service_client.UptimeCheckServiceClient): + __doc__ = uptime_check_service_client.UptimeCheckServiceClient.__doc__ + enums = enums + + +__all__ = ( + 'enums', + 'types', + 'AlertPolicyServiceClient', + 'GroupServiceClient', + 'MetricServiceClient', + 'NotificationChannelServiceClient', + 'UptimeCheckServiceClient', +) diff --git a/monitoring/google/cloud/monitoring/_dataframe.py b/monitoring/google/cloud/monitoring_v3/_dataframe.py similarity index 68% rename from monitoring/google/cloud/monitoring/_dataframe.py rename to monitoring/google/cloud/monitoring_v3/_dataframe.py index d7334a6f1974..24708249e562 100644 --- a/monitoring/google/cloud/monitoring/_dataframe.py +++ b/monitoring/google/cloud/monitoring_v3/_dataframe.py @@ -15,6 +15,12 @@ """Time series as :mod:`pandas` dataframes.""" import itertools +try: + import pandas +except ImportError: # pragma: NO COVER + pandas = None + +from google.cloud.monitoring_v3.types import TimeSeries TOP_RESOURCE_LABELS = ( 'project_id', @@ -25,12 +31,36 @@ ) +def _extract_header(time_series): + """Return a copy of time_series with the points removed.""" + return TimeSeries( + metric=time_series.metric, + resource=time_series.resource, + metric_kind=time_series.metric_kind, + value_type=time_series.value_type + ) + + +def _extract_labels(time_series): + """Build the combined resource and metric labels, with resource_type.""" + labels = {'resource_type': time_series.resource.type} + labels.update(time_series.resource.labels) + labels.update(time_series.metric.labels) + return labels + + +def _extract_value(typed_value): + """Extract the value from a TypedValue.""" + value_type = typed_value.WhichOneof('value') + return typed_value.__getattribute__(value_type) + + def _build_dataframe(time_series_iterable, label=None, labels=None): # pragma: NO COVER """Build a :mod:`pandas` dataframe out of time series. :type time_series_iterable: - iterable over :class:`~google.cloud.monitoring.timeseries.TimeSeries` + iterable over :class:`~google.cloud.monitoring_v3.types.TimeSeries` :param time_series_iterable: An iterable (e.g., a query object) yielding time series. @@ -54,27 +84,30 @@ def _build_dataframe(time_series_iterable, :rtype: :class:`pandas.DataFrame` :returns: A dataframe where each column represents one time series. + + :raises: :exc:`RuntimeError` if `pandas` is not installed. """ - import pandas # pylint: disable=import-error + if pandas is None: + raise RuntimeError('This method requires `pandas` to be installed.') - if labels is not None: - if label is not None: - raise ValueError('Cannot specify both "label" and "labels".') - elif not labels: - raise ValueError('"labels" must be non-empty or None.') + if label is not None: + if labels: + raise ValueError('Cannot specify both `label` and `labels`.') + labels = (label,) columns = [] headers = [] for time_series in time_series_iterable: pandas_series = pandas.Series( - data=[point.value for point in time_series.points], - index=[point.end_time for point in time_series.points], + data=[_extract_value(point.value) for point in time_series.points], + index=[point.interval.end_time.ToNanoseconds() + for point in time_series.points], ) columns.append(pandas_series) - headers.append(time_series.header()) + headers.append(_extract_header(time_series)) # Implement a smart default of using all available labels. - if label is None and labels is None: + if labels is None: resource_labels = set(itertools.chain.from_iterable( header.resource.labels for header in headers)) metric_labels = set(itertools.chain.from_iterable( @@ -92,8 +125,8 @@ def _build_dataframe(time_series_iterable, # Build a multi-level stack of column headers. Some labels may # be undefined for some time series. levels = [] - for key in labels or [label]: - level = [header.labels.get(key, '') for header in headers] + for key in labels: + level = [_extract_labels(header).get(key, '') for header in headers] levels.append(level) # Build a column Index or MultiIndex. Do not include level names @@ -101,7 +134,7 @@ def _build_dataframe(time_series_iterable, # by specifying "label". dataframe.columns = pandas.MultiIndex.from_arrays( levels, - names=labels or None) + names=labels if not label else None) # Sort the rows just in case (since the API doesn't guarantee the # ordering), and sort the columns lexicographically. diff --git a/monitoring/google/cloud/monitoring_v3/gapic/__init__.py b/monitoring/google/cloud/monitoring_v3/gapic/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/monitoring/google/cloud/monitoring_v3/gapic/alert_policy_service_client.py b/monitoring/google/cloud/monitoring_v3/gapic/alert_policy_service_client.py new file mode 100644 index 000000000000..748aa24ebe60 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/alert_policy_service_client.py @@ -0,0 +1,529 @@ +# 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. +"""Accesses the google.monitoring.v3 AlertPolicyService API.""" + +import functools +import pkg_resources + +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.grpc_helpers +import google.api_core.page_iterator +import google.api_core.path_template + +from google.cloud.monitoring_v3.gapic import alert_policy_service_client_config +from google.cloud.monitoring_v3.gapic import enums +from google.cloud.monitoring_v3.proto import alert_pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 +from google.cloud.monitoring_v3.proto import alert_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-monitoring', ).version + + +class AlertPolicyServiceClient(object): + """ + The AlertPolicyService API is used to manage (list, create, delete, + edit) alert policies in Stackdriver Monitoring. An alerting policy is + a description of the conditions under which some aspect of your + system is considered to be \"unhealthy\" and the ways to notify + people or services about this state. In addition to using this API, alert + policies can also be managed through + `Stackdriver Monitoring `_, + which can be reached by clicking the \"Monitoring\" tab in + `Cloud Console `_. + """ + + SERVICE_ADDRESS = 'monitoring.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary. + _INTERFACE_NAME = 'google.monitoring.v3.AlertPolicyService' + + @classmethod + def project_path(cls, project): + """Return a fully-qualified project string.""" + return google.api_core.path_template.expand( + 'projects/{project}', + project=project, + ) + + @classmethod + def alert_policy_path(cls, project, alert_policy): + """Return a fully-qualified alert_policy string.""" + return google.api_core.path_template.expand( + 'projects/{project}/alertPolicies/{alert_policy}', + project=project, + alert_policy=alert_policy, + ) + + @classmethod + def alert_policy_condition_path(cls, project, alert_policy, condition): + """Return a fully-qualified alert_policy_condition string.""" + return google.api_core.path_template.expand( + 'projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}', + project=project, + alert_policy=alert_policy, + condition=condition, + ) + + def __init__(self, + channel=None, + credentials=None, + client_config=alert_policy_service_client_config.config, + client_info=None): + """Constructor. + + 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. + client_config (dict): 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. + """ + # 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 to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + + # Create the channel. + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES, + ) + + # Create the gRPC stubs. + self.alert_policy_service_stub = ( + alert_service_pb2_grpc.AlertPolicyServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + # 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.) + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config['interfaces'][self._INTERFACE_NAME], ) + + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. + self._list_alert_policies = google.api_core.gapic_v1.method.wrap_method( + self.alert_policy_service_stub.ListAlertPolicies, + default_retry=method_configs['ListAlertPolicies'].retry, + default_timeout=method_configs['ListAlertPolicies'].timeout, + client_info=client_info, + ) + self._get_alert_policy = google.api_core.gapic_v1.method.wrap_method( + self.alert_policy_service_stub.GetAlertPolicy, + default_retry=method_configs['GetAlertPolicy'].retry, + default_timeout=method_configs['GetAlertPolicy'].timeout, + client_info=client_info, + ) + self._create_alert_policy = google.api_core.gapic_v1.method.wrap_method( + self.alert_policy_service_stub.CreateAlertPolicy, + default_retry=method_configs['CreateAlertPolicy'].retry, + default_timeout=method_configs['CreateAlertPolicy'].timeout, + client_info=client_info, + ) + self._delete_alert_policy = google.api_core.gapic_v1.method.wrap_method( + self.alert_policy_service_stub.DeleteAlertPolicy, + default_retry=method_configs['DeleteAlertPolicy'].retry, + default_timeout=method_configs['DeleteAlertPolicy'].timeout, + client_info=client_info, + ) + self._update_alert_policy = google.api_core.gapic_v1.method.wrap_method( + self.alert_policy_service_stub.UpdateAlertPolicy, + default_retry=method_configs['UpdateAlertPolicy'].retry, + default_timeout=method_configs['UpdateAlertPolicy'].timeout, + client_info=client_info, + ) + + # Service calls + def list_alert_policies(self, + name, + filter_=None, + order_by=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists the existing alerting policies for the project. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.AlertPolicyServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_alert_policies(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_alert_policies(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The project whose alert policies are to be listed. The format is + + :: + + projects/[PROJECT_ID] + + Note that this field names the parent container in which the alerting + policies to be listed are stored. To retrieve a single alerting policy + by name, use the + ``GetAlertPolicy`` + operation, instead. + filter_ (str): If provided, this field specifies the criteria that must be met by + alert policies to be included in the response. + + For more details, see [sorting and + filtering](/monitoring/api/v3/sorting-and-filtering). + order_by (str): A comma-separated list of fields by which to sort the result. Supports + the same set of field references as the ``filter`` field. Entries can be + prefixed with a minus sign to sort by the field in descending order. + + For more details, see [sorting and + filtering](/monitoring/api/v3/sorting-and-filtering). + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.AlertPolicy` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = alert_service_pb2.ListAlertPoliciesRequest( + name=name, + filter=filter_, + order_by=order_by, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_alert_policies, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='alert_policies', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_alert_policy(self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single alerting policy. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.AlertPolicyServiceClient() + >>> + >>> name = client.alert_policy_path('[PROJECT]', '[ALERT_POLICY]') + >>> + >>> response = client.get_alert_policy(name) + + Args: + name (str): The alerting policy to retrieve. The format is + + :: + + projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.AlertPolicy` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = alert_service_pb2.GetAlertPolicyRequest(name=name, ) + return self._get_alert_policy( + request, retry=retry, timeout=timeout, metadata=metadata) + + def create_alert_policy(self, + name, + alert_policy, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Creates a new alerting policy. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.AlertPolicyServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``alert_policy``: + >>> alert_policy = {} + >>> + >>> response = client.create_alert_policy(name, alert_policy) + + Args: + name (str): The project in which to create the alerting policy. The format is + ``projects/[PROJECT_ID]``. + + Note that this field names the parent container in which the alerting + policy will be written, not the name of the created policy. The alerting + policy that is returned will have a name that contains a normalized + representation of this name as a prefix but adds a suffix of the form + ``/alertPolicies/[POLICY_ID]``, identifying the policy in the container. + alert_policy (Union[dict, ~google.cloud.monitoring_v3.types.AlertPolicy]): The requested alerting policy. You should omit the ``name`` field in this + policy. The name will be returned in the new policy, including + a new [ALERT_POLICY_ID] value. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.AlertPolicy` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.AlertPolicy` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = alert_service_pb2.CreateAlertPolicyRequest( + name=name, + alert_policy=alert_policy, + ) + return self._create_alert_policy( + request, retry=retry, timeout=timeout, metadata=metadata) + + def delete_alert_policy(self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Deletes an alerting policy. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.AlertPolicyServiceClient() + >>> + >>> name = client.alert_policy_path('[PROJECT]', '[ALERT_POLICY]') + >>> + >>> client.delete_alert_policy(name) + + Args: + name (str): The alerting policy to delete. The format is: + + :: + + projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + + For more information, see ``AlertPolicy``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = alert_service_pb2.DeleteAlertPolicyRequest(name=name, ) + self._delete_alert_policy( + request, retry=retry, timeout=timeout, metadata=metadata) + + def update_alert_policy(self, + alert_policy, + update_mask=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Updates an alerting policy. You can either replace the entire policy with + a new one or replace only certain fields in the current alerting policy by + specifying the fields to be updated via ``updateMask``. Returns the + updated alerting policy. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.AlertPolicyServiceClient() + >>> + >>> # TODO: Initialize ``alert_policy``: + >>> alert_policy = {} + >>> + >>> response = client.update_alert_policy(alert_policy) + + Args: + alert_policy (Union[dict, ~google.cloud.monitoring_v3.types.AlertPolicy]): Required. The updated alerting policy or the updated values for the + fields listed in ``update_mask``. + If ``update_mask`` is not empty, any fields in this policy that are + not in ``update_mask`` are ignored. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.AlertPolicy` + update_mask (Union[dict, ~google.cloud.monitoring_v3.types.FieldMask]): Optional. A list of alerting policy field names. If this field is not + empty, each listed field in the existing alerting policy is set to the + value of the corresponding field in the supplied policy (``alert_policy``), + or to the field's default value if the field is not in the supplied + alerting policy. Fields not listed retain their previous value. + + Examples of valid field masks include ``display_name``, ``documentation``, + ``documentation.content``, ``documentation.mime_type``, ``user_labels``, + ``user_label.nameofkey``, ``enabled``, ``conditions``, ``combiner``, etc. + + If this field is empty, then the supplied alerting policy replaces the + existing policy. It is the same as deleting the existing policy and + adding the supplied policy, except for the following: + + + The new policy will have the same ``[ALERT_POLICY_ID]`` as the former + policy. This gives you continuity with the former policy in your + notifications and incidents. + + Conditions in the new policy will keep their former ``[CONDITION_ID]`` if + the supplied condition includes the `name` field with that + `[CONDITION_ID]`. If the supplied condition omits the `name` field, + then a new `[CONDITION_ID]` is created. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.FieldMask` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.AlertPolicy` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = alert_service_pb2.UpdateAlertPolicyRequest( + alert_policy=alert_policy, + update_mask=update_mask, + ) + return self._update_alert_policy( + request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/monitoring/google/cloud/monitoring_v3/gapic/alert_policy_service_client_config.py b/monitoring/google/cloud/monitoring_v3/gapic/alert_policy_service_client_config.py new file mode 100644 index 000000000000..39185cab3235 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/alert_policy_service_client_config.py @@ -0,0 +1,48 @@ +config = { + "interfaces": { + "google.monitoring.v3.AlertPolicyService": { + "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": { + "ListAlertPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetAlertPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateAlertPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteAlertPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateAlertPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/monitoring/google/cloud/monitoring_v3/gapic/enums.py b/monitoring/google/cloud/monitoring_v3/gapic/enums.py new file mode 100644 index 000000000000..ae433cb6e21a --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/enums.py @@ -0,0 +1,439 @@ +# 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. +"""Wrappers for protocol buffer enum types.""" + + +class ComparisonType(object): + """ + Specifies an ordering relationship on two arguments, here called left and + right. + + Attributes: + COMPARISON_UNSPECIFIED (int): No ordering relationship is specified. + COMPARISON_GT (int): The left argument is greater than the right argument. + COMPARISON_GE (int): The left argument is greater than or equal to the right argument. + COMPARISON_LT (int): The left argument is less than the right argument. + COMPARISON_LE (int): The left argument is less than or equal to the right argument. + COMPARISON_EQ (int): The left argument is equal to the right argument. + COMPARISON_NE (int): The left argument is not equal to the right argument. + """ + COMPARISON_UNSPECIFIED = 0 + COMPARISON_GT = 1 + COMPARISON_GE = 2 + COMPARISON_LT = 3 + COMPARISON_LE = 4 + COMPARISON_EQ = 5 + COMPARISON_NE = 6 + + +class ServiceTier(object): + """ + The tier of service for a Stackdriver account. Please see the + `service tiers documentation `_ + for more details. + + Attributes: + SERVICE_TIER_UNSPECIFIED (int): An invalid sentinel value, used to indicate that a tier has not + been provided explicitly. + SERVICE_TIER_BASIC (int): The Stackdriver Basic tier, a free tier of service that provides basic + features, a moderate allotment of logs, and access to built-in metrics. + A number of features are not available in this tier. For more details, + see `the service tiers documentation `_. + SERVICE_TIER_PREMIUM (int): The Stackdriver Premium tier, a higher, more expensive tier of service + that provides access to all Stackdriver features, lets you use Stackdriver + with AWS accounts, and has a larger allotments for logs and metrics. For + more details, see `the service tiers documentation `_. + """ + SERVICE_TIER_UNSPECIFIED = 0 + SERVICE_TIER_BASIC = 1 + SERVICE_TIER_PREMIUM = 2 + + +class UptimeCheckRegion(object): + """ + The regions from which an uptime check can be run. + + Attributes: + REGION_UNSPECIFIED (int): Default value if no region is specified. Will result in uptime checks + running from all regions. + USA (int): Allows checks to run from locations within the United States of America. + EUROPE (int): Allows checks to run from locations within the continent of Europe. + SOUTH_AMERICA (int): Allows checks to run from locations within the continent of South + America. + ASIA_PACIFIC (int): Allows checks to run from locations within the Asia Pacific area (ex: + Singapore). + """ + REGION_UNSPECIFIED = 0 + USA = 1 + EUROPE = 2 + SOUTH_AMERICA = 3 + ASIA_PACIFIC = 4 + + +class GroupResourceType(object): + """ + The supported resource types that can be used as values of + group_resource.resource_type. gae_app and uptime_url are not allowed + because group checks on App Engine modules and URLs are not allowed. + + Attributes: + RESOURCE_TYPE_UNSPECIFIED (int): Default value (not valid). + INSTANCE (int): A group of instances (could be either GCE or AWS_EC2). + AWS_ELB_LOAD_BALANCER (int): A group of AWS load balancers. + """ + RESOURCE_TYPE_UNSPECIFIED = 0 + INSTANCE = 1 + AWS_ELB_LOAD_BALANCER = 2 + + +class LabelDescriptor(object): + class ValueType(object): + """ + Value types that can be used as label values. + + Attributes: + STRING (int): A variable-length string. This is the default. + BOOL (int): Boolean; true or false. + INT64 (int): A 64-bit signed integer. + """ + STRING = 0 + BOOL = 1 + INT64 = 2 + + +class Aggregation(object): + class Aligner(object): + """ + The Aligner describes how to bring the data points in a single + time series into temporal alignment. + + Attributes: + ALIGN_NONE (int): No alignment. Raw data is returned. Not valid if cross-time + series reduction is requested. The value type of the result is + the same as the value type of the input. + ALIGN_DELTA (int): Align and convert to delta metric type. This alignment is valid + for cumulative metrics and delta metrics. Aligning an existing + delta metric to a delta metric requires that the alignment + period be increased. The value type of the result is the same + as the value type of the input. + + One can think of this aligner as a rate but without time units; that + is, the output is conceptually (second_point - first_point). + ALIGN_RATE (int): Align and convert to a rate. This alignment is valid for + cumulative metrics and delta metrics with numeric values. The output is a + gauge metric with value type + ``DOUBLE``. + + One can think of this aligner as conceptually providing the slope of + the line that passes through the value at the start and end of the + window. In other words, this is conceptually ((y1 - y0)/(t1 - t0)), + and the output unit is one that has a \"/time\" dimension. + + If, by rate, you are looking for percentage change, see the + ``ALIGN_PERCENT_CHANGE`` aligner option. + ALIGN_INTERPOLATE (int): Align by interpolating between adjacent points around the + period boundary. This alignment is valid for gauge + metrics with numeric values. The value type of the result is the same + as the value type of the input. + ALIGN_NEXT_OLDER (int): Align by shifting the oldest data point before the period + boundary to the boundary. This alignment is valid for gauge + metrics. The value type of the result is the same as the + value type of the input. + ALIGN_MIN (int): Align time series via aggregation. The resulting data point in + the alignment period is the minimum of all data points in the + period. This alignment is valid for gauge and delta metrics with numeric + values. The value type of the result is the same as the value + type of the input. + ALIGN_MAX (int): Align time series via aggregation. The resulting data point in + the alignment period is the maximum of all data points in the + period. This alignment is valid for gauge and delta metrics with numeric + values. The value type of the result is the same as the value + type of the input. + ALIGN_MEAN (int): Align time series via aggregation. The resulting data point in + the alignment period is the average or arithmetic mean of all + data points in the period. This alignment is valid for gauge and delta + metrics with numeric values. The value type of the output is + ``DOUBLE``. + ALIGN_COUNT (int): Align time series via aggregation. The resulting data point in + the alignment period is the count of all data points in the + period. This alignment is valid for gauge and delta metrics with numeric + or Boolean values. The value type of the output is + ``INT64``. + ALIGN_SUM (int): Align time series via aggregation. The resulting data point in + the alignment period is the sum of all data points in the + period. This alignment is valid for gauge and delta metrics with numeric + and distribution values. The value type of the output is the + same as the value type of the input. + ALIGN_STDDEV (int): Align time series via aggregation. The resulting data point in + the alignment period is the standard deviation of all data + points in the period. This alignment is valid for gauge and delta metrics + with numeric values. The value type of the output is + ``DOUBLE``. + ALIGN_COUNT_TRUE (int): Align time series via aggregation. The resulting data point in + the alignment period is the count of True-valued data points in the + period. This alignment is valid for gauge metrics with + Boolean values. The value type of the output is + ``INT64``. + ALIGN_COUNT_FALSE (int): Align time series via aggregation. The resulting data point in + the alignment period is the count of False-valued data points in the + period. This alignment is valid for gauge metrics with + Boolean values. The value type of the output is + ``INT64``. + ALIGN_FRACTION_TRUE (int): Align time series via aggregation. The resulting data point in + the alignment period is the fraction of True-valued data points in the + period. This alignment is valid for gauge metrics with Boolean values. + The output value is in the range [0, 1] and has value type + ``DOUBLE``. + ALIGN_PERCENTILE_99 (int): Align time series via aggregation. The resulting data point in + the alignment period is the 99th percentile of all data + points in the period. This alignment is valid for gauge and delta metrics + with distribution values. The output is a gauge metric with value type + ``DOUBLE``. + ALIGN_PERCENTILE_95 (int): Align time series via aggregation. The resulting data point in + the alignment period is the 95th percentile of all data + points in the period. This alignment is valid for gauge and delta metrics + with distribution values. The output is a gauge metric with value type + ``DOUBLE``. + ALIGN_PERCENTILE_50 (int): Align time series via aggregation. The resulting data point in + the alignment period is the 50th percentile of all data + points in the period. This alignment is valid for gauge and delta metrics + with distribution values. The output is a gauge metric with value type + ``DOUBLE``. + ALIGN_PERCENTILE_05 (int): Align time series via aggregation. The resulting data point in + the alignment period is the 5th percentile of all data + points in the period. This alignment is valid for gauge and delta metrics + with distribution values. The output is a gauge metric with value type + ``DOUBLE``. + ALIGN_PERCENT_CHANGE (int): Align and convert to a percentage change. This alignment is valid for + gauge and delta metrics with numeric values. This alignment conceptually + computes the equivalent of \"((current - previous)/previous)*100\" + where previous value is determined based on the alignmentPeriod. + In the event that previous is 0 the calculated value is infinity with the + exception that if both (current - previous) and previous are 0 the + calculated value is 0. + A 10 minute moving mean is computed at each point of the time window + prior to the above calculation to smooth the metric and prevent false + positives from very short lived spikes. + Only applicable for data that is >= 0. Any values < 0 are treated as + no data. While delta metrics are accepted by this alignment special care + should be taken that the values for the metric will always be positive. + The output is a gauge metric with value type + ``DOUBLE``. + """ + ALIGN_NONE = 0 + ALIGN_DELTA = 1 + ALIGN_RATE = 2 + ALIGN_INTERPOLATE = 3 + ALIGN_NEXT_OLDER = 4 + ALIGN_MIN = 10 + ALIGN_MAX = 11 + ALIGN_MEAN = 12 + ALIGN_COUNT = 13 + ALIGN_SUM = 14 + ALIGN_STDDEV = 15 + ALIGN_COUNT_TRUE = 16 + ALIGN_COUNT_FALSE = 24 + ALIGN_FRACTION_TRUE = 17 + ALIGN_PERCENTILE_99 = 18 + ALIGN_PERCENTILE_95 = 19 + ALIGN_PERCENTILE_50 = 20 + ALIGN_PERCENTILE_05 = 21 + ALIGN_PERCENT_CHANGE = 23 + + class Reducer(object): + """ + A Reducer describes how to aggregate data points from multiple + time series into a single time series. + + Attributes: + REDUCE_NONE (int): No cross-time series reduction. The output of the aligner is + returned. + REDUCE_MEAN (int): Reduce by computing the mean across time series for each + alignment period. This reducer is valid for delta and + gauge metrics with numeric or distribution values. The value type of the + output is ``DOUBLE``. + REDUCE_MIN (int): Reduce by computing the minimum across time series for each + alignment period. This reducer is valid for delta and + gauge metrics with numeric values. The value type of the output + is the same as the value type of the input. + REDUCE_MAX (int): Reduce by computing the maximum across time series for each + alignment period. This reducer is valid for delta and + gauge metrics with numeric values. The value type of the output + is the same as the value type of the input. + REDUCE_SUM (int): Reduce by computing the sum across time series for each + alignment period. This reducer is valid for delta and + gauge metrics with numeric and distribution values. The value type of + the output is the same as the value type of the input. + REDUCE_STDDEV (int): Reduce by computing the standard deviation across time series + for each alignment period. This reducer is valid for delta + and gauge metrics with numeric or distribution values. The value type of + the output is ``DOUBLE``. + REDUCE_COUNT (int): Reduce by computing the count of data points across time series + for each alignment period. This reducer is valid for delta + and gauge metrics of numeric, Boolean, distribution, and string value + type. The value type of the output is + ``INT64``. + REDUCE_COUNT_TRUE (int): Reduce by computing the count of True-valued data points across time + series for each alignment period. This reducer is valid for delta + and gauge metrics of Boolean value type. The value type of + the output is ``INT64``. + REDUCE_COUNT_FALSE (int): Reduce by computing the count of False-valued data points across time + series for each alignment period. This reducer is valid for delta + and gauge metrics of Boolean value type. The value type of + the output is ``INT64``. + REDUCE_FRACTION_TRUE (int): Reduce by computing the fraction of True-valued data points across time + series for each alignment period. This reducer is valid for delta + and gauge metrics of Boolean value type. The output value is in the + range [0, 1] and has value type + ``DOUBLE``. + REDUCE_PERCENTILE_99 (int): Reduce by computing 99th percentile of data points across time series + for each alignment period. This reducer is valid for gauge and delta + metrics of numeric and distribution type. The value of the output is + ``DOUBLE`` + REDUCE_PERCENTILE_95 (int): Reduce by computing 95th percentile of data points across time series + for each alignment period. This reducer is valid for gauge and delta + metrics of numeric and distribution type. The value of the output is + ``DOUBLE`` + REDUCE_PERCENTILE_50 (int): Reduce by computing 50th percentile of data points across time series + for each alignment period. This reducer is valid for gauge and delta + metrics of numeric and distribution type. The value of the output is + ``DOUBLE`` + REDUCE_PERCENTILE_05 (int): Reduce by computing 5th percentile of data points across time series + for each alignment period. This reducer is valid for gauge and delta + metrics of numeric and distribution type. The value of the output is + ``DOUBLE`` + """ + REDUCE_NONE = 0 + REDUCE_MEAN = 1 + REDUCE_MIN = 2 + REDUCE_MAX = 3 + REDUCE_SUM = 4 + REDUCE_STDDEV = 5 + REDUCE_COUNT = 6 + REDUCE_COUNT_TRUE = 7 + REDUCE_COUNT_FALSE = 15 + REDUCE_FRACTION_TRUE = 8 + REDUCE_PERCENTILE_99 = 9 + REDUCE_PERCENTILE_95 = 10 + REDUCE_PERCENTILE_50 = 11 + REDUCE_PERCENTILE_05 = 12 + + +class NotificationChannel(object): + class VerificationStatus(object): + """ + Indicates whether the channel has been verified or not. It is illegal + to specify this field in a + ````CreateNotificationChannel```` + or an + ````UpdateNotificationChannel```` + operation. + + Attributes: + VERIFICATION_STATUS_UNSPECIFIED (int): Sentinel value used to indicate that the state is unknown, omitted, or + is not applicable (as in the case of channels that neither support + nor require verification in order to function). + UNVERIFIED (int): The channel has yet to be verified and requires verification to function. + Note that this state also applies to the case where the verification + process has been initiated by sending a verification code but where + the verification code has not been submitted to complete the process. + VERIFIED (int): It has been proven that notifications can be received on this + notification channel and that someone on the project has access + to messages that are delivered to that channel. + """ + VERIFICATION_STATUS_UNSPECIFIED = 0 + UNVERIFIED = 1 + VERIFIED = 2 + + +class AlertPolicy(object): + class ConditionCombinerType(object): + """ + Operators for combining conditions. + + Attributes: + COMBINE_UNSPECIFIED (int): An unspecified combiner. + AND (int): Combine conditions using the logical ``AND`` operator. An + incident is created only if all conditions are met + simultaneously. This combiner is satisfied if all conditions are + met, even if they are met on completely different resources. + OR (int): Combine conditions using the logical ``OR`` operator. An incident + is created if any of the listed conditions is met. + AND_WITH_MATCHING_RESOURCE (int): Combine conditions using logical ``AND`` operator, but unlike the regular + ``AND`` option, an incident is created only if all conditions are met + simultaneously on at least one resource. + """ + COMBINE_UNSPECIFIED = 0 + AND = 1 + OR = 2 + AND_WITH_MATCHING_RESOURCE = 3 + + +class MetricDescriptor(object): + class MetricKind(object): + """ + The kind of measurement. It describes how the data is reported. + + Attributes: + METRIC_KIND_UNSPECIFIED (int): Do not use this default value. + GAUGE (int): An instantaneous measurement of a value. + DELTA (int): The change in a value during a time interval. + CUMULATIVE (int): A value accumulated over a time interval. Cumulative + measurements in a time series should have the same start time + and increasing end times, until an event resets the cumulative + value to zero and sets a new start time for the following + points. + """ + METRIC_KIND_UNSPECIFIED = 0 + GAUGE = 1 + DELTA = 2 + CUMULATIVE = 3 + + class ValueType(object): + """ + The value type of a metric. + + Attributes: + VALUE_TYPE_UNSPECIFIED (int): Do not use this default value. + BOOL (int): The value is a boolean. + This value type can be used only if the metric kind is ``GAUGE``. + INT64 (int): The value is a signed 64-bit integer. + DOUBLE (int): The value is a double precision floating point number. + STRING (int): The value is a text string. + This value type can be used only if the metric kind is ``GAUGE``. + DISTRIBUTION (int): The value is a ````Distribution````. + MONEY (int): The value is money. + """ + VALUE_TYPE_UNSPECIFIED = 0 + BOOL = 1 + INT64 = 2 + DOUBLE = 3 + STRING = 4 + DISTRIBUTION = 5 + MONEY = 6 + + +class ListTimeSeriesRequest(object): + class TimeSeriesView(object): + """ + Controls which fields are returned by ``ListTimeSeries``. + + Attributes: + FULL (int): Returns the identity of the metric(s), the time series, + and the time series data. + HEADERS (int): Returns the identity of the metric and the time series resource, + but not the time series data. + """ + FULL = 0 + HEADERS = 1 diff --git a/monitoring/google/cloud/monitoring_v3/gapic/group_service_client.py b/monitoring/google/cloud/monitoring_v3/gapic/group_service_client.py new file mode 100644 index 000000000000..3baedc19f224 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/group_service_client.py @@ -0,0 +1,593 @@ +# 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. +"""Accesses the google.monitoring.v3 GroupService API.""" + +import functools +import pkg_resources + +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.grpc_helpers +import google.api_core.page_iterator +import google.api_core.path_template +import google.api_core.protobuf_helpers + +from google.cloud.monitoring_v3.gapic import enums +from google.cloud.monitoring_v3.gapic import group_service_client_config +from google.cloud.monitoring_v3.proto import alert_pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 +from google.cloud.monitoring_v3.proto import common_pb2 +from google.cloud.monitoring_v3.proto import group_pb2 +from google.cloud.monitoring_v3.proto import group_service_pb2 +from google.cloud.monitoring_v3.proto import group_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-monitoring', ).version + + +class GroupServiceClient(object): + """ + The Group API lets you inspect and manage your + `groups `_. + + A group is a named filter that is used to identify + a collection of monitored resources. Groups are typically used to + mirror the physical and/or logical topology of the environment. + Because group membership is computed dynamically, monitored + resources that are started in the future are automatically placed + in matching groups. By using a group to name monitored resources in, + for example, an alert policy, the target of that alert policy is + updated automatically as monitored resources are added and removed + from the infrastructure. + """ + + SERVICE_ADDRESS = 'monitoring.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary. + _INTERFACE_NAME = 'google.monitoring.v3.GroupService' + + @classmethod + def project_path(cls, project): + """Return a fully-qualified project string.""" + return google.api_core.path_template.expand( + 'projects/{project}', + project=project, + ) + + @classmethod + def group_path(cls, project, group): + """Return a fully-qualified group string.""" + return google.api_core.path_template.expand( + 'projects/{project}/groups/{group}', + project=project, + group=group, + ) + + def __init__(self, + channel=None, + credentials=None, + client_config=group_service_client_config.config, + client_info=None): + """Constructor. + + 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. + client_config (dict): 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. + """ + # 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 to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + + # Create the channel. + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES, + ) + + # Create the gRPC stubs. + self.group_service_stub = ( + group_service_pb2_grpc.GroupServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + # 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.) + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config['interfaces'][self._INTERFACE_NAME], ) + + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. + self._list_groups = google.api_core.gapic_v1.method.wrap_method( + self.group_service_stub.ListGroups, + default_retry=method_configs['ListGroups'].retry, + default_timeout=method_configs['ListGroups'].timeout, + client_info=client_info, + ) + self._get_group = google.api_core.gapic_v1.method.wrap_method( + self.group_service_stub.GetGroup, + default_retry=method_configs['GetGroup'].retry, + default_timeout=method_configs['GetGroup'].timeout, + client_info=client_info, + ) + self._create_group = google.api_core.gapic_v1.method.wrap_method( + self.group_service_stub.CreateGroup, + default_retry=method_configs['CreateGroup'].retry, + default_timeout=method_configs['CreateGroup'].timeout, + client_info=client_info, + ) + self._update_group = google.api_core.gapic_v1.method.wrap_method( + self.group_service_stub.UpdateGroup, + default_retry=method_configs['UpdateGroup'].retry, + default_timeout=method_configs['UpdateGroup'].timeout, + client_info=client_info, + ) + self._delete_group = google.api_core.gapic_v1.method.wrap_method( + self.group_service_stub.DeleteGroup, + default_retry=method_configs['DeleteGroup'].retry, + default_timeout=method_configs['DeleteGroup'].timeout, + client_info=client_info, + ) + self._list_group_members = google.api_core.gapic_v1.method.wrap_method( + self.group_service_stub.ListGroupMembers, + default_retry=method_configs['ListGroupMembers'].retry, + default_timeout=method_configs['ListGroupMembers'].timeout, + client_info=client_info, + ) + + # Service calls + def list_groups(self, + name, + children_of_group=None, + ancestors_of_group=None, + descendants_of_group=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists the existing groups. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.GroupServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_groups(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_groups(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The project whose groups are to be listed. The format is + ``\"projects/{project_id_or_number}\"``. + children_of_group (str): A group name: ``\"projects/{project_id_or_number}/groups/{group_id}\"``. + Returns groups whose ``parentName`` field contains the group + name. If no groups have this parent, the results are empty. + ancestors_of_group (str): A group name: ``\"projects/{project_id_or_number}/groups/{group_id}\"``. + Returns groups that are ancestors of the specified group. + The groups are returned in order, starting with the immediate parent and + ending with the most distant ancestor. If the specified group has no + immediate parent, the results are empty. + descendants_of_group (str): A group name: ``\"projects/{project_id_or_number}/groups/{group_id}\"``. + Returns the descendants of the specified group. This is a superset of + the results returned by the ``childrenOfGroup`` filter, and includes + children-of-children, and so forth. + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.Group` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + # Sanity check: We have some fields which are mutually exclusive; + # raise ValueError if more than one is sent. + google.api_core.protobuf_helpers.check_oneof( + children_of_group=children_of_group, + ancestors_of_group=ancestors_of_group, + descendants_of_group=descendants_of_group, + ) + + request = group_service_pb2.ListGroupsRequest( + name=name, + children_of_group=children_of_group, + ancestors_of_group=ancestors_of_group, + descendants_of_group=descendants_of_group, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_groups, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='group', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_group(self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single group. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.GroupServiceClient() + >>> + >>> name = client.group_path('[PROJECT]', '[GROUP]') + >>> + >>> response = client.get_group(name) + + Args: + name (str): The group to retrieve. The format is + ``\"projects/{project_id_or_number}/groups/{group_id}\"``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.Group` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = group_service_pb2.GetGroupRequest(name=name, ) + return self._get_group( + request, retry=retry, timeout=timeout, metadata=metadata) + + def create_group(self, + name, + group, + validate_only=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Creates a new group. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.GroupServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``group``: + >>> group = {} + >>> + >>> response = client.create_group(name, group) + + Args: + name (str): The project in which to create the group. The format is + ``\"projects/{project_id_or_number}\"``. + group (Union[dict, ~google.cloud.monitoring_v3.types.Group]): A group definition. It is an error to define the ``name`` field because + the system assigns the name. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.Group` + validate_only (bool): If true, validate this request but do not create the group. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.Group` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = group_service_pb2.CreateGroupRequest( + name=name, + group=group, + validate_only=validate_only, + ) + return self._create_group( + request, retry=retry, timeout=timeout, metadata=metadata) + + def update_group(self, + group, + validate_only=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Updates an existing group. + You can change any group attributes except ``name``. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.GroupServiceClient() + >>> + >>> # TODO: Initialize ``group``: + >>> group = {} + >>> + >>> response = client.update_group(group) + + Args: + group (Union[dict, ~google.cloud.monitoring_v3.types.Group]): The new definition of the group. All fields of the existing group, + excepting ``name``, are replaced with the corresponding fields of this group. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.Group` + validate_only (bool): If true, validate this request but do not update the existing group. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.Group` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = group_service_pb2.UpdateGroupRequest( + group=group, + validate_only=validate_only, + ) + return self._update_group( + request, retry=retry, timeout=timeout, metadata=metadata) + + def delete_group(self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Deletes an existing group. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.GroupServiceClient() + >>> + >>> name = client.group_path('[PROJECT]', '[GROUP]') + >>> + >>> client.delete_group(name) + + Args: + name (str): The group to delete. The format is + ``\"projects/{project_id_or_number}/groups/{group_id}\"``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = group_service_pb2.DeleteGroupRequest(name=name, ) + self._delete_group( + request, retry=retry, timeout=timeout, metadata=metadata) + + def list_group_members(self, + name, + page_size=None, + filter_=None, + interval=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists the monitored resources that are members of a group. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.GroupServiceClient() + >>> + >>> name = client.group_path('[PROJECT]', '[GROUP]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_group_members(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_group_members(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The group whose members are listed. The format is + ``\"projects/{project_id_or_number}/groups/{group_id}\"``. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + filter_ (str): An optional `list filter `_ describing + the members to be returned. The filter may reference the type, labels, and + metadata of monitored resources that comprise the group. + For example, to return only resources representing Compute Engine VM + instances, use this filter: + + :: + + resource.type = \"gce_instance\" + interval (Union[dict, ~google.cloud.monitoring_v3.types.TimeInterval]): An optional time interval for which results should be returned. Only + members that were part of the group during the specified interval are + included in the response. If no interval is provided then the group + membership over the last minute is returned. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.TimeInterval` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.MonitoredResource` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = group_service_pb2.ListGroupMembersRequest( + name=name, + page_size=page_size, + filter=filter_, + interval=interval, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_group_members, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='members', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator diff --git a/monitoring/google/cloud/monitoring_v3/gapic/group_service_client_config.py b/monitoring/google/cloud/monitoring_v3/gapic/group_service_client_config.py new file mode 100644 index 000000000000..18788b255fbc --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/group_service_client_config.py @@ -0,0 +1,53 @@ +config = { + "interfaces": { + "google.monitoring.v3.GroupService": { + "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": { + "ListGroups": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetGroup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateGroup": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateGroup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteGroup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListGroupMembers": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/monitoring/google/cloud/monitoring_v3/gapic/metric_service_client.py b/monitoring/google/cloud/monitoring_v3/gapic/metric_service_client.py new file mode 100644 index 000000000000..778aedaf0fd0 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/metric_service_client.py @@ -0,0 +1,775 @@ +# 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. +"""Accesses the google.monitoring.v3 MetricService API.""" + +import functools +import pkg_resources + +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.grpc_helpers +import google.api_core.page_iterator +import google.api_core.path_template + +from google.api import metric_pb2 as api_metric_pb2 +from google.api import monitored_resource_pb2 +from google.cloud.monitoring_v3.gapic import enums +from google.cloud.monitoring_v3.gapic import metric_service_client_config +from google.cloud.monitoring_v3.proto import alert_pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 +from google.cloud.monitoring_v3.proto import common_pb2 +from google.cloud.monitoring_v3.proto import group_pb2 +from google.cloud.monitoring_v3.proto import group_service_pb2 +from google.cloud.monitoring_v3.proto import metric_pb2 as proto_metric_pb2 +from google.cloud.monitoring_v3.proto import metric_service_pb2 +from google.cloud.monitoring_v3.proto import metric_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-monitoring', ).version + + +class MetricServiceClient(object): + """ + Manages metric descriptors, monitored resource descriptors, and + time series data. + """ + + SERVICE_ADDRESS = 'monitoring.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary. + _INTERFACE_NAME = 'google.monitoring.v3.MetricService' + + @classmethod + def project_path(cls, project): + """Return a fully-qualified project string.""" + return google.api_core.path_template.expand( + 'projects/{project}', + project=project, + ) + + @classmethod + def metric_descriptor_path(cls, project, metric_descriptor): + """Return a fully-qualified metric_descriptor string.""" + return google.api_core.path_template.expand( + 'projects/{project}/metricDescriptors/{metric_descriptor=**}', + project=project, + metric_descriptor=metric_descriptor, + ) + + @classmethod + def monitored_resource_descriptor_path(cls, project, + monitored_resource_descriptor): + """Return a fully-qualified monitored_resource_descriptor string.""" + return google.api_core.path_template.expand( + 'projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}', + project=project, + monitored_resource_descriptor=monitored_resource_descriptor, + ) + + def __init__(self, + channel=None, + credentials=None, + client_config=metric_service_client_config.config, + client_info=None): + """Constructor. + + 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. + client_config (dict): 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. + """ + # 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 to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + + # Create the channel. + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES, + ) + + # Create the gRPC stubs. + self.metric_service_stub = ( + metric_service_pb2_grpc.MetricServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + # 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.) + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config['interfaces'][self._INTERFACE_NAME], ) + + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. + self._list_monitored_resource_descriptors = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.ListMonitoredResourceDescriptors, + default_retry=method_configs[ + 'ListMonitoredResourceDescriptors'].retry, + default_timeout=method_configs['ListMonitoredResourceDescriptors'] + .timeout, + client_info=client_info, + ) + self._get_monitored_resource_descriptor = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.GetMonitoredResourceDescriptor, + default_retry=method_configs[ + 'GetMonitoredResourceDescriptor'].retry, + default_timeout=method_configs['GetMonitoredResourceDescriptor'] + .timeout, + client_info=client_info, + ) + self._list_metric_descriptors = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.ListMetricDescriptors, + default_retry=method_configs['ListMetricDescriptors'].retry, + default_timeout=method_configs['ListMetricDescriptors'].timeout, + client_info=client_info, + ) + self._get_metric_descriptor = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.GetMetricDescriptor, + default_retry=method_configs['GetMetricDescriptor'].retry, + default_timeout=method_configs['GetMetricDescriptor'].timeout, + client_info=client_info, + ) + self._create_metric_descriptor = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.CreateMetricDescriptor, + default_retry=method_configs['CreateMetricDescriptor'].retry, + default_timeout=method_configs['CreateMetricDescriptor'].timeout, + client_info=client_info, + ) + self._delete_metric_descriptor = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.DeleteMetricDescriptor, + default_retry=method_configs['DeleteMetricDescriptor'].retry, + default_timeout=method_configs['DeleteMetricDescriptor'].timeout, + client_info=client_info, + ) + self._list_time_series = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.ListTimeSeries, + default_retry=method_configs['ListTimeSeries'].retry, + default_timeout=method_configs['ListTimeSeries'].timeout, + client_info=client_info, + ) + self._create_time_series = google.api_core.gapic_v1.method.wrap_method( + self.metric_service_stub.CreateTimeSeries, + default_retry=method_configs['CreateTimeSeries'].retry, + default_timeout=method_configs['CreateTimeSeries'].timeout, + client_info=client_info, + ) + + # Service calls + def list_monitored_resource_descriptors( + self, + name, + filter_=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_monitored_resource_descriptors(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_monitored_resource_descriptors(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The project on which to execute the request. The format is + ``\"projects/{project_id_or_number}\"``. + filter_ (str): An optional `filter `_ describing + the descriptors to be returned. The filter can reference + the descriptor's type and labels. For example, the + following filter returns only Google Compute Engine descriptors + that have an ``id`` label: + + :: + + resource.type = starts_with(\"gce_\") AND resource.label:id + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.MonitoredResourceDescriptor` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.ListMonitoredResourceDescriptorsRequest( + name=name, + filter=filter_, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_monitored_resource_descriptors, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='resource_descriptors', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_monitored_resource_descriptor( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.monitored_resource_descriptor_path('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]') + >>> + >>> response = client.get_monitored_resource_descriptor(name) + + Args: + name (str): The monitored resource descriptor to get. The format is + ``\"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}\"``. + The ``{resource_type}`` is a predefined type, such as + ``cloudsql_database``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.MonitoredResourceDescriptor` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.GetMonitoredResourceDescriptorRequest( + name=name, ) + return self._get_monitored_resource_descriptor( + request, retry=retry, timeout=timeout, metadata=metadata) + + def list_metric_descriptors( + self, + name, + filter_=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_metric_descriptors(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_metric_descriptors(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The project on which to execute the request. The format is + ``\"projects/{project_id_or_number}\"``. + filter_ (str): If this field is empty, all custom and + system-defined metric descriptors are returned. + Otherwise, the `filter `_ + specifies which metric descriptors are to be + returned. For example, the following filter matches all + `custom metrics `_: + + :: + + metric.type = starts_with(\"custom.googleapis.com/\") + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.MetricDescriptor` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.ListMetricDescriptorsRequest( + name=name, + filter=filter_, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_metric_descriptors, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='metric_descriptors', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_metric_descriptor(self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single metric descriptor. This method does not require a Stackdriver account. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.metric_descriptor_path('[PROJECT]', '[METRIC_DESCRIPTOR]') + >>> + >>> response = client.get_metric_descriptor(name) + + Args: + name (str): The metric descriptor on which to execute the request. The format is + ``\"projects/{project_id_or_number}/metricDescriptors/{metric_id}\"``. + An example value of ``{metric_id}`` is + ``\"compute.googleapis.com/instance/disk/read_bytes_count\"``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.MetricDescriptor` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.GetMetricDescriptorRequest(name=name, ) + return self._get_metric_descriptor( + request, retry=retry, timeout=timeout, metadata=metadata) + + def create_metric_descriptor( + self, + name, + metric_descriptor, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Creates a new metric descriptor. + User-created metric descriptors define + `custom metrics `_. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``metric_descriptor``: + >>> metric_descriptor = {} + >>> + >>> response = client.create_metric_descriptor(name, metric_descriptor) + + Args: + name (str): The project on which to execute the request. The format is + ``\"projects/{project_id_or_number}\"``. + metric_descriptor (Union[dict, ~google.cloud.monitoring_v3.types.MetricDescriptor]): The new `custom metric `_ + descriptor. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.MetricDescriptor` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.MetricDescriptor` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.CreateMetricDescriptorRequest( + name=name, + metric_descriptor=metric_descriptor, + ) + return self._create_metric_descriptor( + request, retry=retry, timeout=timeout, metadata=metadata) + + def delete_metric_descriptor( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Deletes a metric descriptor. Only user-created + `custom metrics `_ can be deleted. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.metric_descriptor_path('[PROJECT]', '[METRIC_DESCRIPTOR]') + >>> + >>> client.delete_metric_descriptor(name) + + Args: + name (str): The metric descriptor on which to execute the request. The format is + ``\"projects/{project_id_or_number}/metricDescriptors/{metric_id}\"``. + An example of ``{metric_id}`` is: + ``\"custom.googleapis.com/my_test_metric\"``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.DeleteMetricDescriptorRequest(name=name, ) + self._delete_metric_descriptor( + request, retry=retry, timeout=timeout, metadata=metadata) + + def list_time_series(self, + name, + filter_, + interval, + view, + aggregation=None, + order_by=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists time series that match a filter. This method does not require a Stackdriver account. + + Example: + >>> from google.cloud import monitoring_v3 + >>> from google.cloud.monitoring_v3 import enums + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``filter_``: + >>> filter_ = '' + >>> + >>> # TODO: Initialize ``interval``: + >>> interval = {} + >>> + >>> # TODO: Initialize ``view``: + >>> view = enums.ListTimeSeriesRequest.TimeSeriesView.FULL + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_time_series(name, filter_, interval, view): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_time_series(name, filter_, interval, view, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The project on which to execute the request. The format is + \"projects/{project_id_or_number}\". + filter_ (str): A `monitoring filter `_ that specifies which time + series should be returned. The filter must specify a single metric type, + and can additionally specify metric labels and other information. For + example: + + :: + + metric.type = \"compute.googleapis.com/instance/cpu/usage_time\" AND + metric.label.instance_name = \"my-instance-name\" + interval (Union[dict, ~google.cloud.monitoring_v3.types.TimeInterval]): The time interval for which results should be returned. Only time series + that contain data points in the specified interval are included + in the response. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.TimeInterval` + view (~google.cloud.monitoring_v3.types.TimeSeriesView): Specifies which information is returned about the time series. + aggregation (Union[dict, ~google.cloud.monitoring_v3.types.Aggregation]): By default, the raw time series data is returned. + Use this field to combine multiple time series for different + views of the data. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.Aggregation` + order_by (str): Specifies the order in which the points of the time series should + be returned. By default, results are not ordered. Currently, + this field must be left blank. + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.TimeSeries` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.ListTimeSeriesRequest( + name=name, + filter=filter_, + interval=interval, + view=view, + aggregation=aggregation, + order_by=order_by, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_time_series, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='time_series', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def create_time_series(self, + name, + time_series, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Creates or adds data to one or more time series. + The response is empty if all time series in the request were written. + If any time series could not be written, a corresponding failure message is + included in the error response. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.MetricServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``time_series``: + >>> time_series = [] + >>> + >>> client.create_time_series(name, time_series) + + Args: + name (str): The project on which to execute the request. The format is + ``\"projects/{project_id_or_number}\"``. + time_series (list[Union[dict, ~google.cloud.monitoring_v3.types.TimeSeries]]): The new data to be added to a list of time series. + Adds at most one data point to each of several time series. The new data + point must be more recent than any other point in its time series. Each + ``TimeSeries`` value must fully specify a unique time series by supplying + all label values for the metric and the monitored resource. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.TimeSeries` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = metric_service_pb2.CreateTimeSeriesRequest( + name=name, + time_series=time_series, + ) + self._create_time_series( + request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/monitoring/google/cloud/monitoring_v3/gapic/metric_service_client_config.py b/monitoring/google/cloud/monitoring_v3/gapic/metric_service_client_config.py new file mode 100644 index 000000000000..24353b5c4f7a --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/metric_service_client_config.py @@ -0,0 +1,63 @@ +config = { + "interfaces": { + "google.monitoring.v3.MetricService": { + "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": { + "ListMonitoredResourceDescriptors": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetMonitoredResourceDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListMetricDescriptors": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetMetricDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateMetricDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteMetricDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListTimeSeries": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateTimeSeries": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/monitoring/google/cloud/monitoring_v3/gapic/notification_channel_service_client.py b/monitoring/google/cloud/monitoring_v3/gapic/notification_channel_service_client.py new file mode 100644 index 000000000000..a7d8927bfb55 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/notification_channel_service_client.py @@ -0,0 +1,674 @@ +# 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. +"""Accesses the google.monitoring.v3 NotificationChannelService API.""" + +import functools +import pkg_resources + +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.grpc_helpers +import google.api_core.page_iterator +import google.api_core.path_template + +from google.api import metric_pb2 as api_metric_pb2 +from google.api import monitored_resource_pb2 +from google.cloud.monitoring_v3.gapic import enums +from google.cloud.monitoring_v3.gapic import notification_channel_service_client_config +from google.cloud.monitoring_v3.proto import alert_pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 +from google.cloud.monitoring_v3.proto import common_pb2 +from google.cloud.monitoring_v3.proto import group_pb2 +from google.cloud.monitoring_v3.proto import group_service_pb2 +from google.cloud.monitoring_v3.proto import metric_pb2 as proto_metric_pb2 +from google.cloud.monitoring_v3.proto import metric_service_pb2 +from google.cloud.monitoring_v3.proto import notification_pb2 +from google.cloud.monitoring_v3.proto import notification_service_pb2 +from google.cloud.monitoring_v3.proto import notification_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-monitoring', ).version + + +class NotificationChannelServiceClient(object): + """ + The Notification Channel API provides access to configuration that + controls how messages related to incidents are sent. + """ + + SERVICE_ADDRESS = 'monitoring.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary. + _INTERFACE_NAME = 'google.monitoring.v3.NotificationChannelService' + + @classmethod + def project_path(cls, project): + """Return a fully-qualified project string.""" + return google.api_core.path_template.expand( + 'projects/{project}', + project=project, + ) + + @classmethod + def notification_channel_path(cls, project, notification_channel): + """Return a fully-qualified notification_channel string.""" + return google.api_core.path_template.expand( + 'projects/{project}/notificationChannels/{notification_channel}', + project=project, + notification_channel=notification_channel, + ) + + @classmethod + def notification_channel_descriptor_path(cls, project, channel_descriptor): + """Return a fully-qualified notification_channel_descriptor string.""" + return google.api_core.path_template.expand( + 'projects/{project}/notificationChannelDescriptors/{channel_descriptor}', + project=project, + channel_descriptor=channel_descriptor, + ) + + def __init__( + self, + channel=None, + credentials=None, + client_config=notification_channel_service_client_config.config, + client_info=None): + """Constructor. + + 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. + client_config (dict): 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. + """ + # 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 to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + + # Create the channel. + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES, + ) + + # Create the gRPC stubs. + self.notification_channel_service_stub = ( + notification_service_pb2_grpc.NotificationChannelServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + # 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.) + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config['interfaces'][self._INTERFACE_NAME], ) + + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. + self._list_notification_channel_descriptors = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub. + ListNotificationChannelDescriptors, + default_retry=method_configs[ + 'ListNotificationChannelDescriptors'].retry, + default_timeout=method_configs[ + 'ListNotificationChannelDescriptors'].timeout, + client_info=client_info, + ) + self._get_notification_channel_descriptor = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub. + GetNotificationChannelDescriptor, + default_retry=method_configs[ + 'GetNotificationChannelDescriptor'].retry, + default_timeout=method_configs[ + 'GetNotificationChannelDescriptor'].timeout, + client_info=client_info, + ) + self._list_notification_channels = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub.ListNotificationChannels, + default_retry=method_configs['ListNotificationChannels'].retry, + default_timeout=method_configs['ListNotificationChannels'].timeout, + client_info=client_info, + ) + self._get_notification_channel = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub.GetNotificationChannel, + default_retry=method_configs['GetNotificationChannel'].retry, + default_timeout=method_configs['GetNotificationChannel'].timeout, + client_info=client_info, + ) + self._create_notification_channel = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub.CreateNotificationChannel, + default_retry=method_configs['CreateNotificationChannel'].retry, + default_timeout=method_configs['CreateNotificationChannel'] + .timeout, + client_info=client_info, + ) + self._update_notification_channel = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub.UpdateNotificationChannel, + default_retry=method_configs['UpdateNotificationChannel'].retry, + default_timeout=method_configs['UpdateNotificationChannel'] + .timeout, + client_info=client_info, + ) + self._delete_notification_channel = google.api_core.gapic_v1.method.wrap_method( + self.notification_channel_service_stub.DeleteNotificationChannel, + default_retry=method_configs['DeleteNotificationChannel'].retry, + default_timeout=method_configs['DeleteNotificationChannel'] + .timeout, + client_info=client_info, + ) + + # Service calls + def list_notification_channel_descriptors( + self, + name, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists the descriptors for supported channel types. The use of descriptors + makes it possible for new channel types to be dynamically added. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_notification_channel_descriptors(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_notification_channel_descriptors(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The REST resource name of the parent from which to retrieve + the notification channel descriptors. The expected syntax is: + + :: + + projects/[PROJECT_ID] + + Note that this names the parent container in which to look for the + descriptors; to retrieve a single descriptor by name, use the + ``GetNotificationChannelDescriptor`` + operation, instead. + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.NotificationChannelDescriptor` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.ListNotificationChannelDescriptorsRequest( + name=name, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_notification_channel_descriptors, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='channel_descriptors', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_notification_channel_descriptor( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single channel descriptor. The descriptor indicates which fields + are expected / permitted for a notification channel of the given type. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> name = client.notification_channel_descriptor_path('[PROJECT]', '[CHANNEL_DESCRIPTOR]') + >>> + >>> response = client.get_notification_channel_descriptor(name) + + Args: + name (str): The channel type for which to execute the request. The format is + ``projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.NotificationChannelDescriptor` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.GetNotificationChannelDescriptorRequest( + name=name, ) + return self._get_notification_channel_descriptor( + request, retry=retry, timeout=timeout, metadata=metadata) + + def list_notification_channels( + self, + name, + filter_=None, + order_by=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists the notification channels that have been created for the project. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_notification_channels(name): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_notification_channels(name, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + name (str): The project on which to execute the request. The format is + ``projects/[PROJECT_ID]``. That is, this names the container + in which to look for the notification channels; it does not name a + specific channel. To query a specific channel by REST resource name, use + the + ````GetNotificationChannel```` operation. + filter_ (str): If provided, this field specifies the criteria that must be met by + notification channels to be included in the response. + + For more details, see [sorting and + filtering](/monitoring/api/v3/sorting-and-filtering). + order_by (str): A comma-separated list of fields by which to sort the result. Supports + the same set of fields as in ``filter``. Entries can be prefixed with + a minus sign to sort in descending rather than ascending order. + + For more details, see [sorting and + filtering](/monitoring/api/v3/sorting-and-filtering). + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.NotificationChannel` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.ListNotificationChannelsRequest( + name=name, + filter=filter_, + order_by=order_by, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_notification_channels, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='notification_channels', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_notification_channel( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single notification channel. The channel includes the relevant + configuration details with which the channel was created. However, the + response may truncate or omit passwords, API keys, or other private key + matter and thus the response may not be 100% identical to the information + that was supplied in the call to the create method. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]') + >>> + >>> response = client.get_notification_channel(name) + + Args: + name (str): The channel for which to execute the request. The format is + ``projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.NotificationChannel` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.GetNotificationChannelRequest( + name=name, ) + return self._get_notification_channel( + request, retry=retry, timeout=timeout, metadata=metadata) + + def create_notification_channel( + self, + name, + notification_channel, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Creates a new notification channel, representing a single notification + endpoint such as an email address, SMS number, or pagerduty service. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``notification_channel``: + >>> notification_channel = {} + >>> + >>> response = client.create_notification_channel(name, notification_channel) + + Args: + name (str): The project on which to execute the request. The format is: + + :: + + projects/[PROJECT_ID] + + Note that this names the container into which the channel will be + written. This does not name the newly created channel. The resulting + channel's name will have a normalized version of this field as a prefix, + but will add ``/notificationChannels/[CHANNEL_ID]`` to identify the channel. + notification_channel (Union[dict, ~google.cloud.monitoring_v3.types.NotificationChannel]): The definition of the ``NotificationChannel`` to create. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.NotificationChannel` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.NotificationChannel` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.CreateNotificationChannelRequest( + name=name, + notification_channel=notification_channel, + ) + return self._create_notification_channel( + request, retry=retry, timeout=timeout, metadata=metadata) + + def update_notification_channel( + self, + notification_channel, + update_mask=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Updates a notification channel. Fields not specified in the field mask + remain unchanged. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> # TODO: Initialize ``notification_channel``: + >>> notification_channel = {} + >>> + >>> response = client.update_notification_channel(notification_channel) + + Args: + notification_channel (Union[dict, ~google.cloud.monitoring_v3.types.NotificationChannel]): A description of the changes to be applied to the specified + notification channel. The description must provide a definition for + fields to be updated; the names of these fields should also be + included in the ``update_mask``. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.NotificationChannel` + update_mask (Union[dict, ~google.cloud.monitoring_v3.types.FieldMask]): The fields to update. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.FieldMask` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.NotificationChannel` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.UpdateNotificationChannelRequest( + notification_channel=notification_channel, + update_mask=update_mask, + ) + return self._update_notification_channel( + request, retry=retry, timeout=timeout, metadata=metadata) + + def delete_notification_channel( + self, + name, + force=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Deletes a notification channel. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.NotificationChannelServiceClient() + >>> + >>> name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]') + >>> + >>> client.delete_notification_channel(name) + + Args: + name (str): The channel for which to execute the request. The format is + ``projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]``. + force (bool): If true, the notification channel will be deleted regardless of its + use in alert policies (the policies will be updated to remove the + channel). If false, channels that are still referenced by an existing + alerting policy will fail to be deleted in a delete operation. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = notification_service_pb2.DeleteNotificationChannelRequest( + name=name, + force=force, + ) + self._delete_notification_channel( + request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/monitoring/google/cloud/monitoring_v3/gapic/notification_channel_service_client_config.py b/monitoring/google/cloud/monitoring_v3/gapic/notification_channel_service_client_config.py new file mode 100644 index 000000000000..7907cc9bf16c --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/notification_channel_service_client_config.py @@ -0,0 +1,58 @@ +config = { + "interfaces": { + "google.monitoring.v3.NotificationChannelService": { + "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": { + "ListNotificationChannelDescriptors": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannelDescriptor": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListNotificationChannels": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetNotificationChannel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateNotificationChannel": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNotificationChannel": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNotificationChannel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/monitoring/google/cloud/monitoring_v3/gapic/uptime_check_service_client.py b/monitoring/google/cloud/monitoring_v3/gapic/uptime_check_service_client.py new file mode 100644 index 000000000000..fe7ca5dc68e3 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/uptime_check_service_client.py @@ -0,0 +1,565 @@ +# 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. +"""Accesses the google.monitoring.v3 UptimeCheckService API.""" + +import functools +import pkg_resources + +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.grpc_helpers +import google.api_core.page_iterator +import google.api_core.path_template + +from google.api import metric_pb2 as api_metric_pb2 +from google.api import monitored_resource_pb2 +from google.cloud.monitoring_v3.gapic import enums +from google.cloud.monitoring_v3.gapic import uptime_check_service_client_config +from google.cloud.monitoring_v3.proto import alert_pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 +from google.cloud.monitoring_v3.proto import common_pb2 +from google.cloud.monitoring_v3.proto import group_pb2 +from google.cloud.monitoring_v3.proto import group_service_pb2 +from google.cloud.monitoring_v3.proto import metric_pb2 as proto_metric_pb2 +from google.cloud.monitoring_v3.proto import metric_service_pb2 +from google.cloud.monitoring_v3.proto import notification_pb2 +from google.cloud.monitoring_v3.proto import notification_service_pb2 +from google.cloud.monitoring_v3.proto import uptime_pb2 +from google.cloud.monitoring_v3.proto import uptime_service_pb2 +from google.cloud.monitoring_v3.proto import uptime_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-monitoring', ).version + + +class UptimeCheckServiceClient(object): + """ + The UptimeCheckService API is used to manage (list, create, delete, edit) + uptime check configurations in the Stackdriver Monitoring product. An uptime + check is a piece of configuration that determines which resources and + services to monitor for availability. These configurations can also be + configured interactively by navigating to the [Cloud Console] + (http://console.cloud.google.com), selecting the appropriate project, + clicking on \"Monitoring\" on the left-hand side to navigate to Stackdriver, + and then clicking on \"Uptime\". + """ + + SERVICE_ADDRESS = 'monitoring.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary. + _INTERFACE_NAME = 'google.monitoring.v3.UptimeCheckService' + + @classmethod + def project_path(cls, project): + """Return a fully-qualified project string.""" + return google.api_core.path_template.expand( + 'projects/{project}', + project=project, + ) + + @classmethod + def uptime_check_config_path(cls, project, uptime_check_config): + """Return a fully-qualified uptime_check_config string.""" + return google.api_core.path_template.expand( + 'projects/{project}/uptimeCheckConfigs/{uptime_check_config}', + project=project, + uptime_check_config=uptime_check_config, + ) + + def __init__(self, + channel=None, + credentials=None, + client_config=uptime_check_service_client_config.config, + client_info=None): + """Constructor. + + 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. + client_config (dict): 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. + """ + # 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 to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + + # Create the channel. + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES, + ) + + # Create the gRPC stubs. + self.uptime_check_service_stub = ( + uptime_service_pb2_grpc.UptimeCheckServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + # 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.) + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config['interfaces'][self._INTERFACE_NAME], ) + + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. + self._list_uptime_check_configs = google.api_core.gapic_v1.method.wrap_method( + self.uptime_check_service_stub.ListUptimeCheckConfigs, + default_retry=method_configs['ListUptimeCheckConfigs'].retry, + default_timeout=method_configs['ListUptimeCheckConfigs'].timeout, + client_info=client_info, + ) + self._get_uptime_check_config = google.api_core.gapic_v1.method.wrap_method( + self.uptime_check_service_stub.GetUptimeCheckConfig, + default_retry=method_configs['GetUptimeCheckConfig'].retry, + default_timeout=method_configs['GetUptimeCheckConfig'].timeout, + client_info=client_info, + ) + self._create_uptime_check_config = google.api_core.gapic_v1.method.wrap_method( + self.uptime_check_service_stub.CreateUptimeCheckConfig, + default_retry=method_configs['CreateUptimeCheckConfig'].retry, + default_timeout=method_configs['CreateUptimeCheckConfig'].timeout, + client_info=client_info, + ) + self._update_uptime_check_config = google.api_core.gapic_v1.method.wrap_method( + self.uptime_check_service_stub.UpdateUptimeCheckConfig, + default_retry=method_configs['UpdateUptimeCheckConfig'].retry, + default_timeout=method_configs['UpdateUptimeCheckConfig'].timeout, + client_info=client_info, + ) + self._delete_uptime_check_config = google.api_core.gapic_v1.method.wrap_method( + self.uptime_check_service_stub.DeleteUptimeCheckConfig, + default_retry=method_configs['DeleteUptimeCheckConfig'].retry, + default_timeout=method_configs['DeleteUptimeCheckConfig'].timeout, + client_info=client_info, + ) + self._list_uptime_check_ips = google.api_core.gapic_v1.method.wrap_method( + self.uptime_check_service_stub.ListUptimeCheckIps, + default_retry=method_configs['ListUptimeCheckIps'].retry, + default_timeout=method_configs['ListUptimeCheckIps'].timeout, + client_info=client_info, + ) + + # Service calls + def list_uptime_check_configs( + self, + parent, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Lists the existing valid uptime check configurations for the project, + leaving out any invalid configurations. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.UptimeCheckServiceClient() + >>> + >>> parent = client.project_path('[PROJECT]') + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_uptime_check_configs(parent): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_uptime_check_configs(parent, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): The project whose uptime check configurations are listed. The format is + + ``projects/[PROJECT_ID]``. + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.UptimeCheckConfig` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = uptime_service_pb2.ListUptimeCheckConfigsRequest( + parent=parent, + page_size=page_size, + ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_uptime_check_configs, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='uptime_check_configs', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator + + def get_uptime_check_config( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Gets a single uptime check configuration. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.UptimeCheckServiceClient() + >>> + >>> name = client.uptime_check_config_path('[PROJECT]', '[UPTIME_CHECK_CONFIG]') + >>> + >>> response = client.get_uptime_check_config(name) + + Args: + name (str): The uptime check configuration to retrieve. The format is + + ``projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.UptimeCheckConfig` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = uptime_service_pb2.GetUptimeCheckConfigRequest(name=name, ) + return self._get_uptime_check_config( + request, retry=retry, timeout=timeout, metadata=metadata) + + def create_uptime_check_config( + self, + parent, + uptime_check_config, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Creates a new uptime check configuration. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.UptimeCheckServiceClient() + >>> + >>> parent = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``uptime_check_config``: + >>> uptime_check_config = {} + >>> + >>> response = client.create_uptime_check_config(parent, uptime_check_config) + + Args: + parent (str): The project in which to create the uptime check. The format is: + + ``projects/[PROJECT_ID]``. + uptime_check_config (Union[dict, ~google.cloud.monitoring_v3.types.UptimeCheckConfig]): The new uptime check configuration. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.UptimeCheckConfig` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.UptimeCheckConfig` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = uptime_service_pb2.CreateUptimeCheckConfigRequest( + parent=parent, + uptime_check_config=uptime_check_config, + ) + return self._create_uptime_check_config( + request, retry=retry, timeout=timeout, metadata=metadata) + + def update_uptime_check_config( + self, + uptime_check_config, + update_mask=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Updates an uptime check configuration. You can either replace the entire + configuration with a new one or replace only certain fields in the current + configuration by specifying the fields to be updated via ``\"updateMask\"``. + Returns the updated configuration. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.UptimeCheckServiceClient() + >>> + >>> # TODO: Initialize ``uptime_check_config``: + >>> uptime_check_config = {} + >>> + >>> response = client.update_uptime_check_config(uptime_check_config) + + Args: + uptime_check_config (Union[dict, ~google.cloud.monitoring_v3.types.UptimeCheckConfig]): Required. If an ``\"updateMask\"`` has been specified, this field gives + the values for the set of fields mentioned in the ``\"updateMask\"``. If an + ``\"updateMask\"`` has not been given, this uptime check configuration replaces + the current configuration. If a field is mentioned in ``\"updateMask``\" but + the corresonding field is omitted in this partial uptime check + configuration, it has the effect of deleting/clearing the field from the + configuration on the server. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.UptimeCheckConfig` + update_mask (Union[dict, ~google.cloud.monitoring_v3.types.FieldMask]): Optional. If present, only the listed fields in the current uptime check + configuration are updated with values from the new configuration. If this + field is empty, then the current configuration is completely replaced with + the new configuration. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.monitoring_v3.types.FieldMask` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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.monitoring_v3.types.UptimeCheckConfig` 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = uptime_service_pb2.UpdateUptimeCheckConfigRequest( + uptime_check_config=uptime_check_config, + update_mask=update_mask, + ) + return self._update_uptime_check_config( + request, retry=retry, timeout=timeout, metadata=metadata) + + def delete_uptime_check_config( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Deletes an uptime check configuration. Note that this method will fail + if the uptime check configuration is referenced by an alert policy or + other dependent configs that would be rendered invalid by the deletion. + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.UptimeCheckServiceClient() + >>> + >>> name = client.uptime_check_config_path('[PROJECT]', '[UPTIME_CHECK_CONFIG]') + >>> + >>> client.delete_uptime_check_config(name) + + Args: + name (str): The uptime check configuration to delete. The format is + + ``projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = uptime_service_pb2.DeleteUptimeCheckConfigRequest( + name=name, ) + self._delete_uptime_check_config( + request, retry=retry, timeout=timeout, metadata=metadata) + + def list_uptime_check_ips(self, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): + """ + Returns the list of IPs that checkers run from + + Example: + >>> from google.cloud import monitoring_v3 + >>> + >>> client = monitoring_v3.UptimeCheckServiceClient() + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_uptime_check_ips(): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_uptime_check_ips(options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + 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 not + be retried. + 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.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.monitoring_v3.types.UptimeCheckIp` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + 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. + """ + if metadata is None: + metadata = [] + metadata = list(metadata) + request = uptime_service_pb2.ListUptimeCheckIpsRequest( + page_size=page_size, ) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_uptime_check_ips, + retry=retry, + timeout=timeout, + metadata=metadata), + request=request, + items_field='uptime_check_ips', + request_token_field='page_token', + response_token_field='next_page_token', + ) + return iterator diff --git a/monitoring/google/cloud/monitoring_v3/gapic/uptime_check_service_client_config.py b/monitoring/google/cloud/monitoring_v3/gapic/uptime_check_service_client_config.py new file mode 100644 index 000000000000..3bac592e01a2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/gapic/uptime_check_service_client_config.py @@ -0,0 +1,53 @@ +config = { + "interfaces": { + "google.monitoring.v3.UptimeCheckService": { + "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": { + "ListUptimeCheckConfigs": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteUptimeCheckConfig": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListUptimeCheckIps": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/monitoring/google/cloud/monitoring_v3/proto/__init__.py b/monitoring/google/cloud/monitoring_v3/proto/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/monitoring/google/cloud/monitoring_v3/proto/alert_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/alert_pb2.py new file mode 100644 index 000000000000..262ac177153e --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/alert_pb2.py @@ -0,0 +1,833 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/alert.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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.cloud.monitoring_v3.proto import common_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2 +from google.cloud.monitoring_v3.proto import mutation_record_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_mutation__record__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/alert.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n,google/cloud/monitoring_v3/proto/alert.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a-google/cloud/monitoring_v3/proto/common.proto\x1a\x36google/cloud/monitoring_v3/proto/mutation_record.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1egoogle/protobuf/wrappers.proto\"\xdd\x0c\n\x0b\x41lertPolicy\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\x12\x46\n\rdocumentation\x18\r \x01(\x0b\x32/.google.monitoring.v3.AlertPolicy.Documentation\x12\x46\n\x0buser_labels\x18\x10 \x03(\x0b\x32\x31.google.monitoring.v3.AlertPolicy.UserLabelsEntry\x12?\n\nconditions\x18\x0c \x03(\x0b\x32+.google.monitoring.v3.AlertPolicy.Condition\x12I\n\x08\x63ombiner\x18\x06 \x01(\x0e\x32\x37.google.monitoring.v3.AlertPolicy.ConditionCombinerType\x12+\n\x07\x65nabled\x18\x11 \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12\x1d\n\x15notification_channels\x18\x0e \x03(\t\x12=\n\x0f\x63reation_record\x18\n \x01(\x0b\x32$.google.monitoring.v3.MutationRecord\x12=\n\x0fmutation_record\x18\x0b \x01(\x0b\x32$.google.monitoring.v3.MutationRecord\x1a\x33\n\rDocumentation\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12\x11\n\tmime_type\x18\x02 \x01(\t\x1a\xf8\x06\n\tCondition\x12\x0c\n\x04name\x18\x0c \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x06 \x01(\t\x12Z\n\x13\x63ondition_threshold\x18\x01 \x01(\x0b\x32;.google.monitoring.v3.AlertPolicy.Condition.MetricThresholdH\x00\x12U\n\x10\x63ondition_absent\x18\x02 \x01(\x0b\x32\x39.google.monitoring.v3.AlertPolicy.Condition.MetricAbsenceH\x00\x1a\x35\n\x07Trigger\x12\x0f\n\x05\x63ount\x18\x01 \x01(\x05H\x00\x12\x11\n\x07percent\x18\x02 \x01(\x01H\x00\x42\x06\n\x04type\x1a\x81\x03\n\x0fMetricThreshold\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x37\n\x0c\x61ggregations\x18\x08 \x03(\x0b\x32!.google.monitoring.v3.Aggregation\x12\x1a\n\x12\x64\x65nominator_filter\x18\t \x01(\t\x12\x43\n\x18\x64\x65nominator_aggregations\x18\n \x03(\x0b\x32!.google.monitoring.v3.Aggregation\x12\x38\n\ncomparison\x18\x04 \x01(\x0e\x32$.google.monitoring.v3.ComparisonType\x12\x17\n\x0fthreshold_value\x18\x05 \x01(\x01\x12+\n\x08\x64uration\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x44\n\x07trigger\x18\x07 \x01(\x0b\x32\x33.google.monitoring.v3.AlertPolicy.Condition.Trigger\x1a\xcb\x01\n\rMetricAbsence\x12\x0e\n\x06\x66ilter\x18\x01 \x01(\t\x12\x37\n\x0c\x61ggregations\x18\x05 \x03(\x0b\x32!.google.monitoring.v3.Aggregation\x12+\n\x08\x64uration\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x44\n\x07trigger\x18\x03 \x01(\x0b\x32\x33.google.monitoring.v3.AlertPolicy.Condition.TriggerB\x0b\n\tcondition\x1a\x31\n\x0fUserLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"a\n\x15\x43onditionCombinerType\x12\x17\n\x13\x43OMBINE_UNSPECIFIED\x10\x00\x12\x07\n\x03\x41ND\x10\x01\x12\x06\n\x02OR\x10\x02\x12\x1e\n\x1a\x41ND_WITH_MATCHING_RESOURCE\x10\x03\x42\xa2\x01\n\x18\x63om.google.monitoring.v3B\nAlertProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_mutation__record__pb2.DESCRIPTOR,google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,]) + + + +_ALERTPOLICY_CONDITIONCOMBINERTYPE = _descriptor.EnumDescriptor( + name='ConditionCombinerType', + full_name='google.monitoring.v3.AlertPolicy.ConditionCombinerType', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='COMBINE_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='AND', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='OR', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='AND_WITH_MATCHING_RESOURCE', index=3, number=3, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1800, + serialized_end=1897, +) +_sym_db.RegisterEnumDescriptor(_ALERTPOLICY_CONDITIONCOMBINERTYPE) + + +_ALERTPOLICY_DOCUMENTATION = _descriptor.Descriptor( + name='Documentation', + full_name='google.monitoring.v3.AlertPolicy.Documentation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='content', full_name='google.monitoring.v3.AlertPolicy.Documentation.content', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='mime_type', full_name='google.monitoring.v3.AlertPolicy.Documentation.mime_type', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=805, + serialized_end=856, +) + +_ALERTPOLICY_CONDITION_TRIGGER = _descriptor.Descriptor( + name='Trigger', + full_name='google.monitoring.v3.AlertPolicy.Condition.Trigger', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='count', full_name='google.monitoring.v3.AlertPolicy.Condition.Trigger.count', index=0, + number=1, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='percent', full_name='google.monitoring.v3.AlertPolicy.Condition.Trigger.percent', index=1, + number=2, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='type', full_name='google.monitoring.v3.AlertPolicy.Condition.Trigger.type', + index=0, containing_type=None, fields=[]), + ], + serialized_start=1087, + serialized_end=1140, +) + +_ALERTPOLICY_CONDITION_METRICTHRESHOLD = _descriptor.Descriptor( + name='MetricThreshold', + full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.filter', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='aggregations', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.aggregations', index=1, + number=8, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='denominator_filter', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.denominator_filter', index=2, + number=9, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='denominator_aggregations', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.denominator_aggregations', index=3, + number=10, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='comparison', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.comparison', index=4, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='threshold_value', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.threshold_value', index=5, + number=5, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='duration', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.duration', index=6, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='trigger', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricThreshold.trigger', index=7, + number=7, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1143, + serialized_end=1528, +) + +_ALERTPOLICY_CONDITION_METRICABSENCE = _descriptor.Descriptor( + name='MetricAbsence', + full_name='google.monitoring.v3.AlertPolicy.Condition.MetricAbsence', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricAbsence.filter', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='aggregations', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricAbsence.aggregations', index=1, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='duration', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricAbsence.duration', index=2, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='trigger', full_name='google.monitoring.v3.AlertPolicy.Condition.MetricAbsence.trigger', index=3, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1531, + serialized_end=1734, +) + +_ALERTPOLICY_CONDITION = _descriptor.Descriptor( + name='Condition', + full_name='google.monitoring.v3.AlertPolicy.Condition', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.AlertPolicy.Condition.name', index=0, + number=12, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.AlertPolicy.Condition.display_name', index=1, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='condition_threshold', full_name='google.monitoring.v3.AlertPolicy.Condition.condition_threshold', index=2, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='condition_absent', full_name='google.monitoring.v3.AlertPolicy.Condition.condition_absent', index=3, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[_ALERTPOLICY_CONDITION_TRIGGER, _ALERTPOLICY_CONDITION_METRICTHRESHOLD, _ALERTPOLICY_CONDITION_METRICABSENCE, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='condition', full_name='google.monitoring.v3.AlertPolicy.Condition.condition', + index=0, containing_type=None, fields=[]), + ], + serialized_start=859, + serialized_end=1747, +) + +_ALERTPOLICY_USERLABELSENTRY = _descriptor.Descriptor( + name='UserLabelsEntry', + full_name='google.monitoring.v3.AlertPolicy.UserLabelsEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='google.monitoring.v3.AlertPolicy.UserLabelsEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='value', full_name='google.monitoring.v3.AlertPolicy.UserLabelsEntry.value', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1749, + serialized_end=1798, +) + +_ALERTPOLICY = _descriptor.Descriptor( + name='AlertPolicy', + full_name='google.monitoring.v3.AlertPolicy', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.AlertPolicy.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.AlertPolicy.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='documentation', full_name='google.monitoring.v3.AlertPolicy.documentation', index=2, + number=13, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='user_labels', full_name='google.monitoring.v3.AlertPolicy.user_labels', index=3, + number=16, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='conditions', full_name='google.monitoring.v3.AlertPolicy.conditions', index=4, + number=12, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='combiner', full_name='google.monitoring.v3.AlertPolicy.combiner', index=5, + number=6, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='enabled', full_name='google.monitoring.v3.AlertPolicy.enabled', index=6, + number=17, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='notification_channels', full_name='google.monitoring.v3.AlertPolicy.notification_channels', index=7, + number=14, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='creation_record', full_name='google.monitoring.v3.AlertPolicy.creation_record', index=8, + number=10, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='mutation_record', full_name='google.monitoring.v3.AlertPolicy.mutation_record', index=9, + number=11, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[_ALERTPOLICY_DOCUMENTATION, _ALERTPOLICY_CONDITION, _ALERTPOLICY_USERLABELSENTRY, ], + enum_types=[ + _ALERTPOLICY_CONDITIONCOMBINERTYPE, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=268, + serialized_end=1897, +) + +_ALERTPOLICY_DOCUMENTATION.containing_type = _ALERTPOLICY +_ALERTPOLICY_CONDITION_TRIGGER.containing_type = _ALERTPOLICY_CONDITION +_ALERTPOLICY_CONDITION_TRIGGER.oneofs_by_name['type'].fields.append( + _ALERTPOLICY_CONDITION_TRIGGER.fields_by_name['count']) +_ALERTPOLICY_CONDITION_TRIGGER.fields_by_name['count'].containing_oneof = _ALERTPOLICY_CONDITION_TRIGGER.oneofs_by_name['type'] +_ALERTPOLICY_CONDITION_TRIGGER.oneofs_by_name['type'].fields.append( + _ALERTPOLICY_CONDITION_TRIGGER.fields_by_name['percent']) +_ALERTPOLICY_CONDITION_TRIGGER.fields_by_name['percent'].containing_oneof = _ALERTPOLICY_CONDITION_TRIGGER.oneofs_by_name['type'] +_ALERTPOLICY_CONDITION_METRICTHRESHOLD.fields_by_name['aggregations'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._AGGREGATION +_ALERTPOLICY_CONDITION_METRICTHRESHOLD.fields_by_name['denominator_aggregations'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._AGGREGATION +_ALERTPOLICY_CONDITION_METRICTHRESHOLD.fields_by_name['comparison'].enum_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._COMPARISONTYPE +_ALERTPOLICY_CONDITION_METRICTHRESHOLD.fields_by_name['duration'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_ALERTPOLICY_CONDITION_METRICTHRESHOLD.fields_by_name['trigger'].message_type = _ALERTPOLICY_CONDITION_TRIGGER +_ALERTPOLICY_CONDITION_METRICTHRESHOLD.containing_type = _ALERTPOLICY_CONDITION +_ALERTPOLICY_CONDITION_METRICABSENCE.fields_by_name['aggregations'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._AGGREGATION +_ALERTPOLICY_CONDITION_METRICABSENCE.fields_by_name['duration'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_ALERTPOLICY_CONDITION_METRICABSENCE.fields_by_name['trigger'].message_type = _ALERTPOLICY_CONDITION_TRIGGER +_ALERTPOLICY_CONDITION_METRICABSENCE.containing_type = _ALERTPOLICY_CONDITION +_ALERTPOLICY_CONDITION.fields_by_name['condition_threshold'].message_type = _ALERTPOLICY_CONDITION_METRICTHRESHOLD +_ALERTPOLICY_CONDITION.fields_by_name['condition_absent'].message_type = _ALERTPOLICY_CONDITION_METRICABSENCE +_ALERTPOLICY_CONDITION.containing_type = _ALERTPOLICY +_ALERTPOLICY_CONDITION.oneofs_by_name['condition'].fields.append( + _ALERTPOLICY_CONDITION.fields_by_name['condition_threshold']) +_ALERTPOLICY_CONDITION.fields_by_name['condition_threshold'].containing_oneof = _ALERTPOLICY_CONDITION.oneofs_by_name['condition'] +_ALERTPOLICY_CONDITION.oneofs_by_name['condition'].fields.append( + _ALERTPOLICY_CONDITION.fields_by_name['condition_absent']) +_ALERTPOLICY_CONDITION.fields_by_name['condition_absent'].containing_oneof = _ALERTPOLICY_CONDITION.oneofs_by_name['condition'] +_ALERTPOLICY_USERLABELSENTRY.containing_type = _ALERTPOLICY +_ALERTPOLICY.fields_by_name['documentation'].message_type = _ALERTPOLICY_DOCUMENTATION +_ALERTPOLICY.fields_by_name['user_labels'].message_type = _ALERTPOLICY_USERLABELSENTRY +_ALERTPOLICY.fields_by_name['conditions'].message_type = _ALERTPOLICY_CONDITION +_ALERTPOLICY.fields_by_name['combiner'].enum_type = _ALERTPOLICY_CONDITIONCOMBINERTYPE +_ALERTPOLICY.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE +_ALERTPOLICY.fields_by_name['creation_record'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_mutation__record__pb2._MUTATIONRECORD +_ALERTPOLICY.fields_by_name['mutation_record'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_mutation__record__pb2._MUTATIONRECORD +_ALERTPOLICY_CONDITIONCOMBINERTYPE.containing_type = _ALERTPOLICY +DESCRIPTOR.message_types_by_name['AlertPolicy'] = _ALERTPOLICY +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +AlertPolicy = _reflection.GeneratedProtocolMessageType('AlertPolicy', (_message.Message,), dict( + + Documentation = _reflection.GeneratedProtocolMessageType('Documentation', (_message.Message,), dict( + DESCRIPTOR = _ALERTPOLICY_DOCUMENTATION, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + , + __doc__ = """A content string and a MIME type that describes the content string's + format. + + + Attributes: + content: + The text of the documentation, interpreted according to + ``mime_type``. The content may not exceed 8,192 Unicode + characters and may not exceed more than 10,240 bytes when + encoded in UTF-8 format, whichever is smaller. + mime_type: + The format of the ``content`` field. Presently, only the value + ``"text/markdown"`` is supported. See `Markdown + `__ for more + information. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy.Documentation) + )) + , + + Condition = _reflection.GeneratedProtocolMessageType('Condition', (_message.Message,), dict( + + Trigger = _reflection.GeneratedProtocolMessageType('Trigger', (_message.Message,), dict( + DESCRIPTOR = _ALERTPOLICY_CONDITION_TRIGGER, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + , + __doc__ = """Specifies how many time series must fail a predicate to trigger a + condition. If not specified, then a ``{count: 1}`` trigger is used. + + + Attributes: + type: + A type of trigger. + count: + The absolute number of time series that must fail the + predicate for the condition to be triggered. + percent: + The percentage of time series that must fail the predicate for + the condition to be triggered. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy.Condition.Trigger) + )) + , + + MetricThreshold = _reflection.GeneratedProtocolMessageType('MetricThreshold', (_message.Message,), dict( + DESCRIPTOR = _ALERTPOLICY_CONDITION_METRICTHRESHOLD, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + , + __doc__ = """A condition type that compares a collection of time series against a + threshold. + + + Attributes: + filter: + A `filter `__ that identifies + which time series should be compared with the threshold. The + filter is similar to the one that is specified in the + ```MetricService.ListTimeSeries`` request + `__ + (that call is useful to verify the time series that will be + retrieved / processed) and must specify the metric type and + optionally may contain restrictions on resource type, resource + labels, and metric labels. This field may not exceed 2048 + Unicode characters in length. + aggregations: + Specifies the alignment of data points in individual time + series as well as how to combine the retrieved time series + together (such as when aggregating multiple streams on each + resource to a single stream for each resource or when + aggregating streams across all members of a group of + resrouces). Multiple aggregations are applied in the order + specified. This field is similar to the one in the + ```MetricService.ListTimeSeries`` request + `__. + It is advisable to use the ``ListTimeSeries`` method when + debugging this field. + denominator_filter: + A `filter `__ that identifies a + time series that should be used as the denominator of a ratio + that will be compared with the threshold. If a + ``denominator_filter`` is specified, the time series specified + by the ``filter`` field will be used as the numerator. The + filter is similar to the one that is specified in the + ```MetricService.ListTimeSeries`` request + `__ + (that call is useful to verify the time series that will be + retrieved / processed) and must specify the metric type and + optionally may contain restrictions on resource type, resource + labels, and metric labels. This field may not exceed 2048 + Unicode characters in length. + denominator_aggregations: + Specifies the alignment of data points in individual time + series selected by ``denominatorFilter`` as well as how to + combine the retrieved time series together (such as when + aggregating multiple streams on each resource to a single + stream for each resource or when aggregating streams across + all members of a group of resources). When computing ratios, + the ``aggregations`` and ``denominator_aggregations`` fields + must use the same alignment period and produce time series + that have the same periodicity and labels. This field is + similar to the one in the ```MetricService.ListTimeSeries`` + request + `__. + It is advisable to use the ``ListTimeSeries`` method when + debugging this field. + comparison: + The comparison to apply between the time series (indicated by + ``filter`` and ``aggregation``) and the threshold (indicated + by ``threshold_value``). The comparison is applied on each + time series, with the time series on the left-hand side and + the threshold on the right-hand side. Only ``COMPARISON_LT`` + and ``COMPARISON_GT`` are supported currently. + threshold_value: + A value against which to compare the time series. + duration: + The amount of time that a time series must violate the + threshold to be considered failing. Currently, only values + that are a multiple of a minute--e.g. 60, 120, or 300 seconds + --are supported. If an invalid value is given, an error will + be returned. The ``Duration.nanos`` field is ignored. When + choosing a duration, it is useful to keep in mind the + frequency of the underlying time series data (which may also + be affected by any alignments specified in the ``aggregation`` + field); a good duration is long enough so that a single + outlier does not generate spurious alerts, but short enough + that unhealthy states are detected and alerted on quickly. + trigger: + The number/percent of time series for which the comparison + must hold in order for the condition to trigger. If + unspecified, then the condition will trigger if the comparison + is true for any of the time series that have been identified + by ``filter`` and ``aggregations``, or by the ratio, if + ``denominator_filter`` and ``denominator_aggregations`` are + specified. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy.Condition.MetricThreshold) + )) + , + + MetricAbsence = _reflection.GeneratedProtocolMessageType('MetricAbsence', (_message.Message,), dict( + DESCRIPTOR = _ALERTPOLICY_CONDITION_METRICABSENCE, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + , + __doc__ = """A condition type that checks that monitored resources are reporting + data. The configuration defines a metric and a set of monitored + resources. The predicate is considered in violation when a time series + for the specified metric of a monitored resource does not include any + data in the specified ``duration``. + + + Attributes: + filter: + A `filter `__ that identifies + which time series should be compared with the threshold. The + filter is similar to the one that is specified in the + ```MetricService.ListTimeSeries`` request + `__ + (that call is useful to verify the time series that will be + retrieved / processed) and must specify the metric type and + optionally may contain restrictions on resource type, resource + labels, and metric labels. This field may not exceed 2048 + Unicode characters in length. + aggregations: + Specifies the alignment of data points in individual time + series as well as how to combine the retrieved time series + together (such as when aggregating multiple streams on each + resource to a single stream for each resource or when + aggregating streams across all members of a group of + resrouces). Multiple aggregations are applied in the order + specified. This field is similar to the one in the + ```MetricService.ListTimeSeries`` request + `__. + It is advisable to use the ``ListTimeSeries`` method when + debugging this field. + duration: + The amount of time that a time series must fail to report new + data to be considered failing. Currently, only values that are + a multiple of a minute--e.g. 60, 120, or 300 seconds--are + supported. If an invalid value is given, an error will be + returned. The ``Duration.nanos`` field is ignored. + trigger: + The number/percent of time series for which the comparison + must hold in order for the condition to trigger. If + unspecified, then the condition will trigger if the comparison + is true for any of the time series that have been identified + by ``filter`` and ``aggregations``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy.Condition.MetricAbsence) + )) + , + DESCRIPTOR = _ALERTPOLICY_CONDITION, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + , + __doc__ = """A condition is a true/false test that determines when an alerting policy + should open an incident. If a condition evaluates to true, it signifies + that something is wrong. + + + Attributes: + name: + Required if the condition exists. The unique resource name for + this condition. Its syntax is: :: projects/[PROJECT_ID]/ + alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID] + ``[CONDITION_ID]`` is assigned by Stackdriver Monitoring when + the condition is created as part of a new or updated alerting + policy. When calling the [alertPolicies.create][google.monito + ring.v3.AlertPolicyService.CreateAlertPolicy] method, do not + include the ``name`` field in the conditions of the requested + alerting policy. Stackdriver Monitoring creates the condition + identifiers and includes them in the new policy. When calling + the [alertPolicies.update][google.monitoring.v3.AlertPolicySer + vice.UpdateAlertPolicy] method to update a policy, including a + condition ``name`` causes the existing condition to be + updated. Conditions without names are added to the updated + policy. Existing conditions are deleted if they are not + updated. Best practice is to preserve ``[CONDITION_ID]`` if + you make only small changes, such as those to condition + thresholds, durations, or trigger values. Otherwise, treat the + change as a new condition and let the existing condition be + deleted. + display_name: + A short name or phrase used to identify the condition in + dashboards, notifications, and incidents. To avoid confusion, + don't use the same display name for multiple conditions in the + same policy. + condition: + Only one of the following condition types will be specified. + condition_threshold: + A condition that compares a time series against a threshold. + condition_absent: + A condition that checks that a time series continues to + receive new data points. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy.Condition) + )) + , + + UserLabelsEntry = _reflection.GeneratedProtocolMessageType('UserLabelsEntry', (_message.Message,), dict( + DESCRIPTOR = _ALERTPOLICY_USERLABELSENTRY, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy.UserLabelsEntry) + )) + , + DESCRIPTOR = _ALERTPOLICY, + __module__ = 'google.cloud.monitoring_v3.proto.alert_pb2' + , + __doc__ = """A description of the conditions under which some aspect of your system + is considered to be "unhealthy" and the ways to notify people or + services about this state. For an overview of alert policies, see + `Introduction to Alerting `__. + + + Attributes: + name: + Required if the policy exists. The resource name for this + policy. The syntax is: :: + projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + ``[ALERT_POLICY_ID]`` is assigned by Stackdriver Monitoring + when the policy is created. When calling the [alertPolicies.cr + eate][google.monitoring.v3.AlertPolicyService.CreateAlertPolic + y] method, do not include the ``name`` field in the alerting + policy passed as part of the request. + display_name: + A short name or phrase used to identify the policy in + dashboards, notifications, and incidents. To avoid confusion, + don't use the same display name for multiple policies in the + same project. The name is limited to 512 Unicode characters. + documentation: + Documentation that is included with notifications and + incidents related to this policy. Best practice is for the + documentation to include information to help responders + understand, mitigate, escalate, and correct the underlying + problems detected by the alerting policy. Notification + channels that have limited capacity might not show this + documentation. + user_labels: + User-supplied key/value data to be used for organizing and + identifying the ``AlertPolicy`` objects. The field can + contain up to 64 entries. Each key and value is limited to 63 + Unicode characters or 128 bytes, whichever is smaller. Labels + and values can contain only lowercase letters, numerals, + underscores, and dashes. Keys must begin with a letter. + conditions: + A list of conditions for the policy. The conditions are + combined by AND or OR according to the ``combiner`` field. If + the combined conditions evaluate to true, then an incident is + created. A policy can have from one to six conditions. + combiner: + How to combine the results of multiple conditions to determine + if an incident should be opened. + enabled: + Whether or not the policy is enabled. On write, the default + interpretation if unset is that the policy is enabled. On + read, clients should not make any assumption about the state + if it has not been populated. The field should always be + populated on List and Get operations, unless a field + projection has been specified that strips it out. + notification_channels: + Identifies the notification channels to which notifications + should be sent when incidents are opened or closed or when new + violations occur on an already opened incident. Each element + of this array corresponds to the ``name`` field in each of the + [``NotificationChannel``][google.monitoring.v3.NotificationCha + nnel] objects that are returned from the [``ListNotificationCh + annels``][google.monitoring.v3.NotificationChannelService.List + NotificationChannels] method. The syntax of the entries in + this field is: :: + projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] + creation_record: + A read-only record of the creation of the alerting policy. If + provided in a call to create or update, this field will be + ignored. + mutation_record: + A read-only record of the most recent change to the alerting + policy. If provided in a call to create or update, this field + will be ignored. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.AlertPolicy) + )) +_sym_db.RegisterMessage(AlertPolicy) +_sym_db.RegisterMessage(AlertPolicy.Documentation) +_sym_db.RegisterMessage(AlertPolicy.Condition) +_sym_db.RegisterMessage(AlertPolicy.Condition.Trigger) +_sym_db.RegisterMessage(AlertPolicy.Condition.MetricThreshold) +_sym_db.RegisterMessage(AlertPolicy.Condition.MetricAbsence) +_sym_db.RegisterMessage(AlertPolicy.UserLabelsEntry) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\nAlertProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +_ALERTPOLICY_USERLABELSENTRY.has_options = True +_ALERTPOLICY_USERLABELSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/alert_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/alert_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/alert_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/alert_service_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/alert_service_pb2.py new file mode 100644 index 000000000000..b736e46b408a --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/alert_service_pb2.py @@ -0,0 +1,499 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/alert_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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.cloud.monitoring_v3.proto import alert_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__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/monitoring_v3/proto/alert_service.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n4google/cloud/monitoring_v3/proto/alert_service.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a,google/cloud/monitoring_v3/proto/alert.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\"a\n\x18\x43reateAlertPolicyRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x37\n\x0c\x61lert_policy\x18\x02 \x01(\x0b\x32!.google.monitoring.v3.AlertPolicy\"%\n\x15GetAlertPolicyRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"q\n\x18ListAlertPoliciesRequest\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x05 \x01(\t\x12\x10\n\x08order_by\x18\x06 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"o\n\x19ListAlertPoliciesResponse\x12\x39\n\x0e\x61lert_policies\x18\x03 \x03(\x0b\x32!.google.monitoring.v3.AlertPolicy\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x84\x01\n\x18UpdateAlertPolicyRequest\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\x12\x37\n\x0c\x61lert_policy\x18\x03 \x01(\x0b\x32!.google.monitoring.v3.AlertPolicy\"(\n\x18\x44\x65leteAlertPolicyRequest\x12\x0c\n\x04name\x18\x03 \x01(\t2\xae\x06\n\x12\x41lertPolicyService\x12\xa1\x01\n\x11ListAlertPolicies\x12..google.monitoring.v3.ListAlertPoliciesRequest\x1a/.google.monitoring.v3.ListAlertPoliciesResponse\"+\x82\xd3\xe4\x93\x02%\x12#/v3/{name=projects/*}/alertPolicies\x12\x8f\x01\n\x0eGetAlertPolicy\x12+.google.monitoring.v3.GetAlertPolicyRequest\x1a!.google.monitoring.v3.AlertPolicy\"-\x82\xd3\xe4\x93\x02\'\x12%/v3/{name=projects/*/alertPolicies/*}\x12\xa1\x01\n\x11\x43reateAlertPolicy\x12..google.monitoring.v3.CreateAlertPolicyRequest\x1a!.google.monitoring.v3.AlertPolicy\"9\x82\xd3\xe4\x93\x02\x33\"#/v3/{name=projects/*}/alertPolicies:\x0c\x61lert_policy\x12\x8a\x01\n\x11\x44\x65leteAlertPolicy\x12..google.monitoring.v3.DeleteAlertPolicyRequest\x1a\x16.google.protobuf.Empty\"-\x82\xd3\xe4\x93\x02\'*%/v3/{name=projects/*/alertPolicies/*}\x12\xb0\x01\n\x11UpdateAlertPolicy\x12..google.monitoring.v3.UpdateAlertPolicyRequest\x1a!.google.monitoring.v3.AlertPolicy\"H\x82\xd3\xe4\x93\x02\x42\x32\x32/v3/{alert_policy.name=projects/*/alertPolicies/*}:\x0c\x61lert_policyB\xa9\x01\n\x18\x63om.google.monitoring.v3B\x11\x41lertServiceProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,]) + + + + +_CREATEALERTPOLICYREQUEST = _descriptor.Descriptor( + name='CreateAlertPolicyRequest', + full_name='google.monitoring.v3.CreateAlertPolicyRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.CreateAlertPolicyRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='alert_policy', full_name='google.monitoring.v3.CreateAlertPolicyRequest.alert_policy', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=217, + serialized_end=314, +) + + +_GETALERTPOLICYREQUEST = _descriptor.Descriptor( + name='GetAlertPolicyRequest', + full_name='google.monitoring.v3.GetAlertPolicyRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetAlertPolicyRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=316, + serialized_end=353, +) + + +_LISTALERTPOLICIESREQUEST = _descriptor.Descriptor( + name='ListAlertPoliciesRequest', + full_name='google.monitoring.v3.ListAlertPoliciesRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListAlertPoliciesRequest.name', index=0, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.ListAlertPoliciesRequest.filter', index=1, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='order_by', full_name='google.monitoring.v3.ListAlertPoliciesRequest.order_by', index=2, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListAlertPoliciesRequest.page_size', index=3, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListAlertPoliciesRequest.page_token', index=4, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=355, + serialized_end=468, +) + + +_LISTALERTPOLICIESRESPONSE = _descriptor.Descriptor( + name='ListAlertPoliciesResponse', + full_name='google.monitoring.v3.ListAlertPoliciesResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='alert_policies', full_name='google.monitoring.v3.ListAlertPoliciesResponse.alert_policies', index=0, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListAlertPoliciesResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=470, + serialized_end=581, +) + + +_UPDATEALERTPOLICYREQUEST = _descriptor.Descriptor( + name='UpdateAlertPolicyRequest', + full_name='google.monitoring.v3.UpdateAlertPolicyRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='update_mask', full_name='google.monitoring.v3.UpdateAlertPolicyRequest.update_mask', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='alert_policy', full_name='google.monitoring.v3.UpdateAlertPolicyRequest.alert_policy', index=1, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=584, + serialized_end=716, +) + + +_DELETEALERTPOLICYREQUEST = _descriptor.Descriptor( + name='DeleteAlertPolicyRequest', + full_name='google.monitoring.v3.DeleteAlertPolicyRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.DeleteAlertPolicyRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=718, + serialized_end=758, +) + +_CREATEALERTPOLICYREQUEST.fields_by_name['alert_policy'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2._ALERTPOLICY +_LISTALERTPOLICIESRESPONSE.fields_by_name['alert_policies'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2._ALERTPOLICY +_UPDATEALERTPOLICYREQUEST.fields_by_name['update_mask'].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK +_UPDATEALERTPOLICYREQUEST.fields_by_name['alert_policy'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2._ALERTPOLICY +DESCRIPTOR.message_types_by_name['CreateAlertPolicyRequest'] = _CREATEALERTPOLICYREQUEST +DESCRIPTOR.message_types_by_name['GetAlertPolicyRequest'] = _GETALERTPOLICYREQUEST +DESCRIPTOR.message_types_by_name['ListAlertPoliciesRequest'] = _LISTALERTPOLICIESREQUEST +DESCRIPTOR.message_types_by_name['ListAlertPoliciesResponse'] = _LISTALERTPOLICIESRESPONSE +DESCRIPTOR.message_types_by_name['UpdateAlertPolicyRequest'] = _UPDATEALERTPOLICYREQUEST +DESCRIPTOR.message_types_by_name['DeleteAlertPolicyRequest'] = _DELETEALERTPOLICYREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +CreateAlertPolicyRequest = _reflection.GeneratedProtocolMessageType('CreateAlertPolicyRequest', (_message.Message,), dict( + DESCRIPTOR = _CREATEALERTPOLICYREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.alert_service_pb2' + , + __doc__ = """The protocol for the ``CreateAlertPolicy`` request. + + + Attributes: + name: + The project in which to create the alerting policy. The format + is ``projects/[PROJECT_ID]``. Note that this field names the + parent container in which the alerting policy will be written, + not the name of the created policy. The alerting policy that + is returned will have a name that contains a normalized + representation of this name as a prefix but adds a suffix of + the form ``/alertPolicies/[POLICY_ID]``, identifying the + policy in the container. + alert_policy: + The requested alerting policy. You should omit the ``name`` + field in this policy. The name will be returned in the new + policy, including a new [ALERT\_POLICY\_ID] value. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateAlertPolicyRequest) + )) +_sym_db.RegisterMessage(CreateAlertPolicyRequest) + +GetAlertPolicyRequest = _reflection.GeneratedProtocolMessageType('GetAlertPolicyRequest', (_message.Message,), dict( + DESCRIPTOR = _GETALERTPOLICYREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.alert_service_pb2' + , + __doc__ = """The protocol for the ``GetAlertPolicy`` request. + + + Attributes: + name: + The alerting policy to retrieve. The format is :: + projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetAlertPolicyRequest) + )) +_sym_db.RegisterMessage(GetAlertPolicyRequest) + +ListAlertPoliciesRequest = _reflection.GeneratedProtocolMessageType('ListAlertPoliciesRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTALERTPOLICIESREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.alert_service_pb2' + , + __doc__ = """The protocol for the ``ListAlertPolicies`` request. + + + Attributes: + name: + The project whose alert policies are to be listed. The format + is :: projects/[PROJECT_ID] Note that this field names + the parent container in which the alerting policies to be + listed are stored. To retrieve a single alerting policy by + name, use the [GetAlertPolicy][google.monitoring.v3.AlertPolic + yService.GetAlertPolicy] operation, instead. + filter: + If provided, this field specifies the criteria that must be + met by alert policies to be included in the response. For + more details, see `sorting and filtering + `__. + order_by: + A comma-separated list of fields by which to sort the result. + Supports the same set of field references as the ``filter`` + field. Entries can be prefixed with a minus sign to sort by + the field in descending order. For more details, see `sorting + and filtering `__. + page_size: + The maximum number of results to return in a single response. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return more + results from the previous method call. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListAlertPoliciesRequest) + )) +_sym_db.RegisterMessage(ListAlertPoliciesRequest) + +ListAlertPoliciesResponse = _reflection.GeneratedProtocolMessageType('ListAlertPoliciesResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTALERTPOLICIESRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.alert_service_pb2' + , + __doc__ = """The protocol for the ``ListAlertPolicies`` response. + + + Attributes: + alert_policies: + The returned alert policies. + next_page_token: + If there might be more results than were returned, then this + field is set to a non-empty value. To see the additional + results, use that value as ``pageToken`` in the next call to + this method. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListAlertPoliciesResponse) + )) +_sym_db.RegisterMessage(ListAlertPoliciesResponse) + +UpdateAlertPolicyRequest = _reflection.GeneratedProtocolMessageType('UpdateAlertPolicyRequest', (_message.Message,), dict( + DESCRIPTOR = _UPDATEALERTPOLICYREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.alert_service_pb2' + , + __doc__ = """The protocol for the ``UpdateAlertPolicy`` request. + + + Attributes: + update_mask: + Optional. A list of alerting policy field names. If this field + is not empty, each listed field in the existing alerting + policy is set to the value of the corresponding field in the + supplied policy (``alert_policy``), or to the field's default + value if the field is not in the supplied alerting policy. + Fields not listed retain their previous value. Examples of + valid field masks include ``display_name``, ``documentation``, + ``documentation.content``, ``documentation.mime_type``, + ``user_labels``, ``user_label.nameofkey``, ``enabled``, + ``conditions``, ``combiner``, etc. If this field is empty, + then the supplied alerting policy replaces the existing + policy. It is the same as deleting the existing policy and + adding the supplied policy, except for the following: - The + new policy will have the same ``[ALERT_POLICY_ID]`` as the + former policy. This gives you continuity with the former + policy in your notifications and incidents. - Conditions + in the new policy will keep their former ``[CONDITION_ID]`` + if the supplied condition includes the ``name`` field with + that ``[CONDITION_ID]``. If the supplied condition omits + the ``name`` field, then a new ``[CONDITION_ID]`` is created. + alert_policy: + Required. The updated alerting policy or the updated values + for the fields listed in ``update_mask``. If ``update_mask`` + is not empty, any fields in this policy that are not in + ``update_mask`` are ignored. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UpdateAlertPolicyRequest) + )) +_sym_db.RegisterMessage(UpdateAlertPolicyRequest) + +DeleteAlertPolicyRequest = _reflection.GeneratedProtocolMessageType('DeleteAlertPolicyRequest', (_message.Message,), dict( + DESCRIPTOR = _DELETEALERTPOLICYREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.alert_service_pb2' + , + __doc__ = """The protocol for the ``DeleteAlertPolicy`` request. + + + Attributes: + name: + The alerting policy to delete. The format is: :: + projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] For + more information, see + [AlertPolicy][google.monitoring.v3.AlertPolicy]. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.DeleteAlertPolicyRequest) + )) +_sym_db.RegisterMessage(DeleteAlertPolicyRequest) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\021AlertServiceProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) + +_ALERTPOLICYSERVICE = _descriptor.ServiceDescriptor( + name='AlertPolicyService', + full_name='google.monitoring.v3.AlertPolicyService', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=761, + serialized_end=1575, + methods=[ + _descriptor.MethodDescriptor( + name='ListAlertPolicies', + full_name='google.monitoring.v3.AlertPolicyService.ListAlertPolicies', + index=0, + containing_service=None, + input_type=_LISTALERTPOLICIESREQUEST, + output_type=_LISTALERTPOLICIESRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002%\022#/v3/{name=projects/*}/alertPolicies')), + ), + _descriptor.MethodDescriptor( + name='GetAlertPolicy', + full_name='google.monitoring.v3.AlertPolicyService.GetAlertPolicy', + index=1, + containing_service=None, + input_type=_GETALERTPOLICYREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2._ALERTPOLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002\'\022%/v3/{name=projects/*/alertPolicies/*}')), + ), + _descriptor.MethodDescriptor( + name='CreateAlertPolicy', + full_name='google.monitoring.v3.AlertPolicyService.CreateAlertPolicy', + index=2, + containing_service=None, + input_type=_CREATEALERTPOLICYREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2._ALERTPOLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0023\"#/v3/{name=projects/*}/alertPolicies:\014alert_policy')), + ), + _descriptor.MethodDescriptor( + name='DeleteAlertPolicy', + full_name='google.monitoring.v3.AlertPolicyService.DeleteAlertPolicy', + index=3, + containing_service=None, + input_type=_DELETEALERTPOLICYREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002\'*%/v3/{name=projects/*/alertPolicies/*}')), + ), + _descriptor.MethodDescriptor( + name='UpdateAlertPolicy', + full_name='google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy', + index=4, + containing_service=None, + input_type=_UPDATEALERTPOLICYREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2._ALERTPOLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002B22/v3/{alert_policy.name=projects/*/alertPolicies/*}:\014alert_policy')), + ), +]) +_sym_db.RegisterServiceDescriptor(_ALERTPOLICYSERVICE) + +DESCRIPTOR.services_by_name['AlertPolicyService'] = _ALERTPOLICYSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/alert_service_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/alert_service_pb2_grpc.py new file mode 100644 index 000000000000..c9248fdbc9e1 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/alert_service_pb2_grpc.py @@ -0,0 +1,135 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.monitoring_v3.proto import alert_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class AlertPolicyServiceStub(object): + """The AlertPolicyService API is used to manage (list, create, delete, + edit) alert policies in Stackdriver Monitoring. An alerting policy is + a description of the conditions under which some aspect of your + system is considered to be "unhealthy" and the ways to notify + people or services about this state. In addition to using this API, alert + policies can also be managed through + [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), + which can be reached by clicking the "Monitoring" tab in + [Cloud Console](https://console.cloud.google.com/). + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListAlertPolicies = channel.unary_unary( + '/google.monitoring.v3.AlertPolicyService/ListAlertPolicies', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.ListAlertPoliciesRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.ListAlertPoliciesResponse.FromString, + ) + self.GetAlertPolicy = channel.unary_unary( + '/google.monitoring.v3.AlertPolicyService/GetAlertPolicy', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.GetAlertPolicyRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.AlertPolicy.FromString, + ) + self.CreateAlertPolicy = channel.unary_unary( + '/google.monitoring.v3.AlertPolicyService/CreateAlertPolicy', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.CreateAlertPolicyRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.AlertPolicy.FromString, + ) + self.DeleteAlertPolicy = channel.unary_unary( + '/google.monitoring.v3.AlertPolicyService/DeleteAlertPolicy', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.DeleteAlertPolicyRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.UpdateAlertPolicy = channel.unary_unary( + '/google.monitoring.v3.AlertPolicyService/UpdateAlertPolicy', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.UpdateAlertPolicyRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.AlertPolicy.FromString, + ) + + +class AlertPolicyServiceServicer(object): + """The AlertPolicyService API is used to manage (list, create, delete, + edit) alert policies in Stackdriver Monitoring. An alerting policy is + a description of the conditions under which some aspect of your + system is considered to be "unhealthy" and the ways to notify + people or services about this state. In addition to using this API, alert + policies can also be managed through + [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), + which can be reached by clicking the "Monitoring" tab in + [Cloud Console](https://console.cloud.google.com/). + """ + + def ListAlertPolicies(self, request, context): + """Lists the existing alerting policies for the project. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetAlertPolicy(self, request, context): + """Gets a single alerting policy. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateAlertPolicy(self, request, context): + """Creates a new alerting policy. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def DeleteAlertPolicy(self, request, context): + """Deletes an alerting policy. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def UpdateAlertPolicy(self, request, context): + """Updates an alerting policy. You can either replace the entire policy with + a new one or replace only certain fields in the current alerting policy by + specifying the fields to be updated via `updateMask`. Returns the + updated alerting policy. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_AlertPolicyServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'ListAlertPolicies': grpc.unary_unary_rpc_method_handler( + servicer.ListAlertPolicies, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.ListAlertPoliciesRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.ListAlertPoliciesResponse.SerializeToString, + ), + 'GetAlertPolicy': grpc.unary_unary_rpc_method_handler( + servicer.GetAlertPolicy, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.GetAlertPolicyRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.AlertPolicy.SerializeToString, + ), + 'CreateAlertPolicy': grpc.unary_unary_rpc_method_handler( + servicer.CreateAlertPolicy, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.CreateAlertPolicyRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.AlertPolicy.SerializeToString, + ), + 'DeleteAlertPolicy': grpc.unary_unary_rpc_method_handler( + servicer.DeleteAlertPolicy, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.DeleteAlertPolicyRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'UpdateAlertPolicy': grpc.unary_unary_rpc_method_handler( + servicer.UpdateAlertPolicy, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__service__pb2.UpdateAlertPolicyRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_alert__pb2.AlertPolicy.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.monitoring.v3.AlertPolicyService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/monitoring/google/cloud/monitoring_v3/proto/common_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/common_pb2.py new file mode 100644 index 000000000000..40805bc689b2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/common_pb2.py @@ -0,0 +1,574 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/common.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf.internal import enum_type_wrapper +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 +from google.protobuf import descriptor_pb2 +# @@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 distribution_pb2 as google_dot_api_dot_distribution__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/common.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n-google/cloud/monitoring_v3/proto/common.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a\x1dgoogle/api/distribution.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xaa\x01\n\nTypedValue\x12\x14\n\nbool_value\x18\x01 \x01(\x08H\x00\x12\x15\n\x0bint64_value\x18\x02 \x01(\x03H\x00\x12\x16\n\x0c\x64ouble_value\x18\x03 \x01(\x01H\x00\x12\x16\n\x0cstring_value\x18\x04 \x01(\tH\x00\x12\x36\n\x12\x64istribution_value\x18\x05 \x01(\x0b\x32\x18.google.api.DistributionH\x00\x42\x07\n\x05value\"l\n\x0cTimeInterval\x12,\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xad\x07\n\x0b\x41ggregation\x12\x33\n\x10\x61lignment_period\x18\x01 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x45\n\x12per_series_aligner\x18\x02 \x01(\x0e\x32).google.monitoring.v3.Aggregation.Aligner\x12G\n\x14\x63ross_series_reducer\x18\x04 \x01(\x0e\x32).google.monitoring.v3.Aggregation.Reducer\x12\x17\n\x0fgroup_by_fields\x18\x05 \x03(\t\"\x8b\x03\n\x07\x41ligner\x12\x0e\n\nALIGN_NONE\x10\x00\x12\x0f\n\x0b\x41LIGN_DELTA\x10\x01\x12\x0e\n\nALIGN_RATE\x10\x02\x12\x15\n\x11\x41LIGN_INTERPOLATE\x10\x03\x12\x14\n\x10\x41LIGN_NEXT_OLDER\x10\x04\x12\r\n\tALIGN_MIN\x10\n\x12\r\n\tALIGN_MAX\x10\x0b\x12\x0e\n\nALIGN_MEAN\x10\x0c\x12\x0f\n\x0b\x41LIGN_COUNT\x10\r\x12\r\n\tALIGN_SUM\x10\x0e\x12\x10\n\x0c\x41LIGN_STDDEV\x10\x0f\x12\x14\n\x10\x41LIGN_COUNT_TRUE\x10\x10\x12\x15\n\x11\x41LIGN_COUNT_FALSE\x10\x18\x12\x17\n\x13\x41LIGN_FRACTION_TRUE\x10\x11\x12\x17\n\x13\x41LIGN_PERCENTILE_99\x10\x12\x12\x17\n\x13\x41LIGN_PERCENTILE_95\x10\x13\x12\x17\n\x13\x41LIGN_PERCENTILE_50\x10\x14\x12\x17\n\x13\x41LIGN_PERCENTILE_05\x10\x15\x12\x18\n\x14\x41LIGN_PERCENT_CHANGE\x10\x17\"\xb1\x02\n\x07Reducer\x12\x0f\n\x0bREDUCE_NONE\x10\x00\x12\x0f\n\x0bREDUCE_MEAN\x10\x01\x12\x0e\n\nREDUCE_MIN\x10\x02\x12\x0e\n\nREDUCE_MAX\x10\x03\x12\x0e\n\nREDUCE_SUM\x10\x04\x12\x11\n\rREDUCE_STDDEV\x10\x05\x12\x10\n\x0cREDUCE_COUNT\x10\x06\x12\x15\n\x11REDUCE_COUNT_TRUE\x10\x07\x12\x16\n\x12REDUCE_COUNT_FALSE\x10\x0f\x12\x18\n\x14REDUCE_FRACTION_TRUE\x10\x08\x12\x18\n\x14REDUCE_PERCENTILE_99\x10\t\x12\x18\n\x14REDUCE_PERCENTILE_95\x10\n\x12\x18\n\x14REDUCE_PERCENTILE_50\x10\x0b\x12\x18\n\x14REDUCE_PERCENTILE_05\x10\x0c*\x9e\x01\n\x0e\x43omparisonType\x12\x1a\n\x16\x43OMPARISON_UNSPECIFIED\x10\x00\x12\x11\n\rCOMPARISON_GT\x10\x01\x12\x11\n\rCOMPARISON_GE\x10\x02\x12\x11\n\rCOMPARISON_LT\x10\x03\x12\x11\n\rCOMPARISON_LE\x10\x04\x12\x11\n\rCOMPARISON_EQ\x10\x05\x12\x11\n\rCOMPARISON_NE\x10\x06*]\n\x0bServiceTier\x12\x1c\n\x18SERVICE_TIER_UNSPECIFIED\x10\x00\x12\x16\n\x12SERVICE_TIER_BASIC\x10\x01\x12\x18\n\x14SERVICE_TIER_PREMIUM\x10\x02\x42\xa3\x01\n\x18\x63om.google.monitoring.v3B\x0b\x43ommonProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_distribution__pb2.DESCRIPTOR,google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) + +_COMPARISONTYPE = _descriptor.EnumDescriptor( + name='ComparisonType', + full_name='google.monitoring.v3.ComparisonType', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='COMPARISON_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='COMPARISON_GT', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='COMPARISON_GE', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='COMPARISON_LT', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='COMPARISON_LE', index=4, number=4, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='COMPARISON_EQ', index=5, number=5, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='COMPARISON_NE', index=6, number=6, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1425, + serialized_end=1583, +) +_sym_db.RegisterEnumDescriptor(_COMPARISONTYPE) + +ComparisonType = enum_type_wrapper.EnumTypeWrapper(_COMPARISONTYPE) +_SERVICETIER = _descriptor.EnumDescriptor( + name='ServiceTier', + full_name='google.monitoring.v3.ServiceTier', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='SERVICE_TIER_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SERVICE_TIER_BASIC', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SERVICE_TIER_PREMIUM', index=2, number=2, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1585, + serialized_end=1678, +) +_sym_db.RegisterEnumDescriptor(_SERVICETIER) + +ServiceTier = enum_type_wrapper.EnumTypeWrapper(_SERVICETIER) +COMPARISON_UNSPECIFIED = 0 +COMPARISON_GT = 1 +COMPARISON_GE = 2 +COMPARISON_LT = 3 +COMPARISON_LE = 4 +COMPARISON_EQ = 5 +COMPARISON_NE = 6 +SERVICE_TIER_UNSPECIFIED = 0 +SERVICE_TIER_BASIC = 1 +SERVICE_TIER_PREMIUM = 2 + + +_AGGREGATION_ALIGNER = _descriptor.EnumDescriptor( + name='Aligner', + full_name='google.monitoring.v3.Aggregation.Aligner', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='ALIGN_NONE', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_DELTA', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_RATE', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_INTERPOLATE', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_NEXT_OLDER', index=4, number=4, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_MIN', index=5, number=10, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_MAX', index=6, number=11, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_MEAN', index=7, number=12, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_COUNT', index=8, number=13, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_SUM', index=9, number=14, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_STDDEV', index=10, number=15, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_COUNT_TRUE', index=11, number=16, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_COUNT_FALSE', index=12, number=24, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_FRACTION_TRUE', index=13, number=17, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_PERCENTILE_99', index=14, number=18, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_PERCENTILE_95', index=15, number=19, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_PERCENTILE_50', index=16, number=20, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_PERCENTILE_05', index=17, number=21, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALIGN_PERCENT_CHANGE', index=18, number=23, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=719, + serialized_end=1114, +) +_sym_db.RegisterEnumDescriptor(_AGGREGATION_ALIGNER) + +_AGGREGATION_REDUCER = _descriptor.EnumDescriptor( + name='Reducer', + full_name='google.monitoring.v3.Aggregation.Reducer', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='REDUCE_NONE', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_MEAN', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_MIN', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_MAX', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_SUM', index=4, number=4, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_STDDEV', index=5, number=5, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_COUNT', index=6, number=6, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_COUNT_TRUE', index=7, number=7, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_COUNT_FALSE', index=8, number=15, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_FRACTION_TRUE', index=9, number=8, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_PERCENTILE_99', index=10, number=9, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_PERCENTILE_95', index=11, number=10, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_PERCENTILE_50', index=12, number=11, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='REDUCE_PERCENTILE_05', index=13, number=12, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1117, + serialized_end=1422, +) +_sym_db.RegisterEnumDescriptor(_AGGREGATION_REDUCER) + + +_TYPEDVALUE = _descriptor.Descriptor( + name='TypedValue', + full_name='google.monitoring.v3.TypedValue', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='bool_value', full_name='google.monitoring.v3.TypedValue.bool_value', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='int64_value', full_name='google.monitoring.v3.TypedValue.int64_value', index=1, + number=2, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='double_value', full_name='google.monitoring.v3.TypedValue.double_value', index=2, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='string_value', full_name='google.monitoring.v3.TypedValue.string_value', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='distribution_value', full_name='google.monitoring.v3.TypedValue.distribution_value', index=4, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='value', full_name='google.monitoring.v3.TypedValue.value', + index=0, containing_type=None, fields=[]), + ], + serialized_start=198, + serialized_end=368, +) + + +_TIMEINTERVAL = _descriptor.Descriptor( + name='TimeInterval', + full_name='google.monitoring.v3.TimeInterval', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='end_time', full_name='google.monitoring.v3.TimeInterval.end_time', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='start_time', full_name='google.monitoring.v3.TimeInterval.start_time', index=1, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=370, + serialized_end=478, +) + + +_AGGREGATION = _descriptor.Descriptor( + name='Aggregation', + full_name='google.monitoring.v3.Aggregation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='alignment_period', full_name='google.monitoring.v3.Aggregation.alignment_period', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='per_series_aligner', full_name='google.monitoring.v3.Aggregation.per_series_aligner', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='cross_series_reducer', full_name='google.monitoring.v3.Aggregation.cross_series_reducer', index=2, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='group_by_fields', full_name='google.monitoring.v3.Aggregation.group_by_fields', index=3, + number=5, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + _AGGREGATION_ALIGNER, + _AGGREGATION_REDUCER, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=481, + serialized_end=1422, +) + +_TYPEDVALUE.fields_by_name['distribution_value'].message_type = google_dot_api_dot_distribution__pb2._DISTRIBUTION +_TYPEDVALUE.oneofs_by_name['value'].fields.append( + _TYPEDVALUE.fields_by_name['bool_value']) +_TYPEDVALUE.fields_by_name['bool_value'].containing_oneof = _TYPEDVALUE.oneofs_by_name['value'] +_TYPEDVALUE.oneofs_by_name['value'].fields.append( + _TYPEDVALUE.fields_by_name['int64_value']) +_TYPEDVALUE.fields_by_name['int64_value'].containing_oneof = _TYPEDVALUE.oneofs_by_name['value'] +_TYPEDVALUE.oneofs_by_name['value'].fields.append( + _TYPEDVALUE.fields_by_name['double_value']) +_TYPEDVALUE.fields_by_name['double_value'].containing_oneof = _TYPEDVALUE.oneofs_by_name['value'] +_TYPEDVALUE.oneofs_by_name['value'].fields.append( + _TYPEDVALUE.fields_by_name['string_value']) +_TYPEDVALUE.fields_by_name['string_value'].containing_oneof = _TYPEDVALUE.oneofs_by_name['value'] +_TYPEDVALUE.oneofs_by_name['value'].fields.append( + _TYPEDVALUE.fields_by_name['distribution_value']) +_TYPEDVALUE.fields_by_name['distribution_value'].containing_oneof = _TYPEDVALUE.oneofs_by_name['value'] +_TIMEINTERVAL.fields_by_name['end_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_TIMEINTERVAL.fields_by_name['start_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_AGGREGATION.fields_by_name['alignment_period'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_AGGREGATION.fields_by_name['per_series_aligner'].enum_type = _AGGREGATION_ALIGNER +_AGGREGATION.fields_by_name['cross_series_reducer'].enum_type = _AGGREGATION_REDUCER +_AGGREGATION_ALIGNER.containing_type = _AGGREGATION +_AGGREGATION_REDUCER.containing_type = _AGGREGATION +DESCRIPTOR.message_types_by_name['TypedValue'] = _TYPEDVALUE +DESCRIPTOR.message_types_by_name['TimeInterval'] = _TIMEINTERVAL +DESCRIPTOR.message_types_by_name['Aggregation'] = _AGGREGATION +DESCRIPTOR.enum_types_by_name['ComparisonType'] = _COMPARISONTYPE +DESCRIPTOR.enum_types_by_name['ServiceTier'] = _SERVICETIER +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +TypedValue = _reflection.GeneratedProtocolMessageType('TypedValue', (_message.Message,), dict( + DESCRIPTOR = _TYPEDVALUE, + __module__ = 'google.cloud.monitoring_v3.proto.common_pb2' + , + __doc__ = """A single strongly-typed value. + + + Attributes: + value: + The typed value field. + bool_value: + A Boolean value: ``true`` or ``false``. + int64_value: + A 64-bit integer. Its range is approximately ±9.2x1018. + double_value: + A 64-bit double-precision floating-point number. Its magnitude + is approximately ±10±300 and it has 16 significant digits of + precision. + string_value: + A variable-length string value. + distribution_value: + A distribution value. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.TypedValue) + )) +_sym_db.RegisterMessage(TypedValue) + +TimeInterval = _reflection.GeneratedProtocolMessageType('TimeInterval', (_message.Message,), dict( + DESCRIPTOR = _TIMEINTERVAL, + __module__ = 'google.cloud.monitoring_v3.proto.common_pb2' + , + __doc__ = """A time interval extending just after a start time through an end time. + If the start time is the same as the end time, then the interval + represents a single point in time. + + + Attributes: + end_time: + Required. The end of the time interval. + start_time: + Optional. The beginning of the time interval. The default + value for the start time is the end time. The start time must + not be later than the end time. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.TimeInterval) + )) +_sym_db.RegisterMessage(TimeInterval) + +Aggregation = _reflection.GeneratedProtocolMessageType('Aggregation', (_message.Message,), dict( + DESCRIPTOR = _AGGREGATION, + __module__ = 'google.cloud.monitoring_v3.proto.common_pb2' + , + __doc__ = """Describes how to combine multiple time series to provide different views + of the data. Aggregation consists of an alignment step on individual + time series (``alignment_period`` and ``per_series_aligner``) followed + by an optional reduction step of the data across the aligned time series + (``cross_series_reducer`` and ``group_by_fields``). For more details, + see `Aggregation `__. + + + Attributes: + alignment_period: + The alignment period for per-[time + series][google.monitoring.v3.TimeSeries] alignment. If + present, ``alignmentPeriod`` must be at least 60 seconds. + After per-time series alignment, each time series will contain + data points only on the period boundaries. If + ``perSeriesAligner`` is not specified or equals + ``ALIGN_NONE``, then this field is ignored. If + ``perSeriesAligner`` is specified and does not equal + ``ALIGN_NONE``, then this field must be defined; otherwise an + error is returned. + per_series_aligner: + The approach to be used to align individual time series. Not + all alignment functions may be applied to all time series, + depending on the metric type and value type of the original + time series. Alignment may change the metric type or the value + type of the time series. Time series data must be aligned in + order to perform cross-time series reduction. If + ``crossSeriesReducer`` is specified, then ``perSeriesAligner`` + must be specified and not equal ``ALIGN_NONE`` and + ``alignmentPeriod`` must be specified; otherwise, an error is + returned. + cross_series_reducer: + The approach to be used to combine time series. Not all + reducer functions may be applied to all time series, depending + on the metric type and the value type of the original time + series. Reduction may change the metric type of value type of + the time series. Time series data must be aligned in order to + perform cross-time series reduction. If ``crossSeriesReducer`` + is specified, then ``perSeriesAligner`` must be specified and + not equal ``ALIGN_NONE`` and ``alignmentPeriod`` must be + specified; otherwise, an error is returned. + group_by_fields: + The set of fields to preserve when ``crossSeriesReducer`` is + specified. The ``groupByFields`` determine how the time series + are partitioned into subsets prior to applying the aggregation + function. Each subset contains time series that have the same + value for each of the grouping fields. Each individual time + series is a member of exactly one subset. The + ``crossSeriesReducer`` is applied to each subset of time + series. It is not possible to reduce across different resource + types, so this field implicitly contains ``resource.type``. + Fields not specified in ``groupByFields`` are aggregated away. + If ``groupByFields`` is not specified and all the time series + have the same resource type, then the time series are + aggregated into a single output time series. If + ``crossSeriesReducer`` is not defined, this field is ignored. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.Aggregation) + )) +_sym_db.RegisterMessage(Aggregation) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\013CommonProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/common_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/common_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/common_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/group_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/group_pb2.py new file mode 100644 index 000000000000..ea312128072a --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/group_pb2.py @@ -0,0 +1,152 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/group.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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/group.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n,google/cloud/monitoring_v3/proto/group.proto\x12\x14google.monitoring.v3\"d\n\x05Group\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\x12\x13\n\x0bparent_name\x18\x03 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x05 \x01(\t\x12\x12\n\nis_cluster\x18\x06 \x01(\x08\x42\xa2\x01\n\x18\x63om.google.monitoring.v3B\nGroupProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') +) + + + + +_GROUP = _descriptor.Descriptor( + name='Group', + full_name='google.monitoring.v3.Group', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.Group.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.Group.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='parent_name', full_name='google.monitoring.v3.Group.parent_name', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.Group.filter', index=3, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='is_cluster', full_name='google.monitoring.v3.Group.is_cluster', index=4, + number=6, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=70, + serialized_end=170, +) + +DESCRIPTOR.message_types_by_name['Group'] = _GROUP +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Group = _reflection.GeneratedProtocolMessageType('Group', (_message.Message,), dict( + DESCRIPTOR = _GROUP, + __module__ = 'google.cloud.monitoring_v3.proto.group_pb2' + , + __doc__ = """The description of a dynamic collection of monitored resources. Each + group has a filter that is matched against monitored resources and their + associated metadata. If a group's filter matches an available monitored + resource, then that resource is a member of that group. Groups can + contain any number of monitored resources, and each monitored resource + can be a member of any number of groups. + + Groups can be nested in parent-child hierarchies. The ``parentName`` + field identifies an optional parent for each group. If a group has a + parent, then the only monitored resources available to be matched by the + group's filter are the resources contained in the parent group. In other + words, a group contains the monitored resources that match its filter + and the filters of all the group's ancestors. A group without a parent + can contain any monitored resource. + + For example, consider an infrastructure running a set of instances with + two user-defined tags: ``"environment"`` and ``"role"``. A parent group + has a filter, ``environment="production"``. A child of that parent group + has a filter, ``role="transcoder"``. The parent group contains all + instances in the production environment, regardless of their roles. The + child group contains instances that have the transcoder role *and* are + in the production environment. + + The monitored resources contained in a group can change at any moment, + depending on what resources exist and what filters are associated with + the group and its ancestors. + + + Attributes: + name: + Output only. The name of this group. The format is + ``"projects/{project_id_or_number}/groups/{group_id}"``. When + creating a group, this field is ignored and a new name is + created consisting of the project specified in the call to + ``CreateGroup`` and a unique ``{group_id}`` that is generated + automatically. + display_name: + A user-assigned name for this group, used only for display + purposes. + parent_name: + The name of the group's parent, if it has one. The format is + ``"projects/{project_id_or_number}/groups/{group_id}"``. For + groups with no parent, ``parentName`` is the empty string, + ``""``. + filter: + The filter used to determine which monitored resources belong + to this group. + is_cluster: + If true, the members of this group are considered to be a + cluster. The system can perform additional analysis on groups + that are clusters. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.Group) + )) +_sym_db.RegisterMessage(Group) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\nGroupProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/group_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/group_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/group_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/group_service_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/group_service_pb2.py new file mode 100644 index 000000000000..7b1b64eb9543 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/group_service_pb2.py @@ -0,0 +1,687 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/group_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 +from google.protobuf import descriptor_pb2 +# @@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 monitored_resource_pb2 as google_dot_api_dot_monitored__resource__pb2 +from google.cloud.monitoring_v3.proto import common_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2 +from google.cloud.monitoring_v3.proto import group_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/group_service.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n4google/cloud/monitoring_v3/proto/group_service.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a#google/api/monitored_resource.proto\x1a-google/cloud/monitoring_v3/proto/common.proto\x1a,google/cloud/monitoring_v3/proto/group.proto\x1a\x1bgoogle/protobuf/empty.proto\"\xad\x01\n\x11ListGroupsRequest\x12\x0c\n\x04name\x18\x07 \x01(\t\x12\x1b\n\x11\x63hildren_of_group\x18\x02 \x01(\tH\x00\x12\x1c\n\x12\x61ncestors_of_group\x18\x03 \x01(\tH\x00\x12\x1e\n\x14\x64\x65scendants_of_group\x18\x04 \x01(\tH\x00\x12\x11\n\tpage_size\x18\x05 \x01(\x05\x12\x12\n\npage_token\x18\x06 \x01(\tB\x08\n\x06\x66ilter\"Y\n\x12ListGroupsResponse\x12*\n\x05group\x18\x01 \x03(\x0b\x32\x1b.google.monitoring.v3.Group\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x1f\n\x0fGetGroupRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"e\n\x12\x43reateGroupRequest\x12\x0c\n\x04name\x18\x04 \x01(\t\x12*\n\x05group\x18\x02 \x01(\x0b\x32\x1b.google.monitoring.v3.Group\x12\x15\n\rvalidate_only\x18\x03 \x01(\x08\"W\n\x12UpdateGroupRequest\x12*\n\x05group\x18\x02 \x01(\x0b\x32\x1b.google.monitoring.v3.Group\x12\x15\n\rvalidate_only\x18\x03 \x01(\x08\"\"\n\x12\x44\x65leteGroupRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"\x94\x01\n\x17ListGroupMembersRequest\x12\x0c\n\x04name\x18\x07 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x05 \x01(\t\x12\x34\n\x08interval\x18\x06 \x01(\x0b\x32\".google.monitoring.v3.TimeInterval\"w\n\x18ListGroupMembersResponse\x12.\n\x07members\x18\x01 \x03(\x0b\x32\x1d.google.api.MonitoredResource\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\x12\x12\n\ntotal_size\x18\x03 \x01(\x05\x32\xbb\x06\n\x0cGroupService\x12\x85\x01\n\nListGroups\x12\'.google.monitoring.v3.ListGroupsRequest\x1a(.google.monitoring.v3.ListGroupsResponse\"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/v3/{name=projects/*}/groups\x12v\n\x08GetGroup\x12%.google.monitoring.v3.GetGroupRequest\x1a\x1b.google.monitoring.v3.Group\"&\x82\xd3\xe4\x93\x02 \x12\x1e/v3/{name=projects/*/groups/*}\x12\x81\x01\n\x0b\x43reateGroup\x12(.google.monitoring.v3.CreateGroupRequest\x1a\x1b.google.monitoring.v3.Group\"+\x82\xd3\xe4\x93\x02%\"\x1c/v3/{name=projects/*}/groups:\x05group\x12\x89\x01\n\x0bUpdateGroup\x12(.google.monitoring.v3.UpdateGroupRequest\x1a\x1b.google.monitoring.v3.Group\"3\x82\xd3\xe4\x93\x02-\x1a$/v3/{group.name=projects/*/groups/*}:\x05group\x12w\n\x0b\x44\x65leteGroup\x12(.google.monitoring.v3.DeleteGroupRequest\x1a\x16.google.protobuf.Empty\"&\x82\xd3\xe4\x93\x02 *\x1e/v3/{name=projects/*/groups/*}\x12\xa1\x01\n\x10ListGroupMembers\x12-.google.monitoring.v3.ListGroupMembersRequest\x1a..google.monitoring.v3.ListGroupMembersResponse\".\x82\xd3\xe4\x93\x02(\x12&/v3/{name=projects/*/groups/*}/membersB\xa9\x01\n\x18\x63om.google.monitoring.v3B\x11GroupServiceProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_monitored__resource__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,]) + + + + +_LISTGROUPSREQUEST = _descriptor.Descriptor( + name='ListGroupsRequest', + full_name='google.monitoring.v3.ListGroupsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListGroupsRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='children_of_group', full_name='google.monitoring.v3.ListGroupsRequest.children_of_group', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='ancestors_of_group', full_name='google.monitoring.v3.ListGroupsRequest.ancestors_of_group', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='descendants_of_group', full_name='google.monitoring.v3.ListGroupsRequest.descendants_of_group', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListGroupsRequest.page_size', index=4, + number=5, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListGroupsRequest.page_token', index=5, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='filter', full_name='google.monitoring.v3.ListGroupsRequest.filter', + index=0, containing_type=None, fields=[]), + ], + serialized_start=268, + serialized_end=441, +) + + +_LISTGROUPSRESPONSE = _descriptor.Descriptor( + name='ListGroupsResponse', + full_name='google.monitoring.v3.ListGroupsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='group', full_name='google.monitoring.v3.ListGroupsResponse.group', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListGroupsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=443, + serialized_end=532, +) + + +_GETGROUPREQUEST = _descriptor.Descriptor( + name='GetGroupRequest', + full_name='google.monitoring.v3.GetGroupRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetGroupRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=534, + serialized_end=565, +) + + +_CREATEGROUPREQUEST = _descriptor.Descriptor( + name='CreateGroupRequest', + full_name='google.monitoring.v3.CreateGroupRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.CreateGroupRequest.name', index=0, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='group', full_name='google.monitoring.v3.CreateGroupRequest.group', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='validate_only', full_name='google.monitoring.v3.CreateGroupRequest.validate_only', index=2, + number=3, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=567, + serialized_end=668, +) + + +_UPDATEGROUPREQUEST = _descriptor.Descriptor( + name='UpdateGroupRequest', + full_name='google.monitoring.v3.UpdateGroupRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='group', full_name='google.monitoring.v3.UpdateGroupRequest.group', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='validate_only', full_name='google.monitoring.v3.UpdateGroupRequest.validate_only', index=1, + number=3, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=670, + serialized_end=757, +) + + +_DELETEGROUPREQUEST = _descriptor.Descriptor( + name='DeleteGroupRequest', + full_name='google.monitoring.v3.DeleteGroupRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.DeleteGroupRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=759, + serialized_end=793, +) + + +_LISTGROUPMEMBERSREQUEST = _descriptor.Descriptor( + name='ListGroupMembersRequest', + full_name='google.monitoring.v3.ListGroupMembersRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListGroupMembersRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListGroupMembersRequest.page_size', index=1, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListGroupMembersRequest.page_token', index=2, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.ListGroupMembersRequest.filter', index=3, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='interval', full_name='google.monitoring.v3.ListGroupMembersRequest.interval', index=4, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=796, + serialized_end=944, +) + + +_LISTGROUPMEMBERSRESPONSE = _descriptor.Descriptor( + name='ListGroupMembersResponse', + full_name='google.monitoring.v3.ListGroupMembersResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='members', full_name='google.monitoring.v3.ListGroupMembersResponse.members', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListGroupMembersResponse.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='total_size', full_name='google.monitoring.v3.ListGroupMembersResponse.total_size', index=2, + number=3, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=946, + serialized_end=1065, +) + +_LISTGROUPSREQUEST.oneofs_by_name['filter'].fields.append( + _LISTGROUPSREQUEST.fields_by_name['children_of_group']) +_LISTGROUPSREQUEST.fields_by_name['children_of_group'].containing_oneof = _LISTGROUPSREQUEST.oneofs_by_name['filter'] +_LISTGROUPSREQUEST.oneofs_by_name['filter'].fields.append( + _LISTGROUPSREQUEST.fields_by_name['ancestors_of_group']) +_LISTGROUPSREQUEST.fields_by_name['ancestors_of_group'].containing_oneof = _LISTGROUPSREQUEST.oneofs_by_name['filter'] +_LISTGROUPSREQUEST.oneofs_by_name['filter'].fields.append( + _LISTGROUPSREQUEST.fields_by_name['descendants_of_group']) +_LISTGROUPSREQUEST.fields_by_name['descendants_of_group'].containing_oneof = _LISTGROUPSREQUEST.oneofs_by_name['filter'] +_LISTGROUPSRESPONSE.fields_by_name['group'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2._GROUP +_CREATEGROUPREQUEST.fields_by_name['group'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2._GROUP +_UPDATEGROUPREQUEST.fields_by_name['group'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2._GROUP +_LISTGROUPMEMBERSREQUEST.fields_by_name['interval'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._TIMEINTERVAL +_LISTGROUPMEMBERSRESPONSE.fields_by_name['members'].message_type = google_dot_api_dot_monitored__resource__pb2._MONITOREDRESOURCE +DESCRIPTOR.message_types_by_name['ListGroupsRequest'] = _LISTGROUPSREQUEST +DESCRIPTOR.message_types_by_name['ListGroupsResponse'] = _LISTGROUPSRESPONSE +DESCRIPTOR.message_types_by_name['GetGroupRequest'] = _GETGROUPREQUEST +DESCRIPTOR.message_types_by_name['CreateGroupRequest'] = _CREATEGROUPREQUEST +DESCRIPTOR.message_types_by_name['UpdateGroupRequest'] = _UPDATEGROUPREQUEST +DESCRIPTOR.message_types_by_name['DeleteGroupRequest'] = _DELETEGROUPREQUEST +DESCRIPTOR.message_types_by_name['ListGroupMembersRequest'] = _LISTGROUPMEMBERSREQUEST +DESCRIPTOR.message_types_by_name['ListGroupMembersResponse'] = _LISTGROUPMEMBERSRESPONSE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListGroupsRequest = _reflection.GeneratedProtocolMessageType('ListGroupsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTGROUPSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``ListGroup`` request. + + + Attributes: + name: + The project whose groups are to be listed. The format is + ``"projects/{project_id_or_number}"``. + filter: + An optional filter consisting of a single group name. The + filters limit the groups returned based on their parent-child + relationship with the specified group. If no filter is + specified, all groups are returned. + children_of_group: + A group name: + ``"projects/{project_id_or_number}/groups/{group_id}"``. + Returns groups whose ``parentName`` field contains the group + name. If no groups have this parent, the results are empty. + ancestors_of_group: + A group name: + ``"projects/{project_id_or_number}/groups/{group_id}"``. + Returns groups that are ancestors of the specified group. The + groups are returned in order, starting with the immediate + parent and ending with the most distant ancestor. If the + specified group has no immediate parent, the results are + empty. + descendants_of_group: + A group name: + ``"projects/{project_id_or_number}/groups/{group_id}"``. + Returns the descendants of the specified group. This is a + superset of the results returned by the ``childrenOfGroup`` + filter, and includes children-of-children, and so forth. + page_size: + A positive number that is the maximum number of results to + return. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return + additional results from the previous method call. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListGroupsRequest) + )) +_sym_db.RegisterMessage(ListGroupsRequest) + +ListGroupsResponse = _reflection.GeneratedProtocolMessageType('ListGroupsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTGROUPSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``ListGroups`` response. + + + Attributes: + group: + The groups that match the specified filters. + next_page_token: + If there are more results than have been returned, then this + field is set to a non-empty value. To see the additional + results, use that value as ``pageToken`` in the next call to + this method. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListGroupsResponse) + )) +_sym_db.RegisterMessage(ListGroupsResponse) + +GetGroupRequest = _reflection.GeneratedProtocolMessageType('GetGroupRequest', (_message.Message,), dict( + DESCRIPTOR = _GETGROUPREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``GetGroup`` request. + + + Attributes: + name: + The group to retrieve. The format is + ``"projects/{project_id_or_number}/groups/{group_id}"``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetGroupRequest) + )) +_sym_db.RegisterMessage(GetGroupRequest) + +CreateGroupRequest = _reflection.GeneratedProtocolMessageType('CreateGroupRequest', (_message.Message,), dict( + DESCRIPTOR = _CREATEGROUPREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``CreateGroup`` request. + + + Attributes: + name: + The project in which to create the group. The format is + ``"projects/{project_id_or_number}"``. + group: + A group definition. It is an error to define the ``name`` + field because the system assigns the name. + validate_only: + If true, validate this request but do not create the group. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateGroupRequest) + )) +_sym_db.RegisterMessage(CreateGroupRequest) + +UpdateGroupRequest = _reflection.GeneratedProtocolMessageType('UpdateGroupRequest', (_message.Message,), dict( + DESCRIPTOR = _UPDATEGROUPREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``UpdateGroup`` request. + + + Attributes: + group: + The new definition of the group. All fields of the existing + group, excepting ``name``, are replaced with the corresponding + fields of this group. + validate_only: + If true, validate this request but do not update the existing + group. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UpdateGroupRequest) + )) +_sym_db.RegisterMessage(UpdateGroupRequest) + +DeleteGroupRequest = _reflection.GeneratedProtocolMessageType('DeleteGroupRequest', (_message.Message,), dict( + DESCRIPTOR = _DELETEGROUPREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``DeleteGroup`` request. You can only delete a group if it has no + children. + + + Attributes: + name: + The group to delete. The format is + ``"projects/{project_id_or_number}/groups/{group_id}"``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.DeleteGroupRequest) + )) +_sym_db.RegisterMessage(DeleteGroupRequest) + +ListGroupMembersRequest = _reflection.GeneratedProtocolMessageType('ListGroupMembersRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTGROUPMEMBERSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``ListGroupMembers`` request. + + + Attributes: + name: + The group whose members are listed. The format is + ``"projects/{project_id_or_number}/groups/{group_id}"``. + page_size: + A positive number that is the maximum number of results to + return. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return + additional results from the previous method call. + filter: + An optional `list filter + `__ describing the + members to be returned. The filter may reference the type, + labels, and metadata of monitored resources that comprise the + group. For example, to return only resources representing + Compute Engine VM instances, use this filter: :: + resource.type = "gce_instance" + interval: + An optional time interval for which results should be + returned. Only members that were part of the group during the + specified interval are included in the response. If no + interval is provided then the group membership over the last + minute is returned. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListGroupMembersRequest) + )) +_sym_db.RegisterMessage(ListGroupMembersRequest) + +ListGroupMembersResponse = _reflection.GeneratedProtocolMessageType('ListGroupMembersResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTGROUPMEMBERSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.group_service_pb2' + , + __doc__ = """The ``ListGroupMembers`` response. + + + Attributes: + members: + A set of monitored resources in the group. + next_page_token: + If there are more results than have been returned, then this + field is set to a non-empty value. To see the additional + results, use that value as ``pageToken`` in the next call to + this method. + total_size: + The total number of elements matching this request. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListGroupMembersResponse) + )) +_sym_db.RegisterMessage(ListGroupMembersResponse) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\021GroupServiceProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) + +_GROUPSERVICE = _descriptor.ServiceDescriptor( + name='GroupService', + full_name='google.monitoring.v3.GroupService', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=1068, + serialized_end=1895, + methods=[ + _descriptor.MethodDescriptor( + name='ListGroups', + full_name='google.monitoring.v3.GroupService.ListGroups', + index=0, + containing_service=None, + input_type=_LISTGROUPSREQUEST, + output_type=_LISTGROUPSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002\036\022\034/v3/{name=projects/*}/groups')), + ), + _descriptor.MethodDescriptor( + name='GetGroup', + full_name='google.monitoring.v3.GroupService.GetGroup', + index=1, + containing_service=None, + input_type=_GETGROUPREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2._GROUP, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002 \022\036/v3/{name=projects/*/groups/*}')), + ), + _descriptor.MethodDescriptor( + name='CreateGroup', + full_name='google.monitoring.v3.GroupService.CreateGroup', + index=2, + containing_service=None, + input_type=_CREATEGROUPREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2._GROUP, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002%\"\034/v3/{name=projects/*}/groups:\005group')), + ), + _descriptor.MethodDescriptor( + name='UpdateGroup', + full_name='google.monitoring.v3.GroupService.UpdateGroup', + index=3, + containing_service=None, + input_type=_UPDATEGROUPREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2._GROUP, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002-\032$/v3/{group.name=projects/*/groups/*}:\005group')), + ), + _descriptor.MethodDescriptor( + name='DeleteGroup', + full_name='google.monitoring.v3.GroupService.DeleteGroup', + index=4, + containing_service=None, + input_type=_DELETEGROUPREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002 *\036/v3/{name=projects/*/groups/*}')), + ), + _descriptor.MethodDescriptor( + name='ListGroupMembers', + full_name='google.monitoring.v3.GroupService.ListGroupMembers', + index=5, + containing_service=None, + input_type=_LISTGROUPMEMBERSREQUEST, + output_type=_LISTGROUPMEMBERSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002(\022&/v3/{name=projects/*/groups/*}/members')), + ), +]) +_sym_db.RegisterServiceDescriptor(_GROUPSERVICE) + +DESCRIPTOR.services_by_name['GroupService'] = _GROUPSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/group_service_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/group_service_pb2_grpc.py new file mode 100644 index 000000000000..6f7d4b507fe7 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/group_service_pb2_grpc.py @@ -0,0 +1,156 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.monitoring_v3.proto import group_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2 +from google.cloud.monitoring_v3.proto import group_service_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class GroupServiceStub(object): + """The Group API lets you inspect and manage your + [groups](google.monitoring.v3.Group). + + A group is a named filter that is used to identify + a collection of monitored resources. Groups are typically used to + mirror the physical and/or logical topology of the environment. + Because group membership is computed dynamically, monitored + resources that are started in the future are automatically placed + in matching groups. By using a group to name monitored resources in, + for example, an alert policy, the target of that alert policy is + updated automatically as monitored resources are added and removed + from the infrastructure. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListGroups = channel.unary_unary( + '/google.monitoring.v3.GroupService/ListGroups', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupsResponse.FromString, + ) + self.GetGroup = channel.unary_unary( + '/google.monitoring.v3.GroupService/GetGroup', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.GetGroupRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.Group.FromString, + ) + self.CreateGroup = channel.unary_unary( + '/google.monitoring.v3.GroupService/CreateGroup', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.CreateGroupRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.Group.FromString, + ) + self.UpdateGroup = channel.unary_unary( + '/google.monitoring.v3.GroupService/UpdateGroup', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.UpdateGroupRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.Group.FromString, + ) + self.DeleteGroup = channel.unary_unary( + '/google.monitoring.v3.GroupService/DeleteGroup', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.DeleteGroupRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.ListGroupMembers = channel.unary_unary( + '/google.monitoring.v3.GroupService/ListGroupMembers', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupMembersRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupMembersResponse.FromString, + ) + + +class GroupServiceServicer(object): + """The Group API lets you inspect and manage your + [groups](google.monitoring.v3.Group). + + A group is a named filter that is used to identify + a collection of monitored resources. Groups are typically used to + mirror the physical and/or logical topology of the environment. + Because group membership is computed dynamically, monitored + resources that are started in the future are automatically placed + in matching groups. By using a group to name monitored resources in, + for example, an alert policy, the target of that alert policy is + updated automatically as monitored resources are added and removed + from the infrastructure. + """ + + def ListGroups(self, request, context): + """Lists the existing groups. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetGroup(self, request, context): + """Gets a single group. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateGroup(self, request, context): + """Creates a new group. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def UpdateGroup(self, request, context): + """Updates an existing group. + You can change any group attributes except `name`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def DeleteGroup(self, request, context): + """Deletes an existing group. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ListGroupMembers(self, request, context): + """Lists the monitored resources that are members of a group. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_GroupServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'ListGroups': grpc.unary_unary_rpc_method_handler( + servicer.ListGroups, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupsResponse.SerializeToString, + ), + 'GetGroup': grpc.unary_unary_rpc_method_handler( + servicer.GetGroup, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.GetGroupRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.Group.SerializeToString, + ), + 'CreateGroup': grpc.unary_unary_rpc_method_handler( + servicer.CreateGroup, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.CreateGroupRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.Group.SerializeToString, + ), + 'UpdateGroup': grpc.unary_unary_rpc_method_handler( + servicer.UpdateGroup, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.UpdateGroupRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__pb2.Group.SerializeToString, + ), + 'DeleteGroup': grpc.unary_unary_rpc_method_handler( + servicer.DeleteGroup, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.DeleteGroupRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'ListGroupMembers': grpc.unary_unary_rpc_method_handler( + servicer.ListGroupMembers, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupMembersRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_group__service__pb2.ListGroupMembersResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.monitoring.v3.GroupService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/monitoring/google/cloud/monitoring_v3/proto/metric_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/metric_pb2.py new file mode 100644 index 000000000000..f0d884b53399 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/metric_pb2.py @@ -0,0 +1,216 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/metric.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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import metric_pb2 as google_dot_api_dot_metric__pb2 +from google.api import monitored_resource_pb2 as google_dot_api_dot_monitored__resource__pb2 +from google.cloud.monitoring_v3.proto import common_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/metric.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n-google/cloud/monitoring_v3/proto/metric.proto\x12\x14google.monitoring.v3\x1a\x17google/api/metric.proto\x1a#google/api/monitored_resource.proto\x1a-google/cloud/monitoring_v3/proto/common.proto\"n\n\x05Point\x12\x34\n\x08interval\x18\x01 \x01(\x0b\x32\".google.monitoring.v3.TimeInterval\x12/\n\x05value\x18\x02 \x01(\x0b\x32 .google.monitoring.v3.TypedValue\"\x88\x02\n\nTimeSeries\x12\"\n\x06metric\x18\x01 \x01(\x0b\x32\x12.google.api.Metric\x12/\n\x08resource\x18\x02 \x01(\x0b\x32\x1d.google.api.MonitoredResource\x12<\n\x0bmetric_kind\x18\x03 \x01(\x0e\x32\'.google.api.MetricDescriptor.MetricKind\x12:\n\nvalue_type\x18\x04 \x01(\x0e\x32&.google.api.MetricDescriptor.ValueType\x12+\n\x06points\x18\x05 \x03(\x0b\x32\x1b.google.monitoring.v3.PointB\xa3\x01\n\x18\x63om.google.monitoring.v3B\x0bMetricProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_metric__pb2.DESCRIPTOR,google_dot_api_dot_monitored__resource__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2.DESCRIPTOR,]) + + + + +_POINT = _descriptor.Descriptor( + name='Point', + full_name='google.monitoring.v3.Point', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='interval', full_name='google.monitoring.v3.Point.interval', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='value', full_name='google.monitoring.v3.Point.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=180, + serialized_end=290, +) + + +_TIMESERIES = _descriptor.Descriptor( + name='TimeSeries', + full_name='google.monitoring.v3.TimeSeries', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='metric', full_name='google.monitoring.v3.TimeSeries.metric', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='resource', full_name='google.monitoring.v3.TimeSeries.resource', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='metric_kind', full_name='google.monitoring.v3.TimeSeries.metric_kind', index=2, + number=3, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='value_type', full_name='google.monitoring.v3.TimeSeries.value_type', index=3, + number=4, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='points', full_name='google.monitoring.v3.TimeSeries.points', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=293, + serialized_end=557, +) + +_POINT.fields_by_name['interval'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._TIMEINTERVAL +_POINT.fields_by_name['value'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._TYPEDVALUE +_TIMESERIES.fields_by_name['metric'].message_type = google_dot_api_dot_metric__pb2._METRIC +_TIMESERIES.fields_by_name['resource'].message_type = google_dot_api_dot_monitored__resource__pb2._MONITOREDRESOURCE +_TIMESERIES.fields_by_name['metric_kind'].enum_type = google_dot_api_dot_metric__pb2._METRICDESCRIPTOR_METRICKIND +_TIMESERIES.fields_by_name['value_type'].enum_type = google_dot_api_dot_metric__pb2._METRICDESCRIPTOR_VALUETYPE +_TIMESERIES.fields_by_name['points'].message_type = _POINT +DESCRIPTOR.message_types_by_name['Point'] = _POINT +DESCRIPTOR.message_types_by_name['TimeSeries'] = _TIMESERIES +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), dict( + DESCRIPTOR = _POINT, + __module__ = 'google.cloud.monitoring_v3.proto.metric_pb2' + , + __doc__ = """A single data point in a time series. + + + Attributes: + interval: + The time interval to which the data point applies. For GAUGE + metrics, only the end time of the interval is used. For DELTA + metrics, the start and end time should specify a non-zero + interval, with subsequent points specifying contiguous and + non-overlapping intervals. For CUMULATIVE metrics, the start + and end time should specify a non-zero interval, with + subsequent points specifying the same start time and + increasing end times, until an event resets the cumulative + value to zero and sets a new start time for the following + points. + value: + The value of the data point. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.Point) + )) +_sym_db.RegisterMessage(Point) + +TimeSeries = _reflection.GeneratedProtocolMessageType('TimeSeries', (_message.Message,), dict( + DESCRIPTOR = _TIMESERIES, + __module__ = 'google.cloud.monitoring_v3.proto.metric_pb2' + , + __doc__ = """A collection of data points that describes the time-varying values of a + metric. A time series is identified by a combination of a + fully-specified monitored resource and a fully-specified metric. This + type is used for both listing and creating time series. + + + Attributes: + metric: + The associated metric. A fully-specified metric used to + identify the time series. + resource: + The associated resource. A fully-specified monitored resource + used to identify the time series. + metric_kind: + The metric kind of the time series. When listing time series, + this metric kind might be different from the metric kind of + the associated metric if this time series is an alignment or + reduction of other time series. When creating a time series, + this field is optional. If present, it must be the same as the + metric kind of the associated metric. If the associated + metric's descriptor must be auto-created, then this field + specifies the metric kind of the new descriptor and must be + either ``GAUGE`` (the default) or ``CUMULATIVE``. + value_type: + The value type of the time series. When listing time series, + this value type might be different from the value type of the + associated metric if this time series is an alignment or + reduction of other time series. When creating a time series, + this field is optional. If present, it must be the same as the + type of the data in the ``points`` field. + points: + The data points of this time series. When listing time series, + the order of the points is specified by the list method. When + creating a time series, this field must contain exactly one + point and the point's type must be the same as the value type + of the associated metric. If the associated metric's + descriptor must be auto-created, then the value type of the + descriptor is determined by the point's type, which must be + ``BOOL``, ``INT64``, ``DOUBLE``, or ``DISTRIBUTION``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.TimeSeries) + )) +_sym_db.RegisterMessage(TimeSeries) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\013MetricProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/metric_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/metric_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/metric_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/metric_service_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/metric_service_pb2.py new file mode 100644 index 000000000000..91dfbd949722 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/metric_service_pb2.py @@ -0,0 +1,970 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/metric_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 +from google.protobuf import descriptor_pb2 +# @@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 metric_pb2 as google_dot_api_dot_metric__pb2 +from google.api import monitored_resource_pb2 as google_dot_api_dot_monitored__resource__pb2 +from google.cloud.monitoring_v3.proto import common_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2 +from google.cloud.monitoring_v3.proto import metric_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/metric_service.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n5google/cloud/monitoring_v3/proto/metric_service.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/metric.proto\x1a#google/api/monitored_resource.proto\x1a-google/cloud/monitoring_v3/proto/common.proto\x1a-google/cloud/monitoring_v3/proto/metric.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x17google/rpc/status.proto\"n\n\'ListMonitoredResourceDescriptorsRequest\x12\x0c\n\x04name\x18\x05 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\"\x8a\x01\n(ListMonitoredResourceDescriptorsResponse\x12\x45\n\x14resource_descriptors\x18\x01 \x03(\x0b\x32\'.google.api.MonitoredResourceDescriptor\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"5\n%GetMonitoredResourceDescriptorRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"c\n\x1cListMetricDescriptorsRequest\x12\x0c\n\x04name\x18\x05 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\"r\n\x1dListMetricDescriptorsResponse\x12\x38\n\x12metric_descriptors\x18\x01 \x03(\x0b\x32\x1c.google.api.MetricDescriptor\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"*\n\x1aGetMetricDescriptorRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"f\n\x1d\x43reateMetricDescriptorRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x37\n\x11metric_descriptor\x18\x02 \x01(\x0b\x32\x1c.google.api.MetricDescriptor\"-\n\x1d\x44\x65leteMetricDescriptorRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"\xcf\x02\n\x15ListTimeSeriesRequest\x12\x0c\n\x04name\x18\n \x01(\t\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x34\n\x08interval\x18\x04 \x01(\x0b\x32\".google.monitoring.v3.TimeInterval\x12\x36\n\x0b\x61ggregation\x18\x05 \x01(\x0b\x32!.google.monitoring.v3.Aggregation\x12\x10\n\x08order_by\x18\x06 \x01(\t\x12H\n\x04view\x18\x07 \x01(\x0e\x32:.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView\x12\x11\n\tpage_size\x18\x08 \x01(\x05\x12\x12\n\npage_token\x18\t \x01(\t\"\'\n\x0eTimeSeriesView\x12\x08\n\x04\x46ULL\x10\x00\x12\x0b\n\x07HEADERS\x10\x01\"h\n\x16ListTimeSeriesResponse\x12\x35\n\x0btime_series\x18\x01 \x03(\x0b\x32 .google.monitoring.v3.TimeSeries\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"^\n\x17\x43reateTimeSeriesRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x35\n\x0btime_series\x18\x02 \x03(\x0b\x32 .google.monitoring.v3.TimeSeries\"r\n\x15\x43reateTimeSeriesError\x12\x35\n\x0btime_series\x18\x01 \x01(\x0b\x32 .google.monitoring.v3.TimeSeries\x12\"\n\x06status\x18\x02 \x01(\x0b\x32\x12.google.rpc.Status2\xf5\n\n\rMetricService\x12\xdd\x01\n ListMonitoredResourceDescriptors\x12=.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest\x1a>.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse\":\x82\xd3\xe4\x93\x02\x34\x12\x32/v3/{name=projects/*}/monitoredResourceDescriptors\x12\xc4\x01\n\x1eGetMonitoredResourceDescriptor\x12;.google.monitoring.v3.GetMonitoredResourceDescriptorRequest\x1a\'.google.api.MonitoredResourceDescriptor\"<\x82\xd3\xe4\x93\x02\x36\x12\x34/v3/{name=projects/*/monitoredResourceDescriptors/*}\x12\xb1\x01\n\x15ListMetricDescriptors\x12\x32.google.monitoring.v3.ListMetricDescriptorsRequest\x1a\x33.google.monitoring.v3.ListMetricDescriptorsResponse\"/\x82\xd3\xe4\x93\x02)\x12\'/v3/{name=projects/*}/metricDescriptors\x12\x99\x01\n\x13GetMetricDescriptor\x12\x30.google.monitoring.v3.GetMetricDescriptorRequest\x1a\x1c.google.api.MetricDescriptor\"2\x82\xd3\xe4\x93\x02,\x12*/v3/{name=projects/*/metricDescriptors/**}\x12\xaf\x01\n\x16\x43reateMetricDescriptor\x12\x33.google.monitoring.v3.CreateMetricDescriptorRequest\x1a\x1c.google.api.MetricDescriptor\"B\x82\xd3\xe4\x93\x02<\"\'/v3/{name=projects/*}/metricDescriptors:\x11metric_descriptor\x12\x99\x01\n\x16\x44\x65leteMetricDescriptor\x12\x33.google.monitoring.v3.DeleteMetricDescriptorRequest\x1a\x16.google.protobuf.Empty\"2\x82\xd3\xe4\x93\x02,**/v3/{name=projects/*/metricDescriptors/**}\x12\x95\x01\n\x0eListTimeSeries\x12+.google.monitoring.v3.ListTimeSeriesRequest\x1a,.google.monitoring.v3.ListTimeSeriesResponse\"(\x82\xd3\xe4\x93\x02\"\x12 /v3/{name=projects/*}/timeSeries\x12\x86\x01\n\x10\x43reateTimeSeries\x12-.google.monitoring.v3.CreateTimeSeriesRequest\x1a\x16.google.protobuf.Empty\"+\x82\xd3\xe4\x93\x02%\" /v3/{name=projects/*}/timeSeries:\x01*B\xaa\x01\n\x18\x63om.google.monitoring.v3B\x12MetricServiceProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_metric__pb2.DESCRIPTOR,google_dot_api_dot_monitored__resource__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_rpc_dot_status__pb2.DESCRIPTOR,]) + + + +_LISTTIMESERIESREQUEST_TIMESERIESVIEW = _descriptor.EnumDescriptor( + name='TimeSeriesView', + full_name='google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='FULL', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='HEADERS', index=1, number=1, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1336, + serialized_end=1375, +) +_sym_db.RegisterEnumDescriptor(_LISTTIMESERIESREQUEST_TIMESERIESVIEW) + + +_LISTMONITOREDRESOURCEDESCRIPTORSREQUEST = _descriptor.Descriptor( + name='ListMonitoredResourceDescriptorsRequest', + full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsRequest.name', index=0, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsRequest.filter', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsRequest.page_size', index=2, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsRequest.page_token', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=319, + serialized_end=429, +) + + +_LISTMONITOREDRESOURCEDESCRIPTORSRESPONSE = _descriptor.Descriptor( + name='ListMonitoredResourceDescriptorsResponse', + full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='resource_descriptors', full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsResponse.resource_descriptors', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListMonitoredResourceDescriptorsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=432, + serialized_end=570, +) + + +_GETMONITOREDRESOURCEDESCRIPTORREQUEST = _descriptor.Descriptor( + name='GetMonitoredResourceDescriptorRequest', + full_name='google.monitoring.v3.GetMonitoredResourceDescriptorRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetMonitoredResourceDescriptorRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=572, + serialized_end=625, +) + + +_LISTMETRICDESCRIPTORSREQUEST = _descriptor.Descriptor( + name='ListMetricDescriptorsRequest', + full_name='google.monitoring.v3.ListMetricDescriptorsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListMetricDescriptorsRequest.name', index=0, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.ListMetricDescriptorsRequest.filter', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListMetricDescriptorsRequest.page_size', index=2, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListMetricDescriptorsRequest.page_token', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=627, + serialized_end=726, +) + + +_LISTMETRICDESCRIPTORSRESPONSE = _descriptor.Descriptor( + name='ListMetricDescriptorsResponse', + full_name='google.monitoring.v3.ListMetricDescriptorsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='metric_descriptors', full_name='google.monitoring.v3.ListMetricDescriptorsResponse.metric_descriptors', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListMetricDescriptorsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=728, + serialized_end=842, +) + + +_GETMETRICDESCRIPTORREQUEST = _descriptor.Descriptor( + name='GetMetricDescriptorRequest', + full_name='google.monitoring.v3.GetMetricDescriptorRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetMetricDescriptorRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=844, + serialized_end=886, +) + + +_CREATEMETRICDESCRIPTORREQUEST = _descriptor.Descriptor( + name='CreateMetricDescriptorRequest', + full_name='google.monitoring.v3.CreateMetricDescriptorRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.CreateMetricDescriptorRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='metric_descriptor', full_name='google.monitoring.v3.CreateMetricDescriptorRequest.metric_descriptor', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=888, + serialized_end=990, +) + + +_DELETEMETRICDESCRIPTORREQUEST = _descriptor.Descriptor( + name='DeleteMetricDescriptorRequest', + full_name='google.monitoring.v3.DeleteMetricDescriptorRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.DeleteMetricDescriptorRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=992, + serialized_end=1037, +) + + +_LISTTIMESERIESREQUEST = _descriptor.Descriptor( + name='ListTimeSeriesRequest', + full_name='google.monitoring.v3.ListTimeSeriesRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListTimeSeriesRequest.name', index=0, + number=10, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.ListTimeSeriesRequest.filter', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='interval', full_name='google.monitoring.v3.ListTimeSeriesRequest.interval', index=2, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='aggregation', full_name='google.monitoring.v3.ListTimeSeriesRequest.aggregation', index=3, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='order_by', full_name='google.monitoring.v3.ListTimeSeriesRequest.order_by', index=4, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='view', full_name='google.monitoring.v3.ListTimeSeriesRequest.view', index=5, + number=7, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListTimeSeriesRequest.page_size', index=6, + number=8, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListTimeSeriesRequest.page_token', index=7, + number=9, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + _LISTTIMESERIESREQUEST_TIMESERIESVIEW, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1040, + serialized_end=1375, +) + + +_LISTTIMESERIESRESPONSE = _descriptor.Descriptor( + name='ListTimeSeriesResponse', + full_name='google.monitoring.v3.ListTimeSeriesResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='time_series', full_name='google.monitoring.v3.ListTimeSeriesResponse.time_series', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListTimeSeriesResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1377, + serialized_end=1481, +) + + +_CREATETIMESERIESREQUEST = _descriptor.Descriptor( + name='CreateTimeSeriesRequest', + full_name='google.monitoring.v3.CreateTimeSeriesRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.CreateTimeSeriesRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='time_series', full_name='google.monitoring.v3.CreateTimeSeriesRequest.time_series', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1483, + serialized_end=1577, +) + + +_CREATETIMESERIESERROR = _descriptor.Descriptor( + name='CreateTimeSeriesError', + full_name='google.monitoring.v3.CreateTimeSeriesError', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='time_series', full_name='google.monitoring.v3.CreateTimeSeriesError.time_series', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='status', full_name='google.monitoring.v3.CreateTimeSeriesError.status', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1579, + serialized_end=1693, +) + +_LISTMONITOREDRESOURCEDESCRIPTORSRESPONSE.fields_by_name['resource_descriptors'].message_type = google_dot_api_dot_monitored__resource__pb2._MONITOREDRESOURCEDESCRIPTOR +_LISTMETRICDESCRIPTORSRESPONSE.fields_by_name['metric_descriptors'].message_type = google_dot_api_dot_metric__pb2._METRICDESCRIPTOR +_CREATEMETRICDESCRIPTORREQUEST.fields_by_name['metric_descriptor'].message_type = google_dot_api_dot_metric__pb2._METRICDESCRIPTOR +_LISTTIMESERIESREQUEST.fields_by_name['interval'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._TIMEINTERVAL +_LISTTIMESERIESREQUEST.fields_by_name['aggregation'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._AGGREGATION +_LISTTIMESERIESREQUEST.fields_by_name['view'].enum_type = _LISTTIMESERIESREQUEST_TIMESERIESVIEW +_LISTTIMESERIESREQUEST_TIMESERIESVIEW.containing_type = _LISTTIMESERIESREQUEST +_LISTTIMESERIESRESPONSE.fields_by_name['time_series'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__pb2._TIMESERIES +_CREATETIMESERIESREQUEST.fields_by_name['time_series'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__pb2._TIMESERIES +_CREATETIMESERIESERROR.fields_by_name['time_series'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__pb2._TIMESERIES +_CREATETIMESERIESERROR.fields_by_name['status'].message_type = google_dot_rpc_dot_status__pb2._STATUS +DESCRIPTOR.message_types_by_name['ListMonitoredResourceDescriptorsRequest'] = _LISTMONITOREDRESOURCEDESCRIPTORSREQUEST +DESCRIPTOR.message_types_by_name['ListMonitoredResourceDescriptorsResponse'] = _LISTMONITOREDRESOURCEDESCRIPTORSRESPONSE +DESCRIPTOR.message_types_by_name['GetMonitoredResourceDescriptorRequest'] = _GETMONITOREDRESOURCEDESCRIPTORREQUEST +DESCRIPTOR.message_types_by_name['ListMetricDescriptorsRequest'] = _LISTMETRICDESCRIPTORSREQUEST +DESCRIPTOR.message_types_by_name['ListMetricDescriptorsResponse'] = _LISTMETRICDESCRIPTORSRESPONSE +DESCRIPTOR.message_types_by_name['GetMetricDescriptorRequest'] = _GETMETRICDESCRIPTORREQUEST +DESCRIPTOR.message_types_by_name['CreateMetricDescriptorRequest'] = _CREATEMETRICDESCRIPTORREQUEST +DESCRIPTOR.message_types_by_name['DeleteMetricDescriptorRequest'] = _DELETEMETRICDESCRIPTORREQUEST +DESCRIPTOR.message_types_by_name['ListTimeSeriesRequest'] = _LISTTIMESERIESREQUEST +DESCRIPTOR.message_types_by_name['ListTimeSeriesResponse'] = _LISTTIMESERIESRESPONSE +DESCRIPTOR.message_types_by_name['CreateTimeSeriesRequest'] = _CREATETIMESERIESREQUEST +DESCRIPTOR.message_types_by_name['CreateTimeSeriesError'] = _CREATETIMESERIESERROR +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListMonitoredResourceDescriptorsRequest = _reflection.GeneratedProtocolMessageType('ListMonitoredResourceDescriptorsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTMONITOREDRESOURCEDESCRIPTORSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``ListMonitoredResourceDescriptors`` request. + + + Attributes: + name: + The project on which to execute the request. The format is + ``"projects/{project_id_or_number}"``. + filter: + An optional `filter `__ describing + the descriptors to be returned. The filter can reference the + descriptor's type and labels. For example, the following + filter returns only Google Compute Engine descriptors that + have an ``id`` label:: + + resource.type = starts_with("gce_") AND resource.label:id + + page_size: + A positive number that is the maximum number of results to + return. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return + additional results from the previous method call. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListMonitoredResourceDescriptorsRequest) + )) +_sym_db.RegisterMessage(ListMonitoredResourceDescriptorsRequest) + +ListMonitoredResourceDescriptorsResponse = _reflection.GeneratedProtocolMessageType('ListMonitoredResourceDescriptorsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTMONITOREDRESOURCEDESCRIPTORSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``ListMonitoredResourcDescriptors`` response. + + + Attributes: + resource_descriptors: + The monitored resource descriptors that are available to this + project and that match ``filter``, if present. + next_page_token: + If there are more results than have been returned, then this + field is set to a non-empty value. To see the additional + results, use that value as ``pageToken`` in the next call to + this method. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListMonitoredResourceDescriptorsResponse) + )) +_sym_db.RegisterMessage(ListMonitoredResourceDescriptorsResponse) + +GetMonitoredResourceDescriptorRequest = _reflection.GeneratedProtocolMessageType('GetMonitoredResourceDescriptorRequest', (_message.Message,), dict( + DESCRIPTOR = _GETMONITOREDRESOURCEDESCRIPTORREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``GetMonitoredResourceDescriptor`` request. + + + Attributes: + name: + The monitored resource descriptor to get. The format is ``"pro + jects/{project_id_or_number}/monitoredResourceDescriptors/{res + ource_type}"``. The ``{resource_type}`` is a predefined type, + such as ``cloudsql_database``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetMonitoredResourceDescriptorRequest) + )) +_sym_db.RegisterMessage(GetMonitoredResourceDescriptorRequest) + +ListMetricDescriptorsRequest = _reflection.GeneratedProtocolMessageType('ListMetricDescriptorsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTMETRICDESCRIPTORSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``ListMetricDescriptors`` request. + + + Attributes: + name: + The project on which to execute the request. The format is + ``"projects/{project_id_or_number}"``. + filter: + If this field is empty, all custom and system-defined metric + descriptors are returned. Otherwise, the `filter + `__ specifies which metric + descriptors are to be returned. For example, the following + filter matches all `custom metrics `__: :: metric.type = + starts_with("custom.googleapis.com/") + page_size: + A positive number that is the maximum number of results to + return. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return + additional results from the previous method call. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListMetricDescriptorsRequest) + )) +_sym_db.RegisterMessage(ListMetricDescriptorsRequest) + +ListMetricDescriptorsResponse = _reflection.GeneratedProtocolMessageType('ListMetricDescriptorsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTMETRICDESCRIPTORSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``ListMetricDescriptors`` response. + + + Attributes: + metric_descriptors: + The metric descriptors that are available to the project and + that match the value of ``filter``, if present. + next_page_token: + If there are more results than have been returned, then this + field is set to a non-empty value. To see the additional + results, use that value as ``pageToken`` in the next call to + this method. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListMetricDescriptorsResponse) + )) +_sym_db.RegisterMessage(ListMetricDescriptorsResponse) + +GetMetricDescriptorRequest = _reflection.GeneratedProtocolMessageType('GetMetricDescriptorRequest', (_message.Message,), dict( + DESCRIPTOR = _GETMETRICDESCRIPTORREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``GetMetricDescriptor`` request. + + + Attributes: + name: + The metric descriptor on which to execute the request. The + format is ``"projects/{project_id_or_number}/metricDescriptors + /{metric_id}"``. An example value of ``{metric_id}`` is + ``"compute.googleapis.com/instance/disk/read_bytes_count"``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetMetricDescriptorRequest) + )) +_sym_db.RegisterMessage(GetMetricDescriptorRequest) + +CreateMetricDescriptorRequest = _reflection.GeneratedProtocolMessageType('CreateMetricDescriptorRequest', (_message.Message,), dict( + DESCRIPTOR = _CREATEMETRICDESCRIPTORREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``CreateMetricDescriptor`` request. + + + Attributes: + name: + The project on which to execute the request. The format is + ``"projects/{project_id_or_number}"``. + metric_descriptor: + The new `custom metric `__ + descriptor. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateMetricDescriptorRequest) + )) +_sym_db.RegisterMessage(CreateMetricDescriptorRequest) + +DeleteMetricDescriptorRequest = _reflection.GeneratedProtocolMessageType('DeleteMetricDescriptorRequest', (_message.Message,), dict( + DESCRIPTOR = _DELETEMETRICDESCRIPTORREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``DeleteMetricDescriptor`` request. + + + Attributes: + name: + The metric descriptor on which to execute the request. The + format is ``"projects/{project_id_or_number}/metricDescriptors + /{metric_id}"``. An example of ``{metric_id}`` is: + ``"custom.googleapis.com/my_test_metric"``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.DeleteMetricDescriptorRequest) + )) +_sym_db.RegisterMessage(DeleteMetricDescriptorRequest) + +ListTimeSeriesRequest = _reflection.GeneratedProtocolMessageType('ListTimeSeriesRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTTIMESERIESREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``ListTimeSeries`` request. + + + Attributes: + name: + The project on which to execute the request. The format is + "projects/{project\_id\_or\_number}". + filter: + A `monitoring filter `__ that + specifies which time series should be returned. The filter + must specify a single metric type, and can additionally + specify metric labels and other information. For example: :: + metric.type = "compute.googleapis.com/instance/cpu/usage_time" + AND metric.label.instance_name = "my-instance-name" + interval: + The time interval for which results should be returned. Only + time series that contain data points in the specified interval + are included in the response. + aggregation: + By default, the raw time series data is returned. Use this + field to combine multiple time series for different views of + the data. + order_by: + Specifies the order in which the points of the time series + should be returned. By default, results are not ordered. + Currently, this field must be left blank. + view: + Specifies which information is returned about the time series. + page_size: + A positive number that is the maximum number of results to + return. When ``view`` field sets to ``FULL``, it limits the + number of ``Points`` server will return; if ``view`` field is + ``HEADERS``, it limits the number of ``TimeSeries`` server + will return. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return + additional results from the previous method call. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListTimeSeriesRequest) + )) +_sym_db.RegisterMessage(ListTimeSeriesRequest) + +ListTimeSeriesResponse = _reflection.GeneratedProtocolMessageType('ListTimeSeriesResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTTIMESERIESRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``ListTimeSeries`` response. + + + Attributes: + time_series: + One or more time series that match the filter included in the + request. + next_page_token: + If there are more results than have been returned, then this + field is set to a non-empty value. To see the additional + results, use that value as ``pageToken`` in the next call to + this method. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListTimeSeriesResponse) + )) +_sym_db.RegisterMessage(ListTimeSeriesResponse) + +CreateTimeSeriesRequest = _reflection.GeneratedProtocolMessageType('CreateTimeSeriesRequest', (_message.Message,), dict( + DESCRIPTOR = _CREATETIMESERIESREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """The ``CreateTimeSeries`` request. + + + Attributes: + name: + The project on which to execute the request. The format is + ``"projects/{project_id_or_number}"``. + time_series: + The new data to be added to a list of time series. Adds at + most one data point to each of several time series. The new + data point must be more recent than any other point in its + time series. Each ``TimeSeries`` value must fully specify a + unique time series by supplying all label values for the + metric and the monitored resource. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateTimeSeriesRequest) + )) +_sym_db.RegisterMessage(CreateTimeSeriesRequest) + +CreateTimeSeriesError = _reflection.GeneratedProtocolMessageType('CreateTimeSeriesError', (_message.Message,), dict( + DESCRIPTOR = _CREATETIMESERIESERROR, + __module__ = 'google.cloud.monitoring_v3.proto.metric_service_pb2' + , + __doc__ = """Describes the result of a failed request to write data to a time series. + + + Attributes: + time_series: + The time series, including the ``Metric``, + ``MonitoredResource``, and ``Point``\ s (including timestamp + and value) that resulted in the error. This field provides all + of the context that would be needed to retry the operation. + status: + The status of the requested write operation. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateTimeSeriesError) + )) +_sym_db.RegisterMessage(CreateTimeSeriesError) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\022MetricServiceProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) + +_METRICSERVICE = _descriptor.ServiceDescriptor( + name='MetricService', + full_name='google.monitoring.v3.MetricService', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=1696, + serialized_end=3093, + methods=[ + _descriptor.MethodDescriptor( + name='ListMonitoredResourceDescriptors', + full_name='google.monitoring.v3.MetricService.ListMonitoredResourceDescriptors', + index=0, + containing_service=None, + input_type=_LISTMONITOREDRESOURCEDESCRIPTORSREQUEST, + output_type=_LISTMONITOREDRESOURCEDESCRIPTORSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0024\0222/v3/{name=projects/*}/monitoredResourceDescriptors')), + ), + _descriptor.MethodDescriptor( + name='GetMonitoredResourceDescriptor', + full_name='google.monitoring.v3.MetricService.GetMonitoredResourceDescriptor', + index=1, + containing_service=None, + input_type=_GETMONITOREDRESOURCEDESCRIPTORREQUEST, + output_type=google_dot_api_dot_monitored__resource__pb2._MONITOREDRESOURCEDESCRIPTOR, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0026\0224/v3/{name=projects/*/monitoredResourceDescriptors/*}')), + ), + _descriptor.MethodDescriptor( + name='ListMetricDescriptors', + full_name='google.monitoring.v3.MetricService.ListMetricDescriptors', + index=2, + containing_service=None, + input_type=_LISTMETRICDESCRIPTORSREQUEST, + output_type=_LISTMETRICDESCRIPTORSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002)\022\'/v3/{name=projects/*}/metricDescriptors')), + ), + _descriptor.MethodDescriptor( + name='GetMetricDescriptor', + full_name='google.monitoring.v3.MetricService.GetMetricDescriptor', + index=3, + containing_service=None, + input_type=_GETMETRICDESCRIPTORREQUEST, + output_type=google_dot_api_dot_metric__pb2._METRICDESCRIPTOR, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002,\022*/v3/{name=projects/*/metricDescriptors/**}')), + ), + _descriptor.MethodDescriptor( + name='CreateMetricDescriptor', + full_name='google.monitoring.v3.MetricService.CreateMetricDescriptor', + index=4, + containing_service=None, + input_type=_CREATEMETRICDESCRIPTORREQUEST, + output_type=google_dot_api_dot_metric__pb2._METRICDESCRIPTOR, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002<\"\'/v3/{name=projects/*}/metricDescriptors:\021metric_descriptor')), + ), + _descriptor.MethodDescriptor( + name='DeleteMetricDescriptor', + full_name='google.monitoring.v3.MetricService.DeleteMetricDescriptor', + index=5, + containing_service=None, + input_type=_DELETEMETRICDESCRIPTORREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002,**/v3/{name=projects/*/metricDescriptors/**}')), + ), + _descriptor.MethodDescriptor( + name='ListTimeSeries', + full_name='google.monitoring.v3.MetricService.ListTimeSeries', + index=6, + containing_service=None, + input_type=_LISTTIMESERIESREQUEST, + output_type=_LISTTIMESERIESRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002\"\022 /v3/{name=projects/*}/timeSeries')), + ), + _descriptor.MethodDescriptor( + name='CreateTimeSeries', + full_name='google.monitoring.v3.MetricService.CreateTimeSeries', + index=7, + containing_service=None, + input_type=_CREATETIMESERIESREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002%\" /v3/{name=projects/*}/timeSeries:\001*')), + ), +]) +_sym_db.RegisterServiceDescriptor(_METRICSERVICE) + +DESCRIPTOR.services_by_name['MetricService'] = _METRICSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/metric_service_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/metric_service_pb2_grpc.py new file mode 100644 index 000000000000..e091978e4530 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/metric_service_pb2_grpc.py @@ -0,0 +1,176 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.api import metric_pb2 as google_dot_api_dot_metric__pb2 +from google.api import monitored_resource_pb2 as google_dot_api_dot_monitored__resource__pb2 +from google.cloud.monitoring_v3.proto import metric_service_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class MetricServiceStub(object): + """Manages metric descriptors, monitored resource descriptors, and + time series data. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListMonitoredResourceDescriptors = channel.unary_unary( + '/google.monitoring.v3.MetricService/ListMonitoredResourceDescriptors', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMonitoredResourceDescriptorsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMonitoredResourceDescriptorsResponse.FromString, + ) + self.GetMonitoredResourceDescriptor = channel.unary_unary( + '/google.monitoring.v3.MetricService/GetMonitoredResourceDescriptor', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.GetMonitoredResourceDescriptorRequest.SerializeToString, + response_deserializer=google_dot_api_dot_monitored__resource__pb2.MonitoredResourceDescriptor.FromString, + ) + self.ListMetricDescriptors = channel.unary_unary( + '/google.monitoring.v3.MetricService/ListMetricDescriptors', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMetricDescriptorsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMetricDescriptorsResponse.FromString, + ) + self.GetMetricDescriptor = channel.unary_unary( + '/google.monitoring.v3.MetricService/GetMetricDescriptor', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.GetMetricDescriptorRequest.SerializeToString, + response_deserializer=google_dot_api_dot_metric__pb2.MetricDescriptor.FromString, + ) + self.CreateMetricDescriptor = channel.unary_unary( + '/google.monitoring.v3.MetricService/CreateMetricDescriptor', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.CreateMetricDescriptorRequest.SerializeToString, + response_deserializer=google_dot_api_dot_metric__pb2.MetricDescriptor.FromString, + ) + self.DeleteMetricDescriptor = channel.unary_unary( + '/google.monitoring.v3.MetricService/DeleteMetricDescriptor', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.DeleteMetricDescriptorRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.ListTimeSeries = channel.unary_unary( + '/google.monitoring.v3.MetricService/ListTimeSeries', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListTimeSeriesRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListTimeSeriesResponse.FromString, + ) + self.CreateTimeSeries = channel.unary_unary( + '/google.monitoring.v3.MetricService/CreateTimeSeries', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.CreateTimeSeriesRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + + +class MetricServiceServicer(object): + """Manages metric descriptors, monitored resource descriptors, and + time series data. + """ + + def ListMonitoredResourceDescriptors(self, request, context): + """Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetMonitoredResourceDescriptor(self, request, context): + """Gets a single monitored resource descriptor. This method does not require a Stackdriver account. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ListMetricDescriptors(self, request, context): + """Lists metric descriptors that match a filter. This method does not require a Stackdriver account. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetMetricDescriptor(self, request, context): + """Gets a single metric descriptor. This method does not require a Stackdriver account. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateMetricDescriptor(self, request, context): + """Creates a new metric descriptor. + User-created metric descriptors define + [custom metrics](/monitoring/custom-metrics). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def DeleteMetricDescriptor(self, request, context): + """Deletes a metric descriptor. Only user-created + [custom metrics](/monitoring/custom-metrics) can be deleted. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ListTimeSeries(self, request, context): + """Lists time series that match a filter. This method does not require a Stackdriver account. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateTimeSeries(self, request, context): + """Creates or adds data to one or more time series. + The response is empty if all time series in the request were written. + If any time series could not be written, a corresponding failure message is + included in the error response. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_MetricServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'ListMonitoredResourceDescriptors': grpc.unary_unary_rpc_method_handler( + servicer.ListMonitoredResourceDescriptors, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMonitoredResourceDescriptorsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMonitoredResourceDescriptorsResponse.SerializeToString, + ), + 'GetMonitoredResourceDescriptor': grpc.unary_unary_rpc_method_handler( + servicer.GetMonitoredResourceDescriptor, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.GetMonitoredResourceDescriptorRequest.FromString, + response_serializer=google_dot_api_dot_monitored__resource__pb2.MonitoredResourceDescriptor.SerializeToString, + ), + 'ListMetricDescriptors': grpc.unary_unary_rpc_method_handler( + servicer.ListMetricDescriptors, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMetricDescriptorsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListMetricDescriptorsResponse.SerializeToString, + ), + 'GetMetricDescriptor': grpc.unary_unary_rpc_method_handler( + servicer.GetMetricDescriptor, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.GetMetricDescriptorRequest.FromString, + response_serializer=google_dot_api_dot_metric__pb2.MetricDescriptor.SerializeToString, + ), + 'CreateMetricDescriptor': grpc.unary_unary_rpc_method_handler( + servicer.CreateMetricDescriptor, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.CreateMetricDescriptorRequest.FromString, + response_serializer=google_dot_api_dot_metric__pb2.MetricDescriptor.SerializeToString, + ), + 'DeleteMetricDescriptor': grpc.unary_unary_rpc_method_handler( + servicer.DeleteMetricDescriptor, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.DeleteMetricDescriptorRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'ListTimeSeries': grpc.unary_unary_rpc_method_handler( + servicer.ListTimeSeries, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListTimeSeriesRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.ListTimeSeriesResponse.SerializeToString, + ), + 'CreateTimeSeries': grpc.unary_unary_rpc_method_handler( + servicer.CreateTimeSeries, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_metric__service__pb2.CreateTimeSeriesRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.monitoring.v3.MetricService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/monitoring/google/cloud/monitoring_v3/proto/mutation_record_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/mutation_record_pb2.py new file mode 100644 index 000000000000..f2177878e1f7 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/mutation_record_pb2.py @@ -0,0 +1,91 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/mutation_record.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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/mutation_record.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n6google/cloud/monitoring_v3/proto/mutation_record.proto\x12\x14google.monitoring.v3\x1a\x1fgoogle/protobuf/timestamp.proto\"U\n\x0eMutationRecord\x12/\n\x0bmutate_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x12\n\nmutated_by\x18\x02 \x01(\tB\xab\x01\n\x18\x63om.google.monitoring.v3B\x13MutationRecordProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) + + + + +_MUTATIONRECORD = _descriptor.Descriptor( + name='MutationRecord', + full_name='google.monitoring.v3.MutationRecord', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='mutate_time', full_name='google.monitoring.v3.MutationRecord.mutate_time', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='mutated_by', full_name='google.monitoring.v3.MutationRecord.mutated_by', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=113, + serialized_end=198, +) + +_MUTATIONRECORD.fields_by_name['mutate_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +DESCRIPTOR.message_types_by_name['MutationRecord'] = _MUTATIONRECORD +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +MutationRecord = _reflection.GeneratedProtocolMessageType('MutationRecord', (_message.Message,), dict( + DESCRIPTOR = _MUTATIONRECORD, + __module__ = 'google.cloud.monitoring_v3.proto.mutation_record_pb2' + , + __doc__ = """Describes a change made to a configuration. + + + Attributes: + mutate_time: + When the change occurred. + mutated_by: + The email address of the user making the change. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.MutationRecord) + )) +_sym_db.RegisterMessage(MutationRecord) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\023MutationRecordProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/mutation_record_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/mutation_record_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/mutation_record_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/notification_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/notification_pb2.py new file mode 100644 index 000000000000..f66985596ecd --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/notification_pb2.py @@ -0,0 +1,435 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/notification.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 +from google.protobuf import descriptor_pb2 +# @@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 label_pb2 as google_dot_api_dot_label__pb2 +from google.cloud.monitoring_v3.proto import common_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2 +from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/notification.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n3google/cloud/monitoring_v3/proto/notification.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a\x16google/api/label.proto\x1a-google/cloud/monitoring_v3/proto/common.proto\x1a\x1egoogle/protobuf/wrappers.proto\"\xcf\x01\n\x1dNotificationChannelDescriptor\x12\x0c\n\x04name\x18\x06 \x01(\t\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12+\n\x06labels\x18\x04 \x03(\x0b\x32\x1b.google.api.LabelDescriptor\x12:\n\x0fsupported_tiers\x18\x05 \x03(\x0e\x32!.google.monitoring.v3.ServiceTier\"\xb6\x04\n\x13NotificationChannel\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x06 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x03 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\x12\x45\n\x06labels\x18\x05 \x03(\x0b\x32\x35.google.monitoring.v3.NotificationChannel.LabelsEntry\x12N\n\x0buser_labels\x18\x08 \x03(\x0b\x32\x39.google.monitoring.v3.NotificationChannel.UserLabelsEntry\x12Y\n\x13verification_status\x18\t \x01(\x0e\x32<.google.monitoring.v3.NotificationChannel.VerificationStatus\x12+\n\x07\x65nabled\x18\x0b \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x1a\x31\n\x0fUserLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"W\n\x12VerificationStatus\x12#\n\x1fVERIFICATION_STATUS_UNSPECIFIED\x10\x00\x12\x0e\n\nUNVERIFIED\x10\x01\x12\x0c\n\x08VERIFIED\x10\x02\x42\xa9\x01\n\x18\x63om.google.monitoring.v3B\x11NotificationProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_label__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2.DESCRIPTOR,google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,]) + + + +_NOTIFICATIONCHANNEL_VERIFICATIONSTATUS = _descriptor.EnumDescriptor( + name='VerificationStatus', + full_name='google.monitoring.v3.NotificationChannel.VerificationStatus', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='VERIFICATION_STATUS_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='UNVERIFIED', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='VERIFIED', index=2, number=2, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=900, + serialized_end=987, +) +_sym_db.RegisterEnumDescriptor(_NOTIFICATIONCHANNEL_VERIFICATIONSTATUS) + + +_NOTIFICATIONCHANNELDESCRIPTOR = _descriptor.Descriptor( + name='NotificationChannelDescriptor', + full_name='google.monitoring.v3.NotificationChannelDescriptor', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.NotificationChannelDescriptor.name', index=0, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='type', full_name='google.monitoring.v3.NotificationChannelDescriptor.type', index=1, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.NotificationChannelDescriptor.display_name', index=2, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='description', full_name='google.monitoring.v3.NotificationChannelDescriptor.description', index=3, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='labels', full_name='google.monitoring.v3.NotificationChannelDescriptor.labels', index=4, + number=4, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='supported_tiers', full_name='google.monitoring.v3.NotificationChannelDescriptor.supported_tiers', index=5, + number=5, type=14, cpp_type=8, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=211, + serialized_end=418, +) + + +_NOTIFICATIONCHANNEL_LABELSENTRY = _descriptor.Descriptor( + name='LabelsEntry', + full_name='google.monitoring.v3.NotificationChannel.LabelsEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='google.monitoring.v3.NotificationChannel.LabelsEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='value', full_name='google.monitoring.v3.NotificationChannel.LabelsEntry.value', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=802, + serialized_end=847, +) + +_NOTIFICATIONCHANNEL_USERLABELSENTRY = _descriptor.Descriptor( + name='UserLabelsEntry', + full_name='google.monitoring.v3.NotificationChannel.UserLabelsEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='google.monitoring.v3.NotificationChannel.UserLabelsEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='value', full_name='google.monitoring.v3.NotificationChannel.UserLabelsEntry.value', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=849, + serialized_end=898, +) + +_NOTIFICATIONCHANNEL = _descriptor.Descriptor( + name='NotificationChannel', + full_name='google.monitoring.v3.NotificationChannel', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='type', full_name='google.monitoring.v3.NotificationChannel.type', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.NotificationChannel.name', index=1, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.NotificationChannel.display_name', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='description', full_name='google.monitoring.v3.NotificationChannel.description', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='labels', full_name='google.monitoring.v3.NotificationChannel.labels', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='user_labels', full_name='google.monitoring.v3.NotificationChannel.user_labels', index=5, + number=8, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='verification_status', full_name='google.monitoring.v3.NotificationChannel.verification_status', index=6, + number=9, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='enabled', full_name='google.monitoring.v3.NotificationChannel.enabled', index=7, + number=11, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[_NOTIFICATIONCHANNEL_LABELSENTRY, _NOTIFICATIONCHANNEL_USERLABELSENTRY, ], + enum_types=[ + _NOTIFICATIONCHANNEL_VERIFICATIONSTATUS, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=421, + serialized_end=987, +) + +_NOTIFICATIONCHANNELDESCRIPTOR.fields_by_name['labels'].message_type = google_dot_api_dot_label__pb2._LABELDESCRIPTOR +_NOTIFICATIONCHANNELDESCRIPTOR.fields_by_name['supported_tiers'].enum_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_common__pb2._SERVICETIER +_NOTIFICATIONCHANNEL_LABELSENTRY.containing_type = _NOTIFICATIONCHANNEL +_NOTIFICATIONCHANNEL_USERLABELSENTRY.containing_type = _NOTIFICATIONCHANNEL +_NOTIFICATIONCHANNEL.fields_by_name['labels'].message_type = _NOTIFICATIONCHANNEL_LABELSENTRY +_NOTIFICATIONCHANNEL.fields_by_name['user_labels'].message_type = _NOTIFICATIONCHANNEL_USERLABELSENTRY +_NOTIFICATIONCHANNEL.fields_by_name['verification_status'].enum_type = _NOTIFICATIONCHANNEL_VERIFICATIONSTATUS +_NOTIFICATIONCHANNEL.fields_by_name['enabled'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE +_NOTIFICATIONCHANNEL_VERIFICATIONSTATUS.containing_type = _NOTIFICATIONCHANNEL +DESCRIPTOR.message_types_by_name['NotificationChannelDescriptor'] = _NOTIFICATIONCHANNELDESCRIPTOR +DESCRIPTOR.message_types_by_name['NotificationChannel'] = _NOTIFICATIONCHANNEL +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +NotificationChannelDescriptor = _reflection.GeneratedProtocolMessageType('NotificationChannelDescriptor', (_message.Message,), dict( + DESCRIPTOR = _NOTIFICATIONCHANNELDESCRIPTOR, + __module__ = 'google.cloud.monitoring_v3.proto.notification_pb2' + , + __doc__ = """A description of a notification channel. The descriptor includes the + properties of the channel and the set of labels or fields that must be + specified to configure channels of a given type. + + + Attributes: + name: + The full REST resource name for this descriptor. The syntax + is: :: + projects/[PROJECT_ID]/notificationChannelDescriptors/[TYPE] + In the above, ``[TYPE]`` is the value of the ``type`` field. + type: + The type of notification channel, such as "email", "sms", etc. + Notification channel types are globally unique. + display_name: + A human-readable name for the notification channel type. This + form of the name is suitable for a user interface. + description: + A human-readable description of the notification channel type. + The description may include a description of the properties of + the channel and pointers to external documentation. + labels: + The set of labels that must be defined to identify a + particular channel of the corresponding type. Each label + includes a description for how that field should be populated. + supported_tiers: + The tiers that support this notification channel; the project + service tier must be one of the supported\_tiers. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.NotificationChannelDescriptor) + )) +_sym_db.RegisterMessage(NotificationChannelDescriptor) + +NotificationChannel = _reflection.GeneratedProtocolMessageType('NotificationChannel', (_message.Message,), dict( + + LabelsEntry = _reflection.GeneratedProtocolMessageType('LabelsEntry', (_message.Message,), dict( + DESCRIPTOR = _NOTIFICATIONCHANNEL_LABELSENTRY, + __module__ = 'google.cloud.monitoring_v3.proto.notification_pb2' + # @@protoc_insertion_point(class_scope:google.monitoring.v3.NotificationChannel.LabelsEntry) + )) + , + + UserLabelsEntry = _reflection.GeneratedProtocolMessageType('UserLabelsEntry', (_message.Message,), dict( + DESCRIPTOR = _NOTIFICATIONCHANNEL_USERLABELSENTRY, + __module__ = 'google.cloud.monitoring_v3.proto.notification_pb2' + # @@protoc_insertion_point(class_scope:google.monitoring.v3.NotificationChannel.UserLabelsEntry) + )) + , + DESCRIPTOR = _NOTIFICATIONCHANNEL, + __module__ = 'google.cloud.monitoring_v3.proto.notification_pb2' + , + __doc__ = """A ``NotificationChannel`` is a medium through which an alert is + delivered when a policy violation is detected. Examples of channels + include email, SMS, and third-party messaging applications. Fields + containing sensitive information like authentication tokens or contact + info are only partially populated on retrieval. + + + Attributes: + type: + The type of the notification channel. This field matches the + value of the [NotificationChannelDescriptor.type][google.monit + oring.v3.NotificationChannelDescriptor.type] field. + name: + The full REST resource name for this channel. The syntax is: + :: + projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] The + ``[CHANNEL_ID]`` is automatically assigned by the server on + creation. + display_name: + An optional human-readable name for this notification channel. + It is recommended that you specify a non-empty and unique name + in order to make it easier to identify the channels in your + project, though this is not enforced. The display name is + limited to 512 Unicode characters. + description: + An optional human-readable description of this notification + channel. This description may provide additional details, + beyond the display name, for the channel. This may not exceeed + 1024 Unicode characters. + labels: + Configuration fields that define the channel and its behavior. + The permissible and required labels are specified in the [Noti + ficationChannelDescriptor.labels][google.monitoring.v3.Notific + ationChannelDescriptor.labels] of the + ``NotificationChannelDescriptor`` corresponding to the + ``type`` field. + user_labels: + User-supplied key/value data that does not need to conform to + the corresponding ``NotificationChannelDescriptor``'s schema, + unlike the ``labels`` field. This field is intended to be used + for organizing and identifying the ``NotificationChannel`` + objects. The field can contain up to 64 entries. Each key and + value is limited to 63 Unicode characters or 128 bytes, + whichever is smaller. Labels and values can contain only + lowercase letters, numerals, underscores, and dashes. Keys + must begin with a letter. + verification_status: + Indicates whether this channel has been verified or not. On a + [``ListNotificationChannels``][google.monitoring.v3.Notificati + onChannelService.ListNotificationChannels] or [``GetNotificati + onChannel``][google.monitoring.v3.NotificationChannelService.G + etNotificationChannel] operation, this field is expected to be + populated. If the value is ``UNVERIFIED``, then it indicates + that the channel is non-functioning (it both requires + verification and lacks verification); otherwise, it is assumed + that the channel works. If the channel is neither + ``VERIFIED`` nor ``UNVERIFIED``, it implies that the channel + is of a type that does not require verification or that this + specific channel has been exempted from verification because + it was created prior to verification being required for + channels of this type. This field cannot be modified using a + standard [``UpdateNotificationChannel``][google.monitoring.v3. + NotificationChannelService.UpdateNotificationChannel] + operation. To change the value of this field, you must call [` + `VerifyNotificationChannel``][google.monitoring.v3.Notificatio + nChannelService.VerifyNotificationChannel]. + enabled: + Whether notifications are forwarded to the described channel. + This makes it possible to disable delivery of notifications to + a particular channel without removing the channel from all + alerting policies that reference the channel. This is a more + convenient approach when the change is temporary and you want + to receive notifications from the same set of alerting + policies on the channel at some point in the future. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.NotificationChannel) + )) +_sym_db.RegisterMessage(NotificationChannel) +_sym_db.RegisterMessage(NotificationChannel.LabelsEntry) +_sym_db.RegisterMessage(NotificationChannel.UserLabelsEntry) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\021NotificationProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +_NOTIFICATIONCHANNEL_LABELSENTRY.has_options = True +_NOTIFICATIONCHANNEL_LABELSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +_NOTIFICATIONCHANNEL_USERLABELSENTRY.has_options = True +_NOTIFICATIONCHANNEL_USERLABELSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/notification_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/notification_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/notification_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/notification_service_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/notification_service_pb2.py new file mode 100644 index 000000000000..5cd5adc310f8 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/notification_service_pb2.py @@ -0,0 +1,966 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/notification_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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.cloud.monitoring_v3.proto import notification_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__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 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/notification_service.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n;google/cloud/monitoring_v3/proto/notification_service.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a\x33google/cloud/monitoring_v3/proto/notification.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"`\n)ListNotificationChannelDescriptorsRequest\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"\x97\x01\n*ListNotificationChannelDescriptorsResponse\x12P\n\x13\x63hannel_descriptors\x18\x01 \x03(\x0b\x32\x33.google.monitoring.v3.NotificationChannelDescriptor\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"7\n\'GetNotificationChannelDescriptorRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"y\n CreateNotificationChannelRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\x12G\n\x14notification_channel\x18\x02 \x01(\x0b\x32).google.monitoring.v3.NotificationChannel\"x\n\x1fListNotificationChannelsRequest\x12\x0c\n\x04name\x18\x05 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x06 \x01(\t\x12\x10\n\x08order_by\x18\x07 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\"\x85\x01\n ListNotificationChannelsResponse\x12H\n\x15notification_channels\x18\x03 \x03(\x0b\x32).google.monitoring.v3.NotificationChannel\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"-\n\x1dGetNotificationChannelRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\"\x9c\x01\n UpdateNotificationChannelRequest\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\x12G\n\x14notification_channel\x18\x03 \x01(\x0b\x32).google.monitoring.v3.NotificationChannel\"?\n DeleteNotificationChannelRequest\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\r\n\x05\x66orce\x18\x05 \x01(\x08\">\n.SendNotificationChannelVerificationCodeRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"n\n-GetNotificationChannelVerificationCodeRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"o\n.GetNotificationChannelVerificationCodeResponse\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\">\n VerifyNotificationChannelRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\t2\xbb\x10\n\x1aNotificationChannelService\x12\xe5\x01\n\"ListNotificationChannelDescriptors\x12?.google.monitoring.v3.ListNotificationChannelDescriptorsRequest\x1a@.google.monitoring.v3.ListNotificationChannelDescriptorsResponse\"<\x82\xd3\xe4\x93\x02\x36\x12\x34/v3/{name=projects/*}/notificationChannelDescriptors\x12\xd6\x01\n GetNotificationChannelDescriptor\x12=.google.monitoring.v3.GetNotificationChannelDescriptorRequest\x1a\x33.google.monitoring.v3.NotificationChannelDescriptor\">\x82\xd3\xe4\x93\x02\x38\x12\x36/v3/{name=projects/*/notificationChannelDescriptors/*}\x12\xbd\x01\n\x18ListNotificationChannels\x12\x35.google.monitoring.v3.ListNotificationChannelsRequest\x1a\x36.google.monitoring.v3.ListNotificationChannelsResponse\"2\x82\xd3\xe4\x93\x02,\x12*/v3/{name=projects/*}/notificationChannels\x12\xae\x01\n\x16GetNotificationChannel\x12\x33.google.monitoring.v3.GetNotificationChannelRequest\x1a).google.monitoring.v3.NotificationChannel\"4\x82\xd3\xe4\x93\x02.\x12,/v3/{name=projects/*/notificationChannels/*}\x12\xc8\x01\n\x19\x43reateNotificationChannel\x12\x36.google.monitoring.v3.CreateNotificationChannelRequest\x1a).google.monitoring.v3.NotificationChannel\"H\x82\xd3\xe4\x93\x02\x42\"*/v3/{name=projects/*}/notificationChannels:\x14notification_channel\x12\xdf\x01\n\x19UpdateNotificationChannel\x12\x36.google.monitoring.v3.UpdateNotificationChannelRequest\x1a).google.monitoring.v3.NotificationChannel\"_\x82\xd3\xe4\x93\x02Y2A/v3/{notification_channel.name=projects/*/notificationChannels/*}:\x14notification_channel\x12\xa1\x01\n\x19\x44\x65leteNotificationChannel\x12\x36.google.monitoring.v3.DeleteNotificationChannelRequest\x1a\x16.google.protobuf.Empty\"4\x82\xd3\xe4\x93\x02.*,/v3/{name=projects/*/notificationChannels/*}\x12\xd5\x01\n\'SendNotificationChannelVerificationCode\x12\x44.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest\x1a\x16.google.protobuf.Empty\"L\x82\xd3\xe4\x93\x02\x46\"A/v3/{name=projects/*/notificationChannels/*}:sendVerificationCode:\x01*\x12\x80\x02\n&GetNotificationChannelVerificationCode\x12\x43.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest\x1a\x44.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse\"K\x82\xd3\xe4\x93\x02\x45\"@/v3/{name=projects/*/notificationChannels/*}:getVerificationCode:\x01*\x12\xbe\x01\n\x19VerifyNotificationChannel\x12\x36.google.monitoring.v3.VerifyNotificationChannelRequest\x1a).google.monitoring.v3.NotificationChannel\">\x82\xd3\xe4\x93\x02\x38\"3/v3/{name=projects/*/notificationChannels/*}:verify:\x01*B\xb0\x01\n\x18\x63om.google.monitoring.v3B\x18NotificationServiceProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) + + + + +_LISTNOTIFICATIONCHANNELDESCRIPTORSREQUEST = _descriptor.Descriptor( + name='ListNotificationChannelDescriptorsRequest', + full_name='google.monitoring.v3.ListNotificationChannelDescriptorsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListNotificationChannelDescriptorsRequest.name', index=0, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListNotificationChannelDescriptorsRequest.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListNotificationChannelDescriptorsRequest.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=264, + serialized_end=360, +) + + +_LISTNOTIFICATIONCHANNELDESCRIPTORSRESPONSE = _descriptor.Descriptor( + name='ListNotificationChannelDescriptorsResponse', + full_name='google.monitoring.v3.ListNotificationChannelDescriptorsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='channel_descriptors', full_name='google.monitoring.v3.ListNotificationChannelDescriptorsResponse.channel_descriptors', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListNotificationChannelDescriptorsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=363, + serialized_end=514, +) + + +_GETNOTIFICATIONCHANNELDESCRIPTORREQUEST = _descriptor.Descriptor( + name='GetNotificationChannelDescriptorRequest', + full_name='google.monitoring.v3.GetNotificationChannelDescriptorRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetNotificationChannelDescriptorRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=516, + serialized_end=571, +) + + +_CREATENOTIFICATIONCHANNELREQUEST = _descriptor.Descriptor( + name='CreateNotificationChannelRequest', + full_name='google.monitoring.v3.CreateNotificationChannelRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.CreateNotificationChannelRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='notification_channel', full_name='google.monitoring.v3.CreateNotificationChannelRequest.notification_channel', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=573, + serialized_end=694, +) + + +_LISTNOTIFICATIONCHANNELSREQUEST = _descriptor.Descriptor( + name='ListNotificationChannelsRequest', + full_name='google.monitoring.v3.ListNotificationChannelsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.ListNotificationChannelsRequest.name', index=0, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='filter', full_name='google.monitoring.v3.ListNotificationChannelsRequest.filter', index=1, + number=6, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='order_by', full_name='google.monitoring.v3.ListNotificationChannelsRequest.order_by', index=2, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListNotificationChannelsRequest.page_size', index=3, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListNotificationChannelsRequest.page_token', index=4, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=696, + serialized_end=816, +) + + +_LISTNOTIFICATIONCHANNELSRESPONSE = _descriptor.Descriptor( + name='ListNotificationChannelsResponse', + full_name='google.monitoring.v3.ListNotificationChannelsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='notification_channels', full_name='google.monitoring.v3.ListNotificationChannelsResponse.notification_channels', index=0, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListNotificationChannelsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=819, + serialized_end=952, +) + + +_GETNOTIFICATIONCHANNELREQUEST = _descriptor.Descriptor( + name='GetNotificationChannelRequest', + full_name='google.monitoring.v3.GetNotificationChannelRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetNotificationChannelRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=954, + serialized_end=999, +) + + +_UPDATENOTIFICATIONCHANNELREQUEST = _descriptor.Descriptor( + name='UpdateNotificationChannelRequest', + full_name='google.monitoring.v3.UpdateNotificationChannelRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='update_mask', full_name='google.monitoring.v3.UpdateNotificationChannelRequest.update_mask', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='notification_channel', full_name='google.monitoring.v3.UpdateNotificationChannelRequest.notification_channel', index=1, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1002, + serialized_end=1158, +) + + +_DELETENOTIFICATIONCHANNELREQUEST = _descriptor.Descriptor( + name='DeleteNotificationChannelRequest', + full_name='google.monitoring.v3.DeleteNotificationChannelRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.DeleteNotificationChannelRequest.name', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='force', full_name='google.monitoring.v3.DeleteNotificationChannelRequest.force', index=1, + number=5, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1160, + serialized_end=1223, +) + + +_SENDNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST = _descriptor.Descriptor( + name='SendNotificationChannelVerificationCodeRequest', + full_name='google.monitoring.v3.SendNotificationChannelVerificationCodeRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.SendNotificationChannelVerificationCodeRequest.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1225, + serialized_end=1287, +) + + +_GETNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST = _descriptor.Descriptor( + name='GetNotificationChannelVerificationCodeRequest', + full_name='google.monitoring.v3.GetNotificationChannelVerificationCodeRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetNotificationChannelVerificationCodeRequest.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='expire_time', full_name='google.monitoring.v3.GetNotificationChannelVerificationCodeRequest.expire_time', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1289, + serialized_end=1399, +) + + +_GETNOTIFICATIONCHANNELVERIFICATIONCODERESPONSE = _descriptor.Descriptor( + name='GetNotificationChannelVerificationCodeResponse', + full_name='google.monitoring.v3.GetNotificationChannelVerificationCodeResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='code', full_name='google.monitoring.v3.GetNotificationChannelVerificationCodeResponse.code', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='expire_time', full_name='google.monitoring.v3.GetNotificationChannelVerificationCodeResponse.expire_time', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1401, + serialized_end=1512, +) + + +_VERIFYNOTIFICATIONCHANNELREQUEST = _descriptor.Descriptor( + name='VerifyNotificationChannelRequest', + full_name='google.monitoring.v3.VerifyNotificationChannelRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.VerifyNotificationChannelRequest.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='code', full_name='google.monitoring.v3.VerifyNotificationChannelRequest.code', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1514, + serialized_end=1576, +) + +_LISTNOTIFICATIONCHANNELDESCRIPTORSRESPONSE.fields_by_name['channel_descriptors'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNELDESCRIPTOR +_CREATENOTIFICATIONCHANNELREQUEST.fields_by_name['notification_channel'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL +_LISTNOTIFICATIONCHANNELSRESPONSE.fields_by_name['notification_channels'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL +_UPDATENOTIFICATIONCHANNELREQUEST.fields_by_name['update_mask'].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK +_UPDATENOTIFICATIONCHANNELREQUEST.fields_by_name['notification_channel'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL +_GETNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST.fields_by_name['expire_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_GETNOTIFICATIONCHANNELVERIFICATIONCODERESPONSE.fields_by_name['expire_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +DESCRIPTOR.message_types_by_name['ListNotificationChannelDescriptorsRequest'] = _LISTNOTIFICATIONCHANNELDESCRIPTORSREQUEST +DESCRIPTOR.message_types_by_name['ListNotificationChannelDescriptorsResponse'] = _LISTNOTIFICATIONCHANNELDESCRIPTORSRESPONSE +DESCRIPTOR.message_types_by_name['GetNotificationChannelDescriptorRequest'] = _GETNOTIFICATIONCHANNELDESCRIPTORREQUEST +DESCRIPTOR.message_types_by_name['CreateNotificationChannelRequest'] = _CREATENOTIFICATIONCHANNELREQUEST +DESCRIPTOR.message_types_by_name['ListNotificationChannelsRequest'] = _LISTNOTIFICATIONCHANNELSREQUEST +DESCRIPTOR.message_types_by_name['ListNotificationChannelsResponse'] = _LISTNOTIFICATIONCHANNELSRESPONSE +DESCRIPTOR.message_types_by_name['GetNotificationChannelRequest'] = _GETNOTIFICATIONCHANNELREQUEST +DESCRIPTOR.message_types_by_name['UpdateNotificationChannelRequest'] = _UPDATENOTIFICATIONCHANNELREQUEST +DESCRIPTOR.message_types_by_name['DeleteNotificationChannelRequest'] = _DELETENOTIFICATIONCHANNELREQUEST +DESCRIPTOR.message_types_by_name['SendNotificationChannelVerificationCodeRequest'] = _SENDNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST +DESCRIPTOR.message_types_by_name['GetNotificationChannelVerificationCodeRequest'] = _GETNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST +DESCRIPTOR.message_types_by_name['GetNotificationChannelVerificationCodeResponse'] = _GETNOTIFICATIONCHANNELVERIFICATIONCODERESPONSE +DESCRIPTOR.message_types_by_name['VerifyNotificationChannelRequest'] = _VERIFYNOTIFICATIONCHANNELREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListNotificationChannelDescriptorsRequest = _reflection.GeneratedProtocolMessageType('ListNotificationChannelDescriptorsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTNOTIFICATIONCHANNELDESCRIPTORSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``ListNotificationChannelDescriptors`` request. + + + Attributes: + name: + The REST resource name of the parent from which to retrieve + the notification channel descriptors. The expected syntax is: + :: projects/[PROJECT_ID] Note that this names the parent + container in which to look for the descriptors; to retrieve a + single descriptor by name, use the [GetNotificationChannelDesc + riptor][google.monitoring.v3.NotificationChannelService.GetNot + ificationChannelDescriptor] operation, instead. + page_size: + The maximum number of results to return in a single response. + If not set to a positive number, a reasonable value will be + chosen by the service. + page_token: + If non-empty, ``page_token`` must contain a value returned as + the ``next_page_token`` in a previous response to request the + next set of results. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListNotificationChannelDescriptorsRequest) + )) +_sym_db.RegisterMessage(ListNotificationChannelDescriptorsRequest) + +ListNotificationChannelDescriptorsResponse = _reflection.GeneratedProtocolMessageType('ListNotificationChannelDescriptorsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTNOTIFICATIONCHANNELDESCRIPTORSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``ListNotificationChannelDescriptors`` response. + + + Attributes: + channel_descriptors: + The monitored resource descriptors supported for the specified + project, optionally filtered. + next_page_token: + If not empty, indicates that there may be more results that + match the request. Use the value in the ``page_token`` field + in a subsequent request to fetch the next set of results. If + empty, all results have been returned. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListNotificationChannelDescriptorsResponse) + )) +_sym_db.RegisterMessage(ListNotificationChannelDescriptorsResponse) + +GetNotificationChannelDescriptorRequest = _reflection.GeneratedProtocolMessageType('GetNotificationChannelDescriptorRequest', (_message.Message,), dict( + DESCRIPTOR = _GETNOTIFICATIONCHANNELDESCRIPTORREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``GetNotificationChannelDescriptor`` response. + + + Attributes: + name: + The channel type for which to execute the request. The format + is ``projects/[PROJECT_ID]/notificationChannelDescriptors/{cha + nnel_type}``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetNotificationChannelDescriptorRequest) + )) +_sym_db.RegisterMessage(GetNotificationChannelDescriptorRequest) + +CreateNotificationChannelRequest = _reflection.GeneratedProtocolMessageType('CreateNotificationChannelRequest', (_message.Message,), dict( + DESCRIPTOR = _CREATENOTIFICATIONCHANNELREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``CreateNotificationChannel`` request. + + + Attributes: + name: + The project on which to execute the request. The format is: + :: projects/[PROJECT_ID] Note that this names the + container into which the channel will be written. This does + not name the newly created channel. The resulting channel's + name will have a normalized version of this field as a prefix, + but will add ``/notificationChannels/[CHANNEL_ID]`` to + identify the channel. + notification_channel: + The definition of the ``NotificationChannel`` to create. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateNotificationChannelRequest) + )) +_sym_db.RegisterMessage(CreateNotificationChannelRequest) + +ListNotificationChannelsRequest = _reflection.GeneratedProtocolMessageType('ListNotificationChannelsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTNOTIFICATIONCHANNELSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``ListNotificationChannels`` request. + + + Attributes: + name: + The project on which to execute the request. The format is + ``projects/[PROJECT_ID]``. That is, this names the container + in which to look for the notification channels; it does not + name a specific channel. To query a specific channel by REST + resource name, use the [``GetNotificationChannel``][google.mon + itoring.v3.NotificationChannelService.GetNotificationChannel] + operation. + filter: + If provided, this field specifies the criteria that must be + met by notification channels to be included in the response. + For more details, see `sorting and filtering + `__. + order_by: + A comma-separated list of fields by which to sort the result. + Supports the same set of fields as in ``filter``. Entries can + be prefixed with a minus sign to sort in descending rather + than ascending order. For more details, see `sorting and + filtering `__. + page_size: + The maximum number of results to return in a single response. + If not set to a positive number, a reasonable value will be + chosen by the service. + page_token: + If non-empty, ``page_token`` must contain a value returned as + the ``next_page_token`` in a previous response to request the + next set of results. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListNotificationChannelsRequest) + )) +_sym_db.RegisterMessage(ListNotificationChannelsRequest) + +ListNotificationChannelsResponse = _reflection.GeneratedProtocolMessageType('ListNotificationChannelsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTNOTIFICATIONCHANNELSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``ListNotificationChannels`` response. + + + Attributes: + notification_channels: + The notification channels defined for the specified project. + next_page_token: + If not empty, indicates that there may be more results that + match the request. Use the value in the ``page_token`` field + in a subsequent request to fetch the next set of results. If + empty, all results have been returned. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListNotificationChannelsResponse) + )) +_sym_db.RegisterMessage(ListNotificationChannelsResponse) + +GetNotificationChannelRequest = _reflection.GeneratedProtocolMessageType('GetNotificationChannelRequest', (_message.Message,), dict( + DESCRIPTOR = _GETNOTIFICATIONCHANNELREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``GetNotificationChannel`` request. + + + Attributes: + name: + The channel for which to execute the request. The format is + ``projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetNotificationChannelRequest) + )) +_sym_db.RegisterMessage(GetNotificationChannelRequest) + +UpdateNotificationChannelRequest = _reflection.GeneratedProtocolMessageType('UpdateNotificationChannelRequest', (_message.Message,), dict( + DESCRIPTOR = _UPDATENOTIFICATIONCHANNELREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``UpdateNotificationChannel`` request. + + + Attributes: + update_mask: + The fields to update. + notification_channel: + A description of the changes to be applied to the specified + notification channel. The description must provide a + definition for fields to be updated; the names of these fields + should also be included in the ``update_mask``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UpdateNotificationChannelRequest) + )) +_sym_db.RegisterMessage(UpdateNotificationChannelRequest) + +DeleteNotificationChannelRequest = _reflection.GeneratedProtocolMessageType('DeleteNotificationChannelRequest', (_message.Message,), dict( + DESCRIPTOR = _DELETENOTIFICATIONCHANNELREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``DeleteNotificationChannel`` request. + + + Attributes: + name: + The channel for which to execute the request. The format is + ``projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]``. + force: + If true, the notification channel will be deleted regardless + of its use in alert policies (the policies will be updated to + remove the channel). If false, channels that are still + referenced by an existing alerting policy will fail to be + deleted in a delete operation. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.DeleteNotificationChannelRequest) + )) +_sym_db.RegisterMessage(DeleteNotificationChannelRequest) + +SendNotificationChannelVerificationCodeRequest = _reflection.GeneratedProtocolMessageType('SendNotificationChannelVerificationCodeRequest', (_message.Message,), dict( + DESCRIPTOR = _SENDNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``SendNotificationChannelVerificationCode`` request. + + + Attributes: + name: + The notification channel to which to send a verification code. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.SendNotificationChannelVerificationCodeRequest) + )) +_sym_db.RegisterMessage(SendNotificationChannelVerificationCodeRequest) + +GetNotificationChannelVerificationCodeRequest = _reflection.GeneratedProtocolMessageType('GetNotificationChannelVerificationCodeRequest', (_message.Message,), dict( + DESCRIPTOR = _GETNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``GetNotificationChannelVerificationCode`` request. + + + Attributes: + name: + The notification channel for which a verification code is to + be generated and retrieved. This must name a channel that is + already verified; if the specified channel is not verified, + the request will fail. + expire_time: + The desired expiration time. If specified, the API will + guarantee that the returned code will not be valid after the + specified timestamp; however, the API cannot guarantee that + the returned code will be valid for at least as long as the + requested time (the API puts an upper bound on the amount of + time for which a code may be valid). If omitted, a default + expiration will be used, which may be less than the max + permissible expiration (so specifying an expiration may extend + the code's lifetime over omitting an expiration, even though + the API does impose an upper limit on the maximum expiration + that is permitted). + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetNotificationChannelVerificationCodeRequest) + )) +_sym_db.RegisterMessage(GetNotificationChannelVerificationCodeRequest) + +GetNotificationChannelVerificationCodeResponse = _reflection.GeneratedProtocolMessageType('GetNotificationChannelVerificationCodeResponse', (_message.Message,), dict( + DESCRIPTOR = _GETNOTIFICATIONCHANNELVERIFICATIONCODERESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``GetNotificationChannelVerificationCode`` request. + + + Attributes: + code: + The verification code, which may be used to verify other + channels that have an equivalent identity (i.e. other channels + of the same type with the same fingerprint such as other email + channels with the same email address or other sms channels + with the same number). + expire_time: + The expiration time associated with the code that was + returned. If an expiration was provided in the request, this + is the minimum of the requested expiration in the request and + the max permitted expiration. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetNotificationChannelVerificationCodeResponse) + )) +_sym_db.RegisterMessage(GetNotificationChannelVerificationCodeResponse) + +VerifyNotificationChannelRequest = _reflection.GeneratedProtocolMessageType('VerifyNotificationChannelRequest', (_message.Message,), dict( + DESCRIPTOR = _VERIFYNOTIFICATIONCHANNELREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.notification_service_pb2' + , + __doc__ = """The ``VerifyNotificationChannel`` request. + + + Attributes: + name: + The notification channel to verify. + code: + The verification code that was delivered to the channel as a + result of invoking the + ``SendNotificationChannelVerificationCode`` API method or that + was retrieved from a verified channel via + ``GetNotificationChannelVerificationCode``. For example, one + might have "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in + general, one is only guaranteed that the code is valid UTF-8; + one should not make any assumptions regarding the structure or + format of the code). + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.VerifyNotificationChannelRequest) + )) +_sym_db.RegisterMessage(VerifyNotificationChannelRequest) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\030NotificationServiceProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) + +_NOTIFICATIONCHANNELSERVICE = _descriptor.ServiceDescriptor( + name='NotificationChannelService', + full_name='google.monitoring.v3.NotificationChannelService', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=1579, + serialized_end=3686, + methods=[ + _descriptor.MethodDescriptor( + name='ListNotificationChannelDescriptors', + full_name='google.monitoring.v3.NotificationChannelService.ListNotificationChannelDescriptors', + index=0, + containing_service=None, + input_type=_LISTNOTIFICATIONCHANNELDESCRIPTORSREQUEST, + output_type=_LISTNOTIFICATIONCHANNELDESCRIPTORSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0026\0224/v3/{name=projects/*}/notificationChannelDescriptors')), + ), + _descriptor.MethodDescriptor( + name='GetNotificationChannelDescriptor', + full_name='google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor', + index=1, + containing_service=None, + input_type=_GETNOTIFICATIONCHANNELDESCRIPTORREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNELDESCRIPTOR, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0028\0226/v3/{name=projects/*/notificationChannelDescriptors/*}')), + ), + _descriptor.MethodDescriptor( + name='ListNotificationChannels', + full_name='google.monitoring.v3.NotificationChannelService.ListNotificationChannels', + index=2, + containing_service=None, + input_type=_LISTNOTIFICATIONCHANNELSREQUEST, + output_type=_LISTNOTIFICATIONCHANNELSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002,\022*/v3/{name=projects/*}/notificationChannels')), + ), + _descriptor.MethodDescriptor( + name='GetNotificationChannel', + full_name='google.monitoring.v3.NotificationChannelService.GetNotificationChannel', + index=3, + containing_service=None, + input_type=_GETNOTIFICATIONCHANNELREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002.\022,/v3/{name=projects/*/notificationChannels/*}')), + ), + _descriptor.MethodDescriptor( + name='CreateNotificationChannel', + full_name='google.monitoring.v3.NotificationChannelService.CreateNotificationChannel', + index=4, + containing_service=None, + input_type=_CREATENOTIFICATIONCHANNELREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002B\"*/v3/{name=projects/*}/notificationChannels:\024notification_channel')), + ), + _descriptor.MethodDescriptor( + name='UpdateNotificationChannel', + full_name='google.monitoring.v3.NotificationChannelService.UpdateNotificationChannel', + index=5, + containing_service=None, + input_type=_UPDATENOTIFICATIONCHANNELREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002Y2A/v3/{notification_channel.name=projects/*/notificationChannels/*}:\024notification_channel')), + ), + _descriptor.MethodDescriptor( + name='DeleteNotificationChannel', + full_name='google.monitoring.v3.NotificationChannelService.DeleteNotificationChannel', + index=6, + containing_service=None, + input_type=_DELETENOTIFICATIONCHANNELREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002.*,/v3/{name=projects/*/notificationChannels/*}')), + ), + _descriptor.MethodDescriptor( + name='SendNotificationChannelVerificationCode', + full_name='google.monitoring.v3.NotificationChannelService.SendNotificationChannelVerificationCode', + index=7, + containing_service=None, + input_type=_SENDNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002F\"A/v3/{name=projects/*/notificationChannels/*}:sendVerificationCode:\001*')), + ), + _descriptor.MethodDescriptor( + name='GetNotificationChannelVerificationCode', + full_name='google.monitoring.v3.NotificationChannelService.GetNotificationChannelVerificationCode', + index=8, + containing_service=None, + input_type=_GETNOTIFICATIONCHANNELVERIFICATIONCODEREQUEST, + output_type=_GETNOTIFICATIONCHANNELVERIFICATIONCODERESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002E\"@/v3/{name=projects/*/notificationChannels/*}:getVerificationCode:\001*')), + ), + _descriptor.MethodDescriptor( + name='VerifyNotificationChannel', + full_name='google.monitoring.v3.NotificationChannelService.VerifyNotificationChannel', + index=9, + containing_service=None, + input_type=_VERIFYNOTIFICATIONCHANNELREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2._NOTIFICATIONCHANNEL, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0028\"3/v3/{name=projects/*/notificationChannels/*}:verify:\001*')), + ), +]) +_sym_db.RegisterServiceDescriptor(_NOTIFICATIONCHANNELSERVICE) + +DESCRIPTOR.services_by_name['NotificationChannelService'] = _NOTIFICATIONCHANNELSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/notification_service_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/notification_service_pb2_grpc.py new file mode 100644 index 000000000000..69747310a24c --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/notification_service_pb2_grpc.py @@ -0,0 +1,234 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.monitoring_v3.proto import notification_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2 +from google.cloud.monitoring_v3.proto import notification_service_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class NotificationChannelServiceStub(object): + """The Notification Channel API provides access to configuration that + controls how messages related to incidents are sent. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListNotificationChannelDescriptors = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/ListNotificationChannelDescriptors', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelDescriptorsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelDescriptorsResponse.FromString, + ) + self.GetNotificationChannelDescriptor = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/GetNotificationChannelDescriptor', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelDescriptorRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannelDescriptor.FromString, + ) + self.ListNotificationChannels = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/ListNotificationChannels', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelsResponse.FromString, + ) + self.GetNotificationChannel = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/GetNotificationChannel', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.FromString, + ) + self.CreateNotificationChannel = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/CreateNotificationChannel', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.CreateNotificationChannelRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.FromString, + ) + self.UpdateNotificationChannel = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/UpdateNotificationChannel', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.UpdateNotificationChannelRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.FromString, + ) + self.DeleteNotificationChannel = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/DeleteNotificationChannel', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.DeleteNotificationChannelRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.SendNotificationChannelVerificationCode = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/SendNotificationChannelVerificationCode', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.SendNotificationChannelVerificationCodeRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.GetNotificationChannelVerificationCode = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/GetNotificationChannelVerificationCode', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelVerificationCodeRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelVerificationCodeResponse.FromString, + ) + self.VerifyNotificationChannel = channel.unary_unary( + '/google.monitoring.v3.NotificationChannelService/VerifyNotificationChannel', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.VerifyNotificationChannelRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.FromString, + ) + + +class NotificationChannelServiceServicer(object): + """The Notification Channel API provides access to configuration that + controls how messages related to incidents are sent. + """ + + def ListNotificationChannelDescriptors(self, request, context): + """Lists the descriptors for supported channel types. The use of descriptors + makes it possible for new channel types to be dynamically added. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetNotificationChannelDescriptor(self, request, context): + """Gets a single channel descriptor. The descriptor indicates which fields + are expected / permitted for a notification channel of the given type. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ListNotificationChannels(self, request, context): + """Lists the notification channels that have been created for the project. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetNotificationChannel(self, request, context): + """Gets a single notification channel. The channel includes the relevant + configuration details with which the channel was created. However, the + response may truncate or omit passwords, API keys, or other private key + matter and thus the response may not be 100% identical to the information + that was supplied in the call to the create method. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateNotificationChannel(self, request, context): + """Creates a new notification channel, representing a single notification + endpoint such as an email address, SMS number, or pagerduty service. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def UpdateNotificationChannel(self, request, context): + """Updates a notification channel. Fields not specified in the field mask + remain unchanged. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def DeleteNotificationChannel(self, request, context): + """Deletes a notification channel. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def SendNotificationChannelVerificationCode(self, request, context): + """Causes a verification code to be delivered to the channel. The code + can then be supplied in `VerifyNotificationChannel` to verify the channel. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetNotificationChannelVerificationCode(self, request, context): + """Requests a verification code for an already verified channel that can then + be used in a call to VerifyNotificationChannel() on a different channel + with an equivalent identity in the same or in a different project. This + makes it possible to copy a channel between projects without requiring + manual reverification of the channel. If the channel is not in the + verified state, this method will fail (in other words, this may only be + used if the SendNotificationChannelVerificationCode and + VerifyNotificationChannel paths have already been used to put the given + channel into the verified state). + + There is no guarantee that the verification codes returned by this method + will be of a similar structure or form as the ones that are delivered + to the channel via SendNotificationChannelVerificationCode; while + VerifyNotificationChannel() will recognize both the codes delivered via + SendNotificationChannelVerificationCode() and returned from + GetNotificationChannelVerificationCode(), it is typically the case that + the verification codes delivered via + SendNotificationChannelVerificationCode() will be shorter and also + have a shorter expiration (e.g. codes such as "G-123456") whereas + GetVerificationCode() will typically return a much longer, websafe base + 64 encoded string that has a longer expiration time. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def VerifyNotificationChannel(self, request, context): + """Verifies a `NotificationChannel` by proving receipt of the code + delivered to the channel as a result of calling + `SendNotificationChannelVerificationCode`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_NotificationChannelServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'ListNotificationChannelDescriptors': grpc.unary_unary_rpc_method_handler( + servicer.ListNotificationChannelDescriptors, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelDescriptorsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelDescriptorsResponse.SerializeToString, + ), + 'GetNotificationChannelDescriptor': grpc.unary_unary_rpc_method_handler( + servicer.GetNotificationChannelDescriptor, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelDescriptorRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannelDescriptor.SerializeToString, + ), + 'ListNotificationChannels': grpc.unary_unary_rpc_method_handler( + servicer.ListNotificationChannels, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.ListNotificationChannelsResponse.SerializeToString, + ), + 'GetNotificationChannel': grpc.unary_unary_rpc_method_handler( + servicer.GetNotificationChannel, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.SerializeToString, + ), + 'CreateNotificationChannel': grpc.unary_unary_rpc_method_handler( + servicer.CreateNotificationChannel, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.CreateNotificationChannelRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.SerializeToString, + ), + 'UpdateNotificationChannel': grpc.unary_unary_rpc_method_handler( + servicer.UpdateNotificationChannel, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.UpdateNotificationChannelRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.SerializeToString, + ), + 'DeleteNotificationChannel': grpc.unary_unary_rpc_method_handler( + servicer.DeleteNotificationChannel, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.DeleteNotificationChannelRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'SendNotificationChannelVerificationCode': grpc.unary_unary_rpc_method_handler( + servicer.SendNotificationChannelVerificationCode, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.SendNotificationChannelVerificationCodeRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'GetNotificationChannelVerificationCode': grpc.unary_unary_rpc_method_handler( + servicer.GetNotificationChannelVerificationCode, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelVerificationCodeRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.GetNotificationChannelVerificationCodeResponse.SerializeToString, + ), + 'VerifyNotificationChannel': grpc.unary_unary_rpc_method_handler( + servicer.VerifyNotificationChannel, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__service__pb2.VerifyNotificationChannelRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_notification__pb2.NotificationChannel.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.monitoring.v3.NotificationChannelService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/monitoring/google/cloud/monitoring_v3/proto/uptime_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/uptime_pb2.py new file mode 100644 index 000000000000..a967987d31a7 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/uptime_pb2.py @@ -0,0 +1,833 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/uptime.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf.internal import enum_type_wrapper +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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import monitored_resource_pb2 as google_dot_api_dot_monitored__resource__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/cloud/monitoring_v3/proto/uptime.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n-google/cloud/monitoring_v3/proto/uptime.proto\x12\x14google.monitoring.v3\x1a#google/api/monitored_resource.proto\x1a\x1egoogle/protobuf/duration.proto\"\xb2\n\n\x11UptimeCheckConfig\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\x12;\n\x12monitored_resource\x18\x03 \x01(\x0b\x32\x1d.google.api.MonitoredResourceH\x00\x12O\n\x0eresource_group\x18\x04 \x01(\x0b\x32\x35.google.monitoring.v3.UptimeCheckConfig.ResourceGroupH\x00\x12G\n\nhttp_check\x18\x05 \x01(\x0b\x32\x31.google.monitoring.v3.UptimeCheckConfig.HttpCheckH\x01\x12\x45\n\ttcp_check\x18\x06 \x01(\x0b\x32\x30.google.monitoring.v3.UptimeCheckConfig.TcpCheckH\x01\x12)\n\x06period\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x07timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12P\n\x10\x63ontent_matchers\x18\t \x03(\x0b\x32\x36.google.monitoring.v3.UptimeCheckConfig.ContentMatcher\x12\x41\n\x10selected_regions\x18\n \x03(\x0e\x32\'.google.monitoring.v3.UptimeCheckRegion\x12R\n\x11internal_checkers\x18\x0e \x03(\x0b\x32\x37.google.monitoring.v3.UptimeCheckConfig.InternalChecker\x1a\x61\n\rResourceGroup\x12\x10\n\x08group_id\x18\x01 \x01(\t\x12>\n\rresource_type\x18\x02 \x01(\x0e\x32\'.google.monitoring.v3.GroupResourceType\x1a\xe4\x02\n\tHttpCheck\x12\x0f\n\x07use_ssl\x18\x01 \x01(\x08\x12\x0c\n\x04path\x18\x02 \x01(\t\x12\x0c\n\x04port\x18\x03 \x01(\x05\x12X\n\tauth_info\x18\x04 \x01(\x0b\x32\x45.google.monitoring.v3.UptimeCheckConfig.HttpCheck.BasicAuthentication\x12\x14\n\x0cmask_headers\x18\x05 \x01(\x08\x12O\n\x07headers\x18\x06 \x03(\x0b\x32>.google.monitoring.v3.UptimeCheckConfig.HttpCheck.HeadersEntry\x1a\x39\n\x13\x42\x61sicAuthentication\x12\x10\n\x08username\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\x1a.\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x1a\x18\n\x08TcpCheck\x12\x0c\n\x04port\x18\x01 \x01(\x05\x1a!\n\x0e\x43ontentMatcher\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x1ar\n\x0fInternalChecker\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x0f\n\x07network\x18\x02 \x01(\t\x12\x10\n\x08gcp_zone\x18\x03 \x01(\t\x12\x12\n\nchecker_id\x18\x04 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x05 \x01(\tB\n\n\x08resourceB\x14\n\x12\x63heck_request_type\"n\n\rUptimeCheckIp\x12\x37\n\x06region\x18\x01 \x01(\x0e\x32\'.google.monitoring.v3.UptimeCheckRegion\x12\x10\n\x08location\x18\x02 \x01(\t\x12\x12\n\nip_address\x18\x03 \x01(\t*e\n\x11UptimeCheckRegion\x12\x16\n\x12REGION_UNSPECIFIED\x10\x00\x12\x07\n\x03USA\x10\x01\x12\n\n\x06\x45UROPE\x10\x02\x12\x11\n\rSOUTH_AMERICA\x10\x03\x12\x10\n\x0c\x41SIA_PACIFIC\x10\x04*[\n\x11GroupResourceType\x12\x1d\n\x19RESOURCE_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08INSTANCE\x10\x01\x12\x19\n\x15\x41WS_ELB_LOAD_BALANCER\x10\x02\x42\xa3\x01\n\x18\x63om.google.monitoring.v3B\x0bUptimeProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_monitored__resource__pb2.DESCRIPTOR,google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,]) + +_UPTIMECHECKREGION = _descriptor.EnumDescriptor( + name='UptimeCheckRegion', + full_name='google.monitoring.v3.UptimeCheckRegion', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='REGION_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='USA', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='EUROPE', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SOUTH_AMERICA', index=3, number=3, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ASIA_PACIFIC', index=4, number=4, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1585, + serialized_end=1686, +) +_sym_db.RegisterEnumDescriptor(_UPTIMECHECKREGION) + +UptimeCheckRegion = enum_type_wrapper.EnumTypeWrapper(_UPTIMECHECKREGION) +_GROUPRESOURCETYPE = _descriptor.EnumDescriptor( + name='GroupResourceType', + full_name='google.monitoring.v3.GroupResourceType', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='RESOURCE_TYPE_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='INSTANCE', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='AWS_ELB_LOAD_BALANCER', index=2, number=2, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1688, + serialized_end=1779, +) +_sym_db.RegisterEnumDescriptor(_GROUPRESOURCETYPE) + +GroupResourceType = enum_type_wrapper.EnumTypeWrapper(_GROUPRESOURCETYPE) +REGION_UNSPECIFIED = 0 +USA = 1 +EUROPE = 2 +SOUTH_AMERICA = 3 +ASIA_PACIFIC = 4 +RESOURCE_TYPE_UNSPECIFIED = 0 +INSTANCE = 1 +AWS_ELB_LOAD_BALANCER = 2 + + + +_UPTIMECHECKCONFIG_RESOURCEGROUP = _descriptor.Descriptor( + name='ResourceGroup', + full_name='google.monitoring.v3.UptimeCheckConfig.ResourceGroup', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='group_id', full_name='google.monitoring.v3.UptimeCheckConfig.ResourceGroup.group_id', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='resource_type', full_name='google.monitoring.v3.UptimeCheckConfig.ResourceGroup.resource_type', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=804, + serialized_end=901, +) + +_UPTIMECHECKCONFIG_HTTPCHECK_BASICAUTHENTICATION = _descriptor.Descriptor( + name='BasicAuthentication', + full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.BasicAuthentication', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='username', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.BasicAuthentication.username', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='password', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.BasicAuthentication.password', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1155, + serialized_end=1212, +) + +_UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY = _descriptor.Descriptor( + name='HeadersEntry', + full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.HeadersEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.HeadersEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='value', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.HeadersEntry.value', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1214, + serialized_end=1260, +) + +_UPTIMECHECKCONFIG_HTTPCHECK = _descriptor.Descriptor( + name='HttpCheck', + full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='use_ssl', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.use_ssl', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='path', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.path', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='port', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.port', index=2, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='auth_info', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.auth_info', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='mask_headers', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.mask_headers', index=4, + number=5, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='headers', full_name='google.monitoring.v3.UptimeCheckConfig.HttpCheck.headers', index=5, + number=6, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[_UPTIMECHECKCONFIG_HTTPCHECK_BASICAUTHENTICATION, _UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=904, + serialized_end=1260, +) + +_UPTIMECHECKCONFIG_TCPCHECK = _descriptor.Descriptor( + name='TcpCheck', + full_name='google.monitoring.v3.UptimeCheckConfig.TcpCheck', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='port', full_name='google.monitoring.v3.UptimeCheckConfig.TcpCheck.port', index=0, + number=1, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1262, + serialized_end=1286, +) + +_UPTIMECHECKCONFIG_CONTENTMATCHER = _descriptor.Descriptor( + name='ContentMatcher', + full_name='google.monitoring.v3.UptimeCheckConfig.ContentMatcher', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='content', full_name='google.monitoring.v3.UptimeCheckConfig.ContentMatcher.content', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1288, + serialized_end=1321, +) + +_UPTIMECHECKCONFIG_INTERNALCHECKER = _descriptor.Descriptor( + name='InternalChecker', + full_name='google.monitoring.v3.UptimeCheckConfig.InternalChecker', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='project_id', full_name='google.monitoring.v3.UptimeCheckConfig.InternalChecker.project_id', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='network', full_name='google.monitoring.v3.UptimeCheckConfig.InternalChecker.network', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='gcp_zone', full_name='google.monitoring.v3.UptimeCheckConfig.InternalChecker.gcp_zone', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='checker_id', full_name='google.monitoring.v3.UptimeCheckConfig.InternalChecker.checker_id', index=3, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.UptimeCheckConfig.InternalChecker.display_name', index=4, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1323, + serialized_end=1437, +) + +_UPTIMECHECKCONFIG = _descriptor.Descriptor( + name='UptimeCheckConfig', + full_name='google.monitoring.v3.UptimeCheckConfig', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.UptimeCheckConfig.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.monitoring.v3.UptimeCheckConfig.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='monitored_resource', full_name='google.monitoring.v3.UptimeCheckConfig.monitored_resource', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='resource_group', full_name='google.monitoring.v3.UptimeCheckConfig.resource_group', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='http_check', full_name='google.monitoring.v3.UptimeCheckConfig.http_check', index=4, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='tcp_check', full_name='google.monitoring.v3.UptimeCheckConfig.tcp_check', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='period', full_name='google.monitoring.v3.UptimeCheckConfig.period', index=6, + number=7, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='timeout', full_name='google.monitoring.v3.UptimeCheckConfig.timeout', index=7, + number=8, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='content_matchers', full_name='google.monitoring.v3.UptimeCheckConfig.content_matchers', index=8, + number=9, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='selected_regions', full_name='google.monitoring.v3.UptimeCheckConfig.selected_regions', index=9, + number=10, type=14, cpp_type=8, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='internal_checkers', full_name='google.monitoring.v3.UptimeCheckConfig.internal_checkers', index=10, + number=14, 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[_UPTIMECHECKCONFIG_RESOURCEGROUP, _UPTIMECHECKCONFIG_HTTPCHECK, _UPTIMECHECKCONFIG_TCPCHECK, _UPTIMECHECKCONFIG_CONTENTMATCHER, _UPTIMECHECKCONFIG_INTERNALCHECKER, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='resource', full_name='google.monitoring.v3.UptimeCheckConfig.resource', + index=0, containing_type=None, fields=[]), + _descriptor.OneofDescriptor( + name='check_request_type', full_name='google.monitoring.v3.UptimeCheckConfig.check_request_type', + index=1, containing_type=None, fields=[]), + ], + serialized_start=141, + serialized_end=1471, +) + + +_UPTIMECHECKIP = _descriptor.Descriptor( + name='UptimeCheckIp', + full_name='google.monitoring.v3.UptimeCheckIp', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='region', full_name='google.monitoring.v3.UptimeCheckIp.region', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='location', full_name='google.monitoring.v3.UptimeCheckIp.location', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='ip_address', full_name='google.monitoring.v3.UptimeCheckIp.ip_address', 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1473, + serialized_end=1583, +) + +_UPTIMECHECKCONFIG_RESOURCEGROUP.fields_by_name['resource_type'].enum_type = _GROUPRESOURCETYPE +_UPTIMECHECKCONFIG_RESOURCEGROUP.containing_type = _UPTIMECHECKCONFIG +_UPTIMECHECKCONFIG_HTTPCHECK_BASICAUTHENTICATION.containing_type = _UPTIMECHECKCONFIG_HTTPCHECK +_UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY.containing_type = _UPTIMECHECKCONFIG_HTTPCHECK +_UPTIMECHECKCONFIG_HTTPCHECK.fields_by_name['auth_info'].message_type = _UPTIMECHECKCONFIG_HTTPCHECK_BASICAUTHENTICATION +_UPTIMECHECKCONFIG_HTTPCHECK.fields_by_name['headers'].message_type = _UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY +_UPTIMECHECKCONFIG_HTTPCHECK.containing_type = _UPTIMECHECKCONFIG +_UPTIMECHECKCONFIG_TCPCHECK.containing_type = _UPTIMECHECKCONFIG +_UPTIMECHECKCONFIG_CONTENTMATCHER.containing_type = _UPTIMECHECKCONFIG +_UPTIMECHECKCONFIG_INTERNALCHECKER.containing_type = _UPTIMECHECKCONFIG +_UPTIMECHECKCONFIG.fields_by_name['monitored_resource'].message_type = google_dot_api_dot_monitored__resource__pb2._MONITOREDRESOURCE +_UPTIMECHECKCONFIG.fields_by_name['resource_group'].message_type = _UPTIMECHECKCONFIG_RESOURCEGROUP +_UPTIMECHECKCONFIG.fields_by_name['http_check'].message_type = _UPTIMECHECKCONFIG_HTTPCHECK +_UPTIMECHECKCONFIG.fields_by_name['tcp_check'].message_type = _UPTIMECHECKCONFIG_TCPCHECK +_UPTIMECHECKCONFIG.fields_by_name['period'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_UPTIMECHECKCONFIG.fields_by_name['timeout'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_UPTIMECHECKCONFIG.fields_by_name['content_matchers'].message_type = _UPTIMECHECKCONFIG_CONTENTMATCHER +_UPTIMECHECKCONFIG.fields_by_name['selected_regions'].enum_type = _UPTIMECHECKREGION +_UPTIMECHECKCONFIG.fields_by_name['internal_checkers'].message_type = _UPTIMECHECKCONFIG_INTERNALCHECKER +_UPTIMECHECKCONFIG.oneofs_by_name['resource'].fields.append( + _UPTIMECHECKCONFIG.fields_by_name['monitored_resource']) +_UPTIMECHECKCONFIG.fields_by_name['monitored_resource'].containing_oneof = _UPTIMECHECKCONFIG.oneofs_by_name['resource'] +_UPTIMECHECKCONFIG.oneofs_by_name['resource'].fields.append( + _UPTIMECHECKCONFIG.fields_by_name['resource_group']) +_UPTIMECHECKCONFIG.fields_by_name['resource_group'].containing_oneof = _UPTIMECHECKCONFIG.oneofs_by_name['resource'] +_UPTIMECHECKCONFIG.oneofs_by_name['check_request_type'].fields.append( + _UPTIMECHECKCONFIG.fields_by_name['http_check']) +_UPTIMECHECKCONFIG.fields_by_name['http_check'].containing_oneof = _UPTIMECHECKCONFIG.oneofs_by_name['check_request_type'] +_UPTIMECHECKCONFIG.oneofs_by_name['check_request_type'].fields.append( + _UPTIMECHECKCONFIG.fields_by_name['tcp_check']) +_UPTIMECHECKCONFIG.fields_by_name['tcp_check'].containing_oneof = _UPTIMECHECKCONFIG.oneofs_by_name['check_request_type'] +_UPTIMECHECKIP.fields_by_name['region'].enum_type = _UPTIMECHECKREGION +DESCRIPTOR.message_types_by_name['UptimeCheckConfig'] = _UPTIMECHECKCONFIG +DESCRIPTOR.message_types_by_name['UptimeCheckIp'] = _UPTIMECHECKIP +DESCRIPTOR.enum_types_by_name['UptimeCheckRegion'] = _UPTIMECHECKREGION +DESCRIPTOR.enum_types_by_name['GroupResourceType'] = _GROUPRESOURCETYPE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +UptimeCheckConfig = _reflection.GeneratedProtocolMessageType('UptimeCheckConfig', (_message.Message,), dict( + + ResourceGroup = _reflection.GeneratedProtocolMessageType('ResourceGroup', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKCONFIG_RESOURCEGROUP, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """The resource submessage for group checks. It can be used instead of a + monitored resource, when multiple resources are being monitored. + + + Attributes: + group_id: + The group of resources being monitored. Should be only the + group\_id, not projects//groups/. + resource_type: + The resource type of the group members. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.ResourceGroup) + )) + , + + HttpCheck = _reflection.GeneratedProtocolMessageType('HttpCheck', (_message.Message,), dict( + + BasicAuthentication = _reflection.GeneratedProtocolMessageType('BasicAuthentication', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKCONFIG_HTTPCHECK_BASICAUTHENTICATION, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """A type of authentication to perform against the specified resource or + URL that uses username and password. Currently, only Basic + authentication is supported in Uptime Monitoring. + + + Attributes: + username: + The username to authenticate. + password: + The password to authenticate. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.HttpCheck.BasicAuthentication) + )) + , + + HeadersEntry = _reflection.GeneratedProtocolMessageType('HeadersEntry', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.HttpCheck.HeadersEntry) + )) + , + DESCRIPTOR = _UPTIMECHECKCONFIG_HTTPCHECK, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """Information involved in an HTTP/HTTPS uptime check request. + + + Attributes: + use_ssl: + If true, use HTTPS instead of HTTP to run the check. + path: + The path to the page to run the check against. Will be + combined with the host (specified within the + MonitoredResource) and port to construct the full URL. + Optional (defaults to "/"). + port: + The port to the page to run the check against. Will be + combined with host (specified within the MonitoredResource) + and path to construct the full URL. Optional (defaults to 80 + without SSL, or 443 with SSL). + auth_info: + The authentication information. Optional when creating an HTTP + check; defaults to empty. + mask_headers: + Boolean specifiying whether to encrypt the header information. + Encryption should be specified for any headers related to + authentication that you do not wish to be seen when retrieving + the configuration. The server will be responsible for + encrypting the headers. On Get/List calls, if mask\_headers is + set to True then the headers will be obscured with + \*\*\*\*\*\*. + headers: + The list of headers to send as part of the uptime check + request. If two headers have the same key and different + values, they should be entered as a single header, with the + value being a comma-separated list of all the desired values + as described at + https://www.w3.org/Protocols/rfc2616/rfc2616.txt (page 31). + Entering two separate headers with the same key in a Create + call will cause the first to be overwritten by the second. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.HttpCheck) + )) + , + + TcpCheck = _reflection.GeneratedProtocolMessageType('TcpCheck', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKCONFIG_TCPCHECK, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """Information required for a TCP uptime check request. + + + Attributes: + port: + The port to the page to run the check against. Will be + combined with host (specified within the MonitoredResource) to + construct the full URL. Required. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.TcpCheck) + )) + , + + ContentMatcher = _reflection.GeneratedProtocolMessageType('ContentMatcher', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKCONFIG_CONTENTMATCHER, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """Used to perform string matching. Currently, this matches on the exact + content. In the future, it can be expanded to allow for regular + expressions and more complex matching. + + + Attributes: + content: + String content to match + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.ContentMatcher) + )) + , + + InternalChecker = _reflection.GeneratedProtocolMessageType('InternalChecker', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKCONFIG_INTERNALCHECKER, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """Nimbus InternalCheckers. + + + Attributes: + project_id: + The GCP project ID. Not necessarily the same as the + project\_id for the config. + network: + The internal network to perform this uptime check on. + gcp_zone: + The GCP zone the uptime check should egress from. Only + respected for internal uptime checks, where internal\_network + is specified. + checker_id: + The checker ID. + display_name: + The checker's human-readable name. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig.InternalChecker) + )) + , + DESCRIPTOR = _UPTIMECHECKCONFIG, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """This message configures which resources and services to monitor for + availability. + + + Attributes: + name: + A unique resource name for this UptimeCheckConfig. The format + is: ``projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ + ID]``. This field should be omitted when creating the uptime + check configuration; on create, the resource name is assigned + by the server and included in the response. + display_name: + A human-friendly name for the uptime check configuration. The + display name should be unique within a Stackdriver Account in + order to make it easier to identify; however, uniqueness is + not enforced. Required. + resource: + The resource the check is checking. Required. + monitored_resource: + The monitored resource associated with the configuration. + resource_group: + The group resource associated with the configuration. + check_request_type: + The type of uptime check request. + http_check: + Contains information needed to make an HTTP or HTTPS check. + tcp_check: + Contains information needed to make a TCP check. + period: + How often the uptime check is performed. Currently, only 1, 5, + 10, and 15 minutes are supported. Required. + timeout: + The maximum amount of time to wait for the request to complete + (must be between 1 and 60 seconds). Required. + content_matchers: + The expected content on the page the check is run against. + Currently, only the first entry in the list is supported, and + other entries will be ignored. The server will look for an + exact match of the string in the page response's content. This + field is optional and should only be specified if a content + match is required. + selected_regions: + The list of regions from which the check will be run. If this + field is specified, enough regions to include a minimum of 3 + locations must be provided, or an error message is returned. + Not specifying this field will result in uptime checks running + from all regions. + internal_checkers: + The internal checkers that this check will egress from. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckConfig) + )) +_sym_db.RegisterMessage(UptimeCheckConfig) +_sym_db.RegisterMessage(UptimeCheckConfig.ResourceGroup) +_sym_db.RegisterMessage(UptimeCheckConfig.HttpCheck) +_sym_db.RegisterMessage(UptimeCheckConfig.HttpCheck.BasicAuthentication) +_sym_db.RegisterMessage(UptimeCheckConfig.HttpCheck.HeadersEntry) +_sym_db.RegisterMessage(UptimeCheckConfig.TcpCheck) +_sym_db.RegisterMessage(UptimeCheckConfig.ContentMatcher) +_sym_db.RegisterMessage(UptimeCheckConfig.InternalChecker) + +UptimeCheckIp = _reflection.GeneratedProtocolMessageType('UptimeCheckIp', (_message.Message,), dict( + DESCRIPTOR = _UPTIMECHECKIP, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_pb2' + , + __doc__ = """Contains the region, location, and list of IP addresses where checkers + in the location run from. + + + Attributes: + region: + A broad region category in which the IP address is located. + location: + A more specific location within the region that typically + encodes a particular city/town/metro (and its containing + state/province or country) within the broader umbrella region + category. + ip_address: + The IP address from which the uptime check originates. This is + a full IP address (not an IP address range). Most IP + addresses, as of this publication, are in IPv4 format; + however, one should not rely on the IP addresses being in IPv4 + format indefinitely and should support interpreting this field + in either IPv4 or IPv6 format. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UptimeCheckIp) + )) +_sym_db.RegisterMessage(UptimeCheckIp) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\013UptimeProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) +_UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY.has_options = True +_UPTIMECHECKCONFIG_HTTPCHECK_HEADERSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/uptime_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/uptime_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/uptime_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/monitoring/google/cloud/monitoring_v3/proto/uptime_service_pb2.py b/monitoring/google/cloud/monitoring_v3/proto/uptime_service_pb2.py new file mode 100644 index 000000000000..e6b4dfcdb380 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/uptime_service_pb2.py @@ -0,0 +1,590 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/monitoring_v3/proto/uptime_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 +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.cloud.monitoring_v3.proto import uptime_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__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/monitoring_v3/proto/uptime_service.proto', + package='google.monitoring.v3', + syntax='proto3', + serialized_pb=_b('\n5google/cloud/monitoring_v3/proto/uptime_service.proto\x12\x14google.monitoring.v3\x1a\x1cgoogle/api/annotations.proto\x1a-google/cloud/monitoring_v3/proto/uptime.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\"V\n\x1dListUptimeCheckConfigsRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\"\x80\x01\n\x1eListUptimeCheckConfigsResponse\x12\x45\n\x14uptime_check_configs\x18\x01 \x03(\x0b\x32\'.google.monitoring.v3.UptimeCheckConfig\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"+\n\x1bGetUptimeCheckConfigRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"v\n\x1e\x43reateUptimeCheckConfigRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x44\n\x13uptime_check_config\x18\x02 \x01(\x0b\x32\'.google.monitoring.v3.UptimeCheckConfig\"\x97\x01\n\x1eUpdateUptimeCheckConfigRequest\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\x12\x44\n\x13uptime_check_config\x18\x03 \x01(\x0b\x32\'.google.monitoring.v3.UptimeCheckConfig\".\n\x1e\x44\x65leteUptimeCheckConfigRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"B\n\x19ListUptimeCheckIpsRequest\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"t\n\x1aListUptimeCheckIpsResponse\x12=\n\x10uptime_check_ips\x18\x01 \x03(\x0b\x32#.google.monitoring.v3.UptimeCheckIp\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xc7\x08\n\x12UptimeCheckService\x12\xb7\x01\n\x16ListUptimeCheckConfigs\x12\x33.google.monitoring.v3.ListUptimeCheckConfigsRequest\x1a\x34.google.monitoring.v3.ListUptimeCheckConfigsResponse\"2\x82\xd3\xe4\x93\x02,\x12*/v3/{parent=projects/*}/uptimeCheckConfigs\x12\xa6\x01\n\x14GetUptimeCheckConfig\x12\x31.google.monitoring.v3.GetUptimeCheckConfigRequest\x1a\'.google.monitoring.v3.UptimeCheckConfig\"2\x82\xd3\xe4\x93\x02,\x12*/v3/{name=projects/*/uptimeCheckConfigs/*}\x12\xc1\x01\n\x17\x43reateUptimeCheckConfig\x12\x34.google.monitoring.v3.CreateUptimeCheckConfigRequest\x1a\'.google.monitoring.v3.UptimeCheckConfig\"G\x82\xd3\xe4\x93\x02\x41\"*/v3/{parent=projects/*}/uptimeCheckConfigs:\x13uptime_check_config\x12\xd5\x01\n\x17UpdateUptimeCheckConfig\x12\x34.google.monitoring.v3.UpdateUptimeCheckConfigRequest\x1a\'.google.monitoring.v3.UptimeCheckConfig\"[\x82\xd3\xe4\x93\x02U2>/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}:\x13uptime_check_config\x12\x9b\x01\n\x17\x44\x65leteUptimeCheckConfig\x12\x34.google.monitoring.v3.DeleteUptimeCheckConfigRequest\x1a\x16.google.protobuf.Empty\"2\x82\xd3\xe4\x93\x02,**/v3/{name=projects/*/uptimeCheckConfigs/*}\x12\x93\x01\n\x12ListUptimeCheckIps\x12/.google.monitoring.v3.ListUptimeCheckIpsRequest\x1a\x30.google.monitoring.v3.ListUptimeCheckIpsResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/v3/uptimeCheckIpsB\xaa\x01\n\x18\x63om.google.monitoring.v3B\x12UptimeServiceProtoP\x01Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\xaa\x02\x1aGoogle.Cloud.Monitoring.V3\xca\x02\x1aGoogle\\Cloud\\Monitoring\\V3b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,]) + + + + +_LISTUPTIMECHECKCONFIGSREQUEST = _descriptor.Descriptor( + name='ListUptimeCheckConfigsRequest', + full_name='google.monitoring.v3.ListUptimeCheckConfigsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='parent', full_name='google.monitoring.v3.ListUptimeCheckConfigsRequest.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListUptimeCheckConfigsRequest.page_size', index=1, + number=3, 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListUptimeCheckConfigsRequest.page_token', index=2, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=219, + serialized_end=305, +) + + +_LISTUPTIMECHECKCONFIGSRESPONSE = _descriptor.Descriptor( + name='ListUptimeCheckConfigsResponse', + full_name='google.monitoring.v3.ListUptimeCheckConfigsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='uptime_check_configs', full_name='google.monitoring.v3.ListUptimeCheckConfigsResponse.uptime_check_configs', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListUptimeCheckConfigsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=308, + serialized_end=436, +) + + +_GETUPTIMECHECKCONFIGREQUEST = _descriptor.Descriptor( + name='GetUptimeCheckConfigRequest', + full_name='google.monitoring.v3.GetUptimeCheckConfigRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.GetUptimeCheckConfigRequest.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=438, + serialized_end=481, +) + + +_CREATEUPTIMECHECKCONFIGREQUEST = _descriptor.Descriptor( + name='CreateUptimeCheckConfigRequest', + full_name='google.monitoring.v3.CreateUptimeCheckConfigRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='parent', full_name='google.monitoring.v3.CreateUptimeCheckConfigRequest.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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='uptime_check_config', full_name='google.monitoring.v3.CreateUptimeCheckConfigRequest.uptime_check_config', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=483, + serialized_end=601, +) + + +_UPDATEUPTIMECHECKCONFIGREQUEST = _descriptor.Descriptor( + name='UpdateUptimeCheckConfigRequest', + full_name='google.monitoring.v3.UpdateUptimeCheckConfigRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='update_mask', full_name='google.monitoring.v3.UpdateUptimeCheckConfigRequest.update_mask', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='uptime_check_config', full_name='google.monitoring.v3.UpdateUptimeCheckConfigRequest.uptime_check_config', index=1, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=604, + serialized_end=755, +) + + +_DELETEUPTIMECHECKCONFIGREQUEST = _descriptor.Descriptor( + name='DeleteUptimeCheckConfigRequest', + full_name='google.monitoring.v3.DeleteUptimeCheckConfigRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.monitoring.v3.DeleteUptimeCheckConfigRequest.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=757, + serialized_end=803, +) + + +_LISTUPTIMECHECKIPSREQUEST = _descriptor.Descriptor( + name='ListUptimeCheckIpsRequest', + full_name='google.monitoring.v3.ListUptimeCheckIpsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='page_size', full_name='google.monitoring.v3.ListUptimeCheckIpsRequest.page_size', index=0, + 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='page_token', full_name='google.monitoring.v3.ListUptimeCheckIpsRequest.page_token', index=1, + 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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=805, + serialized_end=871, +) + + +_LISTUPTIMECHECKIPSRESPONSE = _descriptor.Descriptor( + name='ListUptimeCheckIpsResponse', + full_name='google.monitoring.v3.ListUptimeCheckIpsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='uptime_check_ips', full_name='google.monitoring.v3.ListUptimeCheckIpsResponse.uptime_check_ips', 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, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='next_page_token', full_name='google.monitoring.v3.ListUptimeCheckIpsResponse.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, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=873, + serialized_end=989, +) + +_LISTUPTIMECHECKCONFIGSRESPONSE.fields_by_name['uptime_check_configs'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKCONFIG +_CREATEUPTIMECHECKCONFIGREQUEST.fields_by_name['uptime_check_config'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKCONFIG +_UPDATEUPTIMECHECKCONFIGREQUEST.fields_by_name['update_mask'].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK +_UPDATEUPTIMECHECKCONFIGREQUEST.fields_by_name['uptime_check_config'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKCONFIG +_LISTUPTIMECHECKIPSRESPONSE.fields_by_name['uptime_check_ips'].message_type = google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKIP +DESCRIPTOR.message_types_by_name['ListUptimeCheckConfigsRequest'] = _LISTUPTIMECHECKCONFIGSREQUEST +DESCRIPTOR.message_types_by_name['ListUptimeCheckConfigsResponse'] = _LISTUPTIMECHECKCONFIGSRESPONSE +DESCRIPTOR.message_types_by_name['GetUptimeCheckConfigRequest'] = _GETUPTIMECHECKCONFIGREQUEST +DESCRIPTOR.message_types_by_name['CreateUptimeCheckConfigRequest'] = _CREATEUPTIMECHECKCONFIGREQUEST +DESCRIPTOR.message_types_by_name['UpdateUptimeCheckConfigRequest'] = _UPDATEUPTIMECHECKCONFIGREQUEST +DESCRIPTOR.message_types_by_name['DeleteUptimeCheckConfigRequest'] = _DELETEUPTIMECHECKCONFIGREQUEST +DESCRIPTOR.message_types_by_name['ListUptimeCheckIpsRequest'] = _LISTUPTIMECHECKIPSREQUEST +DESCRIPTOR.message_types_by_name['ListUptimeCheckIpsResponse'] = _LISTUPTIMECHECKIPSRESPONSE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListUptimeCheckConfigsRequest = _reflection.GeneratedProtocolMessageType('ListUptimeCheckConfigsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTUPTIMECHECKCONFIGSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``ListUptimeCheckConfigs`` request. + + + Attributes: + parent: + The project whose uptime check configurations are listed. The + format is ``projects/[PROJECT_ID]``. + page_size: + The maximum number of results to return in a single response. + The server may further constrain the maximum number of results + returned in a single page. If the page\_size is <=0, the + server will decide the number of results to be returned. + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return more + results from the previous method call. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListUptimeCheckConfigsRequest) + )) +_sym_db.RegisterMessage(ListUptimeCheckConfigsRequest) + +ListUptimeCheckConfigsResponse = _reflection.GeneratedProtocolMessageType('ListUptimeCheckConfigsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTUPTIMECHECKCONFIGSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``ListUptimeCheckConfigs`` response. + + + Attributes: + uptime_check_configs: + The returned uptime check configurations. + next_page_token: + This field represents the pagination token to retrieve the + next page of results. If the value is empty, it means no + further results for the request. To retrieve the next page of + results, the value of the next\_page\_token is passed to the + subsequent List method call (in the request message's + page\_token field). + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListUptimeCheckConfigsResponse) + )) +_sym_db.RegisterMessage(ListUptimeCheckConfigsResponse) + +GetUptimeCheckConfigRequest = _reflection.GeneratedProtocolMessageType('GetUptimeCheckConfigRequest', (_message.Message,), dict( + DESCRIPTOR = _GETUPTIMECHECKCONFIGREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``GetUptimeCheckConfig`` request. + + + Attributes: + name: + The uptime check configuration to retrieve. The format is ``p + rojects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.GetUptimeCheckConfigRequest) + )) +_sym_db.RegisterMessage(GetUptimeCheckConfigRequest) + +CreateUptimeCheckConfigRequest = _reflection.GeneratedProtocolMessageType('CreateUptimeCheckConfigRequest', (_message.Message,), dict( + DESCRIPTOR = _CREATEUPTIMECHECKCONFIGREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``CreateUptimeCheckConfig`` request. + + + Attributes: + parent: + The project in which to create the uptime check. The format + is: ``projects/[PROJECT_ID]``. + uptime_check_config: + The new uptime check configuration. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.CreateUptimeCheckConfigRequest) + )) +_sym_db.RegisterMessage(CreateUptimeCheckConfigRequest) + +UpdateUptimeCheckConfigRequest = _reflection.GeneratedProtocolMessageType('UpdateUptimeCheckConfigRequest', (_message.Message,), dict( + DESCRIPTOR = _UPDATEUPTIMECHECKCONFIGREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``UpdateUptimeCheckConfig`` request. + + + Attributes: + update_mask: + Optional. If present, only the listed fields in the current + uptime check configuration are updated with values from the + new configuration. If this field is empty, then the current + configuration is completely replaced with the new + configuration. + uptime_check_config: + Required. If an ``"updateMask"`` has been specified, this + field gives the values for the set of fields mentioned in the + ``"updateMask"``. If an ``"updateMask"`` has not been given, + this uptime check configuration replaces the current + configuration. If a field is mentioned in ``"updateMask``" but + the corresonding field is omitted in this partial uptime check + configuration, it has the effect of deleting/clearing the + field from the configuration on the server. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.UpdateUptimeCheckConfigRequest) + )) +_sym_db.RegisterMessage(UpdateUptimeCheckConfigRequest) + +DeleteUptimeCheckConfigRequest = _reflection.GeneratedProtocolMessageType('DeleteUptimeCheckConfigRequest', (_message.Message,), dict( + DESCRIPTOR = _DELETEUPTIMECHECKCONFIGREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``DeleteUptimeCheckConfig`` request. + + + Attributes: + name: + The uptime check configuration to delete. The format is ``pro + jects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]``. + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.DeleteUptimeCheckConfigRequest) + )) +_sym_db.RegisterMessage(DeleteUptimeCheckConfigRequest) + +ListUptimeCheckIpsRequest = _reflection.GeneratedProtocolMessageType('ListUptimeCheckIpsRequest', (_message.Message,), dict( + DESCRIPTOR = _LISTUPTIMECHECKIPSREQUEST, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``ListUptimeCheckIps`` request. + + + Attributes: + page_size: + The maximum number of results to return in a single response. + The server may further constrain the maximum number of results + returned in a single page. If the page\_size is <=0, the + server will decide the number of results to be returned. NOTE: + this field is not yet implemented + page_token: + If this field is not empty then it must contain the + ``nextPageToken`` value returned by a previous call to this + method. Using this field causes the method to return more + results from the previous method call. NOTE: this field is not + yet implemented + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListUptimeCheckIpsRequest) + )) +_sym_db.RegisterMessage(ListUptimeCheckIpsRequest) + +ListUptimeCheckIpsResponse = _reflection.GeneratedProtocolMessageType('ListUptimeCheckIpsResponse', (_message.Message,), dict( + DESCRIPTOR = _LISTUPTIMECHECKIPSRESPONSE, + __module__ = 'google.cloud.monitoring_v3.proto.uptime_service_pb2' + , + __doc__ = """The protocol for the ``ListUptimeCheckIps`` response. + + + Attributes: + uptime_check_ips: + The returned list of IP addresses (including region and + location) that the checkers run from. + next_page_token: + This field represents the pagination token to retrieve the + next page of results. If the value is empty, it means no + further results for the request. To retrieve the next page of + results, the value of the next\_page\_token is passed to the + subsequent List method call (in the request message's + page\_token field). NOTE: this field is not yet implemented + """, + # @@protoc_insertion_point(class_scope:google.monitoring.v3.ListUptimeCheckIpsResponse) + )) +_sym_db.RegisterMessage(ListUptimeCheckIpsResponse) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\030com.google.monitoring.v3B\022UptimeServiceProtoP\001Z>google.golang.org/genproto/googleapis/monitoring/v3;monitoring\252\002\032Google.Cloud.Monitoring.V3\312\002\032Google\\Cloud\\Monitoring\\V3')) + +_UPTIMECHECKSERVICE = _descriptor.ServiceDescriptor( + name='UptimeCheckService', + full_name='google.monitoring.v3.UptimeCheckService', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=992, + serialized_end=2087, + methods=[ + _descriptor.MethodDescriptor( + name='ListUptimeCheckConfigs', + full_name='google.monitoring.v3.UptimeCheckService.ListUptimeCheckConfigs', + index=0, + containing_service=None, + input_type=_LISTUPTIMECHECKCONFIGSREQUEST, + output_type=_LISTUPTIMECHECKCONFIGSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002,\022*/v3/{parent=projects/*}/uptimeCheckConfigs')), + ), + _descriptor.MethodDescriptor( + name='GetUptimeCheckConfig', + full_name='google.monitoring.v3.UptimeCheckService.GetUptimeCheckConfig', + index=1, + containing_service=None, + input_type=_GETUPTIMECHECKCONFIGREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKCONFIG, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002,\022*/v3/{name=projects/*/uptimeCheckConfigs/*}')), + ), + _descriptor.MethodDescriptor( + name='CreateUptimeCheckConfig', + full_name='google.monitoring.v3.UptimeCheckService.CreateUptimeCheckConfig', + index=2, + containing_service=None, + input_type=_CREATEUPTIMECHECKCONFIGREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKCONFIG, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002A\"*/v3/{parent=projects/*}/uptimeCheckConfigs:\023uptime_check_config')), + ), + _descriptor.MethodDescriptor( + name='UpdateUptimeCheckConfig', + full_name='google.monitoring.v3.UptimeCheckService.UpdateUptimeCheckConfig', + index=3, + containing_service=None, + input_type=_UPDATEUPTIMECHECKCONFIGREQUEST, + output_type=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2._UPTIMECHECKCONFIG, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002U2>/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}:\023uptime_check_config')), + ), + _descriptor.MethodDescriptor( + name='DeleteUptimeCheckConfig', + full_name='google.monitoring.v3.UptimeCheckService.DeleteUptimeCheckConfig', + index=4, + containing_service=None, + input_type=_DELETEUPTIMECHECKCONFIGREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002,**/v3/{name=projects/*/uptimeCheckConfigs/*}')), + ), + _descriptor.MethodDescriptor( + name='ListUptimeCheckIps', + full_name='google.monitoring.v3.UptimeCheckService.ListUptimeCheckIps', + index=5, + containing_service=None, + input_type=_LISTUPTIMECHECKIPSREQUEST, + output_type=_LISTUPTIMECHECKIPSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002\024\022\022/v3/uptimeCheckIps')), + ), +]) +_sym_db.RegisterServiceDescriptor(_UPTIMECHECKSERVICE) + +DESCRIPTOR.services_by_name['UptimeCheckService'] = _UPTIMECHECKSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/monitoring/google/cloud/monitoring_v3/proto/uptime_service_pb2_grpc.py b/monitoring/google/cloud/monitoring_v3/proto/uptime_service_pb2_grpc.py new file mode 100644 index 000000000000..90dccd7de6c2 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/proto/uptime_service_pb2_grpc.py @@ -0,0 +1,153 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.monitoring_v3.proto import uptime_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2 +from google.cloud.monitoring_v3.proto import uptime_service_pb2 as google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class UptimeCheckServiceStub(object): + """The UptimeCheckService API is used to manage (list, create, delete, edit) + uptime check configurations in the Stackdriver Monitoring product. An uptime + check is a piece of configuration that determines which resources and + services to monitor for availability. These configurations can also be + configured interactively by navigating to the [Cloud Console] + (http://console.cloud.google.com), selecting the appropriate project, + clicking on "Monitoring" on the left-hand side to navigate to Stackdriver, + and then clicking on "Uptime". + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListUptimeCheckConfigs = channel.unary_unary( + '/google.monitoring.v3.UptimeCheckService/ListUptimeCheckConfigs', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckConfigsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckConfigsResponse.FromString, + ) + self.GetUptimeCheckConfig = channel.unary_unary( + '/google.monitoring.v3.UptimeCheckService/GetUptimeCheckConfig', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.GetUptimeCheckConfigRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.UptimeCheckConfig.FromString, + ) + self.CreateUptimeCheckConfig = channel.unary_unary( + '/google.monitoring.v3.UptimeCheckService/CreateUptimeCheckConfig', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.CreateUptimeCheckConfigRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.UptimeCheckConfig.FromString, + ) + self.UpdateUptimeCheckConfig = channel.unary_unary( + '/google.monitoring.v3.UptimeCheckService/UpdateUptimeCheckConfig', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.UpdateUptimeCheckConfigRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.UptimeCheckConfig.FromString, + ) + self.DeleteUptimeCheckConfig = channel.unary_unary( + '/google.monitoring.v3.UptimeCheckService/DeleteUptimeCheckConfig', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.DeleteUptimeCheckConfigRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.ListUptimeCheckIps = channel.unary_unary( + '/google.monitoring.v3.UptimeCheckService/ListUptimeCheckIps', + request_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckIpsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckIpsResponse.FromString, + ) + + +class UptimeCheckServiceServicer(object): + """The UptimeCheckService API is used to manage (list, create, delete, edit) + uptime check configurations in the Stackdriver Monitoring product. An uptime + check is a piece of configuration that determines which resources and + services to monitor for availability. These configurations can also be + configured interactively by navigating to the [Cloud Console] + (http://console.cloud.google.com), selecting the appropriate project, + clicking on "Monitoring" on the left-hand side to navigate to Stackdriver, + and then clicking on "Uptime". + """ + + def ListUptimeCheckConfigs(self, request, context): + """Lists the existing valid uptime check configurations for the project, + leaving out any invalid configurations. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetUptimeCheckConfig(self, request, context): + """Gets a single uptime check configuration. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateUptimeCheckConfig(self, request, context): + """Creates a new uptime check configuration. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def UpdateUptimeCheckConfig(self, request, context): + """Updates an uptime check configuration. You can either replace the entire + configuration with a new one or replace only certain fields in the current + configuration by specifying the fields to be updated via `"updateMask"`. + Returns the updated configuration. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def DeleteUptimeCheckConfig(self, request, context): + """Deletes an uptime check configuration. Note that this method will fail + if the uptime check configuration is referenced by an alert policy or + other dependent configs that would be rendered invalid by the deletion. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def ListUptimeCheckIps(self, request, context): + """Returns the list of IPs that checkers run from + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_UptimeCheckServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'ListUptimeCheckConfigs': grpc.unary_unary_rpc_method_handler( + servicer.ListUptimeCheckConfigs, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckConfigsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckConfigsResponse.SerializeToString, + ), + 'GetUptimeCheckConfig': grpc.unary_unary_rpc_method_handler( + servicer.GetUptimeCheckConfig, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.GetUptimeCheckConfigRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.UptimeCheckConfig.SerializeToString, + ), + 'CreateUptimeCheckConfig': grpc.unary_unary_rpc_method_handler( + servicer.CreateUptimeCheckConfig, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.CreateUptimeCheckConfigRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.UptimeCheckConfig.SerializeToString, + ), + 'UpdateUptimeCheckConfig': grpc.unary_unary_rpc_method_handler( + servicer.UpdateUptimeCheckConfig, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.UpdateUptimeCheckConfigRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__pb2.UptimeCheckConfig.SerializeToString, + ), + 'DeleteUptimeCheckConfig': grpc.unary_unary_rpc_method_handler( + servicer.DeleteUptimeCheckConfig, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.DeleteUptimeCheckConfigRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'ListUptimeCheckIps': grpc.unary_unary_rpc_method_handler( + servicer.ListUptimeCheckIps, + request_deserializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckIpsRequest.FromString, + response_serializer=google_dot_cloud_dot_monitoring__v3_dot_proto_dot_uptime__service__pb2.ListUptimeCheckIpsResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.monitoring.v3.UptimeCheckService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/monitoring/google/cloud/monitoring/query.py b/monitoring/google/cloud/monitoring_v3/query.py similarity index 75% rename from monitoring/google/cloud/monitoring/query.py rename to monitoring/google/cloud/monitoring_v3/query.py index 31e3995ff3c4..258d39272a63 100644 --- a/monitoring/google/cloud/monitoring/query.py +++ b/monitoring/google/cloud/monitoring_v3/query.py @@ -21,63 +21,26 @@ import copy import datetime -import itertools import six -from google.cloud._helpers import _datetime_to_rfc3339 -from google.cloud.monitoring._dataframe import _build_dataframe -from google.cloud.monitoring.timeseries import TimeSeries +from google.cloud.monitoring_v3 import _dataframe +from google.cloud.monitoring_v3 import types +from google.cloud.monitoring_v3.gapic import enums _UTCNOW = datetime.datetime.utcnow # To be replaced by tests. -class Aligner(object): - """Allowed values for the `supported aligners`_.""" - - ALIGN_NONE = 'ALIGN_NONE' - ALIGN_DELTA = 'ALIGN_DELTA' - ALIGN_RATE = 'ALIGN_RATE' - ALIGN_INTERPOLATE = 'ALIGN_INTERPOLATE' - ALIGN_NEXT_OLDER = 'ALIGN_NEXT_OLDER' - ALIGN_MIN = 'ALIGN_MIN' - ALIGN_MAX = 'ALIGN_MAX' - ALIGN_MEAN = 'ALIGN_MEAN' - ALIGN_COUNT = 'ALIGN_COUNT' - ALIGN_SUM = 'ALIGN_SUM' - ALIGN_STDDEV = 'ALIGN_STDDEV' - ALIGN_COUNT_TRUE = 'ALIGN_COUNT_TRUE' - ALIGN_FRACTION_TRUE = 'ALIGN_FRACTION_TRUE' - - -class Reducer(object): - """Allowed values for the `supported reducers`_.""" - - REDUCE_NONE = 'REDUCE_NONE' - REDUCE_MEAN = 'REDUCE_MEAN' - REDUCE_MIN = 'REDUCE_MIN' - REDUCE_MAX = 'REDUCE_MAX' - REDUCE_SUM = 'REDUCE_SUM' - REDUCE_STDDEV = 'REDUCE_STDDEV' - REDUCE_COUNT = 'REDUCE_COUNT' - REDUCE_COUNT_TRUE = 'REDUCE_COUNT_TRUE' - REDUCE_FRACTION_TRUE = 'REDUCE_FRACTION_TRUE' - REDUCE_PERCENTILE_99 = 'REDUCE_PERCENTILE_99' - REDUCE_PERCENTILE_95 = 'REDUCE_PERCENTILE_95' - REDUCE_PERCENTILE_50 = 'REDUCE_PERCENTILE_50' - REDUCE_PERCENTILE_05 = 'REDUCE_PERCENTILE_05' - - class Query(object): """Query object for retrieving metric data. - The preferred way to construct a query object is using the - :meth:`~google.cloud.monitoring.client.Client.query` method - of the :class:`~google.cloud.monitoring.client.Client` class. - - :type client: :class:`google.cloud.monitoring.client.Client` + :type client: :class:`google.cloud.monitoring_v3.gapic. + metric_service_client.MetricServiceClient` :param client: The client to use. + :type project: str + :param project: The project ID or number. + :type metric_type: str :param metric_type: The metric type name. The default value is :data:`Query.DEFAULT_METRIC_TYPE @@ -119,7 +82,7 @@ class Query(object): DEFAULT_METRIC_TYPE = 'compute.googleapis.com/instance/cpu/utilization' - def __init__(self, client, + def __init__(self, client, project, metric_type=DEFAULT_METRIC_TYPE, end_time=None, days=0, hours=0, minutes=0): start_time = None @@ -133,13 +96,14 @@ def __init__(self, client, raise ValueError('Non-zero duration required for time interval.') self._client = client + self._project_path = self._client.project_path(project) self._end_time = end_time self._start_time = start_time self._filter = _Filter(metric_type) - self._per_series_aligner = None - self._alignment_period_seconds = None - self._cross_series_reducer = None + self._per_series_aligner = 0 + self._alignment_period_seconds = 0 + self._cross_series_reducer = 0 self._group_by_fields = () def __iter__(self): @@ -188,7 +152,7 @@ def select_interval(self, end_time, start_time=None): :rtype: :class:`Query` :returns: The new query object. """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._end_time = end_time new_query._start_time = start_time return new_query @@ -206,7 +170,7 @@ def select_group(self, group_id): :rtype: :class:`Query` :returns: The new query object. """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._filter.group_id = group_id return new_query @@ -228,7 +192,7 @@ def select_projects(self, *args): :rtype: :class:`Query` :returns: The new query object. """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._filter.projects = args return new_query @@ -286,7 +250,7 @@ def select_resources(self, *args, **kwargs): .. _defined resource types: https://cloud.google.com/monitoring/api/v3/monitored-resources """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._filter.select_resources(*args, **kwargs) return new_query @@ -345,7 +309,7 @@ def select_metrics(self, *args, **kwargs): :rtype: :class:`Query` :returns: The new query object. """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._filter.select_metrics(*args, **kwargs) return new_query @@ -357,17 +321,21 @@ def align(self, per_series_aligner, seconds=0, minutes=0, hours=0): Example:: - query = query.align(Aligner.ALIGN_MEAN, minutes=5) + from google.cloud.monitoring import enums + query = query.align( + enums.Aggregation.Aligner.ALIGN_MEAN, minutes=5) It is also possible to specify the aligner as a literal string:: query = query.align('ALIGN_MEAN', minutes=5) - :type per_series_aligner: str + :type per_series_aligner: str or + :class:`~google.cloud.monitoring_v3.gapic.enums.Aggregation.Aligner` :param per_series_aligner: The approach to be used to align individual time series. For example: :data:`Aligner.ALIGN_MEAN`. - See :class:`Aligner` and the descriptions of the `supported - aligners`_. + See + :class:`~google.cloud.monitoring_v3.gapic.enums.Aggregation.Aligner` + and the descriptions of the `supported aligners`_. :type seconds: int :param seconds: The number of seconds in the alignment period. @@ -383,9 +351,9 @@ def align(self, per_series_aligner, seconds=0, minutes=0, hours=0): .. _supported aligners: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.alertPolicies#Aligner + projects.timeSeries/list#Aligner """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._per_series_aligner = per_series_aligner new_query._alignment_period_seconds = seconds + 60 * (minutes + 60 * hours) @@ -400,14 +368,17 @@ def reduce(self, cross_series_reducer, *group_by_fields): For example, you could request an aggregated time series for each combination of project and zone as follows:: - query = query.reduce(Reducer.REDUCE_MEAN, + from google.cloud.monitoring import enums + query = query.reduce(enums.Aggregation.Reducer.REDUCE_MEAN, 'resource.project_id', 'resource.zone') - :type cross_series_reducer: str + :type cross_series_reducer: str or + :class:`~google.cloud.monitoring_v3.gapic.enums.Aggregation.Reducer` :param cross_series_reducer: The approach to be used to combine time series. For example: - :data:`Reducer.REDUCE_MEAN`. See :class:`Reducer` and the - descriptions of the `supported reducers`_. + :data:`Reducer.REDUCE_MEAN`. See + :class:`~google.cloud.monitoring_v3.gapic.enums.Aggregation.Reducer` + and the descriptions of the `supported reducers`_. :type group_by_fields: strs :param group_by_fields: @@ -420,9 +391,9 @@ def reduce(self, cross_series_reducer, *group_by_fields): .. _supported reducers: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\ - projects.alertPolicies#Reducer + projects.timeSeries/list#Reducer """ - new_query = self.copy() + new_query = copy.deepcopy(self) new_query._cross_series_reducer = cross_series_reducer new_query._group_by_fields = group_by_fields return new_query @@ -431,7 +402,7 @@ def iter(self, headers_only=False, page_size=None): """Yield all time series objects selected by the query. The generator returned iterates over - :class:`~google.cloud.monitoring.timeseries.TimeSeries` objects + :class:`~google.cloud.monitoring_v3.types.TimeSeries` objects containing points ordered from oldest to newest. Note that the :class:`Query` object itself is an iterable, such that @@ -456,100 +427,50 @@ def iter(self, headers_only=False, page_size=None): :raises: :exc:`ValueError` if the query time interval has not been specified. """ - # The following use of groupby() relies on equality comparison - # of time series as (named) tuples. - for timeseries, fragments in itertools.groupby( - self._iter_fragments(headers_only, page_size), - lambda fragment: fragment.header()): - points = list(itertools.chain.from_iterable( - fragment.points for fragment in fragments)) - points.reverse() # Order from oldest to newest. - yield timeseries.header(points=points) - - def _iter_fragments(self, headers_only=False, page_size=None): - """Yield all time series fragments selected by the query. - - There may be multiple fragments per time series. These will be - contiguous. - - The parameters and return value are as for :meth:`Query.iter`. - """ if self._end_time is None: raise ValueError('Query time interval not specified.') - path = '/projects/{project}/timeSeries/'.format( - project=self._client.project) - - page_token = None - while True: - params = list(self._build_query_params( - headers_only=headers_only, - page_size=page_size, - page_token=page_token, - )) - response = self._client._connection.api_request( - method='GET', - path=path, - query_params=params, - ) - for info in response.get('timeSeries', ()): - yield TimeSeries._from_dict(info) - - page_token = response.get('nextPageToken') - if not page_token: - break - - def _build_query_params(self, headers_only=False, - page_size=None, page_token=None): - """Yield key-value pairs for the URL query string. + params = self._build_query_params(headers_only, page_size) + for ts in self._client.list_time_series(**params): + yield ts - We use a series of key-value pairs (suitable for passing to - ``urlencode``) instead of a ``dict`` to allow for repeated fields. + def _build_query_params(self, headers_only=False, page_size=None): + """Return key-value pairs for the list_time_series API call. :type headers_only: bool :param headers_only: Whether to omit the point data from the - :class:`~google.cloud.monitoring.timeseries.TimeSeries` objects. + :class:`~google.cloud.monitoring_v3.types.TimeSeries` objects. :type page_size: int :param page_size: (Optional) A limit on the number of points to return per page. - - :type page_token: str - :param page_token: (Optional) A token to continue the retrieval. """ - yield 'filter', self.filter - - yield 'interval.endTime', _datetime_to_rfc3339( - self._end_time, ignore_zone=False) - - if self._start_time is not None: - yield 'interval.startTime', _datetime_to_rfc3339( - self._start_time, ignore_zone=False) - - if self._per_series_aligner is not None: - yield 'aggregation.perSeriesAligner', self._per_series_aligner - - if self._alignment_period_seconds is not None: - alignment_period = '{period}s'.format( - period=self._alignment_period_seconds) - yield 'aggregation.alignmentPeriod', alignment_period - - if self._cross_series_reducer is not None: - yield ('aggregation.crossSeriesReducer', - self._cross_series_reducer) - - for field in self._group_by_fields: - yield 'aggregation.groupByFields', field + params = {'name': self._project_path, 'filter_': self.filter} + + params['interval'] = types.TimeInterval() + params['interval'].end_time.FromDatetime(self._end_time) + if self._start_time: + params['interval'].start_time.FromDatetime(self._start_time) + + if (self._per_series_aligner or self._alignment_period_seconds or + self._cross_series_reducer or self._group_by_fields): + params['aggregation'] = types.Aggregation( + per_series_aligner=self._per_series_aligner, + cross_series_reducer=self._cross_series_reducer, + group_by_fields=self._group_by_fields, + alignment_period={'seconds': self._alignment_period_seconds}, + ) if headers_only: - yield 'view', 'HEADERS' + params['view'] = enums.ListTimeSeriesRequest.TimeSeriesView.HEADERS + else: + params['view'] = enums.ListTimeSeriesRequest.TimeSeriesView.FULL if page_size is not None: - yield 'pageSize', page_size + params['page_size'] = page_size - if page_token is not None: - yield 'pageToken', page_token + return params def as_dataframe(self, label=None, labels=None): """Return all the selected time series as a :mod:`pandas` dataframe. @@ -592,18 +513,23 @@ def as_dataframe(self, label=None, labels=None): :rtype: :class:`pandas.DataFrame` :returns: A dataframe where each column represents one time series. """ - return _build_dataframe(self, label, labels) # pragma: NO COVER + return _dataframe._build_dataframe( + self, label, labels) + + def __deepcopy__(self, memo): + """Create a deepcopy of the query object. + + The `client` attribute is copied by reference only. - def copy(self): - """Copy the query object. + :type memo: dict + :param memo: the memo dict to avoid excess copying in case the object + is referenced from its member. :rtype: :class:`Query` :returns: The new query object. """ - # Using copy.deepcopy() would be appropriate, except that we want - # to copy self._client only as a reference. new_query = copy.copy(self) - new_query._filter = copy.copy(self._filter) + new_query._filter = copy.deepcopy(self._filter, memo) return new_query diff --git a/monitoring/google/cloud/monitoring_v3/types.py b/monitoring/google/cloud/monitoring_v3/types.py new file mode 100644 index 000000000000..12408f9d8d47 --- /dev/null +++ b/monitoring/google/cloud/monitoring_v3/types.py @@ -0,0 +1,79 @@ +# 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. + +from __future__ import absolute_import +import sys + +from google.api_core.protobuf_helpers import get_messages + +from google.api import distribution_pb2 +from google.api import http_pb2 +from google.api import label_pb2 +from google.api import metric_pb2 as api_metric_pb2 +from google.api import monitored_resource_pb2 +from google.cloud.monitoring_v3.proto import alert_pb2 +from google.cloud.monitoring_v3.proto import alert_service_pb2 +from google.cloud.monitoring_v3.proto import common_pb2 +from google.cloud.monitoring_v3.proto import group_pb2 +from google.cloud.monitoring_v3.proto import group_service_pb2 +from google.cloud.monitoring_v3.proto import metric_pb2 as proto_metric_pb2 +from google.cloud.monitoring_v3.proto import metric_service_pb2 +from google.cloud.monitoring_v3.proto import mutation_record_pb2 +from google.cloud.monitoring_v3.proto import notification_pb2 +from google.cloud.monitoring_v3.proto import notification_service_pb2 +from google.cloud.monitoring_v3.proto import uptime_pb2 +from google.cloud.monitoring_v3.proto import uptime_service_pb2 +from google.protobuf import any_pb2 +from google.protobuf import descriptor_pb2 +from google.protobuf import duration_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 +from google.protobuf import timestamp_pb2 +from google.protobuf import wrappers_pb2 +from google.rpc import status_pb2 + +names = [] +for module in ( + distribution_pb2, + http_pb2, + label_pb2, + api_metric_pb2, + monitored_resource_pb2, + alert_pb2, + alert_service_pb2, + common_pb2, + group_pb2, + group_service_pb2, + proto_metric_pb2, + metric_service_pb2, + mutation_record_pb2, + notification_pb2, + notification_service_pb2, + uptime_pb2, + uptime_service_pb2, + any_pb2, + descriptor_pb2, + duration_pb2, + empty_pb2, + field_mask_pb2, + timestamp_pb2, + wrappers_pb2, + status_pb2, +): + for name, message in get_messages(module).items(): + message.__module__ = 'google.cloud.monitoring_v3.types' + setattr(sys.modules[__name__], name, message) + names.append(name) + +__all__ = tuple(sorted(names)) diff --git a/monitoring/nox.py b/monitoring/nox.py index 893aeb7209a7..900f88742595 100644 --- a/monitoring/nox.py +++ b/monitoring/nox.py @@ -21,7 +21,6 @@ LOCAL_DEPS = ( os.path.join('..', 'api_core'), - os.path.join('..', 'core'), ) @@ -36,19 +35,25 @@ def default(session): """ # Install all test dependencies, then install this package in-place. session.install('mock', 'pytest', 'pytest-cov', *LOCAL_DEPS) - session.install('-e', '.') + + # Pandas does not support Python 3.4 + if session.interpreter == 'python3.4': + session.install('-e', '.') + else: + session.install('-e', '.[pandas]') # Run py.test against the unit tests. session.run( 'py.test', '--quiet', - '--cov=google.cloud.monitoring', + '--cov=google.cloud.monitoring_v3._dataframe', '--cov=tests.unit', '--cov-append', '--cov-config=.coveragerc', '--cov-report=', '--cov-fail-under=97', 'tests/unit', + *session.posargs ) @@ -88,7 +93,7 @@ def system(session, py): session.install('.') # Run py.test against the system tests. - session.run('py.test', '--quiet', 'tests/system.py') + session.run('py.test', '--quiet', 'tests/system', *session.posargs) @nox.session diff --git a/monitoring/setup.py b/monitoring/setup.py index 30f788d02755..2f3026ccda45 100644 --- a/monitoring/setup.py +++ b/monitoring/setup.py @@ -29,10 +29,10 @@ # 'Development Status :: 5 - Production/Stable' release_status = 'Development Status :: 3 - Alpha' dependencies = [ - 'google-cloud-core<0.29dev,>=0.28.0', - 'google-api-core<2.0.0dev,>=0.1.1', + 'google-api-core[grpc]<2.0.0dev,>=0.1.1', ] extras = { + 'pandas': 'pandas>=0.17.1', } diff --git a/monitoring/tests/system.py b/monitoring/tests/system.py deleted file mode 100644 index 925b1df3f19c..000000000000 --- a/monitoring/tests/system.py +++ /dev/null @@ -1,378 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -from google.cloud.exceptions import BadRequest -from google.cloud.exceptions import InternalServerError -from google.cloud.exceptions import NotFound -from google.cloud.exceptions import ServiceUnavailable -from google.cloud import monitoring - -from test_utils.retry import RetryErrors -from test_utils.retry import RetryResult -from test_utils.system import unique_resource_id - -retry_404 = RetryErrors(NotFound, max_tries=5) -retry_404_500 = RetryErrors((NotFound, InternalServerError)) -retry_500 = RetryErrors(InternalServerError) -retry_503 = RetryErrors(ServiceUnavailable) - - -class TestMonitoring(unittest.TestCase): - - def test_fetch_metric_descriptor(self): - METRIC_TYPE = ( - 'pubsub.googleapis.com/topic/send_message_operation_count') - METRIC_KIND = monitoring.MetricKind.DELTA - VALUE_TYPE = monitoring.ValueType.INT64 - - client = monitoring.Client() - descriptor = client.fetch_metric_descriptor(METRIC_TYPE) - - expected_name = 'projects/{project}/metricDescriptors/{type}'.format( - project=client.project, - type=METRIC_TYPE, - ) - self.assertEqual(descriptor.name, expected_name) - self.assertEqual(descriptor.type, METRIC_TYPE) - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - self.assertTrue(descriptor.description) - - self.assertTrue(descriptor.labels) - for label in descriptor.labels: - self.assertTrue(label.key) - self.assertTrue(label.value_type) - self.assertTrue(label.description) - - def test_list_metric_descriptors(self): - METRIC_TYPE = ( - 'pubsub.googleapis.com/topic/send_message_operation_count') - METRIC_KIND = monitoring.MetricKind.DELTA - VALUE_TYPE = monitoring.ValueType.INT64 - - client = monitoring.Client() - - descriptor = None - for item in client.list_metric_descriptors(): - if item.type == METRIC_TYPE: - descriptor = item - - self.assertIsNotNone(descriptor) - - expected_name = 'projects/{project}/{what}/{type}'.format( - project=client.project, - what='metricDescriptors', - type=METRIC_TYPE, - ) - self.assertEqual(descriptor.name, expected_name) - self.assertEqual(descriptor.type, METRIC_TYPE) - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - self.assertTrue(descriptor.description) - - self.assertTrue(descriptor.labels) - for label in descriptor.labels: - self.assertTrue(label.key) - self.assertTrue(label.value_type) - self.assertTrue(label.description) - - def test_list_metric_descriptors_filtered(self): - client = monitoring.Client() - - PREFIX = 'compute.googleapis.com/' - descriptors = client.list_metric_descriptors(type_prefix=PREFIX) - - # There are currently 18 types with this prefix, but that may change. - self.assertGreater(len(descriptors), 10) - - for descriptor in descriptors: - self.assertTrue(descriptor.type.startswith(PREFIX)) - - def test_fetch_resource_descriptor(self): - RESOURCE_TYPE = 'pubsub_topic' - - client = monitoring.Client() - descriptor = client.fetch_resource_descriptor(RESOURCE_TYPE) - - expected_name = 'projects/{project}/{what}/{type}'.format( - project=client.project, - what='monitoredResourceDescriptors', - type=RESOURCE_TYPE, - ) - self.assertEqual(descriptor.name, expected_name) - self.assertEqual(descriptor.type, RESOURCE_TYPE) - self.assertTrue(descriptor.display_name) - self.assertTrue(descriptor.description) - - self.assertTrue(descriptor.labels) - for label in descriptor.labels: - self.assertTrue(label.key) - self.assertTrue(label.value_type) - self.assertTrue(label.description) - - def test_list_resource_descriptors(self): - RESOURCE_TYPE = 'pubsub_topic' - - client = monitoring.Client() - - descriptor = None - for item in client.list_resource_descriptors(): - if item.type == RESOURCE_TYPE: - descriptor = item - - self.assertIsNotNone(descriptor) - - expected_name = 'projects/{project}/{what}/{type}'.format( - project=client.project, - what='monitoredResourceDescriptors', - type=RESOURCE_TYPE, - ) - self.assertEqual(descriptor.name, expected_name) - self.assertEqual(descriptor.type, RESOURCE_TYPE) - self.assertTrue(descriptor.display_name) - self.assertTrue(descriptor.description) - - self.assertTrue(descriptor.labels) - for label in descriptor.labels: - self.assertTrue(label.key) - self.assertTrue(label.value_type) - self.assertTrue(label.description) - - def test_query(self): - METRIC_TYPE = ( - 'pubsub.googleapis.com/topic/send_message_operation_count') - client = monitoring.Client() - query = client.query(METRIC_TYPE, hours=1) - # There may be no data, but we can ask anyway. - for _ in query: - pass # Not necessarily reached. - - def test_create_and_delete_metric_descriptor(self): - METRIC_TYPE = ('custom.googleapis.com/tmp/system_test_example' + - unique_resource_id()) - METRIC_KIND = monitoring.MetricKind.GAUGE - VALUE_TYPE = monitoring.ValueType.DOUBLE - DESCRIPTION = 'System test example -- DELETE ME!' - - client = monitoring.Client() - descriptor = client.metric_descriptor( - METRIC_TYPE, - metric_kind=METRIC_KIND, - value_type=VALUE_TYPE, - description=DESCRIPTION, - ) - - retry_500(descriptor.create)() - retry_404_500(descriptor.delete)() - - @RetryErrors(exception=BadRequest, max_tries=2) - def test_write_point(self): - METRIC_TYPE = ('custom.googleapis.com/tmp/system_test_example' + - unique_resource_id()) - METRIC_KIND = monitoring.MetricKind.GAUGE - VALUE_TYPE = monitoring.ValueType.DOUBLE - DESCRIPTION = 'System test example -- DELETE ME!' - VALUE = 3.14 - - client = monitoring.Client() - descriptor = client.metric_descriptor( - METRIC_TYPE, - metric_kind=METRIC_KIND, - value_type=VALUE_TYPE, - description=DESCRIPTION, - ) - - descriptor.create() - - metric = client.metric(METRIC_TYPE, {}) - resource = client.resource('global', {}) - - retry_500(client.write_point)(metric, resource, VALUE) - - def _query_timeseries_with_retries(): - MAX_RETRIES = 6 - - def _has_timeseries(result): - return len(list(result)) > 0 - - retry_result = RetryResult( - _has_timeseries, - max_tries=MAX_RETRIES, - backoff=3)(client.query) - return RetryErrors( - BadRequest, - max_tries=MAX_RETRIES, - backoff=3)(retry_result) - - query = _query_timeseries_with_retries()(METRIC_TYPE, minutes=5) - timeseries_list = list(query) - self.assertEqual(len(timeseries_list), 1) - timeseries = timeseries_list[0] - self.assertEqual(timeseries.metric, metric) - # project_id label only exists on output. - del timeseries.resource.labels['project_id'] - self.assertEqual(timeseries.resource, resource) - - descriptor.delete() - - with self.assertRaises(NotFound): - descriptor.delete() - - -class TestMonitoringGroups(unittest.TestCase): - - def setUp(self): - self.to_delete = [] - self.DISPLAY_NAME = 'Testing: New group' - self.FILTER = 'resource.type = "gce_instance"' - self.IS_CLUSTER = True - - def tearDown(self): - for group in self.to_delete: - retry_404(group.delete)() - - def test_create_group(self): - client = monitoring.Client() - group = client.group( - display_name=self.DISPLAY_NAME, - filter_string=self.FILTER, - is_cluster=self.IS_CLUSTER, - ) - - retry_503(group.create)() - self.to_delete.append(group) - - self.assertTrue(group.exists()) - - def test_list_groups(self): - client = monitoring.Client() - new_group = client.group( - display_name=self.DISPLAY_NAME, - filter_string=self.FILTER, - is_cluster=self.IS_CLUSTER, - ) - before_groups = client.list_groups() - before_names = set(group.name for group in before_groups) - - retry_503(new_group.create)() - self.to_delete.append(new_group) - - self.assertTrue(new_group.exists()) - after_groups = client.list_groups() - after_names = set(group.name for group in after_groups) - self.assertEqual(after_names - before_names, - set([new_group.name])) - - def test_reload_group(self): - client = monitoring.Client() - group = client.group( - display_name=self.DISPLAY_NAME, - filter_string=self.FILTER, - is_cluster=self.IS_CLUSTER, - ) - - retry_503(group.create)() - self.to_delete.append(group) - - group.filter = 'resource.type = "aws_ec2_instance"' - group.display_name = 'locally changed name' - group.reload() - self.assertEqual(group.filter, self.FILTER) - self.assertEqual(group.display_name, self.DISPLAY_NAME) - - def test_update_group(self): - NEW_FILTER = 'resource.type = "aws_ec2_instance"' - NEW_DISPLAY_NAME = 'updated' - - client = monitoring.Client() - group = client.group( - display_name=self.DISPLAY_NAME, - filter_string=self.FILTER, - is_cluster=self.IS_CLUSTER, - ) - - retry_503(group.create)() - self.to_delete.append(group) - - group.filter = NEW_FILTER - group.display_name = NEW_DISPLAY_NAME - group.update() - - after = client.fetch_group(group.id) - self.assertEqual(after.filter, NEW_FILTER) - self.assertEqual(after.display_name, NEW_DISPLAY_NAME) - - def test_list_group_members(self): - client = monitoring.Client() - group = client.group( - display_name=self.DISPLAY_NAME, - filter_string=self.FILTER, - is_cluster=self.IS_CLUSTER, - ) - - retry_503(group.create)() - self.to_delete.append(group) - - for member in group.list_members(): - self.assertIsInstance(member, monitoring.Resource) - - def test_group_hierarchy(self): - client = monitoring.Client() - root_group = client.group( - display_name='Testing: Root group', - filter_string=self.FILTER, - ) - - retry_503(root_group.create)() - self.to_delete.insert(0, root_group) - - middle_group = client.group( - display_name='Testing: Middle group', - filter_string=self.FILTER, - parent_id=root_group.id, - ) - - retry_503(middle_group.create)() - self.to_delete.insert(0, middle_group) - - leaf_group = client.group( - display_name='Testing: Leaf group', - filter_string=self.FILTER, - parent_id=middle_group.id, - ) - - retry_503(leaf_group.create)() - self.to_delete.insert(0, leaf_group) - - # Test for parent. - actual_parent = middle_group.fetch_parent() - self.assertTrue(actual_parent.name, root_group.name) - - # Test for children. - actual_children = middle_group.list_children() - children_names = [group.name for group in actual_children] - self.assertEqual(children_names, [leaf_group.name]) - - # Test for descendants. - actual_descendants = root_group.list_descendants() - descendant_names = {group.name for group in actual_descendants} - self.assertEqual(descendant_names, - set([middle_group.name, leaf_group.name])) - - # Test for ancestors. - actual_ancestors = leaf_group.list_ancestors() - ancestor_names = [group.name for group in actual_ancestors] - self.assertEqual(ancestor_names, [middle_group.name, root_group.name]) diff --git a/monitoring/tests/unit/__init__.py b/monitoring/tests/system/gapic/v3/test_system_metric_service_v3.py similarity index 50% rename from monitoring/tests/unit/__init__.py rename to monitoring/tests/system/gapic/v3/test_system_metric_service_v3.py index df379f1e9d88..6beb712c14b1 100644 --- a/monitoring/tests/unit/__init__.py +++ b/monitoring/tests/system/gapic/v3/test_system_metric_service_v3.py @@ -1,4 +1,4 @@ -# Copyright 2016 Google LLC +# Copyright 2017, Google LLC All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,3 +11,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import os +import time + +from google.api import monitored_resource_pb2 +from google.cloud import monitoring_v3 +from google.cloud.monitoring_v3.proto import metric_service_pb2 + + +class TestSystemMetricService(object): + def test_list_monitored_resource_descriptors(self): + project_id = os.environ['PROJECT_ID'] + + client = monitoring_v3.MetricServiceClient() + name = client.project_path(project_id) + response = client.list_monitored_resource_descriptors(name) diff --git a/monitoring/tests/unit/gapic/v3/test_group_service_client_v3.py b/monitoring/tests/unit/gapic/v3/test_group_service_client_v3.py new file mode 100644 index 000000000000..85b7f3f74266 --- /dev/null +++ b/monitoring/tests/unit/gapic/v3/test_group_service_client_v3.py @@ -0,0 +1,301 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# 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. +"""Unit tests.""" + +import pytest + +from google.api import monitored_resource_pb2 +from google.cloud import monitoring_v3 +from google.cloud.monitoring_v3.proto import group_pb2 +from google.cloud.monitoring_v3.proto import group_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 TestGroupServiceClient(object): + def test_list_groups(self): + # Setup Expected Response + next_page_token = '' + group_element = {} + group = [group_element] + expected_response = { + 'next_page_token': next_page_token, + 'group': group + } + expected_response = group_service_pb2.ListGroupsResponse( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + + paged_list_response = client.list_groups(name) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.group[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = group_service_pb2.ListGroupsRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_groups_exception(self): + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + + paged_list_response = client.list_groups(name) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_get_group(self): + # Setup Expected Response + name_2 = 'name2-1052831874' + display_name = 'displayName1615086568' + parent_name = 'parentName1015022848' + filter_ = 'filter-1274492040' + is_cluster = False + expected_response = { + 'name': name_2, + 'display_name': display_name, + 'parent_name': parent_name, + 'filter': filter_, + 'is_cluster': is_cluster + } + expected_response = group_pb2.Group(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup Request + name = client.group_path('[PROJECT]', '[GROUP]') + + response = client.get_group(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = group_service_pb2.GetGroupRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_group_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup request + name = client.group_path('[PROJECT]', '[GROUP]') + + with pytest.raises(CustomException): + client.get_group(name) + + def test_create_group(self): + # Setup Expected Response + name_2 = 'name2-1052831874' + display_name = 'displayName1615086568' + parent_name = 'parentName1015022848' + filter_ = 'filter-1274492040' + is_cluster = False + expected_response = { + 'name': name_2, + 'display_name': display_name, + 'parent_name': parent_name, + 'filter': filter_, + 'is_cluster': is_cluster + } + expected_response = group_pb2.Group(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + group = {} + + response = client.create_group(name, group) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = group_service_pb2.CreateGroupRequest( + name=name, group=group) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_group_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + group = {} + + with pytest.raises(CustomException): + client.create_group(name, group) + + def test_update_group(self): + # Setup Expected Response + name = 'name3373707' + display_name = 'displayName1615086568' + parent_name = 'parentName1015022848' + filter_ = 'filter-1274492040' + is_cluster = False + expected_response = { + 'name': name, + 'display_name': display_name, + 'parent_name': parent_name, + 'filter': filter_, + 'is_cluster': is_cluster + } + expected_response = group_pb2.Group(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup Request + group = {} + + response = client.update_group(group) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = group_service_pb2.UpdateGroupRequest(group=group) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_update_group_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup request + group = {} + + with pytest.raises(CustomException): + client.update_group(group) + + def test_delete_group(self): + channel = ChannelStub() + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup Request + name = client.group_path('[PROJECT]', '[GROUP]') + + client.delete_group(name) + + assert len(channel.requests) == 1 + expected_request = group_service_pb2.DeleteGroupRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_delete_group_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup request + name = client.group_path('[PROJECT]', '[GROUP]') + + with pytest.raises(CustomException): + client.delete_group(name) + + def test_list_group_members(self): + # Setup Expected Response + next_page_token = '' + total_size = -705419236 + members_element = {} + members = [members_element] + expected_response = { + 'next_page_token': next_page_token, + 'total_size': total_size, + 'members': members + } + expected_response = group_service_pb2.ListGroupMembersResponse( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup Request + name = client.group_path('[PROJECT]', '[GROUP]') + + paged_list_response = client.list_group_members(name) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.members[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = group_service_pb2.ListGroupMembersRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_group_members_exception(self): + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.GroupServiceClient(channel=channel) + + # Setup request + name = client.group_path('[PROJECT]', '[GROUP]') + + paged_list_response = client.list_group_members(name) + with pytest.raises(CustomException): + list(paged_list_response) diff --git a/monitoring/tests/unit/gapic/v3/test_metric_service_client_v3.py b/monitoring/tests/unit/gapic/v3/test_metric_service_client_v3.py new file mode 100644 index 000000000000..8c13b36e0a92 --- /dev/null +++ b/monitoring/tests/unit/gapic/v3/test_metric_service_client_v3.py @@ -0,0 +1,392 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# 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. +"""Unit tests.""" + +import pytest + +from google.api import metric_pb2 as api_metric_pb2 +from google.api import monitored_resource_pb2 +from google.cloud import monitoring_v3 +from google.cloud.monitoring_v3 import enums +from google.cloud.monitoring_v3.proto import common_pb2 +from google.cloud.monitoring_v3.proto import metric_pb2 as proto_metric_pb2 +from google.cloud.monitoring_v3.proto import metric_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 TestMetricServiceClient(object): + def test_list_monitored_resource_descriptors(self): + # Setup Expected Response + next_page_token = '' + resource_descriptors_element = {} + resource_descriptors = [resource_descriptors_element] + expected_response = { + 'next_page_token': next_page_token, + 'resource_descriptors': resource_descriptors + } + expected_response = metric_service_pb2.ListMonitoredResourceDescriptorsResponse( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + + paged_list_response = client.list_monitored_resource_descriptors(name) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.resource_descriptors[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.ListMonitoredResourceDescriptorsRequest( + name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_monitored_resource_descriptors_exception(self): + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + + paged_list_response = client.list_monitored_resource_descriptors(name) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_get_monitored_resource_descriptor(self): + # Setup Expected Response + name_2 = 'name2-1052831874' + type_ = 'type3575610' + display_name = 'displayName1615086568' + description = 'description-1724546052' + expected_response = { + 'name': name_2, + 'type': type_, + 'display_name': display_name, + 'description': description + } + expected_response = monitored_resource_pb2.MonitoredResourceDescriptor( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.monitored_resource_descriptor_path( + '[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]') + + response = client.get_monitored_resource_descriptor(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.GetMonitoredResourceDescriptorRequest( + name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_monitored_resource_descriptor_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.monitored_resource_descriptor_path( + '[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]') + + with pytest.raises(CustomException): + client.get_monitored_resource_descriptor(name) + + def test_list_metric_descriptors(self): + # Setup Expected Response + next_page_token = '' + metric_descriptors_element = {} + metric_descriptors = [metric_descriptors_element] + expected_response = { + 'next_page_token': next_page_token, + 'metric_descriptors': metric_descriptors + } + expected_response = metric_service_pb2.ListMetricDescriptorsResponse( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + + paged_list_response = client.list_metric_descriptors(name) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.metric_descriptors[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.ListMetricDescriptorsRequest( + name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_metric_descriptors_exception(self): + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + + paged_list_response = client.list_metric_descriptors(name) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_get_metric_descriptor(self): + # Setup Expected Response + name_2 = 'name2-1052831874' + type_ = 'type3575610' + unit = 'unit3594628' + description = 'description-1724546052' + display_name = 'displayName1615086568' + expected_response = { + 'name': name_2, + 'type': type_, + 'unit': unit, + 'description': description, + 'display_name': display_name + } + expected_response = api_metric_pb2.MetricDescriptor( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.metric_descriptor_path('[PROJECT]', + '[METRIC_DESCRIPTOR]') + + response = client.get_metric_descriptor(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.GetMetricDescriptorRequest( + name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_metric_descriptor_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.metric_descriptor_path('[PROJECT]', + '[METRIC_DESCRIPTOR]') + + with pytest.raises(CustomException): + client.get_metric_descriptor(name) + + def test_create_metric_descriptor(self): + # Setup Expected Response + name_2 = 'name2-1052831874' + type_ = 'type3575610' + unit = 'unit3594628' + description = 'description-1724546052' + display_name = 'displayName1615086568' + expected_response = { + 'name': name_2, + 'type': type_, + 'unit': unit, + 'description': description, + 'display_name': display_name + } + expected_response = api_metric_pb2.MetricDescriptor( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + metric_descriptor = {} + + response = client.create_metric_descriptor(name, metric_descriptor) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.CreateMetricDescriptorRequest( + name=name, metric_descriptor=metric_descriptor) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_metric_descriptor_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + metric_descriptor = {} + + with pytest.raises(CustomException): + client.create_metric_descriptor(name, metric_descriptor) + + def test_delete_metric_descriptor(self): + channel = ChannelStub() + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.metric_descriptor_path('[PROJECT]', + '[METRIC_DESCRIPTOR]') + + client.delete_metric_descriptor(name) + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.DeleteMetricDescriptorRequest( + name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_delete_metric_descriptor_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.metric_descriptor_path('[PROJECT]', + '[METRIC_DESCRIPTOR]') + + with pytest.raises(CustomException): + client.delete_metric_descriptor(name) + + def test_list_time_series(self): + # Setup Expected Response + next_page_token = '' + time_series_element = {} + time_series = [time_series_element] + expected_response = { + 'next_page_token': next_page_token, + 'time_series': time_series + } + expected_response = metric_service_pb2.ListTimeSeriesResponse( + **expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + filter_ = 'filter-1274492040' + interval = {} + view = enums.ListTimeSeriesRequest.TimeSeriesView.FULL + + paged_list_response = client.list_time_series(name, filter_, interval, + view) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.time_series[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.ListTimeSeriesRequest( + name=name, filter=filter_, interval=interval, view=view) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_time_series_exception(self): + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + filter_ = 'filter-1274492040' + interval = {} + view = enums.ListTimeSeriesRequest.TimeSeriesView.FULL + + paged_list_response = client.list_time_series(name, filter_, interval, + view) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_create_time_series(self): + channel = ChannelStub() + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + time_series = [] + + client.create_time_series(name, time_series) + + assert len(channel.requests) == 1 + expected_request = metric_service_pb2.CreateTimeSeriesRequest( + name=name, time_series=time_series) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_time_series_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = monitoring_v3.MetricServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + time_series = [] + + with pytest.raises(CustomException): + client.create_time_series(name, time_series) diff --git a/monitoring/tests/unit/test__dataframe.py b/monitoring/tests/unit/test__dataframe.py index d516d070efaa..82ea346c62fc 100644 --- a/monitoring/tests/unit/test__dataframe.py +++ b/monitoring/tests/unit/test__dataframe.py @@ -52,32 +52,29 @@ ARRAY = [VALUES] * DIMENSIONS[0] -def parse_timestamps(): # pragma: NO COVER - import datetime - from google.cloud._helpers import _RFC3339_MICROS +def parse_timestamps(): + from google.api_core import datetime_helpers - return [datetime.datetime.strptime(t, _RFC3339_MICROS) - for t in TIMESTAMPS] + return [ + datetime_helpers.from_rfc3339(t).replace(tzinfo=None) + for t in TIMESTAMPS] -def generate_query_results(): # pragma: NO COVER - from google.cloud.monitoring.metric import Metric - from google.cloud.monitoring.resource import Resource - from google.cloud.monitoring.timeseries import Point - from google.cloud.monitoring.timeseries import TimeSeries +def generate_query_results(): + from google.cloud.monitoring_v3 import types def P(timestamp, value): - return Point( - start_time=timestamp, - end_time=timestamp, - value=value, - ) + interval = types.TimeInterval() + interval.start_time.FromJsonString(timestamp) + interval.end_time.FromJsonString(timestamp) + return types.Point(interval=interval, value={'double_value': value}) for metric_labels, resource_labels, value in zip( METRIC_LABELS, RESOURCE_LABELS, VALUES): - yield TimeSeries( - metric=Metric(type=METRIC_TYPE, labels=metric_labels), - resource=Resource(type=RESOURCE_TYPE, labels=resource_labels), + yield types.TimeSeries( + metric=types.Metric(type=METRIC_TYPE, labels=metric_labels), + resource=types.MonitoredResource( + type=RESOURCE_TYPE, labels=resource_labels), metric_kind=METRIC_KIND, value_type=VALUE_TYPE, points=[P(t, value) for t in TIMESTAMPS], @@ -85,10 +82,10 @@ def P(timestamp, value): @unittest.skipUnless(HAVE_PANDAS, 'No pandas') -class Test__build_dataframe(unittest.TestCase): # pragma: NO COVER +class Test__build_dataframe(unittest.TestCase): def _call_fut(self, *args, **kwargs): - from google.cloud.monitoring._dataframe import _build_dataframe + from google.cloud.monitoring_v3._dataframe import _build_dataframe return _build_dataframe(*args, **kwargs) @@ -107,7 +104,9 @@ def test_simple_label(self): self.assertEqual(dataframe.shape, DIMENSIONS) self.assertEqual(dataframe.values.tolist(), ARRAY) - self.assertEqual(list(dataframe.columns), INSTANCE_NAMES) + expected_headers = [(instance_name,) + for instance_name in INSTANCE_NAMES] + self.assertEqual(list(dataframe.columns), expected_headers) self.assertIsNone(dataframe.columns.name) self.assertEqual(list(dataframe.index), parse_timestamps()) @@ -141,9 +140,10 @@ def test_multiple_labels_with_just_one(self): self.assertEqual(dataframe.shape, DIMENSIONS) self.assertEqual(dataframe.values.tolist(), ARRAY) - self.assertEqual(list(dataframe.columns), INSTANCE_IDS) + expected_headers = [(instance_id,) for instance_id in INSTANCE_IDS] + self.assertEqual(list(dataframe.columns), expected_headers) self.assertEqual(dataframe.columns.names, NAMES) - self.assertEqual(dataframe.columns.name, NAME) + self.assertIsNone(dataframe.columns.name) self.assertEqual(list(dataframe.index), parse_timestamps()) self.assertIsNone(dataframe.index.name) @@ -192,7 +192,7 @@ def test_empty_table_multiple_labels_with_just_one(self): dataframe = self._call_fut([], labels=NAMES) self.assertEqual(dataframe.shape, (0, 0)) self.assertEqual(dataframe.columns.names, NAMES) - self.assertEqual(dataframe.columns.name, NAME) + self.assertIsNone(dataframe.columns.name) self.assertIsNone(dataframe.index.name) self.assertIsInstance(dataframe.index, pandas.DatetimeIndex) @@ -202,7 +202,7 @@ def test_empty_table_smart_labels(self): dataframe = self._call_fut([]) self.assertEqual(dataframe.shape, (0, 0)) self.assertEqual(dataframe.columns.names, NAMES) - self.assertEqual(dataframe.columns.name, NAME) + self.assertIsNone(dataframe.columns.name) self.assertIsNone(dataframe.index.name) self.assertIsInstance(dataframe.index, pandas.DatetimeIndex) @@ -210,7 +210,8 @@ def test_empty_table_smart_labels(self): class Test__sorted_resource_labels(unittest.TestCase): def _call_fut(self, labels): - from google.cloud.monitoring._dataframe import _sorted_resource_labels + from google.cloud.monitoring_v3._dataframe import ( + _sorted_resource_labels) return _sorted_resource_labels(labels) @@ -218,13 +219,13 @@ def test_empty(self): self.assertEqual(self._call_fut([]), []) def test_sorted(self): - from google.cloud.monitoring._dataframe import TOP_RESOURCE_LABELS + from google.cloud.monitoring_v3._dataframe import TOP_RESOURCE_LABELS EXPECTED = TOP_RESOURCE_LABELS + ('other-1', 'other-2') self.assertSequenceEqual(self._call_fut(EXPECTED), EXPECTED) def test_reversed(self): - from google.cloud.monitoring._dataframe import TOP_RESOURCE_LABELS + from google.cloud.monitoring_v3._dataframe import TOP_RESOURCE_LABELS EXPECTED = TOP_RESOURCE_LABELS + ('other-1', 'other-2') INPUT = list(reversed(EXPECTED)) diff --git a/monitoring/tests/unit/test__http.py b/monitoring/tests/unit/test__http.py deleted file mode 100644 index da3e2ec2cfcf..000000000000 --- a/monitoring/tests/unit/test__http.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -import mock - - -class TestConnection(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring._http import Connection - - return Connection - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - client = object() - connection = self._make_one(client) - self.assertIs(connection._client, client) - - def test_extra_headers(self): - import requests - - from google.cloud import _http as base_http - from google.cloud.monitoring import _http as MUT - - http = mock.create_autospec(requests.Session, instance=True) - response = requests.Response() - response.status_code = 200 - data = b'brent-spiner' - response._content = data - http.request.return_value = response - client = mock.Mock(_http=http, spec=['_http']) - - conn = self._make_one(client) - req_data = 'req-data-boring' - result = conn.api_request( - 'GET', '/rainbow', data=req_data, expect_json=False) - self.assertEqual(result, data) - - expected_headers = { - 'Accept-Encoding': 'gzip', - base_http.CLIENT_INFO_HEADER: MUT._CLIENT_INFO, - 'User-Agent': conn.USER_AGENT, - } - expected_uri = conn.build_api_url('/rainbow') - http.request.assert_called_once_with( - data=req_data, - headers=expected_headers, - method='GET', - url=expected_uri, - ) diff --git a/monitoring/tests/unit/test_client.py b/monitoring/tests/unit/test_client.py deleted file mode 100644 index 64e421706e89..000000000000 --- a/monitoring/tests/unit/test_client.py +++ /dev/null @@ -1,667 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -import mock - - -PROJECT = 'my-project' - - -def _make_credentials(): - import google.auth.credentials - - return mock.Mock(spec=google.auth.credentials.Credentials) - - -class TestClient(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.client import Client - - return Client - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_query(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - from google.cloud.exceptions import NotFound - - START_TIME = datetime.datetime(2016, 4, 6, 22, 5, 0) - END_TIME = datetime.datetime(2016, 4, 6, 22, 10, 0) - MINUTES = 5 - - METRIC_TYPE = 'compute.googleapis.com/instance/cpu/utilization' - METRIC_LABELS = {'instance_name': 'instance-1'} - METRIC_LABELS2 = {'instance_name': 'instance-2'} - - RESOURCE_TYPE = 'gce_instance' - RESOURCE_LABELS = { - 'project_id': 'my-project', - 'zone': 'us-east1-a', - 'instance_id': '1234567890123456789', - } - RESOURCE_LABELS2 = { - 'project_id': 'my-project', - 'zone': 'us-east1-b', - 'instance_id': '9876543210987654321', - } - - METRIC_KIND = 'GAUGE' - VALUE_TYPE = 'DOUBLE' - - TS1 = '2016-04-06T22:05:00.042Z' - TS2 = '2016-04-06T22:05:01.042Z' - TS3 = '2016-04-06T22:05:02.042Z' - - VAL1 = 0.1 - VAL2 = 0.2 - - def P(timestamp, value): - return { - 'interval': {'startTime': timestamp, 'endTime': timestamp}, - 'value': {'doubleValue': value}, - } - - SERIES1 = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'points': [P(TS3, VAL1), P(TS2, VAL1), P(TS1, VAL1)], - } - SERIES2 = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS2}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS2}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'points': [P(TS3, VAL2), P(TS2, VAL2), P(TS1, VAL2)], - } - - RESPONSE = {'timeSeries': [SERIES1, SERIES2]} - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(RESPONSE) - - # A simple query. In practice, it can be very convenient to let the - # end time default to the start of the current minute. - query = client.query(METRIC_TYPE, end_time=END_TIME, minutes=MINUTES) - response = list(query) - - self.assertEqual(len(response), 2) - series1, series2 = response - - self.assertEqual(series1.metric.type, METRIC_TYPE) - self.assertEqual(series2.metric.type, METRIC_TYPE) - self.assertEqual(series1.metric.labels, METRIC_LABELS) - self.assertEqual(series2.metric.labels, METRIC_LABELS2) - - self.assertEqual(series1.resource.type, RESOURCE_TYPE) - self.assertEqual(series2.resource.type, RESOURCE_TYPE) - self.assertEqual(series1.resource.labels, RESOURCE_LABELS) - self.assertEqual(series2.resource.labels, RESOURCE_LABELS2) - - self.assertEqual(series1.metric_kind, METRIC_KIND) - self.assertEqual(series2.metric_kind, METRIC_KIND) - self.assertEqual(series1.value_type, VALUE_TYPE) - self.assertEqual(series2.value_type, VALUE_TYPE) - - self.assertEqual([p.value for p in series1.points], [VAL1, VAL1, VAL1]) - self.assertEqual([p.value for p in series2.points], [VAL2, VAL2, VAL2]) - self.assertEqual([p.end_time for p in series1.points], [TS1, TS2, TS3]) - self.assertEqual([p.end_time for p in series2.points], [TS1, TS2, TS3]) - - expected_request = { - 'method': 'GET', - 'path': '/projects/{project}/timeSeries/'.format(project=PROJECT), - 'query_params': [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', _datetime_to_rfc3339(END_TIME)), - ('interval.startTime', _datetime_to_rfc3339(START_TIME)), - ], - } - - request, = connection._requested - self.assertEqual(request, expected_request) - - with self.assertRaises(NotFound): - list(query) - - def test_metric_descriptor_factory(self): - TYPE = 'custom.googleapis.com/my_metric' - METRIC_KIND = 'GAUGE' - VALUE_TYPE = 'DOUBLE' - DESCRIPTION = 'This is my metric.' - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - client._connection = _Connection() # For safety's sake. - descriptor = client.metric_descriptor(TYPE, - metric_kind=METRIC_KIND, - value_type=VALUE_TYPE, - description=DESCRIPTION) - - self.assertIs(descriptor.client, client) - - self.assertIsNone(descriptor.name) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.labels, ()) - - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - - self.assertEqual(descriptor.unit, '') - self.assertEqual(descriptor.description, DESCRIPTION) - self.assertEqual(descriptor.display_name, '') - - def test_metric_factory(self): - TYPE = 'custom.googleapis.com/my_metric' - LABELS = { - 'instance_name': 'my-instance' - } - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - client._connection = _Connection() # For safety's sake. - metric = client.metric(TYPE, LABELS) - self.assertEqual(metric.type, TYPE) - self.assertEqual(metric.labels, LABELS) - - def test_resource_factory(self): - TYPE = 'https://cloud.google.com/monitoring/api/resources' - LABELS = { - 'instance_id': 'my-instance-id', - 'zone': 'us-central1-f' - } - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - client._connection = _Connection() # For safety's sake. - resource = client.resource(TYPE, LABELS) - self.assertEqual(resource.type, TYPE) - self.assertEqual(resource.labels, LABELS) - - def test_timeseries_factory_gauge(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - - METRIC_TYPE = 'custom.googleapis.com/my_metric' - METRIC_LABELS = { - 'status': 'successful' - } - - RESOURCE_TYPE = 'gce_instance' - RESOURCE_LABELS = { - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-f' - } - - VALUE = 42 - TIME1 = datetime.datetime.utcnow() - TIME1_STR = _datetime_to_rfc3339(TIME1, ignore_zone=False) - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - client._connection = _Connection() # For safety's sake. - metric = client.metric(METRIC_TYPE, METRIC_LABELS) - resource = client.resource(RESOURCE_TYPE, RESOURCE_LABELS) - - # Construct a time series assuming a gauge metric. - timeseries = client.time_series(metric, resource, VALUE, - end_time=TIME1) - self.assertEqual(timeseries.metric, metric) - self.assertEqual(timeseries.resource, resource) - self.assertEqual(len(timeseries.points), 1) - self.assertEqual(timeseries.points[0].value, VALUE) - self.assertIsNone(timeseries.points[0].start_time) - self.assertEqual(timeseries.points[0].end_time, TIME1_STR) - - TIME2 = datetime.datetime.utcnow() - TIME2_STR = _datetime_to_rfc3339(TIME2, ignore_zone=False) - # Construct a time series assuming a gauge metric using the current - # time - with mock.patch('google.cloud.monitoring.client._UTCNOW', - new=lambda: TIME2): - timeseries_no_end = client.time_series(metric, resource, VALUE) - - self.assertEqual(timeseries_no_end.points[0].end_time, TIME2_STR) - self.assertIsNone(timeseries_no_end.points[0].start_time) - - def test_timeseries_factory_cumulative(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - - MY_CUMULATIVE_METRIC = 'custom.googleapis.com/my_cumulative_metric' - METRIC_LABELS = { - 'status': 'successful' - } - - RESOURCE_TYPE = 'gce_instance' - RESOURCE_LABELS = { - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-f' - } - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - client._connection = _Connection() # For safety's sake. - resource = client.resource(RESOURCE_TYPE, RESOURCE_LABELS) - - VALUE = 42 - VALUE2 = 43 - RESET_TIME = datetime.datetime.utcnow() - TIME1 = datetime.datetime.utcnow() - TIME2 = datetime.datetime.utcnow() - - # Construct a couple of time series assuming a cumulative metric. - cumulative_metric = client.metric(MY_CUMULATIVE_METRIC, METRIC_LABELS) - cumulative_timeseries = client.time_series(cumulative_metric, - resource, - VALUE, - start_time=RESET_TIME, - end_time=TIME1) - - cumulative_timeseries2 = client.time_series(cumulative_metric, - resource, - VALUE2, - start_time=RESET_TIME, - end_time=TIME2) - - RESET_TIME_STR = _datetime_to_rfc3339(RESET_TIME, ignore_zone=False) - TIME1_STR = _datetime_to_rfc3339(TIME1, ignore_zone=False) - TIME2_STR = _datetime_to_rfc3339(TIME2, ignore_zone=False) - - self.assertEqual(cumulative_timeseries.points[0].start_time, - RESET_TIME_STR) - self.assertEqual(cumulative_timeseries.points[0].end_time, TIME1_STR) - self.assertEqual(cumulative_timeseries.points[0].value, VALUE) - self.assertEqual(cumulative_timeseries2.points[0].start_time, - RESET_TIME_STR) - self.assertEqual(cumulative_timeseries2.points[0].end_time, - TIME2_STR) - self.assertEqual(cumulative_timeseries2.points[0].value, VALUE2) - - def test_fetch_metric_descriptor(self): - TYPE = 'custom.googleapis.com/my_metric' - NAME = 'projects/{project}/metricDescriptors/{type}'.format( - project=PROJECT, type=TYPE) - DESCRIPTION = 'This is my metric.' - - METRIC_DESCRIPTOR = { - 'name': NAME, - 'type': TYPE, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION, - } - - # This test is identical to TestMetricDescriptor.test_fetch() - # except for the following three lines. - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(METRIC_DESCRIPTOR) - descriptor = client.fetch_metric_descriptor(TYPE) - - self.assertIs(descriptor.client, client) - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.description, DESCRIPTION) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + NAME} - self.assertEqual(request, expected_request) - - def test_list_metric_descriptors(self): - PATH = 'projects/{project}/metricDescriptors/'.format(project=PROJECT) - - TYPE1 = 'custom.googleapis.com/my_metric_1' - DESCRIPTION1 = 'This is my first metric.' - NAME1 = PATH + TYPE1 - METRIC_DESCRIPTOR1 = { - 'name': NAME1, - 'type': TYPE1, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION1, - } - - TYPE2 = 'custom.googleapis.com/my_metric_2' - DESCRIPTION2 = 'This is my second metric.' - NAME2 = PATH + TYPE2 - METRIC_DESCRIPTOR2 = { - 'name': NAME2, - 'type': TYPE2, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION2, - } - - RESPONSE = { - 'metricDescriptors': [METRIC_DESCRIPTOR1, METRIC_DESCRIPTOR2], - } - - # This test is identical to TestMetricDescriptor.test_list() - # except for the following three lines. - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(RESPONSE) - descriptors = client.list_metric_descriptors() - - self.assertEqual(len(descriptors), 2) - descriptor1, descriptor2 = descriptors - - self.assertIs(descriptor1.client, client) - self.assertEqual(descriptor1.name, NAME1) - self.assertEqual(descriptor1.type, TYPE1) - self.assertEqual(descriptor1.description, DESCRIPTION1) - - self.assertIs(descriptor2.client, client) - self.assertEqual(descriptor2.name, NAME2) - self.assertEqual(descriptor2.type, TYPE2) - self.assertEqual(descriptor2.description, DESCRIPTION2) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - self.assertEqual(request, expected_request) - - def test_fetch_resource_descriptor(self): - TYPE = 'gce_instance' - NAME = 'projects/{project}/monitoredResourceDescriptors/{type}'.format( - project=PROJECT, type=TYPE) - DISPLAY_NAME = 'GCE Instance' - DESCRIPTION = 'A VM instance hosted in Google Compute Engine.' - LABEL1 = {'key': 'project_id', 'valueType': 'STRING', - 'description': 'The ID of the GCP project...'} - LABEL2 = {'key': 'instance_id', 'valueType': 'STRING', - 'description': 'The VM instance identifier...'} - LABEL3 = {'key': 'zone', 'valueType': 'STRING', - 'description': 'The GCE zone...'} - - RESOURCE_DESCRIPTOR = { - 'name': NAME, - 'type': TYPE, - 'displayName': DISPLAY_NAME, - 'description': DESCRIPTION, - 'labels': [LABEL1, LABEL2, LABEL3], - } - - # This test is identical to TestResourceDescriptor.test_fetch() - # except for the following three lines. - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(RESOURCE_DESCRIPTOR) - descriptor = client.fetch_resource_descriptor(TYPE) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.display_name, DISPLAY_NAME) - self.assertEqual(descriptor.description, DESCRIPTION) - - self.assertEqual(len(descriptor.labels), 3) - label1, label2, label3 = descriptor.labels - self.assertEqual(label1.key, LABEL1['key']) - self.assertEqual(label2.key, LABEL2['key']) - self.assertEqual(label3.key, LABEL3['key']) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + NAME} - self.assertEqual(request, expected_request) - - def test_list_resource_descriptors(self): - PATH = 'projects/{project}/monitoredResourceDescriptors/'.format( - project=PROJECT) - - TYPE1 = 'custom.googleapis.com/resource-1' - DESCRIPTION1 = 'This is the first resource.' - NAME1 = PATH + TYPE1 - RESOURCE_DESCRIPTOR1 = { - 'name': NAME1, - 'type': TYPE1, - 'description': DESCRIPTION1, - } - - TYPE2 = 'custom.googleapis.com/resource-2' - DESCRIPTION2 = 'This is the second resource.' - NAME2 = PATH + TYPE2 - RESOURCE_DESCRIPTOR2 = { - 'name': NAME2, - 'type': TYPE2, - 'description': DESCRIPTION2, - } - - RESPONSE = { - 'resourceDescriptors': - [RESOURCE_DESCRIPTOR1, RESOURCE_DESCRIPTOR2], - } - - # This test is identical to TestResourceDescriptor.test_list() - # except for the following three lines. - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(RESPONSE) - descriptors = client.list_resource_descriptors() - - self.assertEqual(len(descriptors), 2) - descriptor1, descriptor2 = descriptors - - self.assertEqual(descriptor1.name, NAME1) - self.assertEqual(descriptor1.type, TYPE1) - self.assertEqual(descriptor1.description, DESCRIPTION1) - - self.assertEqual(descriptor2.name, NAME2) - self.assertEqual(descriptor2.type, TYPE2) - self.assertEqual(descriptor2.description, DESCRIPTION2) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - self.assertEqual(request, expected_request) - - def test_group(self): - GROUP_ID = 'GROUP_ID' - DISPLAY_NAME = 'My Group' - PARENT_ID = 'PARENT_ID' - FILTER = 'resource.type = "gce_instance"' - IS_CLUSTER = False - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - group = client.group(GROUP_ID, display_name=DISPLAY_NAME, - parent_id=PARENT_ID, filter_string=FILTER, - is_cluster=IS_CLUSTER) - - self.assertEqual(group.id, GROUP_ID) - self.assertEqual(group.display_name, DISPLAY_NAME) - self.assertEqual(group.parent_id, PARENT_ID) - self.assertEqual(group.filter, FILTER) - self.assertEqual(group.is_cluster, IS_CLUSTER) - - def test_group_defaults(self): - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - group = client.group() - - self.assertIsNone(group.id) - self.assertIsNone(group.display_name) - self.assertIsNone(group.parent_id) - self.assertIsNone(group.filter) - self.assertFalse(group.is_cluster) - - def test_fetch_group(self): - PATH = 'projects/{project}/groups/'.format(project=PROJECT) - GROUP_ID = 'GROUP_ID' - GROUP_NAME = PATH + GROUP_ID - DISPLAY_NAME = 'My Group' - PARENT_ID = 'PARENT_ID' - PARENT_NAME = PATH + PARENT_ID - FILTER = 'resource.type = "gce_instance"' - IS_CLUSTER = False - - GROUP = { - 'name': GROUP_NAME, - 'displayName': DISPLAY_NAME, - 'parentName': PARENT_NAME, - 'filter': FILTER, - 'isCluster': IS_CLUSTER - } - - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(GROUP) - group = client.fetch_group(GROUP_ID) - - self.assertEqual(group.id, GROUP_ID) - self.assertEqual(group.display_name, DISPLAY_NAME) - self.assertEqual(group.parent_id, PARENT_ID) - self.assertEqual(group.filter, FILTER) - self.assertEqual(group.is_cluster, IS_CLUSTER) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + GROUP_NAME} - self.assertEqual(request, expected_request) - - def test_list_groups(self): - PATH = 'projects/{project}/groups/'.format(project=PROJECT) - GROUP_NAME = PATH + 'GROUP_ID' - DISPLAY_NAME = 'My Group' - PARENT_NAME = PATH + 'PARENT_ID' - FILTER = 'resource.type = "gce_instance"' - IS_CLUSTER = False - - GROUP = { - 'name': GROUP_NAME, - 'displayName': DISPLAY_NAME, - 'parentName': PARENT_NAME, - 'filter': FILTER, - 'isCluster': IS_CLUSTER, - } - - RESPONSE = { - 'group': [GROUP], - } - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - connection = client._connection = _Connection(RESPONSE) - groups = client.list_groups() - - self.assertEqual(len(groups), 1) - - group = groups[0] - self.assertEqual(group.name, GROUP_NAME) - self.assertEqual(group.display_name, DISPLAY_NAME) - self.assertEqual(group.parent_name, PARENT_NAME) - self.assertEqual(group.filter, FILTER) - self.assertEqual(group.is_cluster, IS_CLUSTER) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - self.assertEqual(request, expected_request) - - def test_write_time_series(self): - PATH = '/projects/{project}/timeSeries/'.format(project=PROJECT) - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - - RESOURCE_TYPE = 'gce_instance' - RESOURCE_LABELS = { - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-f' - } - - METRIC_TYPE = 'custom.googleapis.com/my_metric' - METRIC_LABELS = { - 'status': 'successful' - } - METRIC_TYPE2 = 'custom.googleapis.com/count_404s' - METRIC_LABELS2 = { - 'request_ip': '127.0.0.1' - } - - connection = client._connection = _Connection({}) - - METRIC = client.metric(METRIC_TYPE, METRIC_LABELS) - METRIC2 = client.metric(METRIC_TYPE2, METRIC_LABELS2) - RESOURCE = client.resource(RESOURCE_TYPE, RESOURCE_LABELS) - - TIMESERIES1 = client.time_series(METRIC, RESOURCE, 3) - TIMESERIES2 = client.time_series(METRIC2, RESOURCE, 3.14) - - expected_data = { - 'timeSeries': [ - TIMESERIES1._to_dict(), - TIMESERIES2._to_dict() - ] - } - expected_request = {'method': 'POST', 'path': PATH, - 'data': expected_data} - - client.write_time_series([TIMESERIES1, TIMESERIES2]) - request, = connection._requested - self.assertEqual(request, expected_request) - - def test_write_point(self): - import datetime - - PATH = '/projects/{project}/timeSeries/'.format(project=PROJECT) - client = self._make_one( - project=PROJECT, credentials=_make_credentials()) - - RESOURCE_TYPE = 'gce_instance' - RESOURCE_LABELS = { - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-f' - } - - METRIC_TYPE = 'custom.googleapis.com/my_metric' - METRIC_LABELS = { - 'status': 'successful' - } - - connection = client._connection = _Connection({}) - - METRIC = client.metric(METRIC_TYPE, METRIC_LABELS) - RESOURCE = client.resource(RESOURCE_TYPE, RESOURCE_LABELS) - VALUE = 3.14 - TIMESTAMP = datetime.datetime.now() - TIMESERIES = client.time_series(METRIC, RESOURCE, VALUE, TIMESTAMP) - - expected_request = {'method': 'POST', 'path': PATH, - 'data': {'timeSeries': [TIMESERIES._to_dict()]}} - - client.write_point(METRIC, RESOURCE, VALUE, TIMESTAMP) - request, = connection._requested - self.assertEqual(request, expected_request) - - -class _Connection(object): - - def __init__(self, *responses): - self._responses = list(responses) - self._requested = [] - - def api_request(self, **kwargs): - from google.cloud.exceptions import NotFound - - self._requested.append(kwargs) - try: - return self._responses.pop(0) - except IndexError: - raise NotFound('miss') diff --git a/monitoring/tests/unit/test_group.py b/monitoring/tests/unit/test_group.py deleted file mode 100644 index 728314053d9d..000000000000 --- a/monitoring/tests/unit/test_group.py +++ /dev/null @@ -1,552 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - - -class Test_group_id_from_name(unittest.TestCase): - - def _call_fut(self, path, project): - from google.cloud.monitoring.group import _group_id_from_name - - return _group_id_from_name(path, project) - - def test_w_empty_name(self): - PROJECT = 'my-project-1234' - PATH = '' - with self.assertRaises(ValueError): - self._call_fut(PATH, PROJECT) - - def test_w_simple_name(self): - GROUP_ID = 'GROUP_ID' - PROJECT = 'my-project-1234' - PATH = 'projects/%s/groups/%s' % (PROJECT, GROUP_ID) - group_id = self._call_fut(PATH, PROJECT) - self.assertEqual(group_id, GROUP_ID) - - def test_w_name_w_all_extras(self): - GROUP_ID = 'GROUP_ID-part.one~part.two%part-three' - PROJECT = 'my-project-1234' - PATH = 'projects/%s/groups/%s' % (PROJECT, GROUP_ID) - group_id = self._call_fut(PATH, PROJECT) - self.assertEqual(group_id, GROUP_ID) - - -class TestGroup(unittest.TestCase): - - def setUp(self): - self.PROJECT = 'PROJECT' - self.GROUP_ID = 'group_id' - self.PARENT_ID = 'parent_id' - self.DISPLAY_NAME = 'My Group' - - self.PATH = 'projects/%s/groups/' % self.PROJECT - self.GROUP_NAME = self.PATH + self.GROUP_ID - self.PARENT_NAME = self.PATH + self.PARENT_ID - - FILTER_TEMPLATE = 'resource.metadata.tag."color"="%s"' - self.FILTER = FILTER_TEMPLATE % ('blue',) - - self.JSON_GROUP = { - 'name': self.GROUP_NAME, - 'displayName': self.DISPLAY_NAME, - 'parentName': self.PARENT_NAME, - 'filter': self.FILTER, - 'isCluster': True, - } - self.JSON_PARENT = { - 'name': self.PARENT_NAME, - 'displayName': 'Parent group', - 'filter': FILTER_TEMPLATE % 'red', - 'isCluster': False, - } - self.JSON_SIBLING = { - 'name': self.PATH + 'sibling_id', - 'displayName': 'Sibling group', - 'parentName': self.PARENT_NAME, - 'filter': FILTER_TEMPLATE % 'orange', - 'isCluster': True, - } - self.JSON_CHILD = { - 'name': self.PATH + 'child_id', - 'displayName': 'Child group', - 'parentName': self.PARENT_NAME, - 'filter': FILTER_TEMPLATE % 'purple', - 'isCluster': False, - } - - def _setUpResources(self): - from google.cloud.monitoring.resource import Resource - - info1 = { - 'type': 'gce_instance', - 'labels': { - 'project_id': 'my-project', - 'instance_id': '1234567890123456788', - 'zone': 'us-central1-a', - } - } - info2 = { - 'type': 'gce_instance', - 'labels': { - 'project_id': 'my-project', - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-a', - } - } - self.RESOURCE1 = Resource._from_dict(info1) - self.RESOURCE2 = Resource._from_dict(info2) - self.MEMBERS = [info1, info2] - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.group import Group - - return Group - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def _make_oneFromJSON(self, info, client=None): - return self._get_target_class()._from_dict(client=client, info=info) - - def _validateGroup(self, actual_group, expected_group_json): - expected_group = self._make_oneFromJSON(expected_group_json) - self.assertEqual(actual_group.id, expected_group.id) - self.assertEqual(actual_group.display_name, - expected_group.display_name) - self.assertEqual(actual_group.parent_id, expected_group.parent_id) - self.assertEqual(actual_group.filter, expected_group.filter) - self.assertEqual(actual_group.is_cluster, expected_group.is_cluster) - - def _validateGroupList(self, client, actual_groups, expected_groups_json): - self.assertEqual(len(actual_groups), len(expected_groups_json)) - for i, group in enumerate(actual_groups): - self.assertIs(group.client, client) - self._validateGroup(group, expected_groups_json[i]) - - def test_constructor(self): - client = _Client(project=self.PROJECT) - group = self._make_one( - client=client, - group_id=self.GROUP_ID, - display_name=self.DISPLAY_NAME, - parent_id=self.PARENT_ID, - filter_string=self.FILTER, - is_cluster=True, - ) - - self.assertIs(group.client, client) - - self.assertEqual(group.id, self.GROUP_ID) - self.assertEqual(group.name, self.GROUP_NAME) - self.assertEqual(group.display_name, self.DISPLAY_NAME) - self.assertEqual(group.parent_id, self.PARENT_ID) - self.assertEqual(group.parent_name, self.PARENT_NAME) - self.assertEqual(group.filter, self.FILTER) - self.assertTrue(group.is_cluster) - - def test_constructor_defaults(self): - client = _Client(project=self.PROJECT) - group = self._make_one(client=client) - - self.assertIs(group.client, client) - - self.assertIsNone(group.id) - self.assertIsNone(group.name) - self.assertIsNone(group.display_name) - self.assertIsNone(group.parent_id) - self.assertIsNone(group.parent_name) - self.assertIsNone(group.filter) - self.assertFalse(group.is_cluster) - - def test_path_no_id(self): - group = self._make_one(client=None) - self.assertRaises(ValueError, getattr, group, 'path') - - def test_path_w_id(self): - client = _Client(project=self.PROJECT) - group = self._make_one(client=client, group_id=self.GROUP_ID) - self.assertEqual(group.path, '/%s' % self.GROUP_NAME) - - def test_from_dict(self): - client = _Client(project=self.PROJECT) - group = self._get_target_class()._from_dict(client, self.JSON_GROUP) - - self.assertIs(group.client, client) - - self.assertEqual(group.name, self.GROUP_NAME) - self.assertEqual(group.display_name, self.DISPLAY_NAME) - self.assertEqual(group.parent_name, self.PARENT_NAME) - self.assertEqual(group.filter, self.FILTER) - self.assertTrue(group.is_cluster) - - def test_from_dict_defaults(self): - client = _Client(project=self.PROJECT) - info = { - 'name': self.GROUP_NAME, - 'displayName': self.DISPLAY_NAME, - 'filter': self.FILTER, - } - group = self._get_target_class()._from_dict(client, info) - - self.assertIs(group.client, client) - - self.assertEqual(group.id, self.GROUP_ID) - self.assertEqual(group.display_name, self.DISPLAY_NAME) - self.assertIsNone(group.parent_id) - self.assertEqual(group.filter, self.FILTER) - self.assertFalse(group.is_cluster) - - def test_to_dict(self): - client = _Client(project=self.PROJECT) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - self.assertEqual(group._to_dict(), self.JSON_GROUP) - - def test_to_dict_defaults(self): - client = _Client(project=self.PROJECT) - group = self._make_one( - client=client, group_id=self.GROUP_ID, - display_name=self.DISPLAY_NAME, - filter_string=self.FILTER) - expected_dict = { - 'name': self.GROUP_NAME, - 'displayName': self.DISPLAY_NAME, - 'filter': self.FILTER, - 'isCluster': False, - } - self.assertEqual(group._to_dict(), expected_dict) - - def test_create(self): - RESPONSE = self.JSON_GROUP - - REQUEST = RESPONSE.copy() - REQUEST.pop('name') - - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_one( - client=client, - display_name=self.DISPLAY_NAME, - parent_id=self.PARENT_ID, - filter_string=self.FILTER, - is_cluster=True - ) - group.create() - - self._validateGroup(group, RESPONSE) - - request, = connection._requested - expected_request = {'method': 'POST', 'path': '/' + self.PATH, - 'data': REQUEST} - self.assertEqual(request, expected_request) - - def test_exists_hit(self): - connection = _Connection(self.JSON_GROUP) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_one(client=client, group_id=self.GROUP_ID) - - self.assertTrue(group.exists()) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + self.GROUP_NAME, - 'query_params': {'fields': 'name'}} - self.assertEqual(request, expected_request) - - def test_exists_miss(self): - connection = _Connection() - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_one(client=client, group_id=self.GROUP_ID) - - self.assertFalse(group.exists()) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + self.GROUP_NAME, - 'query_params': {'fields': 'name'}} - self.assertEqual(request, expected_request) - - def test_reload(self): - connection = _Connection(self.JSON_GROUP) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_one(client, group_id=self.GROUP_ID) - group.reload() - - self.assertIs(group.client, client) - self._validateGroup(group, self.JSON_GROUP) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + self.GROUP_NAME} - self.assertEqual(request, expected_request) - - def test_update(self): - REQUEST = self.JSON_GROUP - RESPONSE = REQUEST - - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(REQUEST, client) - group.update() - - self._validateGroup(group, RESPONSE) - - request, = connection._requested - expected_request = {'method': 'PUT', 'path': '/' + self.GROUP_NAME, - 'data': REQUEST} - self.assertEqual(request, expected_request) - - def test_delete(self): - connection = _Connection(self.JSON_GROUP) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - group.delete() - - request, = connection._requested - expected_request = {'method': 'DELETE', 'path': group.path} - self.assertEqual(request, expected_request) - - def test_fetch_parent(self): - connection = _Connection(self.JSON_PARENT) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - - actual_parent = group.fetch_parent() - - self.assertIs(actual_parent.client, client) - self._validateGroup(actual_parent, self.JSON_PARENT) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + self.PARENT_NAME} - self.assertEqual(request, expected_request) - - def test_fetch_parent_empty(self): - connection = _Connection() - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_one(client=client) - actual_parent = group.fetch_parent() - - self.assertIsNone(actual_parent) - self.assertEqual(connection._requested, []) - - def test_list(self): - LIST_OF_GROUPS = [self.JSON_GROUP, self.JSON_PARENT] - RESPONSE = { - 'group': LIST_OF_GROUPS, - } - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - groups = self._get_target_class()._list(client) - self._validateGroupList(client, groups, LIST_OF_GROUPS) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + self.PATH, - 'query_params': {}} - self.assertEqual(request, expected_request) - - def test_list_paged(self): - from google.cloud.exceptions import NotFound - - LIST_OF_GROUPS = [self.JSON_GROUP, self.JSON_PARENT] - TOKEN = 'second-page-please' - RESPONSE1 = { - 'group': [LIST_OF_GROUPS[0]], - 'nextPageToken': TOKEN, - } - RESPONSE2 = { - 'group': [LIST_OF_GROUPS[1]], - } - - connection = _Connection(RESPONSE1, RESPONSE2) - client = _Client(project=self.PROJECT, connection=connection) - groups = self._get_target_class()._list(client) - self._validateGroupList(client, groups, LIST_OF_GROUPS) - - request1, request2 = connection._requested - expected_request1 = {'method': 'GET', 'path': '/' + self.PATH, - 'query_params': {}} - expected_request2 = {'method': 'GET', 'path': '/' + self.PATH, - 'query_params': {'pageToken': TOKEN}} - self.assertEqual(request1, expected_request1) - self.assertEqual(request2, expected_request2) - - with self.assertRaises(NotFound): - self._get_target_class()._list(client) - - def test_list_children(self): - CHILDREN = [self.JSON_GROUP, self.JSON_SIBLING] - RESPONSE = { - 'group': CHILDREN, - } - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - parent_group = self._make_oneFromJSON(self.JSON_PARENT, client) - groups = parent_group.list_children() - self._validateGroupList(client, groups, CHILDREN) - - request, = connection._requested - expected_request = { - 'method': 'GET', 'path': '/' + self.PATH, - 'query_params': {'childrenOfGroup': self.PARENT_NAME} - } - self.assertEqual(request, expected_request) - - def test_list_ancestors(self): - ANCESTORS = [self.JSON_GROUP, self.JSON_PARENT] - RESPONSE = { - 'group': ANCESTORS, - } - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - child_group = self._make_oneFromJSON(self.JSON_CHILD, client) - groups = child_group.list_ancestors() - self._validateGroupList(client, groups, ANCESTORS) - - request, = connection._requested - expected_request = { - 'method': 'GET', 'path': '/' + self.PATH, - 'query_params': {'ancestorsOfGroup': child_group.name} - } - self.assertEqual(request, expected_request) - - def test_list_descendants(self): - DESCENDANTS = [self.JSON_GROUP, self.JSON_SIBLING, self.JSON_CHILD] - RESPONSE = { - 'group': DESCENDANTS, - } - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - parent_group = self._make_oneFromJSON(self.JSON_PARENT, client) - groups = parent_group.list_descendants() - self._validateGroupList(client, groups, DESCENDANTS) - - request, = connection._requested - expected_request = { - 'method': 'GET', 'path': '/' + self.PATH, - 'query_params': {'descendantsOfGroup': self.PARENT_NAME} - } - self.assertEqual(request, expected_request) - - def test_list_members(self): - self._setUpResources() - RESPONSE = { - 'members': self.MEMBERS, - } - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - members = group.list_members() - - self.assertEqual(members, [self.RESOURCE1, self.RESOURCE2]) - - request, = connection._requested - expected_request = { - 'method': 'GET', 'path': '/%s/members' % self.GROUP_NAME, - 'query_params': {}, - } - self.assertEqual(request, expected_request) - - def test_list_members_paged(self): - self._setUpResources() - TOKEN = 'second-page-please' - RESPONSE1 = { - 'members': [self.MEMBERS[0]], - 'nextPageToken': TOKEN, - } - RESPONSE2 = { - 'members': [self.MEMBERS[1]], - } - - connection = _Connection(RESPONSE1, RESPONSE2) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - members = group.list_members() - - self.assertEqual(members, [self.RESOURCE1, self.RESOURCE2]) - - request1, request2 = connection._requested - expected_request1 = { - 'method': 'GET', 'path': '/%s/members' % self.GROUP_NAME, - 'query_params': {}, - } - expected_request2 = { - 'method': 'GET', 'path': '/%s/members' % self.GROUP_NAME, - 'query_params': {'pageToken': TOKEN}, - } - self.assertEqual(request1, expected_request1) - self.assertEqual(request2, expected_request2) - - def test_list_members_w_all_arguments(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - - self._setUpResources() - - T0 = datetime.datetime(2016, 4, 6, 22, 5, 0) - T1 = datetime.datetime(2016, 4, 6, 22, 10, 0) - MEMBER_FILTER = 'resource.zone = "us-central1-a"' - - RESPONSE = { - 'members': self.MEMBERS, - } - connection = _Connection(RESPONSE) - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - members = group.list_members( - start_time=T0, end_time=T1, filter_string=MEMBER_FILTER) - - self.assertEqual(members, [self.RESOURCE1, self.RESOURCE2]) - - request, = connection._requested - expected_request = { - 'method': 'GET', 'path': '/%s/members' % self.GROUP_NAME, - 'query_params': { - 'interval.startTime': _datetime_to_rfc3339(T0), - 'interval.endTime': _datetime_to_rfc3339(T1), - 'filter': MEMBER_FILTER, - }, - } - self.assertEqual(request, expected_request) - - def test_list_members_w_missing_end_time(self): - import datetime - - T0 = datetime.datetime(2016, 4, 6, 22, 5, 0) - - connection = _Connection() - client = _Client(project=self.PROJECT, connection=connection) - group = self._make_oneFromJSON(self.JSON_GROUP, client) - with self.assertRaises(ValueError): - group.list_members(start_time=T0) - - -class _Connection(object): - - def __init__(self, *responses): - self._responses = list(responses) - self._requested = [] - - def api_request(self, **kwargs): - from google.cloud.exceptions import NotFound - - self._requested.append(kwargs) - try: - return self._responses.pop(0) - except IndexError: - raise NotFound('miss') - - -class _Client(object): - - def __init__(self, project, connection=None): - self.project = project - self._connection = connection diff --git a/monitoring/tests/unit/test_label.py b/monitoring/tests/unit/test_label.py deleted file mode 100644 index e40baf68eb8d..000000000000 --- a/monitoring/tests/unit/test_label.py +++ /dev/null @@ -1,122 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -import mock - - -class TestLabelValueType(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.label import LabelValueType - - return LabelValueType - - def test_one(self): - self.assertTrue(hasattr(self._get_target_class(), 'STRING')) - - def test_names(self): - for name in self._get_target_class().__dict__: - if not name.startswith('_'): - self.assertEqual(getattr(self._get_target_class(), name), name) - - -class TestLabelDescriptor(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.label import LabelDescriptor - - return LabelDescriptor - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - KEY = 'response_code' - VALUE_TYPE = 'INT64' - DESCRIPTION = 'HTTP status code for the request.' - descriptor = self._make_one(key=KEY, value_type=VALUE_TYPE, - description=DESCRIPTION) - self.assertEqual(descriptor.key, KEY) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - self.assertEqual(descriptor.description, DESCRIPTION) - - def test_constructor_defaults(self): - KEY = 'response_code' - descriptor = self._make_one(key=KEY) - self.assertEqual(descriptor.key, KEY) - self.assertEqual(descriptor.value_type, 'STRING') - self.assertEqual(descriptor.description, '') - - def test_from_dict(self): - KEY = 'response_code' - VALUE_TYPE = 'INT64' - DESCRIPTION = 'HTTP status code for the request.' - info = { - 'key': KEY, - 'valueType': VALUE_TYPE, - 'description': DESCRIPTION, - } - descriptor = self._get_target_class()._from_dict(info) - self.assertEqual(descriptor.key, KEY) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - self.assertEqual(descriptor.description, DESCRIPTION) - - def test_from_dict_defaults(self): - KEY = 'response_code' - info = {'key': KEY} - descriptor = self._get_target_class()._from_dict(info) - self.assertEqual(descriptor.key, KEY) - self.assertEqual(descriptor.value_type, 'STRING') - self.assertEqual(descriptor.description, '') - - def test_to_dict(self): - KEY = 'response_code' - VALUE_TYPE = 'INT64' - DESCRIPTION = 'HTTP status code for the request.' - descriptor = self._make_one(key=KEY, value_type=VALUE_TYPE, - description=DESCRIPTION) - expected = { - 'key': KEY, - 'valueType': VALUE_TYPE, - 'description': DESCRIPTION, - } - self.assertEqual(descriptor._to_dict(), expected) - - def test_to_dict_defaults(self): - KEY = 'response_code' - descriptor = self._make_one(key=KEY) - expected = { - 'key': KEY, - 'valueType': 'STRING', - } - self.assertEqual(descriptor._to_dict(), expected) - - def test_equality(self): - KEY = 'response_code' - VALUE_TYPE = 'INT64' - DESCRIPTION = 'HTTP status code for the request.' - descriptor1a = self._make_one(key=KEY, value_type=VALUE_TYPE, - description=DESCRIPTION) - descriptor1b = self._make_one(key=KEY, value_type=VALUE_TYPE, - description=DESCRIPTION) - descriptor2 = self._make_one(key=KEY, value_type=VALUE_TYPE, - description=DESCRIPTION + 'foo') - self.assertEqual(descriptor1a, descriptor1b) - self.assertNotEqual(descriptor1a, descriptor2) - self.assertNotEqual(descriptor1a, object()) - self.assertEqual(descriptor1a, mock.ANY) diff --git a/monitoring/tests/unit/test_metric.py b/monitoring/tests/unit/test_metric.py deleted file mode 100644 index 4007ad747378..000000000000 --- a/monitoring/tests/unit/test_metric.py +++ /dev/null @@ -1,574 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - - -class TestMetricKind(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.metric import MetricKind - - return MetricKind - - def test_one(self): - self.assertTrue(hasattr(self._get_target_class(), 'GAUGE')) - - def test_names(self): - for name in self._get_target_class().__dict__: - if not name.startswith('_'): - self.assertEqual(getattr(self._get_target_class(), name), name) - - -class TestValueType(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.metric import ValueType - - return ValueType - - def test_one(self): - self.assertTrue(hasattr(self._get_target_class(), 'DISTRIBUTION')) - - def test_names(self): - for name in self._get_target_class().__dict__: - if not name.startswith('_'): - self.assertEqual(getattr(self._get_target_class(), name), name) - - -class TestMetricDescriptor(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.metric import MetricDescriptor - - return MetricDescriptor - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - from google.cloud.monitoring.label import LabelDescriptor - - TYPE = 'appengine.googleapis.com/http/server/response_count' - NAME = 'projects/my-project/metricDescriptors/' + TYPE - LABELS = [ - LabelDescriptor(key='loading', value_type='BOOL', - description='Loaded a new instance?'), - LabelDescriptor(key='response_code', value_type='INT64', - description='HTTP status code for the request.'), - ] - - METRIC_KIND = 'DELTA' - VALUE_TYPE = 'INT64' - - UNIT = '{responses}/s' - DESCRIPTION = 'Delta HTTP response count.' - DISPLAY_NAME = 'Response count' - - client = object() - descriptor = self._make_one( - client=client, - name=NAME, - type_=TYPE, - labels=LABELS, - metric_kind=METRIC_KIND, - value_type=VALUE_TYPE, - unit=UNIT, - description=DESCRIPTION, - display_name=DISPLAY_NAME, - ) - - self.assertIs(descriptor.client, client) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.labels, LABELS) - - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - - self.assertEqual(descriptor.unit, UNIT) - self.assertEqual(descriptor.description, DESCRIPTION) - self.assertEqual(descriptor.display_name, DISPLAY_NAME) - - def test_constructor_defaults(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - - client = object() - descriptor = self._make_one(client=client, type_=TYPE) - - self.assertIs(descriptor.client, client) - - self.assertIsNone(descriptor.name) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.labels, ()) - - self.assertEqual(descriptor.metric_kind, 'METRIC_KIND_UNSPECIFIED') - self.assertEqual(descriptor.value_type, 'VALUE_TYPE_UNSPECIFIED') - - self.assertEqual(descriptor.unit, '') - self.assertEqual(descriptor.description, '') - self.assertEqual(descriptor.display_name, '') - - def test_from_dict(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - NAME = 'projects/my-project/metricDescriptors/' + TYPE - LABEL1 = {'key': 'loading', 'valueType': 'BOOL', - 'description': 'Loaded a new instance?'} - LABEL2 = {'key': 'response_code', 'valueType': 'INT64', - 'description': 'HTTP status code for the request.'} - - METRIC_KIND = 'DELTA' - VALUE_TYPE = 'INT64' - - UNIT = '{responses}/s' - DESCRIPTION = 'Delta HTTP response count.' - DISPLAY_NAME = 'Response count' - - info = { - 'name': NAME, - 'type': TYPE, - 'labels': [LABEL1, LABEL2], - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'unit': UNIT, - 'description': DESCRIPTION, - 'displayName': DISPLAY_NAME, - } - client = object() - descriptor = self._get_target_class()._from_dict(client, info) - - self.assertIs(descriptor.client, client) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - - self.assertEqual(len(descriptor.labels), 2) - label1, label2 = descriptor.labels - self.assertEqual(label1.key, LABEL1['key']) - self.assertEqual(label2.key, LABEL2['key']) - - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - - self.assertEqual(descriptor.unit, UNIT) - self.assertEqual(descriptor.description, DESCRIPTION) - self.assertEqual(descriptor.display_name, DISPLAY_NAME) - - def test_from_dict_defaults(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - NAME = 'projects/my-project/metricDescriptors/' + TYPE - METRIC_KIND = 'CUMULATIVE' - VALUE_TYPE = 'DOUBLE' - - info = { - 'name': NAME, - 'type': TYPE, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - } - client = object() - descriptor = self._get_target_class()._from_dict(client, info) - - self.assertIs(descriptor.client, client) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.labels, ()) - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - self.assertEqual(descriptor.unit, '') - self.assertEqual(descriptor.description, '') - self.assertEqual(descriptor.display_name, '') - - def test_to_dict(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - NAME = 'projects/my-project/metricDescriptors/' + TYPE - LABEL1 = {'key': 'loading', 'valueType': 'BOOL', - 'description': 'Loaded a new instance?'} - LABEL2 = {'key': 'response_code', 'valueType': 'INT64', - 'description': 'HTTP status code for the request.'} - - METRIC_KIND = 'DELTA' - VALUE_TYPE = 'INT64' - - UNIT = '{responses}/s' - DESCRIPTION = 'Delta HTTP response count.' - DISPLAY_NAME = 'Response count' - - info = { - 'name': NAME, - 'type': TYPE, - 'labels': [LABEL1, LABEL2], - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'unit': UNIT, - 'description': DESCRIPTION, - 'displayName': DISPLAY_NAME, - } - client = object() - descriptor = self._get_target_class()._from_dict(client, info) - - del info['name'] - self.assertEqual(descriptor._to_dict(), info) - - def test_to_dict_defaults(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - NAME = 'projects/my-project/metricDescriptors/' + TYPE - METRIC_KIND = 'DELTA' - VALUE_TYPE = 'INT64' - - info = { - 'name': NAME, - 'type': TYPE, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - } - client = object() - descriptor = self._get_target_class()._from_dict(client, info) - - del info['name'] - self.assertEqual(descriptor._to_dict(), info) - - def test_create(self): - PROJECT = 'my-project' - TYPE = 'custom.googleapis.com/my_metric' - PATH = 'projects/{project}/metricDescriptors/'.format(project=PROJECT) - NAME = PATH + TYPE - - METRIC_KIND = 'GAUGE' - VALUE_TYPE = 'DOUBLE' - DESCRIPTION = 'This is my metric.' - - REQUEST = { - 'type': TYPE, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'description': DESCRIPTION, - } - RESPONSE = REQUEST.copy() - RESPONSE['name'] = NAME - - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - descriptor = self._make_one( - client=client, - type_=TYPE, - metric_kind=METRIC_KIND, - value_type=VALUE_TYPE, - description=DESCRIPTION, - ) - descriptor.create() - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.labels, ()) - - self.assertEqual(descriptor.metric_kind, METRIC_KIND) - self.assertEqual(descriptor.value_type, VALUE_TYPE) - - self.assertEqual(descriptor.unit, '') - self.assertEqual(descriptor.description, DESCRIPTION) - self.assertEqual(descriptor.display_name, '') - - request, = connection._requested - expected_request = {'method': 'POST', 'path': '/' + PATH, - 'data': REQUEST} - self.assertEqual(request, expected_request) - - def test_delete(self): - PROJECT = 'my-project' - TYPE = 'custom.googleapis.com/my_metric' - NAME = 'projects/{project}/metricDescriptors/{type}'.format( - project=PROJECT, type=TYPE) - - connection = _Connection({}) - client = _Client(project=PROJECT, connection=connection) - descriptor = self._make_one( - client=client, - type_=TYPE, - metric_kind='NOTUSED', - value_type='NOTUSED', - ) - descriptor.delete() - - request, = connection._requested - expected_request = {'method': 'DELETE', 'path': '/' + NAME} - self.assertEqual(request, expected_request) - - def test_fetch(self): - PROJECT = 'my-project' - TYPE = 'custom.googleapis.com/my_metric' - NAME = 'projects/{project}/metricDescriptors/{type}'.format( - project=PROJECT, type=TYPE) - DESCRIPTION = 'This is my metric.' - - METRIC_DESCRIPTOR = { - 'name': NAME, - 'type': TYPE, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION, - } - - connection = _Connection(METRIC_DESCRIPTOR) - client = _Client(project=PROJECT, connection=connection) - descriptor = self._get_target_class()._fetch(client, TYPE) - - self.assertIs(descriptor.client, client) - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.description, DESCRIPTION) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + NAME} - self.assertEqual(request, expected_request) - - def test_list(self): - PROJECT = 'my-project' - PATH = 'projects/{project}/metricDescriptors/'.format(project=PROJECT) - - TYPE1 = 'custom.googleapis.com/my_metric_1' - DESCRIPTION1 = 'This is my first metric.' - NAME1 = PATH + TYPE1 - METRIC_DESCRIPTOR1 = { - 'name': NAME1, - 'type': TYPE1, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION1, - } - - TYPE2 = 'custom.googleapis.com/my_metric_2' - DESCRIPTION2 = 'This is my second metric.' - NAME2 = PATH + TYPE2 - METRIC_DESCRIPTOR2 = { - 'name': NAME2, - 'type': TYPE2, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION2, - } - - RESPONSE = { - 'metricDescriptors': [METRIC_DESCRIPTOR1, METRIC_DESCRIPTOR2], - } - - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list(client) - - self.assertEqual(len(descriptors), 2) - descriptor1, descriptor2 = descriptors - - self.assertIs(descriptor1.client, client) - self.assertEqual(descriptor1.name, NAME1) - self.assertEqual(descriptor1.type, TYPE1) - self.assertEqual(descriptor1.description, DESCRIPTION1) - - self.assertIs(descriptor2.client, client) - self.assertEqual(descriptor2.name, NAME2) - self.assertEqual(descriptor2.type, TYPE2) - self.assertEqual(descriptor2.description, DESCRIPTION2) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - self.assertEqual(request, expected_request) - - def test_list_paged(self): - from google.cloud.exceptions import NotFound - - PROJECT = 'my-project' - PATH = 'projects/{project}/metricDescriptors/'.format(project=PROJECT) - - TYPE1 = 'custom.googleapis.com/my_metric_1' - DESCRIPTION1 = 'This is my first metric.' - NAME1 = PATH + TYPE1 - METRIC_DESCRIPTOR1 = { - 'name': NAME1, - 'type': TYPE1, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION1, - } - - TYPE2 = 'custom.googleapis.com/my_metric_2' - DESCRIPTION2 = 'This is my second metric.' - NAME2 = PATH + TYPE2 - METRIC_DESCRIPTOR2 = { - 'name': NAME2, - 'type': TYPE2, - 'metricKind': 'GAUGE', - 'valueType': 'DOUBLE', - 'description': DESCRIPTION2, - } - - TOKEN = 'second-page-please' - RESPONSE1 = { - 'metricDescriptors': [METRIC_DESCRIPTOR1], - 'nextPageToken': TOKEN, - } - RESPONSE2 = { - 'metricDescriptors': [METRIC_DESCRIPTOR2], - } - - connection = _Connection(RESPONSE1, RESPONSE2) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list(client) - - self.assertEqual(len(descriptors), 2) - descriptor1, descriptor2 = descriptors - - self.assertEqual(descriptor1.name, NAME1) - self.assertEqual(descriptor1.type, TYPE1) - self.assertEqual(descriptor1.description, DESCRIPTION1) - - self.assertEqual(descriptor2.name, NAME2) - self.assertEqual(descriptor2.type, TYPE2) - self.assertEqual(descriptor2.description, DESCRIPTION2) - - request1, request2 = connection._requested - expected_request1 = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - expected_request2 = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {'pageToken': TOKEN}} - self.assertEqual(request1, expected_request1) - self.assertEqual(request2, expected_request2) - - with self.assertRaises(NotFound): - self._get_target_class()._list(client) - - def test_list_filtered(self): - PROJECT = 'my-project' - PATH = 'projects/{project}/metricDescriptors/'.format(project=PROJECT) - - # Request only custom metrics. - FILTER = 'metric.type = starts_with("custom.googleapis.com/")' - - # But let's say there are no custom metrics. - RESPONSE = {'metricDescriptors': []} - - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list(client, FILTER) - - self.assertEqual(len(descriptors), 0) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {'filter': FILTER}} - self.assertEqual(request, expected_request) - - def test_list_filtered_by_type_prefix(self): - PROJECT = 'my-project' - PATH = 'projects/{project}/metricDescriptors/'.format(project=PROJECT) - - # Request only custom metrics. - PREFIX = 'custom.googleapis.com/' - FILTER = 'metric.type = starts_with("{prefix}")'.format(prefix=PREFIX) - - # But let's say there are no custom metrics. - RESPONSE = {'metricDescriptors': []} - - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list( - client, type_prefix=PREFIX) - - self.assertEqual(len(descriptors), 0) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {'filter': FILTER}} - self.assertEqual(request, expected_request) - - -class TestMetric(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.metric import Metric - - return Metric - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - LABELS = { - 'response_code': 200, - 'loading': False, - } - metric = self._make_one(type=TYPE, labels=LABELS) - self.assertEqual(metric.type, TYPE) - self.assertEqual(metric.labels, LABELS) - - def test_from_dict(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - LABELS = { - 'response_code': 200, - 'loading': False, - } - info = { - 'type': TYPE, - 'labels': LABELS, - } - metric = self._get_target_class()._from_dict(info) - self.assertEqual(metric.type, TYPE) - self.assertEqual(metric.labels, LABELS) - - def test_from_dict_defaults(self): - TYPE = 'appengine.googleapis.com/http/server/response_count' - info = {'type': TYPE} - metric = self._get_target_class()._from_dict(info) - self.assertEqual(metric.type, TYPE) - self.assertEqual(metric.labels, {}) - - def test_to_dict(self): - TYPE = 'custom.googleapis.com/my_metric' - LABELS = {} - metric = self._make_one(TYPE, LABELS) - expected_dict = { - 'type': TYPE, - 'labels': LABELS, - } - self.assertEqual(metric._to_dict(), expected_dict) - - -class _Connection(object): - - def __init__(self, *responses): - self._responses = list(responses) - self._requested = [] - - def api_request(self, **kwargs): - from google.cloud.exceptions import NotFound - - self._requested.append(kwargs) - try: - return self._responses.pop(0) - except IndexError: - raise NotFound('miss') - - -class _Client(object): - - def __init__(self, project, connection): - self.project = project - self._connection = connection diff --git a/monitoring/tests/unit/test_query.py b/monitoring/tests/unit/test_query.py index 8a9c386248c4..2b253976039f 100644 --- a/monitoring/tests/unit/test_query.py +++ b/monitoring/tests/unit/test_query.py @@ -12,8 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest +from __future__ import absolute_import +import datetime +import unittest +import mock PROJECT = 'my-project' @@ -36,51 +39,57 @@ METRIC_KIND = 'DELTA' VALUE_TYPE = 'DOUBLE' -TS0 = '2016-04-06T22:05:00.042Z' -TS1 = '2016-04-06T22:05:01.042Z' -TS2 = '2016-04-06T22:05:02.042Z' +TS0 = datetime.datetime(2016, 4, 6, 22, 5, 0, 42) +TS1 = datetime.datetime(2016, 4, 6, 22, 5, 1, 42) +TS2 = datetime.datetime(2016, 4, 6, 22, 5, 2, 42) -class TestAligner(unittest.TestCase): +class MultiCallableStub(object): + """Stub for the grpc.UnaryUnaryMultiCallable interface.""" - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.query import Aligner + def __init__(self, method, channel_stub): + self.method = method + self.channel_stub = channel_stub - return Aligner + def __call__(self, request, timeout=None, metadata=None, credentials=None): + self.channel_stub.requests.append((self.method, request)) - def test_one(self): - self.assertTrue(hasattr(self._get_target_class(), 'ALIGN_RATE')) + response = None + if self.channel_stub.responses: + response = self.channel_stub.responses.pop() - def test_names(self): - for name in self._get_target_class().__dict__: - if not name.startswith('_'): - self.assertEqual(getattr(self._get_target_class(), name), name) + if isinstance(response, Exception): + raise response + if response: + return response -class TestReducer(unittest.TestCase): - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.query import Reducer +class ChannelStub(object): + """Stub for the grpc.Channel interface.""" - return Reducer + def __init__(self, responses=[]): + from google.cloud.monitoring_v3.proto import metric_service_pb2 - def test_one(self): - self.assertTrue(hasattr(self._get_target_class(), - 'REDUCE_PERCENTILE_99')) + self.responses = responses + self.responses = [ + metric_service_pb2.ListTimeSeriesResponse(**response) + for response in responses + ] + self.requests = [] - def test_names(self): - for name in self._get_target_class().__dict__: - if not name.startswith('_'): - self.assertEqual(getattr(self._get_target_class(), name), name) + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + return MultiCallableStub(method, self) class TestQuery(unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.monitoring.query import Query + from google.cloud.monitoring_v3.query import Query return Query @@ -88,14 +97,23 @@ def _make_one(self, *args, **kwargs): return self._get_target_class()(*args, **kwargs) @staticmethod - def _make_timestamp(value): - from google.cloud._helpers import _datetime_to_rfc3339 + def _make_interval(end_time, start_time=None): + from google.cloud.monitoring_v3 import types - return _datetime_to_rfc3339(value) + interval = types.TimeInterval() + interval.end_time.FromDatetime(end_time) + if start_time is not None: + interval.start_time.FromDatetime(start_time) + return interval def test_constructor_minimal(self): - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client) + from google.cloud.monitoring_v3 import MetricServiceClient + + # Mock the API response + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + + query = self._make_one(client, PROJECT) self.assertEqual(query._client, client) self.assertEqual(query._filter.metric_type, @@ -104,20 +122,21 @@ def test_constructor_minimal(self): self.assertIsNone(query._start_time) self.assertIsNone(query._end_time) - self.assertIsNone(query._per_series_aligner) - self.assertIsNone(query._alignment_period_seconds) - self.assertIsNone(query._cross_series_reducer) + self.assertEqual(query._per_series_aligner, 0) + self.assertEqual(query._alignment_period_seconds, 0) + self.assertEqual(query._cross_series_reducer, 0) self.assertEqual(query._group_by_fields, ()) def test_constructor_maximal(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient T1 = datetime.datetime(2016, 4, 7, 2, 30, 30) DAYS, HOURS, MINUTES = 1, 2, 3 T0 = T1 - datetime.timedelta(days=DAYS, hours=HOURS, minutes=MINUTES) - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE, + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE, end_time=T1, days=DAYS, hours=HOURS, minutes=MINUTES) @@ -127,59 +146,71 @@ def test_constructor_maximal(self): self.assertEqual(query._start_time, T0) self.assertEqual(query._end_time, T1) - self.assertIsNone(query._per_series_aligner) - self.assertIsNone(query._alignment_period_seconds) - self.assertIsNone(query._cross_series_reducer) + self.assertEqual(query._per_series_aligner, 0) + self.assertEqual(query._alignment_period_seconds, 0) + self.assertEqual(query._cross_series_reducer, 0) self.assertEqual(query._group_by_fields, ()) def test_constructor_default_end_time(self): - import datetime - import mock + from google.cloud.monitoring_v3 import MetricServiceClient MINUTES = 5 - NOW, T0, T1 = [ - datetime.datetime(2016, 4, 7, 2, 30, 30), - datetime.datetime(2016, 4, 7, 2, 25, 0), - datetime.datetime(2016, 4, 7, 2, 30, 0), - ] + NOW = datetime.datetime(2016, 4, 7, 2, 30, 30) + T0 = datetime.datetime(2016, 4, 7, 2, 25, 0) + T1 = datetime.datetime(2016, 4, 7, 2, 30, 0) - client = _Client(project=PROJECT, connection=_Connection()) - with mock.patch('google.cloud.monitoring.query._UTCNOW', + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + with mock.patch('google.cloud.monitoring_v3.query._UTCNOW', new=lambda: NOW): - query = self._make_one(client, METRIC_TYPE, minutes=MINUTES) + query = self._make_one( + client, PROJECT, METRIC_TYPE, minutes=MINUTES) self.assertEqual(query._start_time, T0) self.assertEqual(query._end_time, T1) def test_constructor_nonzero_duration_illegal(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient T1 = datetime.datetime(2016, 4, 7, 2, 30, 30) - client = _Client(project=PROJECT, connection=_Connection()) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) with self.assertRaises(ValueError): - self._make_one(client, METRIC_TYPE, end_time=T1) + self._make_one(client, PROJECT, METRIC_TYPE, end_time=T1) def test_execution_without_interval_illegal(self): - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + from google.cloud.monitoring_v3 import MetricServiceClient + + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) with self.assertRaises(ValueError): list(query) def test_metric_type(self): - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + from google.cloud.monitoring_v3 import MetricServiceClient + + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) self.assertEqual(query.metric_type, METRIC_TYPE) def test_filter(self): - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + from google.cloud.monitoring_v3 import MetricServiceClient + + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) expected = 'metric.type = "{type}"'.format(type=METRIC_TYPE) self.assertEqual(query.filter, expected) def test_filter_by_group(self): + from google.cloud.monitoring_v3 import MetricServiceClient + GROUP = '1234567' - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_group(GROUP) expected = ( 'metric.type = "{type}"' @@ -188,9 +219,12 @@ def test_filter_by_group(self): self.assertEqual(query.filter, expected) def test_filter_by_projects(self): + from google.cloud.monitoring_v3 import MetricServiceClient + PROJECT1, PROJECT2 = 'project-1', 'project-2' - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_projects(PROJECT1, PROJECT2) expected = ( 'metric.type = "{type}"' @@ -199,9 +233,12 @@ def test_filter_by_projects(self): self.assertEqual(query.filter, expected) def test_filter_by_resources(self): + from google.cloud.monitoring_v3 import MetricServiceClient + ZONE_PREFIX = 'europe-' - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_resources(zone_prefix=ZONE_PREFIX) expected = ( 'metric.type = "{type}"' @@ -210,9 +247,12 @@ def test_filter_by_resources(self): self.assertEqual(query.filter, expected) def test_filter_by_metrics(self): + from google.cloud.monitoring_v3 import MetricServiceClient + INSTANCE = 'my-instance' - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_metrics(instance_name=INSTANCE) expected = ( 'metric.type = "{type}"' @@ -221,66 +261,73 @@ def test_filter_by_metrics(self): self.assertEqual(query.filter, expected) def test_request_parameters_minimal(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient + from google.cloud.monitoring_v3.gapic import enums T1 = datetime.datetime(2016, 4, 7, 2, 30, 0) - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_interval(end_time=T1) - actual = list(query._build_query_params()) - expected = [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', self._make_timestamp(T1)), - ] + actual = query._build_query_params() + expected = { + 'name': u'projects/{}'.format(PROJECT), + 'filter_': 'metric.type = "{type}"'.format(type=METRIC_TYPE), + 'interval': self._make_interval(T1), + 'view': enums.ListTimeSeriesRequest.TimeSeriesView.FULL, + } self.assertEqual(actual, expected) def test_request_parameters_maximal(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient + from google.cloud.monitoring_v3 import types + from google.cloud.monitoring_v3.gapic import enums T0 = datetime.datetime(2016, 4, 7, 2, 0, 0) T1 = datetime.datetime(2016, 4, 7, 2, 30, 0) ALIGNER = 'ALIGN_DELTA' - MINUTES, SECONDS, PERIOD = 1, 30, '90s' + MINUTES, SECONDS, PERIOD_IN_SECONDS = 1, 30, 90 REDUCER = 'REDUCE_MEAN' FIELD1, FIELD2 = 'resource.zone', 'metric.instance_name' PAGE_SIZE = 100 - PAGE_TOKEN = 'second-page-please' - client = _Client(project=PROJECT, connection=_Connection()) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub() + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_interval(start_time=T0, end_time=T1) query = query.align(ALIGNER, minutes=MINUTES, seconds=SECONDS) query = query.reduce(REDUCER, FIELD1, FIELD2) - actual = list(query._build_query_params(headers_only=True, - page_size=PAGE_SIZE, - page_token=PAGE_TOKEN)) - expected = [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', self._make_timestamp(T1)), - ('interval.startTime', self._make_timestamp(T0)), - ('aggregation.perSeriesAligner', ALIGNER), - ('aggregation.alignmentPeriod', PERIOD), - ('aggregation.crossSeriesReducer', REDUCER), - ('aggregation.groupByFields', FIELD1), - ('aggregation.groupByFields', FIELD2), - ('view', 'HEADERS'), - ('pageSize', PAGE_SIZE), - ('pageToken', PAGE_TOKEN), - ] + actual = query._build_query_params(headers_only=True, + page_size=PAGE_SIZE) + expected = { + 'name': 'projects/%s' % PROJECT, + 'filter_': 'metric.type = "{type}"'.format(type=METRIC_TYPE), + 'interval': self._make_interval(T1, T0), + 'aggregation': types.Aggregation( + per_series_aligner=ALIGNER, + alignment_period={'seconds': PERIOD_IN_SECONDS}, + cross_series_reducer=REDUCER, + group_by_fields=[FIELD1, FIELD2], + ), + 'view': enums.ListTimeSeriesRequest.TimeSeriesView.HEADERS, + 'page_size': PAGE_SIZE, + } self.assertEqual(actual, expected) def test_iteration(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient + from google.cloud.monitoring_v3.gapic import enums + from google.cloud.monitoring_v3.proto import metric_service_pb2 T0 = datetime.datetime(2016, 4, 6, 22, 5, 0) T1 = datetime.datetime(2016, 4, 6, 22, 10, 0) - INTERVAL1 = {'startTime': TS0, 'endTime': TS1} - INTERVAL2 = {'startTime': TS1, 'endTime': TS2} + INTERVAL1 = self._make_interval(TS1, TS0) + INTERVAL2 = self._make_interval(TS2, TS1) VALUE1 = 60 # seconds VALUE2 = 60.001 # seconds @@ -288,29 +335,29 @@ def test_iteration(self): SERIES1 = { 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, + 'metric_kind': METRIC_KIND, + 'value_type': VALUE_TYPE, 'points': [ - {'interval': INTERVAL2, 'value': {'doubleValue': VALUE1}}, - {'interval': INTERVAL1, 'value': {'doubleValue': VALUE1}}, + {'interval': INTERVAL2, 'value': {'double_value': VALUE1}}, + {'interval': INTERVAL1, 'value': {'double_value': VALUE1}}, ], } SERIES2 = { 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS2}, 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS2}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, + 'metric_kind': METRIC_KIND, + 'value_type': VALUE_TYPE, 'points': [ - {'interval': INTERVAL2, 'value': {'doubleValue': VALUE2}}, - {'interval': INTERVAL1, 'value': {'doubleValue': VALUE2}}, + {'interval': INTERVAL2, 'value': {'double_value': VALUE2}}, + {'interval': INTERVAL1, 'value': {'double_value': VALUE2}}, ], } - RESPONSE = {'timeSeries': [SERIES1, SERIES2]} + RESPONSE = {'time_series': [SERIES1, SERIES2], 'next_page_token': ''} - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub(responses=[RESPONSE]) + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_interval(start_time=T0, end_time=T1) response = list(query) @@ -322,139 +369,53 @@ def test_iteration(self): self.assertEqual(series1.resource.labels, RESOURCE_LABELS) self.assertEqual(series2.resource.labels, RESOURCE_LABELS2) - self.assertEqual([p.value for p in series1.points], [VALUE1, VALUE1]) - self.assertEqual([p.value for p in series2.points], [VALUE2, VALUE2]) - self.assertEqual([p.end_time for p in series1.points], [TS1, TS2]) - self.assertEqual([p.end_time for p in series2.points], [TS1, TS2]) - - expected_request = { - 'method': 'GET', - 'path': '/projects/{project}/timeSeries/'.format(project=PROJECT), - 'query_params': [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', self._make_timestamp(T1)), - ('interval.startTime', self._make_timestamp(T0)), - ], - } - - request, = connection._requested + self.assertEqual([p.value.double_value for p in series1.points], + [VALUE1, VALUE1]) + self.assertEqual([p.value.double_value for p in series2.points], + [VALUE2, VALUE2]) + self.assertEqual([p.interval for p in series1.points], + [INTERVAL2, INTERVAL1]) + self.assertEqual([p.interval for p in series2.points], + [INTERVAL2, INTERVAL1]) + + expected_request = metric_service_pb2.ListTimeSeriesRequest( + name='projects/' + PROJECT, + filter='metric.type = "{type}"'.format(type=METRIC_TYPE), + interval=self._make_interval(T1, T0), + view=enums.ListTimeSeriesRequest.TimeSeriesView.FULL + ) + request = channel.requests[0][1] self.assertEqual(request, expected_request) - def test_iteration_paged(self): - import copy - import datetime - from google.cloud.exceptions import NotFound - - T0 = datetime.datetime(2016, 4, 6, 22, 5, 0) - T1 = datetime.datetime(2016, 4, 6, 22, 10, 0) - - INTERVAL1 = {'startTime': TS0, 'endTime': TS1} - INTERVAL2 = {'startTime': TS1, 'endTime': TS2} - - VALUE1 = 60 # seconds - VALUE2 = 60.001 # seconds - - SERIES1 = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'points': [ - {'interval': INTERVAL2, 'value': {'doubleValue': VALUE1}}, - {'interval': INTERVAL1, 'value': {'doubleValue': VALUE1}}, - ], - } - SERIES2_PART1 = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS2}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS2}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'points': [ - {'interval': INTERVAL2, 'value': {'doubleValue': VALUE2}}, - ], - } - SERIES2_PART2 = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS2}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS2}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'points': [ - {'interval': INTERVAL1, 'value': {'doubleValue': VALUE2}}, - ], - } - - TOKEN = 'second-page-please' - RESPONSE1 = {'timeSeries': [SERIES1, SERIES2_PART1], - 'nextPageToken': TOKEN} - RESPONSE2 = {'timeSeries': [SERIES2_PART2]} - - connection = _Connection(RESPONSE1, RESPONSE2) - client = _Client(project=PROJECT, connection=connection) - query = self._make_one(client, METRIC_TYPE) - query = query.select_interval(start_time=T0, end_time=T1) - response = list(query) - - self.assertEqual(len(response), 2) - series1, series2 = response - - self.assertEqual(series1.metric.labels, METRIC_LABELS) - self.assertEqual(series2.metric.labels, METRIC_LABELS2) - self.assertEqual(series1.resource.labels, RESOURCE_LABELS) - self.assertEqual(series2.resource.labels, RESOURCE_LABELS2) - - self.assertEqual([p.value for p in series1.points], [VALUE1, VALUE1]) - self.assertEqual([p.value for p in series2.points], [VALUE2, VALUE2]) - self.assertEqual([p.end_time for p in series1.points], [TS1, TS2]) - self.assertEqual([p.end_time for p in series2.points], [TS1, TS2]) - - expected_request1 = { - 'method': 'GET', - 'path': '/projects/{project}/timeSeries/'.format(project=PROJECT), - 'query_params': [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', self._make_timestamp(T1)), - ('interval.startTime', self._make_timestamp(T0)), - ], - } - - expected_request2 = copy.deepcopy(expected_request1) - expected_request2['query_params'].append(('pageToken', TOKEN)) - - request1, request2 = connection._requested - self.assertEqual(request1, expected_request1) - self.assertEqual(request2, expected_request2) - - with self.assertRaises(NotFound): - list(query) - def test_iteration_empty(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient + from google.cloud.monitoring_v3.gapic import enums + from google.cloud.monitoring_v3.proto import metric_service_pb2 T0 = datetime.datetime(2016, 4, 6, 22, 5, 0) T1 = datetime.datetime(2016, 4, 6, 22, 10, 0) - connection = _Connection({}) - client = _Client(project=PROJECT, connection=connection) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub(responses=[{'next_page_token': ''}]) + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_interval(start_time=T0, end_time=T1) response = list(query) self.assertEqual(len(response), 0) - expected_request = { - 'method': 'GET', - 'path': '/projects/{project}/timeSeries/'.format(project=PROJECT), - 'query_params': [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', self._make_timestamp(T1)), - ('interval.startTime', self._make_timestamp(T0)), - ], - } - request, = connection._requested + expected_request = metric_service_pb2.ListTimeSeriesRequest( + name='projects/' + PROJECT, + filter='metric.type = "{type}"'.format(type=METRIC_TYPE), + interval=self._make_interval(T1, T0), + view=enums.ListTimeSeriesRequest.TimeSeriesView.FULL + ) + request = channel.requests[0][1] self.assertEqual(request, expected_request) def test_iteration_headers_only(self): - import datetime + from google.cloud.monitoring_v3 import MetricServiceClient + from google.cloud.monitoring_v3.gapic import enums + from google.cloud.monitoring_v3.proto import metric_service_pb2 T0 = datetime.datetime(2016, 4, 6, 22, 5, 0) T1 = datetime.datetime(2016, 4, 6, 22, 10, 0) @@ -462,21 +423,21 @@ def test_iteration_headers_only(self): SERIES1 = { 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, + 'metric_kind': METRIC_KIND, + 'value_type': VALUE_TYPE, } SERIES2 = { 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS2}, 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS2}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, + 'metric_kind': METRIC_KIND, + 'value_type': VALUE_TYPE, } - RESPONSE = {'timeSeries': [SERIES1, SERIES2]} + RESPONSE = {'time_series': [SERIES1, SERIES2], 'next_page_token': ''} - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - query = self._make_one(client, METRIC_TYPE) + channel = ChannelStub(responses=[RESPONSE]) + client = MetricServiceClient(channel=channel) + query = self._make_one(client, PROJECT, METRIC_TYPE) query = query.select_interval(start_time=T0, end_time=T1) response = list(query.iter(headers_only=True)) @@ -488,21 +449,16 @@ def test_iteration_headers_only(self): self.assertEqual(series1.resource.labels, RESOURCE_LABELS) self.assertEqual(series2.resource.labels, RESOURCE_LABELS2) - self.assertEqual(series1.points, []) - self.assertEqual(series2.points, []) - - expected_request = { - 'method': 'GET', - 'path': '/projects/{project}/timeSeries/'.format(project=PROJECT), - 'query_params': [ - ('filter', 'metric.type = "{type}"'.format(type=METRIC_TYPE)), - ('interval.endTime', self._make_timestamp(T1)), - ('interval.startTime', self._make_timestamp(T0)), - ('view', 'HEADERS'), - ], - } + self.assertFalse(len(series1.points)) + self.assertFalse(len(series2.points)) - request, = connection._requested + expected_request = metric_service_pb2.ListTimeSeriesRequest( + name='projects/' + PROJECT, + filter='metric.type = "{type}"'.format(type=METRIC_TYPE), + interval=self._make_interval(T1, T0), + view=enums.ListTimeSeriesRequest.TimeSeriesView.HEADERS + ) + request = channel.requests[0][1] self.assertEqual(request, expected_request) @@ -510,7 +466,7 @@ class Test_Filter(unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.monitoring.query import _Filter + from google.cloud.monitoring_v3.query import _Filter return _Filter @@ -545,7 +501,7 @@ def test_maximal(self): class Test__build_label_filter(unittest.TestCase): def _call_fut(self, *args, **kwargs): - from google.cloud.monitoring.query import _build_label_filter + from google.cloud.monitoring_v3.query import _build_label_filter return _build_label_filter(*args, **kwargs) @@ -633,26 +589,3 @@ def test_resource_type_suffix(self): actual = self._call_fut('resource', resource_type_suffix='-foo') expected = 'resource.type = ends_with("-foo")' self.assertEqual(actual, expected) - - -class _Connection(object): - - def __init__(self, *responses): - self._responses = list(responses) - self._requested = [] - - def api_request(self, **kwargs): - from google.cloud.exceptions import NotFound - - self._requested.append(kwargs) - try: - return self._responses.pop(0) - except IndexError: - raise NotFound('miss') - - -class _Client(object): - - def __init__(self, project, connection): - self.project = project - self._connection = connection diff --git a/monitoring/tests/unit/test_resource.py b/monitoring/tests/unit/test_resource.py deleted file mode 100644 index 94b01a888847..000000000000 --- a/monitoring/tests/unit/test_resource.py +++ /dev/null @@ -1,357 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - - -class TestResourceDescriptor(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.resource import ResourceDescriptor - - return ResourceDescriptor - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - from google.cloud.monitoring.label import LabelDescriptor - - TYPE = 'gce_instance' - NAME = 'projects/my-project/monitoredResourceDescriptors/' + TYPE - DISPLAY_NAME = 'GCE Instance' - DESCRIPTION = 'A VM instance hosted in Google Compute Engine.' - LABELS = [ - LabelDescriptor(key='project_id', value_type='STRING', - description='The ID of the GCP project...'), - LabelDescriptor(key='instance_id', value_type='STRING', - description='The VM instance identifier...'), - LabelDescriptor(key='zone', value_type='STRING', - description='The GCE zone...'), - ] - - descriptor = self._make_one( - name=NAME, - type_=TYPE, - display_name=DISPLAY_NAME, - description=DESCRIPTION, - labels=LABELS, - ) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.display_name, DISPLAY_NAME) - self.assertEqual(descriptor.description, DESCRIPTION) - self.assertEqual(descriptor.labels, LABELS) - - def test_from_dict(self): - TYPE = 'gce_instance' - NAME = 'projects/my-project/monitoredResourceDescriptors/' + TYPE - DISPLAY_NAME = 'GCE Instance' - DESCRIPTION = 'A VM instance hosted in Google Compute Engine.' - LABEL1 = {'key': 'project_id', 'valueType': 'STRING', - 'description': 'The ID of the GCP project...'} - LABEL2 = {'key': 'instance_id', 'valueType': 'STRING', - 'description': 'The VM instance identifier...'} - LABEL3 = {'key': 'zone', 'valueType': 'STRING', - 'description': 'The GCE zone...'} - - info = { - 'name': NAME, - 'type': TYPE, - 'displayName': DISPLAY_NAME, - 'description': DESCRIPTION, - 'labels': [LABEL1, LABEL2, LABEL3], - } - descriptor = self._get_target_class()._from_dict(info) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.display_name, DISPLAY_NAME) - self.assertEqual(descriptor.description, DESCRIPTION) - - self.assertEqual(len(descriptor.labels), 3) - label1, label2, label3 = descriptor.labels - self.assertEqual(label1.key, LABEL1['key']) - self.assertEqual(label2.key, LABEL2['key']) - self.assertEqual(label3.key, LABEL3['key']) - - def test_from_dict_defaults(self): - TYPE = 'gce_instance' - NAME = 'projects/my-project/monitoredResourceDescriptors/' + TYPE - - info = { - 'name': NAME, - 'type': TYPE, - } - descriptor = self._get_target_class()._from_dict(info) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.display_name, '') - self.assertEqual(descriptor.description, '') - self.assertEqual(descriptor.labels, ()) - - def test_fetch(self): - PROJECT = 'my-project' - TYPE = 'gce_instance' - NAME = 'projects/{project}/monitoredResourceDescriptors/{type}'.format( - project=PROJECT, type=TYPE) - DISPLAY_NAME = 'GCE Instance' - DESCRIPTION = 'A VM instance hosted in Google Compute Engine.' - LABEL1 = {'key': 'project_id', 'valueType': 'STRING', - 'description': 'The ID of the GCP project...'} - LABEL2 = {'key': 'instance_id', 'valueType': 'STRING', - 'description': 'The VM instance identifier...'} - LABEL3 = {'key': 'zone', 'valueType': 'STRING', - 'description': 'The GCE zone...'} - - RESOURCE_DESCRIPTOR = { - 'name': NAME, - 'type': TYPE, - 'displayName': DISPLAY_NAME, - 'description': DESCRIPTION, - 'labels': [LABEL1, LABEL2, LABEL3], - } - - connection = _Connection(RESOURCE_DESCRIPTOR) - client = _Client(project=PROJECT, connection=connection) - descriptor = self._get_target_class()._fetch(client, TYPE) - - self.assertEqual(descriptor.name, NAME) - self.assertEqual(descriptor.type, TYPE) - self.assertEqual(descriptor.display_name, DISPLAY_NAME) - self.assertEqual(descriptor.description, DESCRIPTION) - - self.assertEqual(len(descriptor.labels), 3) - label1, label2, label3 = descriptor.labels - self.assertEqual(label1.key, LABEL1['key']) - self.assertEqual(label2.key, LABEL2['key']) - self.assertEqual(label3.key, LABEL3['key']) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + NAME} - self.assertEqual(request, expected_request) - - def test_list(self): - PROJECT = 'my-project' - PATH = 'projects/{project}/monitoredResourceDescriptors/'.format( - project=PROJECT) - - TYPE1 = 'custom.googleapis.com/resource-1' - DESCRIPTION1 = 'This is the first resource.' - NAME1 = PATH + TYPE1 - RESOURCE_DESCRIPTOR1 = { - 'name': NAME1, - 'type': TYPE1, - 'description': DESCRIPTION1, - } - - TYPE2 = 'custom.googleapis.com/resource-2' - DESCRIPTION2 = 'This is the second resource.' - NAME2 = PATH + TYPE2 - RESOURCE_DESCRIPTOR2 = { - 'name': NAME2, - 'type': TYPE2, - 'description': DESCRIPTION2, - } - - RESPONSE = { - 'resourceDescriptors': - [RESOURCE_DESCRIPTOR1, RESOURCE_DESCRIPTOR2], - } - - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list(client) - - self.assertEqual(len(descriptors), 2) - descriptor1, descriptor2 = descriptors - - self.assertEqual(descriptor1.name, NAME1) - self.assertEqual(descriptor1.type, TYPE1) - self.assertEqual(descriptor1.description, DESCRIPTION1) - - self.assertEqual(descriptor2.name, NAME2) - self.assertEqual(descriptor2.type, TYPE2) - self.assertEqual(descriptor2.description, DESCRIPTION2) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - self.assertEqual(request, expected_request) - - def test_list_paged(self): - from google.cloud.exceptions import NotFound - - PROJECT = 'my-project' - PATH = 'projects/{project}/monitoredResourceDescriptors/'.format( - project=PROJECT) - - TYPE1 = 'custom.googleapis.com/resource-1' - DESCRIPTION1 = 'This is the first resource.' - NAME1 = PATH + TYPE1 - RESOURCE_DESCRIPTOR1 = { - 'name': NAME1, - 'type': TYPE1, - 'description': DESCRIPTION1, - } - - TYPE2 = 'custom.googleapis.com/resource-2' - DESCRIPTION2 = 'This is the second resource.' - NAME2 = PATH + TYPE2 - RESOURCE_DESCRIPTOR2 = { - 'name': NAME2, - 'type': TYPE2, - 'description': DESCRIPTION2, - } - - TOKEN = 'second-page-please' - RESPONSE1 = { - 'resourceDescriptors': [RESOURCE_DESCRIPTOR1], - 'nextPageToken': TOKEN, - } - RESPONSE2 = { - 'resourceDescriptors': [RESOURCE_DESCRIPTOR2], - } - - connection = _Connection(RESPONSE1, RESPONSE2) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list(client) - - self.assertEqual(len(descriptors), 2) - descriptor1, descriptor2 = descriptors - - self.assertEqual(descriptor1.name, NAME1) - self.assertEqual(descriptor1.type, TYPE1) - self.assertEqual(descriptor1.description, DESCRIPTION1) - - self.assertEqual(descriptor2.name, NAME2) - self.assertEqual(descriptor2.type, TYPE2) - self.assertEqual(descriptor2.description, DESCRIPTION2) - - request1, request2 = connection._requested - expected_request1 = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {}} - expected_request2 = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {'pageToken': TOKEN}} - self.assertEqual(request1, expected_request1) - self.assertEqual(request2, expected_request2) - - with self.assertRaises(NotFound): - self._get_target_class()._list(client) - - def test_list_filtered(self): - PROJECT = 'my-project' - PATH = 'projects/{project}/monitoredResourceDescriptors/'.format( - project=PROJECT) - - # Request only resources with type names that start with "foobar_". - FILTER = 'resource.type = starts_with("foobar_")' - - # But there are none. - RESPONSE = {'resourceDescriptors': []} - - connection = _Connection(RESPONSE) - client = _Client(project=PROJECT, connection=connection) - descriptors = self._get_target_class()._list(client, FILTER) - - self.assertEqual(len(descriptors), 0) - - request, = connection._requested - expected_request = {'method': 'GET', 'path': '/' + PATH, - 'query_params': {'filter': FILTER}} - self.assertEqual(request, expected_request) - - -class TestResource(unittest.TestCase): - - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.resource import Resource - - return Resource - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - TYPE = 'gce_instance' - LABELS = { - 'project_id': 'my-project', - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-a', - } - resource = self._make_one(type=TYPE, labels=LABELS) - self.assertEqual(resource.type, TYPE) - self.assertEqual(resource.labels, LABELS) - - def test_from_dict(self): - TYPE = 'gce_instance' - LABELS = { - 'project_id': 'my-project', - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-a', - } - info = { - 'type': TYPE, - 'labels': LABELS, - } - resource = self._get_target_class()._from_dict(info) - self.assertEqual(resource.type, TYPE) - self.assertEqual(resource.labels, LABELS) - - def test_from_dict_defaults(self): - TYPE = 'gce_instance' - info = {'type': TYPE} - resource = self._get_target_class()._from_dict(info) - self.assertEqual(resource.type, TYPE) - self.assertEqual(resource.labels, {}) - - def test_to_dict(self): - TYPE = 'gce_instance' - LABELS = { - 'instance_id': '1234567890123456789', - 'zone': 'us-central1-a', - } - resource = self._make_one(TYPE, LABELS) - expected_dict = { - 'type': TYPE, - 'labels': LABELS, - } - self.assertEqual(resource._to_dict(), expected_dict) - - -class _Connection(object): - - def __init__(self, *responses): - self._responses = list(responses) - self._requested = [] - - def api_request(self, **kwargs): - from google.cloud.exceptions import NotFound - - self._requested.append(kwargs) - try: - return self._responses.pop(0) - except IndexError: - raise NotFound('miss') - - -class _Client(object): - - def __init__(self, project, connection): - self.project = project - self._connection = connection diff --git a/monitoring/tests/unit/test_timeseries.py b/monitoring/tests/unit/test_timeseries.py deleted file mode 100644 index f433a609a303..000000000000 --- a/monitoring/tests/unit/test_timeseries.py +++ /dev/null @@ -1,271 +0,0 @@ -# Copyright 2016 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -METRIC_TYPE = 'compute.googleapis.com/instance/uptime' -METRIC_LABELS = {'instance_name': 'instance-1'} - -RESOURCE_TYPE = 'gce_instance' -RESOURCE_LABELS = { - 'project_id': 'my-project', - 'zone': 'us-east1-a', - 'instance_id': '1234567890123456789', -} - -METRIC_KIND = 'DELTA' -VALUE_TYPE = 'DOUBLE' - -TS0 = '2016-04-06T22:05:00.042Z' -TS1 = '2016-04-06T22:05:01.042Z' -TS2 = '2016-04-06T22:05:02.042Z' - - -class TestTimeSeries(unittest.TestCase): - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.timeseries import TimeSeries - - return TimeSeries - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - from google.cloud.monitoring.metric import Metric - from google.cloud.monitoring.resource import Resource - from google.cloud.monitoring.timeseries import Point - - VALUE = 60 # seconds - - METRIC = Metric(type=METRIC_TYPE, labels=METRIC_LABELS) - RESOURCE = Resource(type=RESOURCE_TYPE, labels=RESOURCE_LABELS) - POINTS = [ - Point(start_time=TS0, end_time=TS1, value=VALUE), - Point(start_time=TS1, end_time=TS2, value=VALUE), - ] - - series = self._make_one(metric=METRIC, - resource=RESOURCE, - metric_kind=METRIC_KIND, - value_type=VALUE_TYPE, - points=POINTS) - - self.assertEqual(series.metric, METRIC) - self.assertEqual(series.resource, RESOURCE) - self.assertEqual(series.metric_kind, METRIC_KIND) - self.assertEqual(series.value_type, VALUE_TYPE) - self.assertEqual(series.points, POINTS) - - def test_from_dict(self): - VALUE = 60 # seconds - - info = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - 'points': [ - { - 'interval': {'startTime': TS0, 'endTime': TS1}, - 'value': {'doubleValue': VALUE}, - }, - { - 'interval': {'startTime': TS1, 'endTime': TS2}, - 'value': {'doubleValue': VALUE}, - }, - ], - } - - series = self._get_target_class()._from_dict(info) - - self.assertEqual(series.metric.type, METRIC_TYPE) - self.assertEqual(series.metric.labels, METRIC_LABELS) - self.assertEqual(series.resource.type, RESOURCE_TYPE) - self.assertEqual(series.resource.labels, RESOURCE_LABELS) - - self.assertEqual(series.metric_kind, METRIC_KIND) - self.assertEqual(series.value_type, VALUE_TYPE) - - self.assertEqual(len(series.points), 2) - point1, point2 = series.points - - self.assertEqual(point1.start_time, TS0) - self.assertEqual(point1.end_time, TS1) - self.assertEqual(point1.value, VALUE) - - self.assertEqual(point2.start_time, TS1) - self.assertEqual(point2.end_time, TS2) - self.assertEqual(point2.value, VALUE) - - def test_from_dict_no_points(self): - info = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - } - - series = self._get_target_class()._from_dict(info) - - self.assertEqual(series.metric.type, METRIC_TYPE) - self.assertEqual(series.metric.labels, METRIC_LABELS) - self.assertEqual(series.resource.type, RESOURCE_TYPE) - self.assertEqual(series.resource.labels, RESOURCE_LABELS) - - self.assertEqual(series.metric_kind, METRIC_KIND) - self.assertEqual(series.value_type, VALUE_TYPE) - - self.assertEqual(series.points, []) - - def test_labels(self): - info = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'metricKind': METRIC_KIND, - 'valueType': VALUE_TYPE, - } - - series = self._get_target_class()._from_dict(info) - - labels = {'resource_type': RESOURCE_TYPE} - labels.update(RESOURCE_LABELS) - labels.update(METRIC_LABELS) - - self.assertIsNone(series._labels) - self.assertEqual(series.labels, labels) - self.assertIsNotNone(series._labels) - self.assertEqual(series.labels, labels) - - def test_to_dict(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - - from google.cloud.monitoring.metric import Metric - from google.cloud.monitoring.resource import Resource - from google.cloud.monitoring.timeseries import Point - - VALUE = 42 - end_time = datetime.datetime.now() - end_time_str = _datetime_to_rfc3339(end_time, ignore_zone=False) - - METRIC = Metric(type=METRIC_TYPE, labels=METRIC_LABELS) - RESOURCE = Resource(type=RESOURCE_TYPE, labels=RESOURCE_LABELS) - POINT = Point(start_time=None, end_time=end_time_str, value=VALUE) - - info = { - 'metric': {'type': METRIC_TYPE, 'labels': METRIC_LABELS}, - 'resource': {'type': RESOURCE_TYPE, 'labels': RESOURCE_LABELS}, - 'points': [{ - 'interval': { - 'endTime': end_time_str}, - 'value': {'int64Value': str(VALUE)}, - }] - } - - series = self._make_one(metric=METRIC, resource=RESOURCE, - metric_kind=None, value_type=None, - points=[POINT]) - series_dict = series._to_dict() - self.assertEqual(info, series_dict) - - -class TestPoint(unittest.TestCase): - @staticmethod - def _get_target_class(): - from google.cloud.monitoring.timeseries import Point - - return Point - - def _make_one(self, *args, **kwargs): - return self._get_target_class()(*args, **kwargs) - - def test_constructor(self): - VALUE = 3.14 - point = self._make_one(start_time=TS0, end_time=TS1, value=VALUE) - self.assertEqual(point.start_time, TS0) - self.assertEqual(point.end_time, TS1) - self.assertEqual(point.value, VALUE) - - def test_from_dict(self): - VALUE = 3.14 - info = { - 'interval': {'startTime': TS0, 'endTime': TS1}, - 'value': {'doubleValue': VALUE}, - } - point = self._get_target_class()._from_dict(info) - self.assertEqual(point.start_time, TS0) - self.assertEqual(point.end_time, TS1) - self.assertEqual(point.value, VALUE) - - def test_from_dict_defaults(self): - VALUE = 3.14 - info = { - 'interval': {'endTime': TS1}, - 'value': {'doubleValue': VALUE}, - } - point = self._get_target_class()._from_dict(info) - self.assertIsNone(point.start_time) - self.assertEqual(point.end_time, TS1) - self.assertEqual(point.value, VALUE) - - def test_from_dict_int64(self): - VALUE = 2 ** 63 - 1 - info = { - 'interval': {'endTime': TS1}, - 'value': {'int64Value': str(VALUE)}, - } - point = self._get_target_class()._from_dict(info) - self.assertIsNone(point.start_time) - self.assertEqual(point.end_time, TS1) - self.assertEqual(point.value, VALUE) - - def test_to_dict_int64(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - - VALUE = 42 - end_time = datetime.datetime.now() - end_time_str = _datetime_to_rfc3339(end_time, ignore_zone=False) - point = self._make_one(end_time=end_time_str, start_time=None, - value=VALUE) - info = { - 'interval': {'endTime': end_time_str}, - 'value': {'int64Value': str(VALUE)}, - } - - point_dict = point._to_dict() - self.assertEqual(info, point_dict) - - def test_to_dict_float_with_start_time(self): - import datetime - from google.cloud._helpers import _datetime_to_rfc3339 - - VALUE = 1.6180339 - start_time = datetime.datetime.now() - start_time_str = _datetime_to_rfc3339(start_time, ignore_zone=False) - end_time = datetime.datetime.now() - end_time_str = _datetime_to_rfc3339(end_time, ignore_zone=False) - - point = self._make_one(end_time=end_time_str, - start_time=start_time_str, value=VALUE) - info = { - 'interval': { - 'startTime': start_time_str, - 'endTime': end_time_str}, - 'value': {'doubleValue': VALUE}, - } - - point_dict = point._to_dict() - self.assertEqual(info, point_dict)