Supporting Modules

This section provides details around the supporting modules used in the freshpy package, which are listed below.


Classes & Exceptions

This section includes modules that contain the classes and exceptions used throughout the package.


Errors Module (freshpy.errors)

This module contains all of the exception classes and error handling functions leveraged throughout the library.

Package:

freshpy.errors

Synopsis:

This module includes custom exceptions

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

28 Dec 2021

Return to Top


Exceptions Module (freshpy.errors.exceptions)

This sub-module contains all of the exception classes leveraged in functions throughout the library.

Module:

freshpy.errors.exceptions

Synopsis:

Collection of exception classes relating to the freshpy library

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

29 Jan 2025

exception freshpy.errors.exceptions.APIConnectionError(*args, **kwargs)[source]

This exception is used when the API query could not be completed due to connection aborts and/or timeouts.

Added in version 1.0.0.

exception freshpy.errors.exceptions.APIRequestError(*args, **kwargs)[source]

This exception is used for generic API request errors when there isn’t a more specific exception.

Added in version 1.0.0.

exception freshpy.errors.exceptions.CurrentlyUnsupportedError(*args, **kwargs)[source]

This exception is used when a feature or functionality being used is currently unsupported.

Added in version 1.0.0.

exception freshpy.errors.exceptions.DELETERequestError(*args, **kwargs)[source]

This exception is used for generic DELETE request errors when there isn’t a more specific exception.

Added in version 1.0.0.

exception freshpy.errors.exceptions.DataMismatchError(*args, **kwargs)[source]

This exception is used when there is a mismatch between two data sources.

Added in version 1.0.0.

exception freshpy.errors.exceptions.FeatureNotConfiguredError(*args, **kwargs)[source]

This exception is used when an API request fails because a feature is not configured.

Added in version 1.0.0.

exception freshpy.errors.exceptions.FreshPyError[source]

This is the base class for FreshPy exceptions.

Added in version 1.0.0.

exception freshpy.errors.exceptions.GETRequestError(*args, **kwargs)[source]

This exception is used for generic GET request errors when there is not a more specific exception.

Added in version 1.0.0.

exception freshpy.errors.exceptions.InvalidFieldError(*args, **kwargs)[source]

This exception is used when an invalid field is provided.

Added in version 1.0.0.

exception freshpy.errors.exceptions.InvalidFilterError(*args, **kwargs)[source]

This exception is used when an invalid filter for an API call is provided.

Added in version 2.0.0.

exception freshpy.errors.exceptions.InvalidFilterLogicError(*args, **kwargs)[source]

This exception is used when an invalid filter logic operator is supplied.

Added in version 1.0.0.

exception freshpy.errors.exceptions.InvalidPayloadValueError(*args, **kwargs)[source]

This exception is used when an invalid value is provided for a payload field.

Added in version 1.0.0.

exception freshpy.errors.exceptions.InvalidPredefinedFilterError(*args, **kwargs)[source]

This exception is used when the API query could not be completed due to connection aborts and/or timeouts.

Added in version 1.0.0.

exception freshpy.errors.exceptions.InvalidRequestTypeError(*args, **kwargs)[source]

This exception is used when an invalid API request type is provided.

Added in version 1.0.0.

exception freshpy.errors.exceptions.InvalidURLError(*args, **kwargs)[source]

This exception is used when a provided URL is invalid.

Added in version 1.0.0.

exception freshpy.errors.exceptions.LookupMismatchError(*args, **kwargs)[source]

This exception is used when a lookup value does not match the supplied lookup type.

Added in version 1.0.0.

exception freshpy.errors.exceptions.MissingAuthDataError(*args, **kwargs)[source]

This exception is used when authentication data is not supplied and therefore a connection cannot occur.

Added in version 1.0.0.

exception freshpy.errors.exceptions.MissingRequiredDataError(*args, **kwargs)[source]

This exception is used when a function or method is missing one or more required arguments.

