Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:
name: Build and Test Driver
runs-on: ubuntu-latest # keep your own runner
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
Expand Down
31 changes: 31 additions & 0 deletions docs/examples/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,37 @@ disabled by setting `verify_server_version=False`.
'password',
verify_server_version=False
)

Headers
^^^^^^^^
To add custom headers to all requests made by the client, provide a dictionary of headers during client instantiation.
.. code-block:: python

from swimlane import Swimlane

swimlane = Swimlane(
'192.168.1.1', # IP address or hostname
'username',
'password',
headers={ 'X-Custom-Header': 'custom-value' }
)
This will add the specified headers to all requests made by the client, including those made by the preconfigured adapters.

Proxies
^^^^^^^^
To use a proxy for all requests made by the client, provide a dictionary of proxies during client instantiation.
.. code-block:: python

from swimlane import Swimlane

swimlane = Swimlane(
'192.168.1.1', # IP address or hostname
'username',
'password',
proxies={ 'http': 'http://10.10.1.10:3128', 'https': 'http://10.10.1.10:1080' }
)
This will use the specified proxies for all requests made by the client, including those made by the preconfigured adapters.

Available Adapters
------------------

Expand Down
22 changes: 18 additions & 4 deletions swimlane/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ class Swimlane(object):
'https://192.168.1.1',
'username',
'password',
verify_ssl=False
verify_ssl=False,
headers={'Custom-Header': 'value'},
proxies={'http': 'http://proxy.example.com:8080', 'https': 'https://proxy.example.com:8080'}
)

# Or establish connection using personal access token
swimlane = Swimlane(
'https://192.168.1.1',
access_token='abcdefg',
verify_ssl=False
verify_ssl=False,
headers={'Custom-Header': 'value'},
proxies={'http': 'http://proxy.example.com:8080', 'https': 'https://proxy.example.com:8080'}
)

# Retrieve an app
Expand All @@ -100,7 +104,9 @@ def __init__(
write_to_read_only: bool=False,
retry: bool=True,
max_retries: int=5,
retry_interval: int=5
retry_interval: int=5,
headers=None,
proxies=None
):
self.__verify_auth_params(username, password, access_token)

Expand All @@ -119,7 +125,15 @@ def __init__(

self._session = WrappedSession()
self._session.verify = verify_ssl

self._session.headers.update(headers or {})
self._session.proxies.update(proxies or {})
if self.host.scheme == 'http':
# Disable SSL verification for HTTP connections
self._session.verify = False
else:
# Ensure SSL verification is enabled for HTTPS connections
self._session.verify = verify_ssl

self.retry = retry
self.max_retries = max_retries
self.retry_interval = retry_interval
Expand Down
Loading