geti_sdk.http_session

Introduction

The http_session package acts as a wrapper around requests.Session and handles all http requests to the GETi cluster.

Normally it is not necessary to interact with the classes in this package directly, as they are instantiated through the main geti_sdk.Geti class.

However, a GetiSession can be established directly using the following code snippet:

from geti_sdk.http_session import ServerCredentialConfig, GetiSession

config = ServerCredentialConfig(
  host="https://0.0.0.0", username="dummy_user", password="dummy_password"
)
session = GetiSession(server_config=config)

Initializing the session will perform authentication on the GETi server.

Module contents

class geti_sdk.http_session.geti_session.GetiSession(server_config: ServerTokenConfig | ServerCredentialConfig)

Bases: Session

Wrapper for requests.session that sets the correct headers and cookies, and handles authentication and authorization.

Parameters:

server_config – Server configuration holding the hostname (or ip address) of the Intel® Geti™ server, as well as the details required for authentication (either username and password or personal access token)

property platform_serving_mode: str

Return the type of the GETi platform service.

property version: GetiVersion

Return the version of the Intel® Geti™ platform that is running on the server.

Returns:

Version object holding the Intel® Geti™ version number

property organization_id: str

Return the organization id for the user who is associated with the GetiSession

authenticate_with_password(verbose: bool = True)

Get a new authentication cookie from the server.

Parameters:

verbose – True to print progress output, False to suppress output

get_rest_response(url: str, method: str, contenttype: str = 'json', data: Any | None = None, allow_reauthentication: bool = True, include_organization_id: bool = True, allow_text_response: bool = False, request_headers: Dict[str, str] = {}) Response | dict | list

Return the REST response from a request to url with method.

Parameters:
  • url – the REST url without the hostname and api pattern

  • method – ‘GET’, ‘POST’, ‘PUT’, ‘DELETE’

  • contenttype – currently either ‘json’, ‘jpeg’, ‘multipart’, ‘zip’, or ‘’, defaults to “json”

  • data – the data to send in a post request, as json

  • allow_reauthentication – True to handle authentication errors by attempting to re-authenticate. If set to False, such errors will be raised instead.

  • include_organization_id – True to include the organization ID in the base URL. Can be set to False for accessing certain internal endpoints that do not require an organization ID, but do require error handling.

  • allow_text_response – False to trigger error handling when the server returns a response with text/html content. This can happen in some cases when authentication has expired. However, some endpoints are designed to return text responses, for those endpoints this parameter should be set to True

  • request_headers – Additional headers to include in the request

logout(verbose: bool = True) None

Log out of the server and end the session. All HTTPAdapters are closed and cookies and headers are cleared.

Parameters:

verbose – False to suppress output messages

property base_url: str

Return the base URL to the Intel Geti server. If the server is running Geti v1.9 or later, the organization ID will be included in the URL

class geti_sdk.http_session.server_config.ServerTokenConfig(host: str, token: str, *, has_valid_certificate: bool = False, proxies: Dict[str, str] | None = None)

Bases: ServerConfig

Configuration for an Intel® Geti™ server that uses a personal access token (API key) for authentication.

Variables:

token – Personal access token that can be used to connect to the server.

token: str
class geti_sdk.http_session.server_config.ServerCredentialConfig(host: str, username: str, password: str, *, has_valid_certificate: bool = False, proxies: Dict[str, str] | None = None)

Bases: ServerConfig

Configuration for an Intel® Geti™ server that requires authentication via username and password.

NOTE: This is a legacy authentication method. Recent server versions should authenticate via a personal access token (API key)

Variables:
  • username – Username to log in to the instance.

  • password – Password required to log in to the instance

username: str
password: str
class geti_sdk.http_session.exception.GetiRequestException(method: str, url: str, status_code: int, request_data: Dict[str, dict | str | list | BinaryIO], response_data: dict | str | list | None = None)

Bases: Exception

Exception representing an unsuccessful http request to the Intel® Geti™ server.