swimlane.core.client module

Core Swimlane client class

class swimlane.core.client.Swimlane(host, username, password, verify_ssl=True, default_timeout=60, verify_server_version=True, resource_cache_size=0)[source]

Bases: object

Swimlane API client

Core class used throughout library for all API requests and server interactions

Parameters:
  • host (str) – Full RFC-1738 URL pointing to Swimlane host. Defaults will be provided for all parts
  • username (str) – Authentication username
  • password (str) – Authentication password
  • verify_ssl (bool) – Verify SSL (ignored on HTTP). Disable to use self-signed certificates
  • default_timeout (int) – Default request connect and read timeout in seconds for all requests
  • verify_server_version (bool) – Verify server version has same major version as client package. May require additional requests, set False to disable check
  • resource_cache_size (int) – Maximum number of each resource type to keep in memory cache. Set 0 to disable caching. Disabled by default
host

pyuri.URI – Full RFC-1738 URL pointing to Swimlane host

apps

AppAdapterAppAdapter configured for current Swimlane instance

users

UserAdapterUserAdapter configured for current Swimlane instance

groups

GroupAdapterGroupAdapter configured for current Swimlane instance

resources_cache

ResourcesCache – Cache checked by all supported adapters for current Swimlane instance

Examples

# Establish connection
swimlane = Swimlane(
    'https://192.168.1.1',
    'username',
    'password',
    verify_ssl=False
)

# Retrieve an app
app = swimlane.apps.get(name='Target App')
request(method, api_endpoint, **kwargs)[source]

Wrapper for underlying requests.Session

Handles generating full API URL, session reuse and auth, request defaults, and invalid response status codes

Used throughout library as the core underlying request/response method for all interactions with server

Parameters:
  • method (str) – Request method (get, post, put, etc.)
  • api_endpoint (str) – Portion of URL matching API endpoint route as listed in platform /docs help page
  • **kwargs (dict) – Remaining arguments passed through to actual request call

Notes

All other provided kwargs are passed to underlying requests.Session.request() call

Raises:
Returns:

Successful response instances

Return type:

requests.Response

Examples

Request and parse server settings endpoint response

>>> server_settings = swimlane.request('get', 'settings').json()
settings

Retrieve and cache settings from server

user

User record instance for authenticated user

version

Server API version

class swimlane.core.client.SwimlaneAuth(swimlane, username, password, verify_ssl=True)[source]

Bases: swimlane.core.resolver.SwimlaneResolver

Handles authentication for all requests

authenticate(username, password, verify_ssl=True)[source]

Send login request and return User instance and login headers