Samples¶
Samples are dictionaries with a small subset of data for each event type.
-
Samples.
__init__
(api, sample_event_directory)¶ For each event Alooma stores sample dictionaries. This class will help you interact and copy the samples for testing. We run integration testing on the entirety of the sample set before deploying.
Parameters: - api – The Alooma API client authentication
- sample_event_directory – The full path and name of the directory in which to store sample events such as /Users/myname/code/hover/alooma-etl/sample_events
Build Sample File Path and File Name¶
-
Samples.
build_sample_file_path_and_file_name
(sample_file_type='event', name=None)¶ Constructs the file path and name for writing the samples
Parameters: - sample_file_type – The type of file either ‘event’ or ‘input’
- name – The name of the event or input
Returns: a file path with the file name
Print Samples¶
-
static
Samples.
print_samples
(sample_list, view_all_or_index='all', pprint_indent=2, pprint_width=200, pprint_depth=5)¶ Prints all the samples in a list or pretty prints a single sample
Parameters: - sample_list – A list of samples
- view_all_or_index – ‘all’ to print all samples or a number to print sample by index
- pprint_indent – The indent value to pprint dictionaries
- pprint_width – The width value to pprint dictionaries
- pprint_depth – The depth value to pprint dictionaries
Returns: None
Get Samples for Event from Alooma API¶
-
Samples.
get_samples_for_event_from_alooma_api
(event_name)¶ Gets samples for a single event from the API
Parameters: event_name – The event for which to get samples Returns: A list of samples
View Samples for Event from Alooma API¶
-
Samples.
view_samples_for_event_from_alooma_api
(event_name, view_all_or_index='all')¶ View samples for an event from the API. Print all or a single event by index.
Parameters: - event_name – The name of the event for which to view samples
- view_all_or_index – Specify to view ‘all’ the samples for an event or a specific event by index number
Get Samples from Saved Sample Files¶
-
Samples.
get_samples_from_saved_sample_files
(sample_file_type='event', name=None)¶ Gets the samples for an event or input from a saved file
Parameters: - sample_file_type – The name of the file to retrieve samples for. Exclude the .json extension
- name – The name of the event or input to get the samples for
Returns: A list with the samples from the file
View Samples from File¶
-
Samples.
view_samples_from_file
(sample_file_type='event', name=None, view_all_or_index='all', pprint_indent=2, pprint_width=200, pprint_depth=5)¶ Prints the samples for an event or input from the API
Parameters: - sample_file_type – Whether the samples are for an ‘event’ or an ‘input’
- name – The name of the event or input
- view_all_or_index – Specify to view ‘all’ the samples for an event or a specific event by index
- pprint_indent – The indent value to pprint dictionaries
- pprint_width – The width value to pprint dictionaries
- pprint_depth – The depth value to pprint dictionaries
Returns: None
Save Alooma Samples to Files¶
-
Samples.
save_alooma_samples_to_files
(event_name=None, input_name=None)¶ Saves samples to files in the specified directory. If no event_name or input_name are specified samples for ALL events will be written to a file
Parameters: - event_name – The event name for samples to save. If specified only samples for this event are retrieved
- input_name – The input name for samples to save. If specified all samples for this input are retrieved
Returns: None
Write Alooma Samples to Files¶
-
Samples.
write_alooma_samples_to_files
(event_list, input_name=None)¶ Writes samples to files for each event. Writes input file with samples for all events in the input when input_name is specified.
Parameters: - event_list – A list of events for which to write samples for
- input_name – The name of the input to write the samples for to limit the samples to a specific input
Returns: None
Get Sample from Any API¶
-
static
Samples.
get_sample_from_any_api
(url, payload, api_key, input_label, print_api_response=True, test_index_number=0, input_type='rest_endpoint')¶ Gets a sample to test from a 3rd party API using the requests package and adds the required Alooma _metadata to the event
Parameters: - url – The URL for which to make the get request e.g. https://harvest.greenhouse.io/v1/scheduled_interviews
- payload – A JSON dictionary with the parameters to add to the requests e.g. {‘updated_after’: ‘2018-08-25T00:00:00Z’}
- api_key – The API key with which to make the request
- preview_events – If True all the events retrieved will be printed to the console
- input_label – The input_label to give these events when deployed in Alooma
- test_index_number – The index number of the event to test
- input_type – The type of input the data will use when deployed to Alooma
Returns: An event with metadata added that can be tested through the transformation code