Added in version 1.0.0.

exception freshpy.errors.exceptions.NotFoundResponseError(*args, **kwargs)[source]

This exception is used when an API query returns a 404 response and there isn’t a more specific class.

Added in version 1.0.0.

exception freshpy.errors.exceptions.POSTRequestError(*args, **kwargs)[source]

This exception is used for generic POST request errors when there isn’t a more specific exception.

Added in version 1.0.0.

exception freshpy.errors.exceptions.PUTRequestError(*args, **kwargs)[source]

This exception is used for generic PUT request errors when there isn’t a more specific exception.

Added in version 1.0.0.

Return to Top


Handlers Module (freshpy.errors.handlers)

This sub-module contains various error handling functions that are leveraged throughout the library.

Module:

freshpy.errors.handlers

Synopsis:

Functions that handle various error situations within the namespace

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

28 Dec 2021

freshpy.errors.handlers.eprint(*args, **kwargs)[source]

This function behaves the same as the print() function but is leveraged to print errors to sys.stderr.

Return to Top


Tools & Utilities

This section includes modules that contain tools and utilities leveraged by other scripts.


Core Utilities Module (freshpy.utils.core_utils)

This module includes various utilities to assist in converting dictionaries to JSON, formatting timestamps, etc.

Module:

freshpy.utils.core_utils

Synopsis:

Collection of supporting utilities and functions to complement the primary modules

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

30 Dec 2021

freshpy.utils.core_utils.construct_query_string(existing_query=None, appendage=None)[source]

This function assists in constructing query strings for URIs to ensure they follow the appropriate format.

Added in version 1.0.0.

Parameters:
  • existing_query (str, None) – The existing query string (if any)

  • appendage (str, None) – The new addition to the query string to be appended (if any)

Returns:

The constructed query string

freshpy.utils.core_utils.url_decode(encoded_string)[source]

This function decodes a url-encoded string.

Added in version 1.0.0.

Parameters:

encoded_string (str) – The url-encoded string

Returns:

The unencoded string

freshpy.utils.core_utils.url_encode(raw_string)[source]

This function encodes a string for use in URLs.

Added in version 1.0.0.

Parameters:

raw_string (str) – The raw string to be encoded

Returns:

The encoded string

Return to Top


Logging Utilities Module (freshpy.utils.log_utils)

This module includes various utilities to assist with logging.

Module:

freshpy.utils.log_utils

Synopsis:

Collection of logging utilities and functions

Usage:

from freshpy.utils import log_utils

Example:

logger = log_utils.initialize_logging(__name__)

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

27 Dec 2021

class freshpy.utils.log_utils.LessThanFilter(exclusive_maximum, name='')[source]

This class allows filters to be set to limit log levels to only less than a specified level.

Added in version 1.0.0.

See also

Zoey Greer is the original author of this class which was provided on Stack Overflow.

filter(record)[source]

This method returns a Boolean integer value indicating whether or not a message should be logged.

Added in version 1.0.0.

Note

A non-zero return indicates that the message will be logged.

freshpy.utils.log_utils.initialize_logging(logger_name=None, log_level=None, formatter=None, debug=None, no_output=None, file_output=None, file_log_level=None, log_file=None, overwrite_log_files=None, console_output=None, console_log_level=None, syslog_output=None, syslog_log_level=None, syslog_address=None, syslog_port=None)[source]

This function initializes logging within a specific module.

Added in version 1.0.0.

Todo

Add details about the parameters

Return to Top


Version Module (freshpy.utils.version)

This module is the primary source of the current version of the freshpy package.

Module:

freshpy.utils.version

Synopsis:

This simple script contains the package version

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

29 Jan 2025

freshpy.utils.version.get_full_version()[source]

This function returns the current full version of the freshpy package.

freshpy.utils.version.get_major_minor_version()[source]

This function returns the current major.minor (i.e. X.Y) version of the freshpy package.

Return to Top