Skip to content

Commit

Permalink
feat!: migrate to microgenerator (#29)
Browse files Browse the repository at this point in the history
See UPGRADING.md for details.
  • Loading branch information
busunkim96 authored Sep 14, 2020
1 parent 6c05397 commit 25f9c38
Show file tree
Hide file tree
Showing 109 changed files with 7,824 additions and 8,698 deletions.
14 changes: 6 additions & 8 deletions packages/google-cloud-trace/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Generated by synthtool. DO NOT EDIT!
[run]
branch = True

[report]
fail_under = 100
show_missing = True
omit = google/cloud/devtools/cloudtrace/__init__.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
46 changes: 0 additions & 46 deletions packages/google-cloud-trace/PUBLISHING.rst

This file was deleted.

20 changes: 3 additions & 17 deletions packages/google-cloud-trace/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Python >= 3.5

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
Python == 2.7.

The last version of this library compatible with Python 2.7 is google-cloud-trace==0.24.0


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


Example Usage
~~~~~~~~~~~~~

.. code-block:: python
from google.cloud.trace import trace_service_client
client = trace_service_client.TraceServiceClient()
project_id = 'your-project-123'
# Iterate over all results
for element in client.list_traces(project_id):
# process element
pass
Next Steps
~~~~~~~~~~

Expand Down
162 changes: 162 additions & 0 deletions packages/google-cloud-trace/UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# 1.0.0 Migration Guide

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.

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

## Supported Python Versions

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


## Handwritten Client Wrapper Removal

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.


```py
from google.cloud import trace_v1

client = trace_v1.TraceServiceClient()
```

```py
from google.cloud import trace_v2

client = trace_v2.TraceServiceClient()
```

**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).

## 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-trace
```

* The scripts `fixup_trace_v1_keywords.py` and `fixup_trace_v2_keywords.py` are shipped with the library. The script expects
an input directory (with the code to convert) and an empty destination directory.

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

**Before:**
```py
from google.cloud import trace_v1

client = trace_v1.TraceServiceClient()
project_id = "my-project"
response = client.list_traces(project_id)
```


**After:**
```py
from google.cloud import trace_v1

client = trace_v1.TraceServiceClient()
project_id = "my-project"
response = client.list_traces(project_id=project_id)
```

### More Details

In `google-cloud-trace<1.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.

**Before:**
```py
def get_trace(
self,
project_id,
trace_id,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
```

In the 1.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](https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudtrace/v2/tracing.proto#L53) specified by the API producer.


**After:**
```py
def get_trace(
self,
request: trace.GetTraceRequest = None,
*,
project_id: str = None,
trace_id: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> trace.Trace:
```

> **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.get_trace(
request={
"project_id": project_id,
"trace_id", trace_id,
}
)
```

```py
response = client.get_trace(
project_id=project_id,
trace_id=trace_id,
)
```

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

```py
response = client.get_trace(
request={
"project_id": project_id,
},
trace_id=trace_id,
)
```



## Enums and Types


**WARNING**: Breaking change

The submodules `types` is no longer available on the unversioned path `trace`.

**Before:**
```py
from google.cloud import trace

trace_ = trace.types.TraceSpan()
```


**After:**
```py
from google.cloud

trace_ = trace_v1.TraceSpan()
trace_ = trace_v1.types.TraceSpan()
```
6 changes: 0 additions & 6 deletions packages/google-cloud-trace/docs/gapic/v1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions packages/google-cloud-trace/docs/gapic/v1/types.rst

This file was deleted.

6 changes: 0 additions & 6 deletions packages/google-cloud-trace/docs/gapic/v2/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions packages/google-cloud-trace/docs/gapic/v2/types.rst

This file was deleted.

11 changes: 5 additions & 6 deletions packages/google-cloud-trace/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ The current version of the API is ``v2``:
.. toctree::
:maxdepth: 2

gapic/v2/api
gapic/v2/types
trace_v2/services
trace_v2/types

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

.. toctree::
:maxdepth: 2

gapic/v1/api
gapic/v1/types
trace_v1/services
trace_v1/types


Changelog
Expand Down
6 changes: 6 additions & 0 deletions packages/google-cloud-trace/docs/trace_v1/services.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Trace v1 API
======================================

.. automodule:: google.cloud.trace_v1.services.trace_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions packages/google-cloud-trace/docs/trace_v1/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Types for Google Cloud Trace v1 API
===================================

.. automodule:: google.cloud.trace_v1.types
:members:
6 changes: 6 additions & 0 deletions packages/google-cloud-trace/docs/trace_v2/services.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Trace v2 API
======================================

.. automodule:: google.cloud.trace_v2.services.trace_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions packages/google-cloud-trace/docs/trace_v2/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Types for Google Cloud Trace v2 API
===================================

.. automodule:: google.cloud.trace_v2.types
:members:
1 change: 0 additions & 1 deletion packages/google-cloud-trace/google/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion packages/google-cloud-trace/google/cloud/__init__.py

This file was deleted.

Loading

0 comments on commit 25f9c38

Please sign in to comment.