bullhorn_interface package¶
Submodules¶
bullhorn_interface.api module¶
-
bullhorn_interface.api.
AND
(*args, **kwargs)[source]¶ Facilitates building of queries for use with api_search and api_query
Parameters: - args – (args) query strings to be combined with AND
- kwargs – (kwargs) key/value pairs to be combined with AND
Returns:
-
class
bullhorn_interface.api.
Interface
(username='', password='', max_connection_attempts=5, max_refresh_attempts=10, independent=True)[source]¶ Bases:
object
-
api_call
(command='', method='', entity='', entity_id='', select_fields='*', query='', body='', attempt=0, **kwargs)[source]¶ Serves as an abstract Python API layer for Bullhorns REST API
Parameters: - command – (str) command that bullhorn accepts (see bullhorn api reference material)
- method – (str) HTTP verbs telling the API how you want to interact with the data (“GET”, “POST”, “UPDATE”, “DELETE)
- entity – (str) Bullhorn entity that you wish to interact with
- entity_id – (int, str) (sometimes optional) numeric id corresponding to the desired entity, required for all POST and UPDATE commands
- select_fields – (str, list) fields desired in response from API call
- query – (str) SQL style query string (only used when command=”search” and command=”query”)
- body – (dict) dictionary of items to be posted during “UPDATE” or “POST” (when command=”entity” or command=”entityFiles”)
- attempt – (int) nth attempt at the api_call, after 10 attempts it will stop attempting the call
- kwargs – (kwargs) additional parameters to be passed to the request URL (count=100 becomes &count=100)
Returns: hopefully a dict with the key “data” with a list of the searched, queried, added, or updated data
-
api_create
(entity='', select_fields='*', **kwargs)[source]¶ Creates an entity of the specified type with the specified passed kwargs.
Parameters: - entity – (str) desired entity type to be created
- select_fields – (list, str) SELECT fields to be returned by the API call
- kwargs – (kwarg) attributes that the created entity will have *ex: interface.api_create(entity=”Candidate”, lastName=”Doe”, firstName=”John”, name=”John Doe”)
Returns: (dict) hopefully a dictionary with a key called ‘data’ in it with info about the newly created entity
-
api_delete
(entity='', entity_id='')[source]¶ Deletes the specified entity with the specified entity_id.
Parameters: - entity – (str) Bullhorn entity type to be deleted
- entity_id – (int, str) Bullhorn ID of entity to be deleted
Returns: tells you if it worked or gives an error message
-
api_query
(entity='', where='', select_fields='*', **kwargs)[source]¶ Conducts a Query using SQL style where clauses with the given parameters passed to api_call
Parameters: - entity – (str) Bullhorn Entity that is being queried
- where – (SQL str) SQL style where clause for query
- select_fields – (list, str) list of fields to be selected in query
- kwargs – (kwargs) additional kwargs to be passed to api_call
Returns: (dict) hopefully a dictionary with a key called ‘data’ in it with a list of your desired results
-
api_search
(entity='', entity_id='', query='', select_fields='*', count='500', **kwargs)[source]¶ Conducts an API search with the given parameters passed to api_call
Parameters: - entity – (str) Bullhorn Entity that is being searched
- entity_id – (str, int) optional numeric id corresponding to the desired entity
- query – (str) string describing SQL style query, overrides entity_id
- select_fields – (str, list) fields returned by API response
- count – (str, int) number of records returned by API call, is ignored if greater than 500
- kwargs – (kwargs) values to be passed with AND to the query (supports equivalence only) * example: interface.api_search(entity=”ClientCorporation”, id=44) will have query=”id:44” * example: interface.api_search(entity=”ClientCorporation”, query=”numOffices IN [1 TO 100]”, status=‘“Active Account”’) will have query=’numOffices IN [1 TO 100] AND status:”Active Account”’
Returns: (dict) hopefully a dictionary with a key called ‘data’ in it with a list of your desired results
-
api_update
(entity='', entity_id='', select_fields='*', **kwargs)[source]¶ Updates the specified entity with the specified entity_id and the parameters passed as keyword objects.
Parameters: - entity – (str) Bullhorn entity type to be updated
- entity_id – (int, str) Bullhorn ID of entity to be updated
- select_fields – (list, str) SELECT fields to be returned by the API call
- kwargs – attributes that the updated entity will have *ex: interface.api_update(entity=”Candidate”, entity_id=1, phone=”555-555-5555”)
Returns:
-
fresh
(independent=False, attempt=1, max_attempts=10)[source]¶ Keeps auth tokens and API tokens from getting stale. Behavior varies with interface type.
Parameters: - independent – (bool) indicates whether the Interface object is in charge of refreshing its own tokens
- attempt – (int) nth attempt, passed to any login or refresh method
- max_attempts – (int) number of attempts before fresh stops attempting to login or refresh the token
Returns: (bool) whether or not the token(s) is/are fresh
-
get_api_token
(attempt=0)[source]¶ Uses auth token to get an API access token and url which are required to query the REST API
Parameters: attempt – (int) nth attempt Returns:
-
get_file_info
(entity='', entity_id='', select_fields='*')[source]¶ Parameters: - entity – (str) Bullhorn entity type corresponding to the desired files
- entity_id – (str, int) numeric id corresponding to the desired entity
- select_fields – (str, list) (default is “*”) fields to be returned from api_call
Returns: hopefully a dict with the key “data” with a list of a single member corresponding to the desired entityFiles
-
get_token
(*args)[source]¶ Method to retrieve auth or api token. Implementation varies with interface type.
Parameters: args – Returns:
-
grab_tokens
()[source]¶ Method to get both auth and api tokens. Implementation varies with interface type.
Returns:
-
login
(code='', attempt=0)[source]¶ Grants an auth token to valid credentials or provides a method to manually login
Parameters: - code – (str) (sometimes optional) auth code for authenticating through the browser
- attempt – (int) nth login attempt
Returns:
-
refresh_token
(attempt=0)[source]¶ Refreshes an existing API token
Parameters: attempt – (int) nth attempt at refreshing token Returns:
-
save_file_from_url
(url='', path='')[source]¶ Save a file stored in bullhorn from the specified url (url can be retrieved using get_file_info)
Parameters: - url – url pointing to desired file
- path – fully qualified path or file name (use forward slashes regardless of os) * example: path=’/path/to/file.png’ stores in /path/to/file.png * example: path=’file.png’ stores in /current/working/directory/file.png
Returns: None
-
-
class
bullhorn_interface.api.
LiveInterface
(username='', password='', max_connection_attempts=5, max_refresh_attempts=10, independent=True)[source]¶
-
bullhorn_interface.api.
OR
(*args, **kwargs)[source]¶ Facilitates building of queries for use with api_search and api_query
Parameters: - args – (args) query strings to be combined with OR
- kwargs – (kwargs) key/value pairs to be combined with OR
Returns:
bullhorn_interface.helpers module¶
bullhorn_interface.tests module¶
-
class
bullhorn_interface.tests.
InterfaceConfigured
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
config_exists
()[source]¶ Tests to see that the region bullhorn_interface config file has configurations :return:
-