Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
feat!: move API to python microgenerator (#26)
Browse files Browse the repository at this point in the history
* remove generated directories

* change synthtool

* unit test

* update README

* setupfile change

* regeneration

* update documentation

* restructure

* clean up

* feedback

* clean
  • Loading branch information
xiaozhenliu-gg5 committed Jul 30, 2020
1 parent 88f9592 commit b5c1549
Show file tree
Hide file tree
Showing 110 changed files with 10,380 additions and 6,839 deletions.
10 changes: 10 additions & 0 deletions README.rst
Expand Up @@ -34,6 +34,16 @@ In order to use this library, you first need to go through the following steps:
.. _Enable the Stackdriver Monitoring Dashboards API.: https://cloud.google.com/monitoring/dashboards/
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.6

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7.

The last version of this library compatible with Python 2.7 is google-cloud-monitoring-dashboards==1.0.0.

Installation
~~~~~~~~~~~~

Expand Down
121 changes: 121 additions & 0 deletions UPGRADING.md
@@ -0,0 +1,121 @@
# 2.0.0 Migration Guide

The 1.0 release of the `google-cloud-monitoring-dashboards` client is a significant upgrade based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-python), and includes substantial interface changes. Existing code written for earlier versions of this library will likely require updates to use this version. This document describes the changes that have been made, and what you need to do to update your usage.

If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-monitoring-dashboards/issues).

## Supported Python Versions

> **WARNING**: Breaking change
The 2.0.0 release requires Python 3.6+.

## Create Service Client
> **WARNING**: Breaking change
The namespace for importing the service gets changed in the new release.


**Before:**
```py
from google.cloud.monitoring_dashboard import v1
client = v1.DashboardsServiceClient()
```
**After:**
```py
from google.cloud import monitoring_dashboard_v1
client = monitoring_dashboard_v1.DashboardsServiceClient()
```

## Method Calls

> **WARNING**: Breaking change
Methods expect request objects. We provide a script that will convert most common use cases.
* Install the library

```py
python3 -m pip install google-cloud-monitoring-dashboards
```

* The scripts `fixup_dashboard_v1_keywords.py` shipped with the library. It expects
an input directory (with the code to convert) and an empty destination directory.

```sh
$ fixup_dashboard_v1_keywords.py --input-directory .samples/ --output-directory samples/
```

**Before:**
```py
# TODO: Initialize `parent`:
parent = ''
# TODO: Initialize `dashboard`:
dashboard = {}
response = client.create_dashboard(parent, dashboard)
```

**After:**
```py
response = client.create_dashboard(request={"parent": "''", "dashboard": "{}"})
```

### More Details

