Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit d25e49f

Browse files
feat!: move to use microgen (#54)
* feat!: move to use microgen * update * Update google/cloud/monitoring_v3/query.py Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> * Update google/cloud/monitoring_v3/query.py Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
1 parent b8ad0de commit d25e49f

File tree

170 files changed

+44463
-27967
lines changed

Some content is hidden

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

170 files changed

+44463
-27967
lines changed

.coveragerc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ omit =
2323
[report]
2424
fail_under = 100
2525
show_missing = True
26+
omit = google/cloud/monitoring/__init__.py
2627
exclude_lines =
2728
# Re-enable the standard pragma
2829
pragma: NO COVER
2930
# Ignore debug-only repr
3031
def __repr__
31-
# Ignore abstract methods
32-
raise NotImplementedError
33-
omit =
34-
*/gapic/*.py
35-
*/proto/*.py
36-
*/core/*.py
37-
*/site-packages/*.py
38-
google/cloud/__init__.py
32+
# Ignore pkg_resources exceptions.
33+
# This is added at the module level as a safeguard for if someone
34+
# generates the code and tries to run it without pip installing. This
35+
# makes it virtually impossible to test properly.
36+
except pkg_resources.DistributionNotFound

.kokoro/samples/python3.6/common.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ env_vars: {
1313
value: "py-3.6"
1414
}
1515

16+
# Declare build specific Cloud project.
17+
env_vars: {
18+
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
19+
value: "python-docs-samples-tests-py36"
20+
}
21+
1622
env_vars: {
1723
key: "TRAMPOLINE_BUILD_FILE"
1824
value: "github/python-monitoring/.kokoro/test-samples.sh"
@@ -24,12 +30,6 @@ env_vars: {
2430
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
2531
}
2632

27-
# Declare build specific Cloud project.
28-
env_vars: {
29-
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
30-
value: "python-docs-samples-tests-py36"
31-
}
32-
3333
# Download secrets for samples
3434
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
3535

.kokoro/samples/python3.7/common.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ env_vars: {
1313
value: "py-3.7"
1414
}
1515

16+
# Declare build specific Cloud project.
17+
env_vars: {
18+
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
19+
value: "python-docs-samples-tests-py37"
20+
}
21+
1622
env_vars: {
1723
key: "TRAMPOLINE_BUILD_FILE"
1824
value: "github/python-monitoring/.kokoro/test-samples.sh"
@@ -24,12 +30,6 @@ env_vars: {
2430
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
2531
}
2632

27-
# Declare build specific Cloud project.
28-
env_vars: {
29-
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
30-
value: "python-docs-samples-tests-py37"
31-
}
32-
3333
# Download secrets for samples
3434
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
3535

.kokoro/samples/python3.8/common.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ env_vars: {
1313
value: "py-3.8"
1414
}
1515

16+
# Declare build specific Cloud project.
17+
env_vars: {
18+
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
19+
value: "python-docs-samples-tests-py38"
20+
}
21+
1622
env_vars: {
1723
key: "TRAMPOLINE_BUILD_FILE"
1824
value: "github/python-monitoring/.kokoro/test-samples.sh"
@@ -24,12 +30,6 @@ env_vars: {
2430
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
2531
}
2632

27-
# Declare build specific Cloud project.
28-
env_vars: {
29-
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
30-
value: "python-docs-samples-tests-py38"
31-
}
32-
3333
# Download secrets for samples
3434
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
3535

README.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ dependencies.
5151

5252
Supported Python Versions
5353
^^^^^^^^^^^^^^^^^^^^^^^^^
54-
Python >= 3.5
54+
Python >= 3.6
5555

56-
Deprecated Python Versions
57-
^^^^^^^^^^^^^^^^^^^^^^^^^^
58-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
56+
Unsupported Python Versions
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
Python == 2.7.
59+
60+
The last version of this library compatible with Python 2.7 is google-cloud-monitoring==1.1.0.
5961

6062

6163
Mac/Linux

UPGRADING.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# 2.0.0 Migration Guide
2+
3+
The 2.0 release of the `google-cloud-monitoring` 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/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
11+
The 2.0.0 release requires Python 3.6+.
12+
13+
14+
## Method Calls
15+
16+
> **WARNING**: Breaking change
17+
18+
Methods expect request objects. We provide a script that will convert most common use cases.
19+
20+
* Install the library
21+
22+
```py
23+
python3 -m pip install google-cloud-monitoring
24+
```
25+
26+
* The script `fixup_monitoring_v3_keywords.py` is shipped with the library. It expects
27+
an input directory (with the code to convert) and an empty destination directory.
28+
29+
```sh
30+
$ fixup_monitoring_v3_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud import monitoring_v3
36+
37+
client = monitoring_v3.MetricServiceClient()
38+
39+
metric_descriptor = client.get_metric_descriptor("name")
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud import monitoring_v3
46+
47+
client = monitoring_v3.MetricServiceClient()
48+
49+
metric_descriptor = client.get_metric_descriptor(request={"name": "name"})
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-monitoring<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
55+
56+
**Before:**
57+
```py
58+
def create_metric_descriptor(
59+
self,
60+
name,
61+
metric_descriptor,
62+
retry=google.api_core.gapic_v1.method.DEFAULT,
63+
timeout=google.api_core.gapic_v1.method.DEFAULT,
64+
metadata=None,
65+
):
66+
```
67+
68+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
69+
70+
Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer.
71+
72+
73+
**After:**
74+
```py
75+
def create_metric_descriptor(
76+
self,
77+
request: metric_service.CreateMetricDescriptorRequest = None,
78+
*,
79+
name: str = None,
80+
metric_descriptor: ga_metric.MetricDescriptor = None,
81+
retry: retries.Retry = gapic_v1.method.DEFAULT,
82+
timeout: float = None,
83+
metadata: Sequence[Tuple[str, str]] = (),
84+
) -> ga_metric.MetricDescriptor:
85+
```
86+
87+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
88+
> Passing both will result in an error.
89+
90+
91+
Both of these calls are valid:
92+
93+
```py
94+
response = client.create_metric_descriptor(
95+
request={
96+
"name": name,
97+
"metric_descriptor": metric_descriptor
98+
}
99+
)
100+
```
101+
102+
```py
103+
response = client.create_metric_descriptor(
104+
name=name,
105+
metric_descriptor=metric_descriptor
106+
)
107+
```
108+
109+
This call is invalid because it mixes `request` with a keyword argument `metric_descriptor`. Executing this code
110+
will result in an error.
111+
112+
```py
113+
response = client.create_metric_descriptor(
114+
request={
115+
"name": name,
116+
},
117+
metric_descriptor=metric_descriptor
118+
)
119+
```
120+
121+
122+
123+
## Enums and Types
124+
125+
126+
> **WARNING**: Breaking change
127+
128+
The submodules `enums` and `types` have been removed.
129+
130+
**Before:**
131+
```py
132+
from google.cloud import monitoring_v3
133+
134+
launch_stage = monitoring_v3.enums.LaunchStage.ALPHA
135+
policy = monitoring_v3.types.AlertPolicy(name="name")
136+
```
137+
138+
139+
**After:**
140+
```py
141+
from google.cloud import monitoring_v3
142+
143+
launch_stage = monitoring_v3.LaunchStage.ALPHA
144+
policy = monitoring_v3.AlertPolicy(name="name")
145+
```
146+
147+
## Project Path Helper Method
148+
149+
`project_path` method is renamed `common_project_path`.
150+
151+
**Before:**
152+
```py
153+
project_path = client.project_path("project_id")
154+
```
155+
156+
**After:**
157+
```py
158+
project_path = client.common_project_path("project_id")
159+
```

docs/UPGRADING.md

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

docs/gapic/v3/api.rst

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

docs/gapic/v3/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
@@ -8,8 +8,18 @@ Api Reference
88
:maxdepth: 2
99

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

1424
Changelog
1525
---------

0 commit comments

Comments
 (0)