FreshPy Core Object

This section provides details around the core module and the methods used within the core object for the freshpy package, which are listed below.


Init Module (freshpy)

This module (being the primary __init__.py file for the library) provides a “jumping-off-point” to initialize the primary freshpy.core.FreshPy object.

Package:

freshpy

Synopsis:

This is the __init__ module for the freshpy package

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

30 Dec 2021

class freshpy.FreshPy(domain=None, api_key=None)[source]

This is the class for the core object leveraged in this library.

class Tickets(freshpy_object)[source]

This class includes methods associated with Freshservice tickets.

__init__(freshpy_object)[source]

This method initializes the freshpy.core.freshpy.Tickets inner class object.

New in version 1.0.0.

Parameters:

freshpy_object (class[freshpy.FreshPy]) – The core freshpy.FreshPy object

get_ticket(ticket_number, include=None, verify_ssl=True)[source]

This method returns the data for a specific ticket.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • ticket_number (str, int) – The ticket number for which to return data

  • include (str, tuple, list, set, None) – A string or iterable of embedding options

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

JSON data for the given ticket

Raises:

freshpy.errors.exceptions.APIConnectionError

get_tickets(include=None, predefined_filter=None, filters=None, filter_logic='AND', requester_id=None, requester_email=None, ticket_type=None, updated_since=None, ascending=None, descending=None, per_page=None, page=None, verify_ssl=True)[source]

This method returns a sequence of tickets with optional filters.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • include (str, tuple, list, set, None) –

    A string or iterable of embedding options

  • predefined_filter (str, None) – One of the predefined filters (‘new_and_my_open’, ‘watching’, ‘spam’, ‘deleted’)

  • filters (str, dict, None) – Query filter(s) in the form of a structured query string or a dictionary of values

  • filter_logic – Defines the logic to use as necessary in a filter query string (default is AND)

  • requester_id (str, int, None) – The numeric ID of a requester

  • requester_id – The numeric ID of a requester

  • requester_email (str, None) – The email address of a requester

  • ticket_type (str, None) – The type of ticket (e.g. Incident, Service Request, etc.)

  • updated_since (str, None) – A threshold date or timestamp (in UTC format) for when the ticket was last updated

  • ascending (bool, None) – Determines if the tickets should be sorted in ascending order

  • descending (bool, None) – Determines if the tickets should be sorted in descending order (default)

  • per_page (str, int, None) – Displays a certain number of results per query

  • page (str, int, None) – Returns a specific page number (used for paginated results)

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

A list of JSON objects for tickets

Raises:

freshpy.errors.exceptions.InvalidPredefinedFilterError, freshpy.errors.exceptions.APIConnectionError

__init__(domain=None, api_key=None)[source]

This method instantiates the core Fresh object.

New in version 1.0.0.

close()[source]

This core method destroys the instance.

New in version 1.0.0.

get(uri, headers=None, return_json=True, verify_ssl=True)[source]

This method performs a GET request against the Freshservice API with multiple retries on failure.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • uri (string) – The URI to query

  • headers (dict, None) – The HTTP headers to utilize in the REST API call

  • return_json (bool) – Determines if JSON data should be returned

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

The JSON data from the response or the raw requests response.

Raises:

freshpy.errors.exceptions.APIConnectionError

Return to Top


Core Module (freshpy.core)

This module contains the core object and functions to establish the connection to the API and leverage it to perform various actions.

Module:

freshpy.core

Synopsis:

Defines the core freshpy object used to interface with the Freshservice API

Created By:

Jeff Shurtliff

Last Modified:

Jeff Shurtliff

Modified Date:

04 Jan 2022

class freshpy.core.FreshPy(domain=None, api_key=None)[source]

This is the class for the core object leveraged in this library.

class Tickets(freshpy_object)[source]

This class includes methods associated with Freshservice tickets.

__init__(freshpy_object)[source]

This method initializes the freshpy.core.freshpy.Tickets inner class object.

New in version 1.0.0.

Parameters:

freshpy_object (class[freshpy.FreshPy]) – The core freshpy.FreshPy object

get_ticket(ticket_number, include=None, verify_ssl=True)[source]

This method returns the data for a specific ticket.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • ticket_number (str, int) – The ticket number for which to return data

  • include (str, tuple, list, set, None) –

    A string or iterable of embedding options

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

JSON data for the given ticket

Raises:

freshpy.errors.exceptions.APIConnectionError

get_tickets(include=None, predefined_filter=None, filters=None, filter_logic='AND', requester_id=None, requester_email=None, ticket_type=None, updated_since=None, ascending=None, descending=None, per_page=None, page=None, verify_ssl=True)[source]

