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

Commit f0d9d91

Browse files
authored
feat!: migrate to microgenerator (#29)
See UPGRADING.md for details.
1 parent 423fb47 commit f0d9d91

File tree

109 files changed

+7824
-8698
lines changed

Some content is hidden

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

109 files changed

+7824
-8698
lines changed

.coveragerc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,20 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# Generated by synthtool. DO NOT EDIT!
1817
[run]
1918
branch = True
2019

2120
[report]
2221
fail_under = 100
2322
show_missing = True
23+
omit = google/cloud/devtools/cloudtrace/__init__.py
2424
exclude_lines =
2525
# Re-enable the standard pragma
2626
pragma: NO COVER
2727
# Ignore debug-only repr
2828
def __repr__
29-
# Ignore abstract methods
30-
raise NotImplementedError
31-
omit =
32-
*/gapic/*.py
33-
*/proto/*.py
34-
*/core/*.py
35-
*/site-packages/*.py
29+
# Ignore pkg_resources exceptions.
30+
# This is added at the module level as a safeguard for if someone
31+
# generates the code and tries to run it without pip installing. This
32+
# makes it virtually impossible to test properly.
33+
except pkg_resources.DistributionNotFound

PUBLISHING.rst

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

README.rst

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Python >= 3.5
5656

5757
Deprecated Python Versions
5858
^^^^^^^^^^^^^^^^^^^^^^^^^^
59-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
59+
Python == 2.7.
60+
61+
The last version of this library compatible with Python 2.7 is google-cloud-trace==0.24.0
6062

6163

6264
Mac/Linux
@@ -87,22 +89,6 @@ to `Python Development Environment Setup Guide`_ for Google Cloud Platform.
8789
.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup
8890

8991

90-
Example Usage
91-
~~~~~~~~~~~~~
92-
93-
.. code-block:: python
94-
95-
from google.cloud.trace import trace_service_client
96-
97-
client = trace_service_client.TraceServiceClient()
98-
project_id = 'your-project-123'
99-
100-
# Iterate over all results
101-
for element in client.list_traces(project_id):
102-
# process element
103-
pass
104-
105-
10692
Next Steps
10793
~~~~~~~~~~
10894

UPGRADING.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# 1.0.0 Migration Guide
2+
3+
The 1.0 release of the `google-cloud-trace` 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-trace/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
11+
The 1.0.0 release requires Python 3.6+.
12+
13+
14+
## Handwritten Client Wrapper Removal
15+
16+
The handwritten client wrapper `trace_v1.Client()` and `trace_v2.Client()` have been removed. Please use `TraceServiceClient` directly. The primary diference is that a `project_id` must always be supplied to method calls.
17+
18+
19+
```py
20+
from google.cloud import trace_v1
21+
22+
client = trace_v1.TraceServiceClient()
23+
```
24+
25+
```py
26+
from google.cloud import trace_v2
27+
28+
client = trace_v2.TraceServiceClient()
29+
```
30+
31+
**NOTE**: The following sections identify changes between the previous `TraceServiceClient()` and the current `TraceServiceClient()` (not the handwritten wrapper `Client()`). If you were previously using `Client()`, it may be more helpful to reference the [samples](https://github.com/googleapis/python-trace/tree/master/samples/snippets).
32+
33+
## Method Calls
34+
35+
> **WARNING**: Breaking change
36+
Methods expect request objects. We provide a script that will convert most common use cases.
37+
38+
* Install the library
39+
40+
```py
41+
python3 -m pip install google-cloud-trace
42+
```
43+
44+
* The scripts `fixup_trace_v1_keywords.py` and `fixup_trace_v2_keywords.py` are shipped with the library. The script expects
45+
an input directory (with the code to convert) and an empty destination directory.
46+
47+
```sh
48+
$ fixup_trace_v1_keywords.py --input-directory .samples/ --output-directory samples/
49+
```
50+
51+
**Before:**
52+
```py
53+
from google.cloud import trace_v1
54+
55+
client = trace_v1.TraceServiceClient()
56+
project_id = "my-project"
57+
response = client.list_traces(project_id)
58+
```
59+
60+
61+
**After:**
62+
```py
63+
from google.cloud import trace_v1
64+
65+
client = trace_v1.TraceServiceClient()
66+
project_id = "my-project"
67+
response = client.list_traces(project_id=project_id)
68+
```
69+
70+
### More Details
71+
72+
In `google-cloud-trace<1.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
73+
74+
**Before:**
75+
```py
76+
def get_trace(
77+
self,
78+
project_id,
79+
trace_id,
80+
retry=google.api_core.gapic_v1.method.DEFAULT,
81+
timeout=google.api_core.gapic_v1.method.DEFAULT,
82+
metadata=None,
83+
):
84+
```
85+
86+
In the 1.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
87+
88+
Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudtrace/v2/tracing.proto#L53) specified by the API producer.
89+
90+
91+
**After:**
92+
```py
93+
def get_trace(
94+
self,
95+
request: trace.GetTraceRequest = None,
96+
*,
97+
project_id: str = None,
98+
trace_id: str = None,
99+
retry: retries.Retry = gapic_v1.method.DEFAULT,
100+
timeout: float = None,
101+
metadata: Sequence[Tuple[str, str]] = (),
102+
) -> trace.Trace:
103+
```
104+
105+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
106+
> Passing both will result in an error.
107+
108+
109+
Both of these calls are valid:
110+
111+
```py
112+
response = client.get_trace(
113+
request={
114+
"project_id": project_id,
115+
"trace_id", trace_id,
116+
}
117+
)
118+
```
119+
120+
```py
121+
response = client.get_trace(
122+
project_id=project_id,
123+
trace_id=trace_id,
124+
)
125+
```
126+
127+
This call is invalid because it mixes `request` with a keyword argument `trace_id`. Executing this code
128+
will result in an error.
129+
130+
```py
131+
response = client.get_trace(
132+
request={
133+
"project_id": project_id,
134+
},
135+
trace_id=trace_id,
136+
)
137+
```
138+
139+
140+
141+
## Enums and Types
142+
143+
144+
**WARNING**: Breaking change
145+
146+
The submodules `types` is no longer available on the unversioned path `trace`.
147+
148+
**Before:**
149+
```py
150+
from google.cloud import trace
151+
152+
trace_ = trace.types.TraceSpan()
153+
```
154+
155+
156+
**After:**
157+
```py
158+
from google.cloud
159+
160+
trace_ = trace_v1.TraceSpan()
161+
trace_ = trace_v1.types.TraceSpan()
162+
```

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/gapic/v2/api.rst

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

docs/gapic/v2/types.rst

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

docs/index.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ The current version of the API is ``v2``:
1010
.. toctree::
1111
:maxdepth: 2
1212

13-
gapic/v2/api
14-
gapic/v2/types
13+
trace_v2/services
14+
trace_v2/types
1515

1616
Support for the previous API release, ``v1``, is provided for code previously
17-
written against it. In order to use this release, you will want to import from
18-
e.g. ``google.cloud.trace_v1`` in lieu of ``google.cloud.trace_v2``.
17+
written against it.
1918

2019
.. toctree::
2120
:maxdepth: 2
2221

23-
gapic/v1/api
24-
gapic/v1/types
22+
trace_v1/services
23+
trace_v1/types
2524

2625

2726
Changelog

docs/trace_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 Cloud Trace v1 API
2+
======================================
3+
4+
.. automodule:: google.cloud.trace_v1.services.trace_service
5+
:members:
6+
:inherited-members:

0 commit comments

Comments
 (0)