platform module - Platform - BlueCat Gateway - 20.12.1

Gateway Administration Guide

prodname
BlueCat Gateway
version_custom
20.12.1

Definitions about the Gateway Platform and functions for working with related concepts.

Introduction

Gateway runs an enhanced Flask application. It has a field, platform, which is an instance of the Platform class documented here. The recommended way for accessing the platform instance is via flask.current_app.

from flask import current_app

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

class bluecat.gateway.platform.Platform(*args, **kwargs)

Class representing the supported operations with the Gateway Platform.

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.

Parameter Description
path (str, required)

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

key (str, required) Key to use for decrypting
scan_default (bool, required) 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.

Parameter Description
path (str, required)

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

value (str, required) Value to be encrypt and store
key (str, required) Key to use for encrypting
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.

Parameter Description
path (str, required)

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.

Parameter Description
path (str, required)

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.

Parameter Description
path (str, required)

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: 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.

Parameter Description
path (str, required)

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: str

New in version 20.12.1