release-please[bot] | a9c7ddc | 2021-03-03 21:52:06 +0000 | [diff] [blame] | 1 | # 2.0.0 Migration Guide |
| 2 | |
| 3 | The 2.0 release of `google-api-python-client` is a significant upgrade as only |
| 4 | python 3.6 and newer is supported. If you are not able to upgrade python, then |
| 5 | please continue to use version 1.x as we will continue supporting python 2.7+ in |
| 6 | [v1](https://github.com/googleapis/google-api-python-client/tree/v1). |
| 7 | |
| 8 | In addition, discovery documents will no longer be retrieved dynamically when |
| 9 | you call `discovery.build()`. The discovery documents will instead be retrieved |
| 10 | from the client library directly. Existing code written for earlier versions of |
| 11 | this library will not require updating. We believe this new default behaviour |
| 12 | will provide a more predictable experience for users. If always using the latest |
| 13 | version of a service definition is more important than reliability, users should |
| 14 | set the `static_discovery` argument of `discovery.build()` to `False` to |
| 15 | retrieve the service definition from the internet. |
| 16 | |
| 17 | If you experience issues or have questions, please file an [issue](https://github.com/googleapis/google-api-python-client/issues). |
| 18 | |
| 19 | ## Supported Python Versions |
| 20 | |
| 21 | > **WARNING**: Breaking change |
| 22 | |
| 23 | The 2.0.0 release requires Python 3.6+, as such you must upgrade to Python 3.6+ |
| 24 | to use version 2.0.0. |
| 25 | |
| 26 | ## Method Calls |
| 27 | |
| 28 | **Note**: Existing code written for earlier versions of this library will not |
| 29 | require updating. You should only update your code if always using the latest |
| 30 | version of a service definition is more important than reliability. |
| 31 | |
| 32 | > **WARNING**: Breaking change |
| 33 | |
| 34 | The 2.0.0 release no longer retrieves discovery documents dynamically on each |
| 35 | call to `discovery.build()`. Instead, discovery documents are retrieved from |
| 36 | the client library itself. |
| 37 | |
| 38 | Under the hood, the `discovery.build()` function retrieves a discovery artifact |
| 39 | in order to construct the service object. The breaking change is that the |
| 40 | `discovery.build()` function will no longer retrieve discovery artifacts |
| 41 | dynamically. Instead it will use service definitions shipped in the library. |
| 42 | |
| 43 | |
| 44 | **Before:** |
| 45 | ```py |
| 46 | from googleapiclient.discovery import build |
| 47 | |
| 48 | # Retrieve discovery artifacts from the internet |
| 49 | with build('drive', 'v3') as service: |
| 50 | # ... |
| 51 | ``` |
| 52 | |
| 53 | **After:** |
| 54 | ```py |
| 55 | from googleapiclient.discovery import build |
| 56 | |
| 57 | # Retrieve discovery artifacts from the client library |
| 58 | with build('drive', 'v3') as service: |
| 59 | # ... |
| 60 | |
| 61 | # Retrieve discovery artifacts from the internet |
| 62 | with build('drive', 'v3', static_discovery=False) as service: |
| 63 | # ... |
| 64 | ``` |