Utilities#
Credential Utilities#
- Module:
pydplus.credentials
- Synopsis:
Secure parsing and handling for RSA ID Plus legacy key material
- Created By:
Jeff Shurtliff
- Last Modified:
Jeff Shurtliff (via GPT-5.5-codex)
- Modified Date:
17 May 2026
- pydplus.credentials.IDPlusKeyMaterial#
alias of
IDPlusLegacyKeyMaterial
- class pydplus.credentials.IDPlusLegacyKeyMaterial(customer_name: str, access_id: str, access_key_pem: str, admin_rest_api_url: str, description: str | None = None)[source]#
Bases:
objectTyped RSA ID Plus legacy credential material parsed from a .key JSON file.
- Parameters:
customer_name (str) – The RSA tenant customer name from the key file
access_id (str) – The legacy API access identifier
access_key_pem (str) – The RSA private key in PEM format
admin_rest_api_url (str) – The Admin REST API base URL for the tenant
description (str, None) – Optional free-form description from the key file
- Raises:
- property default_pem_filename: str#
Return a sanitized default filename for persisted private key material.
- classmethod from_file(path: str | Path) IDPlusLegacyKeyMaterial[source]#
Parse key material from a .key file path and validate the result.
- Parameters:
path – The path to the .key JSON file
- Returns:
Parsed and validated key material
- Raises:
- classmethod from_json_text(text: str) IDPlusLegacyKeyMaterial[source]#
Parse key material from JSON text and validate the resulting object.
- Parameters:
text (str) – JSON content for the RSA ID Plus .key file
- Returns:
Parsed and validated key material
- Raises:
- write_private_key_pem(path: str | Path | None = None, overwrite: bool = False) Path[source]#
Persist private key material to disk with strict file-system protections.
Note
Persistence is explicit-only and never occurs automatically during parsing.
- Parameters:
path – Optional destination path (Defaults to
~/.pydplus/certs/<safe_filename>.pem)overwrite – Whether to overwrite an existing destination file (
Falseby default)
- Returns:
The final path for the persisted PEM file
- Raises:
FileExistsError,pydplus.errors.exceptions.IDPlusCredentialError
- pydplus.credentials.from_file(path: str | Path) IDPlusLegacyKeyMaterial[source]#
Parse and validate RSA ID Plus key material from file.
- Parameters:
path – Path to a .key credential file
- Returns:
Parsed and validated key material
- pydplus.credentials.from_json_text(text: str) IDPlusLegacyKeyMaterial[source]#
Parse and validate RSA ID Plus key material from JSON text.
- Parameters:
text (str) – JSON content for a .key credential file
- Returns:
Parsed and validated key material
Core Utilities#
- Module:
pydplus.utils.core_utils
- Synopsis:
Collection of supporting utilities and functions to complement the primary modules
- Usage:
from pydplus.utils import core_utils- Example:
encoded_string = core_utils.encode_url(decoded_string)- Created By:
Jeff Shurtliff
- Last Modified:
Jeff Shurtliff
- Modified Date:
30 Mar 2026
- pydplus.utils.core_utils.ensure_ending_slash(path: str, path_type: str = 'url') str[source]#
Ensure that a URL ends with a forward slash (
/) or backslash (\).- Parameters:
- Returns:
The URL string with an ending forward slash
- Raises:
- pydplus.utils.core_utils.file_exists(file_path: str) bool[source]#
Check to see if a file exists at a given file path.
- pydplus.utils.core_utils.get_base_url(url: str, include_scheme: bool = True) str[source]#
Parse a URL to return only the base URL with or without the scheme.
- Parameters:
- Returns:
The base URL as a string
- Raises:
- pydplus.utils.core_utils.get_env_variable_name_by_environment(field: str, env: str | None = None) str[source]#
Retrieve an environment variable name based on a given environment name.
- Parameters:
- Returns:
The environment variable name as a string (e.g.
PYDPLUS_VERIFY_SSL)- Raises:
- pydplus.utils.core_utils.get_file_type(file_path: str) str[source]#
Attempt to identify if a given file path is for a YAML or JSON file.
- Parameters:
file_path (str) – The full path to the file
- Returns:
The file type in string format (e.g.
yamlorjson)- Raises:
TypeError,FileNotFoundError,pydplus.errors.exceptions.UnknownFileTypeError
- pydplus.utils.core_utils.get_random_string(length: int = 32, prefix_string: str = '') str[source]#
Return a random alphanumeric string.
- pydplus.utils.core_utils.normalize_oauth_scope(scope_value: Any, required: bool = False) str | None[source]#
Normalize and validate OAuth scope values into canonical
+-delimited format.- Parameters:
scope_value – Scope value defined as a
+-delimited or space-delimited string, or iterable of scope stringsrequired (bool) – Indicates whether a scope value is mandatory (
Falseby default)
- Returns:
The normalized
+-delimited scope string when defined- Raises:
TypeError,ValueError,pydplus.errors.exceptions.MissingRequiredDataError
- pydplus.utils.core_utils.remove_ending_slash(path: str) str[source]#
Remove a trailing slash at the end of a URL or endpoint when present.
- pydplus.utils.core_utils.split_file_path(full_path: str) Tuple[str, str][source]#
Split a full file path into separate variables for file path and file name.
Helper Utilities#
- Module:
pydplus.utils.helper
- Synopsis:
Module that allows the pydplus library to leverage a helper configuration file
- Usage:
from pydplus.utils import helper- Example:
helper_settings = helper.get_settings('/tmp/helper.yml', 'yaml')- Created By:
Jeff Shurtliff
- Last Modified:
Jeff Shurtliff
- Modified Date:
01 Apr 2026
- pydplus.utils.helper.get_helper_settings(file_path: str, file_type: str = 'json', defined_settings: dict | None = None) dict[str, str | bool | dict][source]#
Return a dictionary of the defined helper settings.
- Parameters:
- Returns:
Dictionary of helper variables
- Raises:
- pydplus.utils.helper.import_helper_file(file_path: str, file_type: str) dict[source]#
Import a YAML (.yml, .yaml) or JSON (.json) helper config file.
- Parameters:
- Returns:
The parsed configuration data
- Raises:
FileNotFoundError,pydplus.errors.exceptions.InvalidHelperFileTypeError
Logging Utilities#
- Module:
pydplus.utils.log_utils
- Synopsis:
Collection of logging utilities and functions
- Usage:
from pydplus.utils import log_utils- Example:
logger = log_utils.initialize_logging(__name__)- Created By:
Jeff Shurtliff
- Last Modified:
Jeff Shurtliff
- Modified Date:
30 Mar 2026
- class pydplus.utils.log_utils.LessThanFilter(exclusive_maximum: int, name: str = '')[source]#
Bases:
FilterAllow filters to be set to limit log levels to only less than a specified level.
See also
Zoey Greer is the original author of this class which was provided on Stack Overflow.
- pydplus.utils.log_utils.initialize_logging(logger_name: str | None = None, log_level: str | int | None = None, formatter: str | Formatter | None = None, debug: bool | None = None, no_output: bool | None = None, file_output: bool | None = None, file_log_level: str | int | None = None, log_file: str | None = None, overwrite_log_files: bool | None = None, console_output: bool | None = None, console_log_level: str | int | None = None, syslog_output: bool | None = None, syslog_log_level: str | int | None = None, syslog_address: str | None = None, syslog_port: int | None = None) Logger[source]#
Initialize and configure a logger instance.
- Parameters:
logger_name – The logger name used by
logging.getLogger().log_level – The overall logger level.
formatter – Optional formatter instance or format string.
debug – If
True, force all logger and handler levels todebug.no_output – If
True, add alogging.NullHandlerand skip all output handlers.file_output – If
True, enable file-based logging output.file_log_level – Log level for the file handler.
log_file – Log file name or path for file output.
overwrite_log_files – If
True, overwrite the log file instead of appending.console_output – If
True, enable console logging output.console_log_level – Log level for console output.
syslog_output – If
True, enable syslog output.syslog_log_level – Log level for syslog output.
syslog_address – Hostname or IP address for the syslog endpoint.
syslog_port – Port for the syslog endpoint.
- Returns:
A configured
logging.Loggerinstance.
Version Utilities#
- Module:
pydplus.utils.version
- Synopsis:
This module contains the package version information
- Created By:
Jeff Shurtliff
- Last Modified:
Jeff Shurtliff (via GPT-5.5-codex)
- Modified Date:
17 May 2026
- pydplus.utils.version.get_full_version() str[source]#
Return the current full version of the
pydpluspackage.The package version is retrieved from the installed package metadata, which is populated from the
versionfield inpyproject.toml.- Returns:
The current package version as a string