In `google-cloud-monitoring-dashboards<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.

**Before:**
```py
def create_dashboard(
self,
parent,
dashboard,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
```

In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.

Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation] specified by the API producer.


**After:**
```py
def create_dashboard(
self,
request: dashboards_service.CreateDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
```

> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
> Passing both will result in an error.
Both of these calls are valid:

```py
response = client.create_dashboard(
request={
"parent": parent,
"dashboard": dashboard,
}
)
```

```py
response = client.create_dashboard(
parent=parent,
dashboard=dashboard,
)
```

This call is invalid because it mixes `request` with a keyword argument `dashboard`. Executing this code will result in an error.

```py
response = client.create_dashboard(
request={
"parent": parent,
},
dashboard=dashboard
)
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 6 additions & 0 deletions docs/dashboard_v1/services.rst
@@ -0,0 +1,6 @@
Services for Google Monitoring Dashboard v1 API
===============================================

.. automodule:: google.cloud.monitoring_dashboard_v1.services.dashboards_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/dashboard_v1/types.rst
@@ -0,0 +1,5 @@
Types for Google Monitoring Dashboard v1 API
============================================

.. automodule:: google.cloud.monitoring_dashboard_v1.types
:members:
6 changes: 0 additions & 6 deletions docs/gapic/v1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1/types.rst

This file was deleted.

14 changes: 12 additions & 2 deletions docs/index.rst
Expand Up @@ -7,5 +7,15 @@ Api Reference
.. toctree::
:maxdepth: 2

gapic/v1/api
gapic/v1/types
dashboard_v1/services
dashboard_v1/types

Migration Guide
---------------

See the guide below for instructions on migrating to the 2.x release of this library.

.. toctree::
:maxdepth: 2

UPGRADING
24 changes: 0 additions & 24 deletions google/__init__.py

This file was deleted.

24 changes: 0 additions & 24 deletions google/cloud/__init__.py

This file was deleted.

88 changes: 88 additions & 0 deletions google/cloud/monitoring_dashboard/__init__.py
@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from google.cloud.monitoring_dashboard_v1.services.dashboards_service.async_client import (
DashboardsServiceAsyncClient,
)
from google.cloud.monitoring_dashboard_v1.services.dashboards_service.client import (
DashboardsServiceClient,
)
from google.cloud.monitoring_dashboard_v1.types.common import Aggregation
from google.cloud.monitoring_dashboard_v1.types.common import PickTimeSeriesFilter
from google.cloud.monitoring_dashboard_v1.types.common import (
StatisticalTimeSeriesFilter,
)
from google.cloud.monitoring_dashboard_v1.types.dashboard import Dashboard
from google.cloud.monitoring_dashboard_v1.types.dashboards_service import (
CreateDashboardRequest,
)
from google.cloud.monitoring_dashboard_v1.types.dashboards_service import (
DeleteDashboardRequest,
)
from google.cloud.monitoring_dashboard_v1.types.dashboards_service import (
GetDashboardRequest,
)
from google.cloud.monitoring_dashboard_v1.types.dashboards_service import (
ListDashboardsRequest,
)
from google.cloud.monitoring_dashboard_v1.types.dashboards_service import (
ListDashboardsResponse,
)
from google.cloud.monitoring_dashboard_v1.types.dashboards_service import (
UpdateDashboardRequest,
)
from google.cloud.monitoring_dashboard_v1.types.layouts import ColumnLayout
from google.cloud.monitoring_dashboard_v1.types.layouts import GridLayout
from google.cloud.monitoring_dashboard_v1.types.layouts import RowLayout
from google.cloud.monitoring_dashboard_v1.types.metrics import SparkChartType
from google.cloud.monitoring_dashboard_v1.types.metrics import Threshold
from google.cloud.monitoring_dashboard_v1.types.metrics import TimeSeriesFilter
from google.cloud.monitoring_dashboard_v1.types.metrics import TimeSeriesFilterRatio
from google.cloud.monitoring_dashboard_v1.types.metrics import TimeSeriesQuery
from google.cloud.monitoring_dashboard_v1.types.scorecard import Scorecard
from google.cloud.monitoring_dashboard_v1.types.text import Text
from google.cloud.monitoring_dashboard_v1.types.widget import Widget
from google.cloud.monitoring_dashboard_v1.types.xychart import ChartOptions
from google.cloud.monitoring_dashboard_v1.types.xychart import XyChart

__all__ = (
"Aggregation",
"ChartOptions",
"ColumnLayout",
"CreateDashboardRequest",
"Dashboard",
"DashboardsServiceAsyncClient",
"DashboardsServiceClient",
"DeleteDashboardRequest",
"GetDashboardRequest",
"GridLayout",
"ListDashboardsRequest",
"ListDashboardsResponse",
"PickTimeSeriesFilter",
"RowLayout",
"Scorecard",
"SparkChartType",
"StatisticalTimeSeriesFilter",
"Text",
"Threshold",
"TimeSeriesFilter",
"TimeSeriesFilterRatio",
"TimeSeriesQuery",
"UpdateDashboardRequest",
"Widget",
"XyChart",
)
2 changes: 2 additions & 0 deletions google/cloud/monitoring_dashboard/py.typed
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-monitoring-dashboard package uses inline types.
29 changes: 0 additions & 29 deletions google/cloud/monitoring_dashboard/v1.py

This file was deleted.

0 comments on commit b5c1549

Please sign in to comment.