Source Utilities package

Subpackages

Submodules

Create Space module

src.utils.create_space.prepare_payload(space_id: str, space_name: str, description: str | None = None, initials: str | None = None, color: str | None = None, disabled_features: list | None = None, image_url: str | None = None) Dict[str, str][source]

Prepare payload for space creation.

Parameters:
  • space_id – Space ID.

  • space_name – Space name.

  • description – Space description.

  • initials – Space initials.

  • color – Space color.

  • disabled_features – Space disabled features.

  • image_url – Space image URL.

Returns:

Payload.

src.utils.create_space.create_space(payload: Dict[str, str]) None[source]

Create space via Kibana API.

Parameters:

payload – Payload.

Returns:

None.

Create Users module

class src.utils.create_users.User(username: str, roles: List[str], password: str = None, password_hash: str = None, full_name: str = None, email: str = None, metadata: dict = None, enabled: bool = True)[source]

Bases: object

prepare_payload() Dict[str, Any][source]

Prepare the request body for the Elasticsearch API user creation request.

Returns:

The request body.

create() None[source]

Create the user in Elasticsearch.

Returns:

None

Raises:

requests.exceptions.HTTPError – If the request fails.

property username: str
property roles: List[str]
validate_roles() None[source]

Validate that the roles are not empty.

Returns:

None

Raises:

ValueError – If no roles are specified.

property password: str
validate_password() None[source]

Validate that the password and password_hash are not both specified.

Returns:

None

Raises:

ValueError – If both password and password_hash are specified.

property password_hash: str
property full_name: str
property email: str
property metadata: dict
property enabled: bool

Get and verify space options module

src.utils.get_and_verify_space_options.get_and_verify_space_options() Tuple[str, str, str | None, str | None, str | None, List[str] | None, str | None][source]

Get space options.

Returns:

A tuple of space options.

src.utils.get_and_verify_space_options.get_and_verify_space_id(get_space_id_fn: ~typing.Callable[[str], str] = <function get_input>) str[source]

Get and verify the space ID

Returns:

String space ID

src.utils.get_and_verify_space_options.get_and_verify_space_name(get_space_name_fn: ~typing.Callable[[str], str] = <function get_input>) str[source]

Get and verify the space name

Returns:

String space name

src.utils.get_and_verify_space_options.get_and_verify_description(get_space_description: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the description

Returns:

String description or None

src.utils.get_and_verify_space_options.get_and_verify_initials(get_space_initials_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the initials

Returns:

String initials or None

src.utils.get_and_verify_space_options.get_and_verify_color(get_space_color_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the color

Returns:

String hex color or None

src.utils.get_and_verify_space_options.get_and_verify_disabled_features(get_space_disabled_features_fn: ~typing.Callable[[str], str] = <function get_input>) List[str] | None[source]

Get and verify the disabled features

Returns:

List of disabled features or None

src.utils.get_and_verify_space_options.get_and_verify_image_url(get_space_image_url_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the image URL

Returns:

String image URL or None

Get and verify user options module

src.utils.get_and_verify_user_options.get_and_verify_user_options() Tuple[str, List[str], str | None, str | None, str | None, str | None, Dict[str, Any] | None, bool][source]

Get and verify user options

Returns:

A tuple of user options.

src.utils.get_and_verify_user_options.get_and_verify_username(get_user_username_fn: ~typing.Callable[[str], str] = <function get_input>) str[source]

Get and verify the username

Returns:

String username

src.utils.get_and_verify_user_options.get_and_verify_roles(get_user_role_fn: ~typing.Callable[[str], str] = <function get_input>) List[str][source]

Get and verify the roles

Returns:

List of roles or None

src.utils.get_and_verify_user_options.get_and_verify_password(get_user_password_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the password

Returns:

String of password or None

src.utils.get_and_verify_user_options.get_and_verify_password_hash(get_user_password_hash_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the password hash

Returns:

String of password hash

src.utils.get_and_verify_user_options.get_and_verify_full_name(get_user_full_name_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the full name

Returns:

String of full name or None

src.utils.get_and_verify_user_options.get_and_verify_email(get_user_email_fn: ~typing.Callable[[str], str] = <function get_input>) str | None[source]

Get and verify the email

Returns:

String of email or None

src.utils.get_and_verify_user_options.get_and_verify_metadata(get_user_metadata_fn: ~typing.Callable[[str], str] = <function get_input>) Dict[str, Any] | None[source]

Get and verify the metadata

Returns:

Dict of metadata or None

src.utils.get_and_verify_user_options.get_and_verify_enabled(get_user_enabled_fn: ~typing.Callable[[str], str] = <function get_input>) bool[source]

Get and verify the enabled status

Returns:

True if enabled, False if disabled

Get mode options module

src.utils.get_mode_options.get_mode_options(mode: str) Tuple[str, str, str | None, str | None, str | None, List[str] | None, str | None] | Tuple[str, List[str], str | None, str | None, str | None, str | None, Dict[str, Any] | None, bool][source]

Get user options for space or user mode.

Parameters:

mode – The mode to run the script in. Required.

Returns:

A tuple of user options.

Load .env module

src.utils.load_env.get_all_env() -> (<class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>)[source]

Get all environment variables.

Returns:

A tuple of environment variables.

Module contents