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