Api Documentation

This section contains more granular documentation of the classes and functions available to the api.

Automated Runner

class Runner(path, *, filesystem=None)[source]

This class handles orchestration of downloading and storing the backup. Options are set in a yaml configuration file. There is an example you can use as a starting point.

Parameters:
  • path – (required) absolute path to the file on the system or relative to the FS object supplied in the filesystem parameter
  • filesystem – (keyword only) a pyfilesystem2 FS object where the yaml config file is located.

Useful Methods/Classes

Download Table

class DownloadTable(base_key, table_name, api_key=None, progress=False, compression=True, fields={}, discard_attach=False)[source]

Downloads all data from a table including atachments.

Parameters:
  • base_key – base id from airtable api url (starts ‘app’)
  • table_name – the table name to download
  • api_key – the airtable api key. If an environment variable ‘AIRTABLE_API_KEY’ is set this is not required.
  • compression – whether to compress attachment data
  • fields – Store the field
  • discard_attach – if true, attachment data will not be downloaded, url and other info will be preservered
download()[source]

Download the data in the table.

Returns:A generator that will download each item in the table as it is iterated based on the options configured.

File I/O

join_files(tmpfs, outfs)[source]

Join the backup json files into a single package (tarball, zip).

Parameters:
  • tmpfs – the temporary fs where the backup is stored.
  • outfs – the filesystem to copy to (should be TarFS or ZipFS). things like compression and encoding should be specified at instantiation.
write_out_backup(backing_store_fs, *, filepath=None, filesystem=None, prefix='')[source]

Write the backup data to its final location. A backing store is required and either a filepath to the packaged backup or the tmp filesystem is required.

Parameters:
  • backing_store_fs (required) – a pyfilesystem2 object to be the final storage location of the backup. (should be OSFS, S3FS, FTPFS, etc.) Can be a single object or list of filesystem objects for copying to multiple backing stores.
  • filepath – path to the zip or tar file containing the backup data (if desired). Can be a path object or str.
  • filesystem – the TmpFS containing the backup data.
  • prefix – a parent directory for the files to be saved under. This is can be a good place to encode some information about the backup. A slash will be appended to the prefix to create a directory or pseudo-directory structure.
write_to_file(downloadtable, tmpfs, prefix='', suffix='')[source]

Write out the table data to a file.

Parameters:
  • downloadtable – A download.DownloadTable object for the table to be saved
  • tmpfs – the temporary filesystem (from pyfilesystem2) to write the file to.
  • prefix – A prefix for a the file name. include a / for directories
  • suffix – A suffix to append to the file name