This method returns a sequence of tickets with optional filters.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • include (str, tuple, list, set, None) –

    A string or iterable of embedding options

  • predefined_filter (str, None) – One of the predefined filters (‘new_and_my_open’, ‘watching’, ‘spam’, ‘deleted’)

  • filters (str, dict, None) – Query filter(s) in the form of a structured query string or a dictionary of values

  • filter_logic – Defines the logic to use as necessary in a filter query string (default is AND)

  • requester_id (str, int, None) – The numeric ID of a requester

  • requester_id – The numeric ID of a requester

  • requester_email (str, None) – The email address of a requester

  • ticket_type (str, None) – The type of ticket (e.g. Incident, Service Request, etc.)

  • updated_since (str, None) – A threshold date or timestamp (in UTC format) for when the ticket was last updated

  • ascending (bool, None) – Determines if the tickets should be sorted in ascending order

  • descending (bool, None) – Determines if the tickets should be sorted in descending order (default)

  • per_page (str, int, None) – Displays a certain number of results per query

  • page (str, int, None) – Returns a specific page number (used for paginated results)

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

A list of JSON objects for tickets

Raises:

freshpy.errors.exceptions.InvalidPredefinedFilterError, freshpy.errors.exceptions.APIConnectionError

__init__(domain=None, api_key=None)[source]

This method instantiates the core Fresh object.

New in version 1.0.0.

close()[source]

This core method destroys the instance.

New in version 1.0.0.

get(uri, headers=None, return_json=True, verify_ssl=True)[source]

This method performs a GET request against the Freshservice API with multiple retries on failure.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • uri (string) – The URI to query

  • headers (dict, None) – The HTTP headers to utilize in the REST API call

  • return_json (bool) – Determines if JSON data should be returned

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

The JSON data from the response or the raw requests response.

Raises:

freshpy.errors.exceptions.APIConnectionError

Return to Top


Core Functionality Subclasses (freshpy.core.FreshPy)

These classes below are inner/nested classes within the core freshpy.core.FreshPy class.

Note

The classes themselves are PascalCase format and singular (e.g. Node, Category, etc.) whereas the names used to call the inner class methods are all lowercase (or snake_case) and plural. (e.g. core_object.nodes.get_node_id(), core_object.categories.get_category_id(), etc.)

Tickets Subclass (freshpy.core.FreshPy.Tickets)

class FreshPy.Tickets(freshpy_object)[source]

This class includes methods associated with Freshservice tickets.

get_ticket(ticket_number, include=None, verify_ssl=True)[source]

This method returns the data for a specific ticket.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • ticket_number (str, int) – The ticket number for which to return data

  • include (str, tuple, list, set, None) –

    A string or iterable of embedding options

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

JSON data for the given ticket

Raises:

freshpy.errors.exceptions.APIConnectionError

get_tickets(include=None, predefined_filter=None, filters=None, filter_logic='AND', requester_id=None, requester_email=None, ticket_type=None, updated_since=None, ascending=None, descending=None, per_page=None, page=None, verify_ssl=True)[source]

This method returns a sequence of tickets with optional filters.

Changed in version 1.1.0: Added the ability to disable SSL verification on API calls.

New in version 1.0.0.

Parameters:
  • include (str, tuple, list, set, None) –

    A string or iterable of embedding options

  • predefined_filter (str, None) – One of the predefined filters (‘new_and_my_open’, ‘watching’, ‘spam’, ‘deleted’)

  • filters (str, dict, None) – Query filter(s) in the form of a structured query string or a dictionary of values

  • filter_logic – Defines the logic to use as necessary in a filter query string (default is AND)

  • requester_id (str, int, None) – The numeric ID of a requester

  • requester_id – The numeric ID of a requester

  • requester_email (str, None) – The email address of a requester

  • ticket_type (str, None) – The type of ticket (e.g. Incident, Service Request, etc.)

  • updated_since (str, None) – A threshold date or timestamp (in UTC format) for when the ticket was last updated

  • ascending (bool, None) – Determines if the tickets should be sorted in ascending order

  • descending (bool, None) – Determines if the tickets should be sorted in descending order (default)

  • per_page (str, int, None) – Displays a certain number of results per query

  • page (str, int, None) – Returns a specific page number (used for paginated results)

  • verify_ssl (bool) – Determines if SSL verification should occur (True by default)

Returns:

A list of JSON objects for tickets

Raises:

freshpy.errors.exceptions.InvalidPredefinedFilterError, freshpy.errors.exceptions.APIConnectionError

Return to Top