Add **options kwargs to operations#420
Merged
Merged
Conversation
bhelx
commented
Aug 12, 2020
| Sort order. | ||
| sort : str | ||
| Sort field. You *really* only want to sort by `updated_at` in ascending | ||
| params.limit : int |
Contributor
Author
There was a problem hiding this comment.
Trying this format so we can document the individual k/v pairs. It's not explicitly supported by sphinx but it works visually.
bhelx
commented
Aug 12, 2020
bhelx
commented
Aug 12, 2020
bhelx
commented
Aug 12, 2020
85515ad to
ce30ce3
Compare
This serves a couple purposes: 1. It adds the **options kwargs to every operation. This will be where you can set custom request options. 2. We no longer support passing in query params as kwargs, they must now be passed as a dict to the `params` kwarg 3. We're adding support for the `headers` kwarg which overrides headers on the request.
ce30ce3 to
c4b20a3
Compare
bhelx
commented
Aug 13, 2020
| items = PageIterator(self.__client, self.__path, params) | ||
| options = self.__options | ||
| if "params" in options: | ||
| options = copy.deepcopy(options) |
Contributor
Author
There was a problem hiding this comment.
Might be able to get away with not doing the deepcopy, but thought we might want to be safe here.
bhelx
commented
Aug 14, 2020
| self.__conn = http.client.HTTPSConnection(HOST, PORT) | ||
|
|
||
| def _make_request(self, method, path, body, params): | ||
| def _make_request(self, method, path, body, **options): |
Contributor
Author
There was a problem hiding this comment.
We probably want to validate the options object. I'll make a follow up ticket for it.
| def _make_request(self, method, path, body, **options): | ||
| try: | ||
| basic_auth = b64encode(bytes(self.__api_key + ":", "ascii")).decode("ascii") | ||
| headers = { |
Contributor
There was a problem hiding this comment.
I've been trying to set these "private" headers after the custom headers to prevent the user from accidentally modifying them.
Contributor
Author
There was a problem hiding this comment.
Making a ticket to follow up with that. as well as add validation for options
douglasmiller
added a commit
that referenced
this pull request
Mar 1, 2021
# Changelog ## [Unreleased](https://github.com/recurly/recurly-client-python/tree/HEAD) [Full Changelog](3.15.0...HEAD) # Major Version Release The 4.x major version of the client pairs with the `v2021-02-25` API version. This version of the client and the API contain breaking changes that should be considered before upgrading your integration. ## Breaking Changes in the API All changes to the core API are documented in the [Developer Portal changelog](https://developers.recurly.com/api/changelog.html#v2021-02-25---current-ga-version) ## Breaking Changes in Client - Add `**options`` kwargs to every operation [[#420](#420)] - Require query params be passed in as a dict to the `params` kwarg [[#420](#420)] - Add support for `headers` kwarg [[#420](#420)] - Add validation to ensure only allowed options are passed to operations [[#430](#430)] - Preserve internal headers that should not be overridden by optional headers [[#430](#430)] **Merged pull requests:** - Updating changelog script and changelog generator config for 4.x release [\#475](#475) ([douglasmiller](https://github.com/douglasmiller)) - Adding options validation and preserving internal headers [\#430](#430) ([douglasmiller](https://github.com/douglasmiller)) - Add \*\*options kwargs to operations [\#420](#420) ([bhelx](https://github.com/bhelx))
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is going into
v3-v2020-01-01. It contains a breaking change as you can no longer pass query params as kwargs into operations.This serves a couple purposes:
**optionskwargs to every operation. This will be whereyou can set custom request options.
be passed as a dict to the
paramskwargheaderskwarg which overrides headerson the request.