pir_pipeline.hses.HSES.HSES

class pir_pipeline.hses.HSES.HSES(url: str = 'https://hses.ohs.acf.hhs.gov/data-team-ws/data?client-id=data-team')

Bases: object

Class for interfacing with the HSES API.

__init__(url: str = 'https://hses.ohs.acf.hhs.gov/data-team-ws/data?client-id=data-team')

Initialize the HSES object with API credentials and URL.

Args:

url (str, optional): The URL to send requests to. Defaults to PROD_URL.

Methods

__init__([url])

Initialize the HSES object with API credentials and URL.

clean_up_tempdir()

Remove the temporary directory used for unzipping files.

export([path, Bucket, Key])

Export the unzipped files to a specified local directory or to an S3 bucket.

get_data()

Retrieve data from the HSES API and store it in memory.

unzip()

Unzip the retrieved data into a temporary directory and append a datestamp to each file.

Attributes

content

Return the content retrieved from the API.

tempdir

Return the temporary directory used to store unzipped files.

clean_up_tempdir() → Self

Remove the temporary directory used for unzipping files.

Returns:

Self: The instance of the class.

property content

Return the content retrieved from the API.

export(path: str | None = None, Bucket: str | None = None, Key: str | None = None) → Self

Export the unzipped files to a specified local directory or to an S3 bucket.

Args:

path (str, optional): Local directory to export files to. Bucket (str, optional): S3 bucket name. Key (str, optional): S3 object key.

Raises:

ValueError: If neither path nor both Bucket and Key are specified. ValueError: If only one of Bucket or Key is specified, or if both local and S3 options are provided.

Returns:

Self: The instance of the class.

get_data() → Self

Retrieve data from the HSES API and store it in memory.

Returns:

Self: The instance of the class.

property tempdir

Return the temporary directory used to store unzipped files.

unzip() → Self

Unzip the retrieved data into a temporary directory and append a datestamp to each file.

Returns:

Self: The instance of the class.