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