Extendable Python wrapper for Fivetran's REST API - reusing snippets of code from Fivetran's api_framework examples.
Current wrapper implements the functionality of retrieving account info, connections, destinations, groups, hybrid deployment agents, privatelinks, and users. It also implements create/delete connector.
import fivetranapi
ft = fivetranapi.connect('api_key', 'api_secret')
ft.print_account_info()
The connect
class can be instantiated with a different api-endpoint for testing purposes.
account_info = ft.get_account_info()
print('Account Id: ' + account_info.account_id)
print('Account Name: ' + account_info.account_name)
print('System Key Id: ' + account_info.system_key_id)
print('User Id: ' + account_info.user_id)
Calls the account information endpoint and returns an an object of the account class with ways to retrieve the configuration.
ft.print_account_info()
Logs the information using the logging object.
connections = ft.get_connections()
for connection in connections:
# ...
ft.print_connections(connections)
Provides a way to access all the connections from the API. The print_connections
method takes an optional array of connection objects to avoid re-querying the API unless necessary.
resp = ft.get_connectors()
# print out the valid connectors?
Uses the metadata-connectors endpoint to retrieve all the valid connectors.
resp = ft.get_connector_schema('azure_sql_db')
pretty_json = json.dumps(resp, indent=4)
print(pretty_json)
Uses the metadata-connector-config endpoint to retrieve the configuration parameters for a connector type which will help craft the payload for creating a connector.
payload = {...}
resp = ft.create_connector(payload)
# .. handle errors
To create a connector you have to provide an appropriate payload based on the Fivetran documentation for each connector type.
resp = ft.delete_connector('connector_id')
# .. handle errors
The delete_connector
takes a connector_id as the only input.
destinations = ft.get_destinations()
for destination in destinations:
#...
# retrieve specific destination
destination = ft.get_destination_detail('destination_id')
ft.print_destinations()
Uses the list-destinations and destination-details endpoinsts to retrieve either all destinations or a specific destination.
groups = ft.get_groups()
for group in groups:
#...
ft.print_groups()
Uses the list-all-groups endpoint to retrieve and log all groups.
hdas = ft.get_hybrid_deployment_agents()
for hda in hdas:
#...
ft.print_hybrid_deployment_agents()
Uses the get-local-processing-agent-list endpoint to retrieve and log all hybrid deployment agents.
privatelinks = ft.get_private_links()
for privatelink in privatelinks:
#...
privatelink = ft.get_private_link_detail('private_link_id')
ft.print_private_links()
Uses the get-private-links and get-private-link-details endpoints to retrieve and log all private links.
users = ft.get_users()
for user in users:
#...
user = ft.get_user_detail('user_id')
ft.print_users()
Uses the list-all-users and user-details to retrieve and log all users.
Dependencies can be installed from the included requirements.txt
Currently consists of logging and requests.
- Handle cursors in responses - but I have no endpoint which paginates at the moment.
Mohammed Sabhi @ Ecolab
Elijah Davis @ Fivetran fivetran-elijahdavis
Licensed under the MIT License.