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

feat!: migrate to use microgen #38

Merged
merged 2 commits into from Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions .coveragerc
Expand Up @@ -21,15 +21,14 @@ branch = True
[report]
fail_under = 100
show_missing = True
omit = google/cloud/tasks/__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
6 changes: 4 additions & 2 deletions README.rst
Expand Up @@ -50,11 +50,13 @@ dependencies.

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

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-tasks==1.5.0.


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

The 2.0 release of the `google-cloud-tasks` 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-tasks/issues).

## Supported Python Versions

> **WARNING**: Breaking change

The 2.0.0 release requires Python 3.6+.


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

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

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

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

client = tasks_v2.CloudTasksClient()

build = client.get_queue("queue_name")
```


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

client = tasks_v2.CloudTasksClient()

build = client.get_queue(request={'name': "queue_name"})
```

### More Details

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

**Before:**
```py
def create_queue(
self,
parent,
queue,
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_queue(
self,
request: cloudtasks.CreateQueueRequest = None,
*,
parent: str = None,
queue: gct_queue.Queue = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gct_queue.Queue:
```

> **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_queue(
request={
"parent": parent,
"queue": queue,
}
)
```

```py
response = client.create_queue(
parent=parent,
queue=queue,
)
```

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

```py
response = client.create_queue(
request={
"parent": parent,
},
queue=queue
)
```



## Enums and Types


> **WARNING**: Breaking change

The submodules `enums` and `types` have been removed.

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

http_method = tasks_v2.enums.HttpMethod.POST
queue = tasks_v2.types.Queue(name="name")
```


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

http_method = tasks_v2.HttpMethod.POST
queue = tasks_v2.Queue(name="name")
```

## Location Path Helper Method

Location path helper method has been removed. Please construct
the path manually.

```py
project = 'my-project'
location = 'location'

location_path = f'projects/{project}/locations/{location}'
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 0 additions & 6 deletions docs/gapic/v2/api.rst

This file was deleted.

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

This file was deleted.

6 changes: 0 additions & 6 deletions docs/gapic/v2beta2/api.rst

This file was deleted.

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

This file was deleted.

6 changes: 0 additions & 6 deletions docs/gapic/v2beta3/api.rst

This file was deleted.

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

This file was deleted.

22 changes: 16 additions & 6 deletions docs/index.rst
Expand Up @@ -11,8 +11,8 @@ API. By default, you will get ``v2``, the latest version.
.. toctree::
:maxdepth: 2

gapic/v2/api
gapic/v2/types
tasks_v2/services
tasks_v2/types


The previous beta releases, spelled ``v2beta3`` and ``v2beta2``, are provided to continue to
Expand All @@ -25,16 +25,26 @@ v2beta3:
.. toctree::
:maxdepth: 2

gapic/v2beta3/api
gapic/v2beta3/types
tasks_v2beta3/services
tasks_v2beta3/types

v2beta2:

.. toctree::
:maxdepth: 2

gapic/v2beta2/api
gapic/v2beta2/types
tasks_v2beta2/services
tasks_v2beta2/types

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

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

.. toctree::
:maxdepth: 2

UPGRADING

Changelog
---------
Expand Down
6 changes: 6 additions & 0 deletions docs/tasks_v2/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Tasks v2 API
======================================

.. automodule:: google.cloud.tasks_v2.services.cloud_tasks
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/tasks_v2/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Tasks v2 API
===================================

.. automodule:: google.cloud.tasks_v2.types
:members:
6 changes: 6 additions & 0 deletions docs/tasks_v2beta2/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Tasks v2beta2 API
===========================================

.. automodule:: google.cloud.tasks_v2beta2.services.cloud_tasks
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/tasks_v2beta2/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Tasks v2beta2 API
========================================

.. automodule:: google.cloud.tasks_v2beta2.types
:members:
6 changes: 6 additions & 0 deletions docs/tasks_v2beta3/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Tasks v2beta3 API
===========================================

.. automodule:: google.cloud.tasks_v2beta3.services.cloud_tasks
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/tasks_v2beta3/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Tasks v2beta3 API
========================================

.. automodule:: google.cloud.tasks_v2beta3.types
:members: