Welcome to Python interface for SW360!

Indices and tables

class sw360.SW360(url: str, token: str, oauth2: bool = False, session: ~requests.sessions.Session | None = <requests.sessions.Session object>)

Python interface to the Siemens SW360 platform

Authentication against a running SW360 instance is performed using an API token. The token will be sent as HTTP header using the format Authorization: <token_type> <token>. Check your SW360 REST API documentation for details on needed type and how to get the token. token_type is “Bearer” for an OAuth workflow and “Token” for tokens generated via the SW360 UI.

Parameters:
  • url (string) – URL of the SW360 instance

  • token (string) – The SW360 REST API token (the cryptic string without “Authorization:” and token_type).

  • oauth2 (boolean) – flag indicating whether this is an OAuth2 token

api_get_raw(url: str = '') str

Request url from REST API and return raw result.

Parameters:

url (string) – the url to be requested

Returns:

the HTTP response

Return type:

string

Raises:

SW360Error – if there is a negative HTTP response

close_api() None

A keep-alive HTTP session is used to access the SW360 REST API. This method allows to explicitly close the connection at a defined time. Normally, you don’t need to call it - session is cleaned up automatically when needed.

get_health_status() Dict[str, Any] | None

Get information about the service’s health.

API endpoint: GET /health

Returns:

service health status

Return type:

JSON health status object

Raises:

SW360Error – if there is a negative HTTP response

login_api(token: str = '') bool

Login to SW360 REST API. This used to have a token parameter due to historic reasons which is ignored.

You need to call this before any other method accessing SW360.

Raises:

SW360Error – if the login fails

exception sw360.SW360Error(response: Response | None = None, url: str = '', message: str = '')

Base exception for SW360 operations

Parameters:
  • message (string) – a general error message

  • response (object) – the response object returned by the requests call

  • url (string) – the URL where the error occurred

class sw360.SW360OAuth2(url: str, user: str, password: str)

SW360 OAuth2 Credentials Restore or create Sw360 oauth2 tokens from user/password if auth server is alive :param url: URL of the SW360 instance :param user: SW360 username :param password: SW360 password :type url: string :type user: string :type password: string

create_client(description: str, writeable: bool = False) None

Create an OAuth2 client

Args:

description (str): Some description of the client writeable (bool): Create the id read/writeable

Raises:

SW360Error: When unable to create a client

generate_token() str

Generate a new bearer token

property refresh_token: str

Return the valid oauth refresh token

property token: str | None

Return the valid oauth token

property url: str

Return current session object url