|
| 1 | +3.0.0 Migration Guide |
| 2 | +===================== |
| 3 | + |
| 4 | +This document describes the breaking changes that have been made, and what you need to do to update your usage. |
| 5 | + |
| 6 | +The most significant change was introduced at v2.0 release based on a `next-gen code generator <https://github.com/googleapis/gapic-generator-python>`_, and includes substantial interface changes. Existing code written for eariler versions of this library will likely require updates to use this version. |
| 7 | + |
| 8 | +If you experience issues or have questions, please file an `issue <https://github.com/googleapis/python-datacatalog/issues>`_. |
| 9 | + |
| 10 | +Supported Python Versions |
| 11 | +------------------------- |
| 12 | + |
| 13 | ++------------------------------+ |
| 14 | +| Applicable previous versions | |
| 15 | ++==============================+ |
| 16 | +| v1.0.0 or lower | |
| 17 | ++------------------------------+ |
| 18 | + |
| 19 | +.. warning: |
| 20 | +
|
| 21 | + **Breaking change:** |
| 22 | + The 2.0.0 release requires Python 3.6+. |
| 23 | +
|
| 24 | +
|
| 25 | +Method Calls |
| 26 | +------------ |
| 27 | + |
| 28 | ++------------------------------+ |
| 29 | +| Applicable previous versions | |
| 30 | ++==============================+ |
| 31 | +| v1.0.0 or lower | |
| 32 | ++------------------------------+ |
| 33 | + |
| 34 | +.. warning: |
| 35 | +
|
| 36 | + **Breaking change:** |
| 37 | + Methods expect request objects. We provide a script that will convert most common use cases. |
| 38 | +
|
| 39 | +* Install the library |
| 40 | + |
| 41 | +.. code-block:: shell |
| 42 | +
|
| 43 | + python3 -m pip install google-cloud-datacatalog |
| 44 | +
|
| 45 | +* The script `fixup_datacatalog_v1_keywords.py` is shipped with the library. It expects |
| 46 | + an input directory (with the code to convert) and an empty destination directory. |
| 47 | + |
| 48 | +.. code-block:: shell |
| 49 | +
|
| 50 | + fixup_datacatalog_v1_keywords.py --input-directory .samples/ --output-directory samples/ |
| 51 | +
|
| 52 | +**Before:** |
| 53 | + |
| 54 | +.. code-block:: python |
| 55 | +
|
| 56 | + from google.cloud import datacatalog_v1 |
| 57 | + datacatalog = datacatalog_v1.DataCatalogClient() |
| 58 | + return datacatalog.lookup_entry(linked_resource=resource_name) |
| 59 | +
|
| 60 | +
|
| 61 | +**After:** |
| 62 | + |
| 63 | +.. code-block:: python |
| 64 | +
|
| 65 | + from google.cloud import datacatalog_v1 |
| 66 | + datacatalog = datacatalog_v1.DataCatalogClient() |
| 67 | + return datacatalog.lookup_entry(request={'linked_resource': resource_name}) |
| 68 | +
|
| 69 | +More Details |
| 70 | +^^^^^^^^^^^^ |
| 71 | + |
| 72 | +In `google-cloud-datacatalog<=1.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters. |
| 73 | + |
| 74 | +**Before:** |
| 75 | + |
| 76 | +.. code-block:: python |
| 77 | +
|
| 78 | + def create_entry_group( |
| 79 | + self, |
| 80 | + parent, |
| 81 | + entry_group_id, |
| 82 | + entry_group=None, |
| 83 | + retry=google.api_core.gapic_v1.method.DEFAULT, |
| 84 | + timeout=google.api_core.gapic_v1.method.DEFAULT, |
| 85 | + metadata=None, |
| 86 | + ): |
| 87 | +
|
| 88 | +Since the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional. |
| 89 | + |
| 90 | +Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer. |
| 91 | + |
| 92 | + |
| 93 | +**After:** |
| 94 | + |
| 95 | +.. code-block:: python |
| 96 | +
|
| 97 | + def create_entry_group( |
| 98 | + self, |
| 99 | + request: datacatalog.CreateEntryGroupRequest = None, |
| 100 | + *, |
| 101 | + parent: str = None, |
| 102 | + entry_group_id: str = None, |
| 103 | + entry_group: datacatalog.EntryGroup = None, |
| 104 | + retry: retries.Retry = gapic_v1.method.DEFAULT, |
| 105 | + timeout: float = None, |
| 106 | + metadata: Sequence[Tuple[str, str]] = (), |
| 107 | + ) -> datacatalog.EntryGroup: |
| 108 | +
|
| 109 | +.. note:: |
| 110 | + |
| 111 | + The `request` parameter and flattened keyword parameters for the API are mutually exclusive. |
| 112 | + Passing both will result in an error. |
| 113 | + |
| 114 | +Both of these calls are valid: |
| 115 | + |
| 116 | +.. code-block:: python |
| 117 | +
|
| 118 | + response = client.create_entry_group( |
| 119 | + request={ |
| 120 | + "parent": parent, |
| 121 | + "entry_group_id": entry_group_id, |
| 122 | + "entry_group": entry_group |
| 123 | + } |
| 124 | + ) |
| 125 | +
|
| 126 | +.. code-block:: python |
| 127 | +
|
| 128 | + response = client.create_entry_group( |
| 129 | + parent=parent, |
| 130 | + entry_group_id=entry_group_id, |
| 131 | + entry_group=entry_group |
| 132 | + ) # Make an API request. |
| 133 | +
|
| 134 | +This call is invalid because it mixes `request` with a keyword argument `entry_group`. Executing this code |
| 135 | +will result in an error. |
| 136 | + |
| 137 | +.. code-block:: python |
| 138 | +
|
| 139 | + response = client.create_entry_group( |
| 140 | + request={ |
| 141 | + "parent": parent, |
| 142 | + "entry_group_id"=entry_group_id |
| 143 | + }, |
| 144 | + entry_group=entry_group |
| 145 | + ) |
| 146 | +
|
| 147 | +
|
| 148 | +
|
| 149 | +Enums and Types |
| 150 | +--------------- |
| 151 | + |
| 152 | ++------------------------------+ |
| 153 | +| Applicable previous versions | |
| 154 | ++==============================+ |
| 155 | +| v2.0.0 or lower | |
| 156 | ++------------------------------+ |
| 157 | + |
| 158 | +.. warning: |
| 159 | +
|
| 160 | + **Breaking changes:** |
| 161 | + The submodules `enums` and `types` have been removed; the `type` attributes were renamed to `type_` to avoid name collisions. |
| 162 | +
|
| 163 | +**Before:** |
| 164 | + |
| 165 | +.. code-block:: python |
| 166 | +
|
| 167 | + from google.cloud import datacatalog_v1 |
| 168 | + entry = datacatalog_v1.types.Entry() |
| 169 | + entry.type = datacatalog_v1.enums.EntryType.FILESET |
| 170 | +
|
| 171 | +
|
| 172 | +**After:** |
| 173 | + |
| 174 | +.. code-block:: python |
| 175 | +
|
| 176 | + from google.cloud import datacatalog_v1 |
| 177 | + entry = datacatalog_v1.Entry() |
| 178 | + entry.type_ = datacatalog_v1.EntryType.FILESET |
| 179 | +
|
| 180 | +The renamed attributes are: |
| 181 | + |
| 182 | +* `TagTemplateField.type` -> `TagTemplatedField.type_` |
| 183 | +* `ColumnSchema.type` -> `ColumnSchema.type_` |
| 184 | +* `Entry.type` -> `Entry.type_` |
| 185 | + |
| 186 | +Common Resource Path Helper Methods |
| 187 | +----------------------------------- |
| 188 | + |
| 189 | ++------------------------------+ |
| 190 | +| Applicable previous versions | |
| 191 | ++==============================+ |
| 192 | +| v1.0.0 or lower | |
| 193 | ++------------------------------+ |
| 194 | + |
| 195 | +The `location_path` method existing in `google-cloud-datacatalog<=1.0.0` was renamed to `common_location_path` in v3.0.0. |
| 196 | + |
| 197 | +If you are upgrading from v1.0.0 or lower, modify your code to use new method name. |
| 198 | + |
| 199 | +If you are upgrading from v2.0.0, and constructing paths manually as described in `previous upgrade guide <https://github.com/googleapis/python-datacatalog/blob/v2.0.0/UPGRADING.md#project-path-helper-methods>`_, now you can use `common_location_path` method. |
| 200 | + |
| 201 | +There are also more resource path helper methods were added: `common_billing_account_path`, `common_folder_path`, `common_organization_path`, and `common_project_path`. |
0 commit comments