Skip to content

thomaseibner/fivetranapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fivetran API Python wrapper

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.

Usage

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

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.

connection

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.

connectors

resp = ft.get_connectors()
# print out the valid connectors?

Uses the metadata-connectors endpoint to retrieve all the valid connectors.

connector payload

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.

create 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.

delete connector

resp = ft.delete_connector('connector_id')
# .. handle errors

The delete_connector takes a connector_id as the only input.

destinations

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

groups = ft.get_groups()
for group in groups:
    #... 
ft.print_groups()

Uses the list-all-groups endpoint to retrieve and log all groups.

hybrid deployment agents

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.

private links

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

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

Dependencies can be installed from the included requirements.txt

Currently consists of logging and requests.

Todo

  • Handle cursors in responses - but I have no endpoint which paginates at the moment.

Author

Thomas Eibner LinkedIn

Credits

Mohammed Sabhi @ Ecolab

Elijah Davis @ Fivetran fivetran-elijahdavis

License

Licensed under the MIT License.

About

Python wrapper for Fivetran's REST API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages