transient name server

” Functions to download and ingest transients from the Transient Name Server (TNS)

host.transient_name_server.build_tns_get_query_data(tns_bot_api_key, transient)[source]

Build the the get query data for a TNS transient.

Parameters:
  • tns_bot_api_key (str) – Transient name server bot api key.

  • transient (dict) – Transient name server transient information.

Returns:

Transient name server query data.

Return type:

(dict)

host.transient_name_server.build_tns_header(tns_bot_id, tns_bot_name)[source]

Builds the TNS header dictionary.

Parameters:
  • tns_bot_id (int) – Transient name server bot id.

  • tns_bot_name (str) – Transient name server bot name.

Returns:

Transient name server header dictionary.

Return type:

(dict)

host.transient_name_server.build_tns_query_data(tns_bot_api_key, data_obj)[source]

Builds tns search data dictionary.

Parameters:
  • tns_bot_api_key (str) – Transient name server bot api key.

  • data_obj (list) – List of data representing the tns query.

Returns:

Transient name server query data.

Return type:

(dict)

host.transient_name_server.build_tns_search_query_data(tns_bot_api_key, time_after)[source]

Build the the search query to find tns transients with a public timestamp after time after.

Parameters:
  • tns_bot_api_key (str) – Transient name server bot api key.

  • time_after (datetime.datetime) – Time to search the transient name server for new transients.

Returns:

Transient name server query data.

Return type:

(dict)

host.transient_name_server.build_tns_url(tns_api_url, mode=None)[source]

Builds the url to the tns api service

Parameters:
  • tns_api_url (str) – URL of the Transient name server API.

  • mode (str) – Which endpoint to access the API. Options are search and get

Returns:

(str) Full transient name server api url

host.transient_name_server.get_daily_tns_staging_csv(date, tns_credentials=None, save_dir='')[source]

Gets the daily staging csv from TNS that contains all transients added and modified at the specified date.

host.transient_name_server.get_tns_credentials()[source]

Retrieves TNS credentials from environment variables

host.transient_name_server.get_tns_zipped_csv(url=None, file_name=None, tns_credentials=None, save_dir='')[source]

Downloads and saves zipped csv file from TNS.

Returns the file name

host.transient_name_server.get_transients_from_tns(time_after, sandbox=False, tns_credentials=None)[source]

Gets transient data from TNS for all transients with public timestamp after time_after.

Parameters:
  • time_after (datetime.datetime) – Time to search the transient name server for new transients.

  • sandbox (bool) – If true uses the transient name server sandbox API, else uses the live transisent name server API

  • tns_credentials (dict) – Transient name server credentials, need to have the keys, TNS_BOT_ID, TNS_BOT_NAME, and TNS_BOT_API_KEY.

Returns:

List of Transients retrieved transients from the transient name

server.

Return type:

(list)

host.transient_name_server.get_transients_from_tns_by_name(transient_list, sandbox=False, tns_credentials=None)[source]

Gets transient data from TNS for all transients with public timestamp after time_after.

Parameters:
  • time_after (datetime.datetime) – Time to search the transient name server for new transients.

  • sandbox (bool) – If true uses the transient name server sandbox API, else uses the live transisent name server API

  • tns_credentials (dict) – Transient name server credentials, need to have the keys, TNS_BOT_ID, TNS_BOT_NAME, and TNS_BOT_API_KEY.

Returns:

List of Transients retrieved transients from the transient name

server.

Return type:

(list)

host.transient_name_server.query_tns(data, headers, search_url)[source]

Query the TNS server

host.transient_name_server.rate_limit_query_tns(data, headers, search_url)[source]

Query TNS but wait if we have reached too many api requests.

host.transient_name_server.tns_staging_blast_transient(tns_transient)[source]

Convert transient name server staging transient into blast transient data model.

Parameters:

tns_transient (Dict) – Dictionary containing transient name server transient information.

Returns:

Transient object with the

tns_transient data.

Return type:

blast_transient (Transient)

host.transient_name_server.tns_staging_file_date_name(date)[source]

Gets the TNS file name for a staging csv for a given date.

host.transient_name_server.tns_to_blast_transient(tns_transient)[source]

Convert transient name server transient into blast transient data model.

Parameters:

tns_transient (Dict) – Dictionary containing transient name server transient information.

Returns:

Transient object with the

tns_transient data.

Return type:

blast_transient (Transient)

host.transient_name_server.update_blast_transient(blast_transient, tns_staging_transient)[source]

Updates blast transient with information from the tns_csv staging