Platform class - Platform - BlueCat Gateway - 24.1

Gateway Administration Guide

Locale
English
Product name
BlueCat Gateway
Version
24.1

class bluecat.gateway.platform.Platform(path)

Class representing the supported operations with the Gateway Platform.

Gateway runs an enhanced Flask application. The recommended way for accessing the platform instance is via flask.current_app.platform.

from flask import current_app

def some_function(path):
   path = current_app.platform.resolve_existing_path(path)
   # Do something with `path`.
Note:

All read operations consider the platform workspaces and whether the default workspace is included in the resolution, is configurable.

All write operations are performed in the custom workspace only.

New in version 20.12.1.

decrypt_value_from_file(path, key, *, scan_default=False)

Decrypt the contents of a file located in a workspace of the platform.

Parameters Description
path (str)

Path to an encrypted file, relative to a workspace of the platform.

key (str)

Key to use for decrypting.

scan_default (bool, optional)

Whether the default workspace to be inspected when resolving the file. Defaults to False.

Returns: Decrypted value.

Return type: str

New in version 20.12.1.

encrypt_value_to_file(path, value, key)

Encrypt a value and store it in a file located in a workspace of the platform.

Parameters Description
path (str)

Path to where an encrypted file should be created. It is relative to a workspace of the platform.

value (str)

Value to encrypt and store.

key (str)

Key to use for encrypting.

Return type: None

New in version 20.12.1.

get_path_for_writing(path)

Return a path that can be used for creating files that are addressable via a path relative to a platform workspace.

Parameters Description
path (str)

Path relative to a platform workspace.

Returns: Full path to a location inside the writable workspace.

Return type: str

Note:

There is no guarantee that the path is immediately writable. Intermediate directories may have to be created. Alternatively, the permissions of existing directories may prevent write operations.

New in version 20.12.1.

resolve_existing_path(path, *, scan_default=False)

Validate the path against the contents of the platform workspaces and return a full path to the resource. The returned value contains the path of a workspace. The validation consists of checking that the path exists.

Parameters Description
path (str)

Path relative to a platform workspace.

scan_default (bool, optional)

Whether the default workspace to be inspected as well. Defaults to False.

Raises:

ResourceError – If the path cannot be resolved.

Returns: Full path to the resource.

Return type: str

New in version 20.12.1.

safe_resolve_certificates_dir_path(path, *, scan_default=False)

Validate the path against the contents of the platform workspaces and return a full path to the resource. The returned value contains the path of a workspace. The validation consists of checking that the path is an existing folder with files.

Parameters Description
path (str)

Path relative to a platform workspace.

scan_default (bool, optional)

Whether the default workspace to be inspected as well. Defaults to False.

Returns: Full path to the resource. Returns None if the path cannot be resolved.

Return type: Optional[str]

New in version 20.12.1.

safe_resolve_existing_path(path, *, scan_default=False)

Validate the path against the contents of the platform workspaces and return a full path to the resource. The returned value contains the path of a workspace. The validation consists of checking that the path exists.

Parameters Description
path (str)

Path relative to a platform workspace.

scan_default (bool, optional)

Whether the default workspace to be inspected as well. Defaults to False.

Returns: Full path to the resource. Returns None if the path cannot be resolved.

Return type: Optional[str]

New in version 20.12.1.