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

Commit b5c1549

Browse files
feat!: move API to python microgenerator (#26)
* remove generated directories * change synthtool * unit test * update README * setupfile change * regeneration * update documentation * restructure * clean up * feedback * clean
1 parent 88f9592 commit b5c1549

110 files changed

Lines changed: 10380 additions & 6839 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ In order to use this library, you first need to go through the following steps:
3434
.. _Enable the Stackdriver Monitoring Dashboards API.: https://cloud.google.com/monitoring/dashboards/
3535
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
3636

37+
Supported Python Versions
38+
^^^^^^^^^^^^^^^^^^^^^^^^^
39+
Python >= 3.6
40+
41+
Deprecated Python Versions
42+
^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
Python == 2.7.
44+
45+
The last version of this library compatible with Python 2.7 is google-cloud-monitoring-dashboards==1.0.0.
46+
3747
Installation
3848
~~~~~~~~~~~~
3949

UPGRADING.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# 2.0.0 Migration Guide
2+
3+
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.
4+
5+
If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-monitoring-dashboards/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
The 2.0.0 release requires Python 3.6+.
11+
12+
## Create Service Client
13+
> **WARNING**: Breaking change
14+
The namespace for importing the service gets changed in the new release.
15+
16+
17+
**Before:**
18+
```py
19+
from google.cloud.monitoring_dashboard import v1
20+
client = v1.DashboardsServiceClient()
21+
```
22+
**After:**
23+
```py
24+
from google.cloud import monitoring_dashboard_v1
25+
client = monitoring_dashboard_v1.DashboardsServiceClient()
26+
```
27+
28+
## Method Calls
29+
30+
> **WARNING**: Breaking change
31+
Methods expect request objects. We provide a script that will convert most common use cases.
32+
* Install the library
33+
34+
```py
35+
python3 -m pip install google-cloud-monitoring-dashboards
36+
```
37+
38+
* The scripts `fixup_dashboard_v1_keywords.py` shipped with the library. It expects
39+
an input directory (with the code to convert) and an empty destination directory.
40+
41+
```sh
42+
$ fixup_dashboard_v1_keywords.py --input-directory .samples/ --output-directory samples/
43+
```
44+
45+
**Before:**
46+
```py
47+
# TODO: Initialize `parent`:
48+
parent = ''
49+
# TODO: Initialize `dashboard`:
50+
dashboard = {}
51+
response = client.create_dashboard(parent, dashboard)
52+
```
53+
54+
**After:**
55+
```py
56+
response = client.create_dashboard(request={"parent": "''", "dashboard": "{}"})
57+
```
58+
59+
### More Details
60+
61+
In `google-cloud-monitoring-dashboards<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
62+
63+
**Before:**
64+
```py
65+
def create_dashboard(
66+
self,
67+
parent,
68+
dashboard,
69+
retry=google.api_core.gapic_v1.method.DEFAULT,
70+
timeout=google.api_core.gapic_v1.method.DEFAULT,
71+
metadata=None,
72+
):
73+
```
74+
75+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
76+
77+
Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation] specified by the API producer.
78+
79+
80+
**After:**
81+
```py
82+
def create_dashboard(
83+
self,
84+
request: dashboards_service.CreateDashboardRequest = None,
85+
*,
86+
retry: retries.Retry = gapic_v1.method.DEFAULT,
87+
timeout: float = None,
88+
metadata: Sequence[Tuple[str, str]] = (),
89+
) -> dashboard.Dashboard:
90+
```
91+
92+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
93+
> Passing both will result in an error.
94+
Both of these calls are valid:
95+
96+
```py
97+
response = client.create_dashboard(
98+
request={
99+
"parent": parent,
100+
"dashboard": dashboard,
101+
}
102+
)
103+
```
104+
105+
```py
106+
response = client.create_dashboard(
107+
parent=parent,
108+
dashboard=dashboard,
109+
)
110+
```
111+
112+
This call is invalid because it mixes `request` with a keyword argument `dashboard`. Executing this code will result in an error.
113+
114+
```py
115+
response = client.create_dashboard(
116+
request={
117+
"parent": parent,
118+
},
119+
dashboard=dashboard
120+
)
121+
```

docs/UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md

docs/dashboard_v1/services.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Monitoring Dashboard v1 API
2+
===============================================
3+
4+
.. automodule:: google.cloud.monitoring_dashboard_v1.services.dashboards_service
5+
:members:
6+
:inherited-members:

docs/dashboard_v1/types.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Monitoring Dashboard v1 API
2+
============================================
3+
4+
.. automodule:: google.cloud.monitoring_dashboard_v1.types
5+
:members:

docs/gapic/v1/api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/gapic/v1/types.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/index.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,15 @@ Api Reference
77
.. toctree::
88
:maxdepth: 2
99

10-
gapic/v1/api
11-
gapic/v1/types
10+
dashboard_v1/services
11+
dashboard_v1/types
12+
13+
Migration Guide
14+
---------------
15+
16+
See the guide below for instructions on migrating to the 2.x release of this library.
17+
18+
.. toctree::
19+
:maxdepth: 2
20+
21+
UPGRADING

google/__init__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

google/cloud/__init__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)