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 |
Anthonios Partheniou | a6f1706 | 2021-03-15 10:18:02 -0400 | [diff] [blame] | 10 | from the client library directly. |
| 11 | |
| 12 | For users of public APIs |
| 13 | ------------------------ |
| 14 | Existing code written for earlier versions of this library will not require |
| 15 | updating. We believe this new default behaviour will provide a more predictable |
| 16 | experience for users. If always using the latest version of a service definition |
| 17 | is more important than reliability, users should set the `static_discovery` |
| 18 | argument of `discovery.build()` to `False` to retrieve the service definition |
| 19 | from the internet. |
| 20 | |
| 21 | For users of private APIs |
| 22 | ------------------------- |
| 23 | If the discovery document requires an authentication key to access it, the |
| 24 | discovery document is private and it will not be shipped with the library. |
| 25 | Only discovery documents listed in [this public directory](https://www.googleapis.com/discovery/v1/apis/) |
| 26 | are included in the library. Users of private APIs should set the |
| 27 | `static_discovery` argument of `discovery.build()` to `False` to continue to |
release-please[bot] | a9c7ddc | 2021-03-03 21:52:06 +0000 | [diff] [blame] | 28 | retrieve the service definition from the internet. |
| 29 | |
| 30 | If you experience issues or have questions, please file an [issue](https://github.com/googleapis/google-api-python-client/issues). |
| 31 | |
| 32 | ## Supported Python Versions |
| 33 | |
| 34 | > **WARNING**: Breaking change |
| 35 | |
| 36 | The 2.0.0 release requires Python 3.6+, as such you must upgrade to Python 3.6+ |
| 37 | to use version 2.0.0. |
| 38 | |
| 39 | ## Method Calls |
| 40 | |
| 41 | **Note**: Existing code written for earlier versions of this library will not |
| 42 | require updating. You should only update your code if always using the latest |
Anthonios Partheniou | a6f1706 | 2021-03-15 10:18:02 -0400 | [diff] [blame] | 43 | version of a service definition is more important than reliability or if you |
| 44 | are using an API which does not have a public discovery document. |
release-please[bot] | a9c7ddc | 2021-03-03 21:52:06 +0000 | [diff] [blame] | 45 | |
| 46 | > **WARNING**: Breaking change |
| 47 | |
| 48 | The 2.0.0 release no longer retrieves discovery documents dynamically on each |
| 49 | call to `discovery.build()`. Instead, discovery documents are retrieved from |
| 50 | the client library itself. |
| 51 | |
| 52 | Under the hood, the `discovery.build()` function retrieves a discovery artifact |
| 53 | in order to construct the service object. The breaking change is that the |
| 54 | `discovery.build()` function will no longer retrieve discovery artifacts |
| 55 | dynamically. Instead it will use service definitions shipped in the library. |
| 56 | |
| 57 | |
| 58 | **Before:** |
| 59 | ```py |
| 60 | from googleapiclient.discovery import build |
| 61 | |
| 62 | # Retrieve discovery artifacts from the internet |
| 63 | with build('drive', 'v3') as service: |
| 64 | # ... |
| 65 | ``` |
| 66 | |
| 67 | **After:** |
| 68 | ```py |
| 69 | from googleapiclient.discovery import build |
| 70 | |
| 71 | # Retrieve discovery artifacts from the client library |
| 72 | with build('drive', 'v3') as service: |
| 73 | # ... |
| 74 | |
| 75 | # Retrieve discovery artifacts from the internet |
| 76 | with build('drive', 'v3', static_discovery=False) as service: |
| 77 | # ... |
| 78 | ``` |