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

Commit

Permalink
feat!: migrate to use microgen
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Sep 1, 2020
1 parent 9d022f7 commit 04828a3
Show file tree
Hide file tree
Showing 143 changed files with 38,737 additions and 26,439 deletions.
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
File renamed without changes.
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
146 changes: 146 additions & 0 deletions UPGRADING.md
@@ -0,0 +1,146 @@
# 2.0.0 Migration Guide

The 2.0 release of the `google-cloud-build` 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-cloudbuild/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-build
```

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

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

**Before:**
```py
from google.cloud.devtools import cloudbuild

client = cloudbuild.CloudBuildClient()

build = client.get_build("project_id")
```


**After:**
```py
from google.cloud.devtools import cloudbuild

client = cloudbuild.CloudBuildClient()

build = client.get_build(request = {'project_id': "project_id"})
```

### More Details

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

**Before:**
```py
def list_builds(
self,
project_id,
page_size=None,
filter_=None,
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](https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudbuild/v1/cloudbuild.proto#L82) specified by the API producer.


**After:**
```py
def list_builds(
self,
request: cloudbuild.ListBuildsRequest = None,
*,
project_id: str = None,
filter: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListBuildsPager:
```

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

```py
response = client.list_builds(
project_id=project_id,
filter=filter,
)
```

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

```py
response = client.list_builds(
request={
"project_id": project_id,
},
filter=filter
)
```



## Enums and Types


> **WARNING**: Breaking change
The submodules `enums` and `types` have been removed.

**Before:**
```py
from google.cloud.devtools import cloudbuild

build_status = cloudbuild.enums.Build.Status.SUCCESS
built_image = cloudbuild.types.BuiltImage(name="name")
```


**After:**
```py
from google.cloud.devtools import cloudbuild

build_status = cloudbuild.Build.Status.SUCCESS
built_image = cloudbuild.BuiltImage(name="name")
```
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:
80 changes: 80 additions & 0 deletions google/cloud/tasks/__init__.py
@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from google.cloud.tasks_v2.services.cloud_tasks.async_client import (
CloudTasksAsyncClient,
)
from google.cloud.tasks_v2.services.cloud_tasks.client import CloudTasksClient
from google.cloud.tasks_v2.types.cloudtasks import CreateQueueRequest
from google.cloud.tasks_v2.types.cloudtasks import CreateTaskRequest
from google.cloud.tasks_v2.types.cloudtasks import DeleteQueueRequest
from google.cloud.tasks_v2.types.cloudtasks import DeleteTaskRequest
from google.cloud.tasks_v2.types.cloudtasks import GetQueueRequest
from google.cloud.tasks_v2.types.cloudtasks import GetTaskRequest
from google.cloud.tasks_v2.types.cloudtasks import ListQueuesRequest
from google.cloud.tasks_v2.types.cloudtasks import ListQueuesResponse
from google.cloud.tasks_v2.types.cloudtasks import ListTasksRequest
from google.cloud.tasks_v2.types.cloudtasks import ListTasksResponse
from google.cloud.tasks_v2.types.cloudtasks import PauseQueueRequest
from google.cloud.tasks_v2.types.cloudtasks import PurgeQueueRequest
from google.cloud.tasks_v2.types.cloudtasks import ResumeQueueRequest
from google.cloud.tasks_v2.types.cloudtasks import RunTaskRequest
from google.cloud.tasks_v2.types.cloudtasks import UpdateQueueRequest
from google.cloud.tasks_v2.types.queue import Queue
from google.cloud.tasks_v2.types.queue import RateLimits
from google.cloud.tasks_v2.types.queue import RetryConfig
from google.cloud.tasks_v2.types.queue import StackdriverLoggingConfig
from google.cloud.tasks_v2.types.target import AppEngineHttpRequest
from google.cloud.tasks_v2.types.target import AppEngineRouting
from google.cloud.tasks_v2.types.target import HttpMethod
from google.cloud.tasks_v2.types.target import HttpRequest
from google.cloud.tasks_v2.types.target import OAuthToken
from google.cloud.tasks_v2.types.target import OidcToken
from google.cloud.tasks_v2.types.task import Attempt
from google.cloud.tasks_v2.types.task import Task

__all__ = (
"AppEngineHttpRequest",
"AppEngineRouting",
"Attempt",
"CloudTasksAsyncClient",
"CloudTasksClient",
"CreateQueueRequest",
"CreateTaskRequest",
"DeleteQueueRequest",
"DeleteTaskRequest",
"GetQueueRequest",
"GetTaskRequest",
"HttpMethod",
"HttpRequest",
"ListQueuesRequest",
"ListQueuesResponse",
"ListTasksRequest",
"ListTasksResponse",
"OAuthToken",
"OidcToken",
"PauseQueueRequest",
"PurgeQueueRequest",
"Queue",
"RateLimits",
"ResumeQueueRequest",
"RetryConfig",
"RunTaskRequest",
"StackdriverLoggingConfig",
"Task",
"UpdateQueueRequest",
)

0 comments on commit 04828a3

Please sign in to comment.