# Python X2Go (Client) API Documentation (v0.6.1.4)

## x2go.backends.profiles.base module

`x2go.backends.profiles.base.X2GoSessionProfiles` class - managing X2Go Client session profiles, base API.

`x2go.backends.profiles.base.X2GoSessionProfiles` is a public API class. Use this class in your Python X2Go based applications.

class x2go.backends.profiles.base.X2GoSessionProfiles(session_profile_defaults=None, logger=None, loglevel=56, **kwargs)

  Bases: `object`

  add_profile(profile_id=None, force_add=False, **kwargs)

    Add a new session profile.

    Parameters:

      - profile_id (`str`) – a custom profile ID–if left empty a profile ID will be auto-generated (Default value = None)

      - kwargs (`dict`) – session profile options for this new session profile

      - force_add (`bool`) – enforce adding of the given profile (Default value = False)

    Returns:

      the (auto-generated) profile ID of the new session profile

    Return type:

      `str`

  check_profile_id_or_name(profile_id_or_name)

    Detect the profile ID from a given string which maybe profile ID or profile name.

    Parameters:

      profile_id_or_name (`str`) – profile ID or profile name

    Returns:

      profile ID

    Return type:

      `str`

    Raises:

      X2GoProfileException – if no such session profile exists

  defaultSessionProfile = {'applications': ['WWWBROWSER', 'MAILCLIENT', 'OFFICE', 'TERMINAL'], 'autoconnect': False, 'autologin': True, 'autostart': False, 'clipboard': 'both', 'command': 'TERMINAL', 'defsndport': True, 'directrdp': False, 'directrdpsettings': '', 'display': 1, 'dpi': 96, 'export': {}, 'forwardsshagent': False, 'fstunnel': True, 'fullscreen': False, 'height': 600, 'host': ['server.mydomain'], 'icon': ':icons/128x128/x2gosession.png', 'iconvfrom': 'UTF-8', 'iconvto': 'UTF-8', 'kdrive': False, 'key': '', 'krblogin': False, 'layout': 'us', 'maxdim': False, 'mimeboxaction': 'OPEN', 'mimeboxextensions': '', 'multidisp': False, 'name': 'NEW_PROFILE', 'pack': '16m-jpeg', 'print': False, 'published': False, 'quality': 9, 'rdpclient': 'rdesktop', 'rdpoptions': '-u X2GO_USER -p X2GO_PASSWORD', 'rdpport': 3389, 'rdpserver': '', 'restoreexports': False, 'rootless': True, 'sessiontitle': '', 'setdpi': False, 'setsessiontitle': False, 'sndport': 4713, 'sound': False, 'soundsystem': 'pulse', 'soundtunnel': True, 'speed': 2, 'sshport': 22, 'sshproxyautologin': True, 'sshproxyhost': 'proxyhost.mydomain', 'sshproxykeyfile': '', 'sshproxyport': 22, 'sshproxysamepass': False, 'sshproxysameuser': False, 'sshproxytype': 'SSH', 'sshproxyuser': '', 'startsoundsystem': False, 'type': 'pc105/us', 'uniquehostkeyaliases': False, 'useexports': True, 'useiconv': False, 'usekbd': True, 'usemimebox': False, 'user': 'buildd', 'usesshproxy': False, 'variant': '', 'width': 800, 'xdmcpserver': 'localhost', 'xinerama': False}
  default_profile_config()

    Return a default session profile.

    Returns:

      default session profile

    Return type:

      `dict`

  delete_profile(profile_id_or_name)

    Delete a session profile from the configuration file.

    Parameters:

      profile_id_or_name (`str`) – profile ID or profile name

  get_pkey_object(profile_id)

    If available, return a PKey (Paramiko/SSH private key) object.

    Parameters:

      profile_id (`str`) – the profile’s unique ID

    Returns:

      a Paramiko/SSH PKey object

    Return type:

      `obj`

  get_profile_config(profile_id_or_name=None, parameter=None, profile_id=None)

    The configuration options for a single session profile.

    Parameters:

      - profile_id_or_name (`str`) – either profile ID or profile name is accepted (Default value = None)

      - parameter (`str`) – if specified, only the value for the given parameter is returned (Default value = None)

      - profile_id (`str`) – profile ID (faster than specifying `profile_id_or_name`) (Default value = None)

    Returns:

      the session profile configuration for the given profile ID (or name)

    Return type:

      `dict`

  get_profile_metatype(profile_id_or_name, force=False)

    Detect a human readable session profile type from the session profile configuration.

    Parameters:

      - profile_id_or_name (`str`) – profile ID or profile name

      - force (`bool`) – re-detect the meta type, otherwise use a cached result (Default value = False)

    Returns:

      the profile ID’s / name’s meta type

    Return type:

      `str`

  get_profile_option_type(option)

    Get the data type for a specific session profile option.

    Parameters:

      option (will be detected by this method) – the option to get the data type for

    Returns:

      the data type of `option`

    Return type:

      `type`

  get_server_hostname(profile_id)

    Retrieve host name of the X2Go Server configured in a session profile.

    Parameters:

      profile_id (`str`) – the profile’s unique ID

    Returns:

      the host name of the X2Go Server configured by the session profile of the given profile ID

    Return type:

      `list`

  get_server_port(profile_id)

    Retrieve SSH port of the X2Go Server configured in a session profile.

    Parameters:

      profile_id (`str`) – the profile’s unique ID

    Returns:

      the SSH port of the X2Go Server configured by the session profile of the given profile ID

    Return type:

      `list`

  get_session_param(profile_id_or_name, param)

    Get a single `x2go.session.X2GoSession` parameter from a specific session profile.

    Parameters:

      - profile_id_or_name (`str`) – either profile ID or profile name is accepted

      - param (`str`) – the parameter name in the `x2go.session.X2GoSession` constructor method

    Returns:

      the value of the session profile option represented by `param`

    Return type:

      depends on the session profile option requested

  has_profile(profile_id_or_name)

    Does a session profile of a given profile ID or profile name exist?

    Parameters:

      profile_id_or_name (`str`) – profile ID or profile name

    Returns:

      `True` if there is such a session profile, `False` otherwise

    Return type:

      `bool`

  has_profile_id(profile_id)

    Does a session profile of a given profile ID exist? (Faster than `has_profile()`.)

    Parameters:

      profile_id (`str`) – profile ID

    Returns:

      `True` if there is such a session profile, `False` otherwise

    Return type:

      `bool`

  has_profile_name(profile_name)

    Does a session profile of a given profile name exist? (Faster than `has_profile()`.)

    Parameters:

      profile_name (`str`) – profile name

    Returns:

      `True` if there is such a session profile, `False` otherwise

    Return type:

      `bool`

  init_profile_cache(profile_id_or_name)

    Some session profile backends (e.g. the broker backends cache dynamic session profile data). On new connections, it is recommented to (re-)initialize these caches.

    Parameters:

      profile_id_or_name (`str`) – profile ID or profile name

  is_mutable(profile_id_or_name=None, profile_id=None)

    Check if a given profile name (or ID) is mutable or not.

    Parameters:

      - profile_id_or_name (`str`) – profile name or profile ID (Default value = None)

      - profile_id (`str`) – if the profile ID is known, pass it in directly and skip the `check_profile_id_or_name()` call (Default value = None)

    Returns:

      `True` if the session profile of the specified name/ID is mutable

    Return type:

      `bool`

    Raises:

      X2GoProfileException – if no such session profile exists

  mutable_profile_ids()

    List all mutable session profiles.

    Returns:

      List up all session profile IDs of mutable session profiles.

    Return type:

      `bool`

  populate_session_profiles()

    Load a session profile set from the configuration storage backend and make it available for this class.

    Returns:

      a set of session profiles

    Return type:

      `dict`

  property profile_ids

    Render a list of all profile IDs found in the session profiles configuration.

  property profile_names

    Render a list of all profile names found in the session profiles configuration.

  supports_mutable_profiles()

    Check if the current session profile backend supports mutable session profiles.

    Returns:

      list of mutable profiles

    Return type:

      `list`

  to_profile_id(profile_name)

    Convert profile name to profile ID.

    Parameters:

      profile_name (`str`) – profile name

    Returns:

      profile ID

    Return type:

      `str`

  to_profile_name(profile_id)

    Convert profile ID to profile name.

    Parameters:

      profile_id (`str`) – profile ID

    Returns:

      profile name

    Return type:

      `str`

  to_session_params(profile_id_or_name=None, profile_id=None)

    Convert session profile options to `x2go.session.X2GoSession` constructor method parameters.

    Parameters:

      - profile_id_or_name (`str`) – either profile ID or profile name is accepted (Default value = None)

      - profile_id (`str`) – profile ID (fast than specifying `profile_id_or_name`) (Default value = None)

    Returns:

      a dictionary of `x2go.session.X2GoSession` constructor method parameters

    Return type:

      `dict`

  update_value(profile_id_or_name, option, value, profile_id=None)

    Update a value in a session profile.

    Parameters:

      - profile_id_or_name (`str`) – the profile ID

      - option (`str`) – the session profile option of the given profile ID

      - value (any type, depends on the session profile option) – the value to update the session profile option with

      - profile_id (`str`) – if the profile ID is known, pass it in directly and skip the `check_profile_id_or_name()` call (Default value = None)

  write()

    Store session profile data to the storage backend.

    Returns:

      `True` if the write process has been successfull, `False` otherwise

    Return type:

      `bool`