Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

feat: Migrate API client to Microgenerator #54

Merged
merged 29 commits into from Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d15145b
Add samples for Data Catalog lookup_entry [(#2148)](https://github.co…
May 10, 2019
ae918c6
Add region tags to support Data Catalog docs [(#2169)](https://github…
May 21, 2019
45dfe60
Adds updates including compute [(#2436)](https://github.com/GoogleClo…
gguuss Oct 23, 2019
8acdfd1
Auto-update dependencies. [(#2005)](https://github.com/GoogleCloudPla…
dpebot Dec 21, 2019
0edabe8
chore(deps): update dependency google-cloud-datacatalog to v0.6.0 [(#…
renovate-bot Mar 10, 2020
6edf172
Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatf…
kurtisvg Apr 2, 2020
c42616a
Update dependency google-cloud-datacatalog to v0.7.0 [(#3320)](https:…
renovate-bot Apr 9, 2020
9f14362
Update Data Catalog samples to V1 [(#3382)](https://github.com/Google…
mesmacosta Apr 23, 2020
978ba8a
chore(deps): update dependency google-cloud-datacatalog to v0.8.0 [(#…
renovate-bot May 20, 2020
7ecbb87
Update dependency google-cloud-datacatalog to v1 [(#4115)](https://gi…
renovate-bot Jun 19, 2020
796d0fd
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot Jul 12, 2020
6e3ce9a
Update dependency pytest to v6 [(#4390)](https://github.com/GoogleClo…
renovate-bot Aug 1, 2020
cb9c41e
Merge branch 'snippets-samples' into add-snippets-samples
hkdevandla Aug 12, 2020
bc14411
chore: update templates
hkdevandla Aug 12, 2020
f570d73
chore: update templates
hkdevandla Aug 13, 2020
81b11fc
feat: Migrate to use Microgenerator
hkdevandla Aug 14, 2020
3d5904a
Merge branch 'master' into add-snippets-samples
hkdevandla Aug 14, 2020
3f89158
feat: Migrate to use Microgenerator
hkdevandla Aug 14, 2020
09d02eb
feat: Migrate to use Microgenerator
hkdevandla Aug 14, 2020
f988dfd
Migrate API to microgenerator
hkdevandla Aug 14, 2020
bbbde39
Migrate API to microgenerator
hkdevandla Aug 14, 2020
972ce0c
Samples tests
hkdevandla Aug 15, 2020
4403214
fix samples tests
hkdevandla Aug 17, 2020
01d07f5
fix lint errors and test coverage metrics
hkdevandla Aug 18, 2020
7981014
docs update
hkdevandla Aug 18, 2020
2038912
fix docs
hkdevandla Aug 18, 2020
cf28425
fix docs
hkdevandla Aug 19, 2020
86cb41d
fix docs
hkdevandla Aug 19, 2020
188fb41
remove .python-version file
hkdevandla Aug 19, 2020
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
11 changes: 6 additions & 5 deletions .coveragerc
Expand Up @@ -21,15 +21,16 @@ branch = True
[report]
fail_under = 100
show_missing = True
omit = google/cloud/datacatalog/__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
11 changes: 11 additions & 0 deletions README.rst
Expand Up @@ -35,6 +35,17 @@ In order to use this library, you first need to go through the following steps:
.. _Enable the Google Cloud Data Catalog API.: https://cloud.google.com/data-catalog
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html


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

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7.

The last version of this library compatible with Python 2.7 is google-cloud-datacatalog==1.0.0.

Installation
~~~~~~~~~~~~

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

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

* The script `fixup_datacatalog_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_datacatalog_v1_keywords.py --input-directory .samples/ --output-directory samples/
```

**Before:**
```py
from google.cloud import datacatalog_v1
datacatalog = datacatalog_v1.DataCatalogClient()
return datacatalog.lookup_entry(linked_resource=resource_name)
```


**After:**
```py
from google.cloud import datacatalog_v1
datacatalog = datacatalog_v1.DataCatalogClient()
return datacatalog.lookup_entry(request={'linked_resource': resource_name})
```

### More Details

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

**Before:**
```py
def create_entry_group(
self,
parent,
entry_group_id,
entry_group=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 specified by the API producer.


**After:**
```py
def create_entry_group(
self,
request: datacatalog.CreateEntryGroupRequest = None,
*,
parent: str = None,
entry_group_id: str = None,
entry_group: datacatalog.EntryGroup = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> datacatalog.EntryGroup:
```

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

```py
response = client.create_entry_group(
parent=parent,
entry_group_id=entry_group_id,
entry_group=entry_group
) # Make an API request.
```

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

```py
response = client.create_entry_group(
request={
"parent": parent,
"entry_group_id"=entry_group_id
},
entry_group=entry_group
)
```



## Enums and Types


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

**Before:**
```py
from google.cloud import datacatalog_v1
entry = datacatalog_v1beta1.types.Entry()
entry.type = datacatalog_v1beta1.enums.EntryType.FILESET
```


**After:**
```py
from google.cloud import datacatalog_v1
entry = datacatalog_v1beta1.Entry()
entry.type = datacatalog_v1beta1.EntryType.FILESET
```

## Project Path Helper Methods

The project path helper method `project_path` has been removed. Please construct
this path manually.

```py
project = 'my-project'
project_path = f'projects/{project}'
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
@@ -0,0 +1 @@
../UPGRADING.md
6 changes: 6 additions & 0 deletions docs/datacatalog_v1/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Datacatalog v1 API
============================================

.. automodule:: google.cloud.datacatalog_v1.services.data_catalog
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/datacatalog_v1/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Datacatalog v1 API
=========================================

.. automodule:: google.cloud.datacatalog_v1.types
:members:
12 changes: 12 additions & 0 deletions docs/datacatalog_v1beta1/services.rst
@@ -0,0 +1,12 @@
Services for Google Cloud Datacatalog v1beta1 API
=================================================

.. automodule:: google.cloud.datacatalog_v1beta1.services.data_catalog
:members:
:inherited-members:
.. automodule:: google.cloud.datacatalog_v1beta1.services.policy_tag_manager
:members:
:inherited-members:
.. automodule:: google.cloud.datacatalog_v1beta1.services.policy_tag_manager_serialization
:members:
:inherited-members:
@@ -1,5 +1,5 @@
Types for Google Cloud Data Catalog API Client
Types for Google Cloud Datacatalog v1beta1 API
==============================================

.. automodule:: google.cloud.datacatalog_v1beta1.types
:members:
:members:
6 changes: 0 additions & 6 deletions docs/gapic/v1/api.rst

This file was deleted.

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

This file was deleted.

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

This file was deleted.

18 changes: 13 additions & 5 deletions docs/index.rst
Expand Up @@ -8,19 +8,27 @@ v1
.. toctree::
:maxdepth: 2

gapic/v1/api
gapic/v1/types

datacatalog_v1/services
datacatalog_v1/types

v1beta1
-------------

.. toctree::
:maxdepth: 2

gapic/v1beta1/api
gapic/v1beta1/types
datacatalog_v1beta1/services
datacatalog_v1beta1/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