Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom headers, update LICENSE - Issues# 28 & 26 - plus general housekeeping #29

Merged
merged 3 commits into from
Feb 25, 2025

Conversation

sbarbett
Copy link
Contributor

@sbarbett sbarbett commented Feb 25, 2025

Housekeeping

  • modified file structure to be more aligned with best practices
  • deleted old obsolete setup.py file
  • fixed license section of README.md (Issue#26)
  • updated .gitignore with common Python template
  • made RestApiConnection class available in __init__.py
  • fixed license_files in pyproject.toml (it excepts a list, not a dictionary)
  • fixed version in about.py

New Feature(s)

Issue#28

  • added constructors to RestApiClient and RestApiConnection classes to support custom HTTP headers (custom_headers)

    from ultra_rest_client import RestApiClient
    client = RestApiClient('username', 'password', custom_headers={"foo":"bar", "user-agent":"hello"})
    zones = client.get_zones()

    Captured header output:

    {
        "Accept": "application/json",
        "Authorization": "Bearer redacted",
        "Content-Type": "application/json",
        "foo": "bar",
        "user-agent": "hello",
        "User-Agent": "udns-python-rest-client-2.2.3"
    }
  • added a public method to RestApiConnection which allows modification of headers after client has been instantiated

    client.rest_api_connection.set_custom_headers({"boo":"far","user-agent":"goodbye"})
    zones = client.get_zones()

    Captured header output:

    {
        "Accept": "application/json",
        "Authorization": "Bearer redacted",
        "Content-Type": "application/json",
        "foo": "bar",
        "boo": "far",
        "user-agent": "goodbye",
        "User-Agent": "udns-python-rest-client-2.2.3"
    }
  • attempting to set the following headers will raise a ValueError

    • Content-Type
    • Authorization
    • Accept
  • updated README.md with example

@stevedejong stevedejong merged commit 24e8954 into ultradns:master Feb 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants