From 2ad4a11f1a53057ae661439ae747e2d6e0ec3338 Mon Sep 17 00:00:00 2001 From: Kolanu Nikshith <123105367+nikshithkolan@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:01:44 +0530 Subject: [PATCH 1/4] feat: headers and proxy --- docs/examples/client.rst | 31 +++++++++++++++++++++++++++++++ swimlane/core/client.py | 22 ++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/docs/examples/client.rst b/docs/examples/client.rst index 64d4c468..0be39828 100644 --- a/docs/examples/client.rst +++ b/docs/examples/client.rst @@ -310,6 +310,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 ------------------ diff --git a/swimlane/core/client.py b/swimlane/core/client.py index 13df8885..403e6d75 100644 --- a/swimlane/core/client.py +++ b/swimlane/core/client.py @@ -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 @@ -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) @@ -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 From 8aac5623e2cfe2ec62d2b109418be28533935f21 Mon Sep 17 00:00:00 2001 From: Kolanu Nikshith <123105367+nikshithkolan@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:04:53 +0530 Subject: [PATCH 2/4] fix: github actions --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index e4eb40c1..06f32801 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -9,7 +9,7 @@ on: jobs: build: name: Build and Test Driver - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: python-version: [3.6, 3.7, 3.12] From 4d2093cf9f181ce64b8e3537428ac79704353acf Mon Sep 17 00:00:00 2001 From: Kolanu Nikshith <123105367+nikshithkolan@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:19:02 +0530 Subject: [PATCH 3/4] fix: self hosted --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 06f32801..f606f30e 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -9,7 +9,7 @@ on: jobs: build: name: Build and Test Driver - runs-on: ubuntu-22.04 + runs-on: self-hosted strategy: matrix: python-version: [3.6, 3.7, 3.12] From e9206ec210889a441509fba1fce7f9fcf4939ea1 Mon Sep 17 00:00:00 2001 From: sandeep-reddy03 <132483470+sandeep-reddy03@users.noreply.github.com> Date: Thu, 4 Dec 2025 14:06:17 +0530 Subject: [PATCH 4/4] fix: change runner from self-hosted to ubuntu-latest --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 55c44fee..2047f109 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -9,7 +9,7 @@ on: jobs: build: name: Build and Test Driver - runs-on: self-hosted + runs-on: ubuntu-latest strategy: matrix: python-version: [3.12]