Skip to content

Add **options kwargs to operations#420

Merged
joannasese merged 3 commits into
v3-v2020-01-01from
options-argument
Aug 14, 2020
Merged

Add **options kwargs to operations#420
joannasese merged 3 commits into
v3-v2020-01-01from
options-argument

Conversation

@bhelx

@bhelx bhelx commented Aug 12, 2020

Copy link
Copy Markdown
Contributor

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:

  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.

Comment thread recurly/client.py
Sort order.
sort : str
Sort field. You *really* only want to sort by `updated_at` in ascending
params.limit : int

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying this format so we can document the individual k/v pairs. It's not explicitly supported by sphinx but it works visually.

Comment thread recurly/client.py Outdated
Comment thread recurly/client.py Outdated
Comment thread recurly/client.py Outdated
@bhelx bhelx force-pushed the options-argument branch 2 times, most recently from 85515ad to ce30ce3 Compare August 13, 2020 20:53
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.
@bhelx bhelx force-pushed the options-argument branch from ce30ce3 to c4b20a3 Compare August 13, 2020 20:56
@bhelx bhelx marked this pull request as ready for review August 13, 2020 21:58
Comment thread recurly/pager.py
items = PageIterator(self.__client, self.__path, params)
options = self.__options
if "params" in options:
options = copy.deepcopy(options)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be able to get away with not doing the deepcopy, but thought we might want to be safe here.

Comment thread recurly/base_client.py
self.__conn = http.client.HTTPSConnection(HOST, PORT)

def _make_request(self, method, path, body, params):
def _make_request(self, method, path, body, **options):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to validate the options object. I'll make a follow up ticket for it.

Comment thread recurly/base_client.py
def _make_request(self, method, path, body, **options):
try:
basic_auth = b64encode(bytes(self.__api_key + ":", "ascii")).decode("ascii")
headers = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to set these "private" headers after the custom headers to prevent the user from accidentally modifying them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a ticket to follow up with that. as well as add validation for options

@joannasese joannasese left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@joannasese joannasese merged commit 3f8f075 into v3-v2020-01-01 Aug 14, 2020
@joannasese joannasese deleted the options-argument branch August 14, 2020 21:02
@joannasese joannasese added the V4 v2021-02-25 Client label Feb 12, 2021
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))
@douglasmiller douglasmiller mentioned this pull request Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

V4 v2021-02-25 Client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants