A sample ds-load
plugin for getting contact and company data out of hubspot.
This plugin can be used with ds-load
to load this data as objects and relations into a Topaz / Aserto directory.
Clone the repo, then:
go mod tidy
mage build
cp dist/ds-load-hubspot_<arch>/ds-load-hubspot ~/.ds-load/plugins
This will make the ds-load-hubspot
plugin available to ds-load
.
Usage: ds-load-hubspot <command>
Hubspot data loader
Commands:
version version information
fetch fetch hubspot data
transform transform hubspot data
export-transform export default transform template
exec fetch and transform hubspot data
get-refresh-token obtain a refresh token from hubspot
Flags:
-h, --help Show context-sensitive help.
-c, --config=CONFIG-FLAG Configuration file path
-v, --verbosity=INT Use to increase output verbosity.
The default command for ds-load-hubspot is exec
, which will run both fetch
and transform
.
To view command-specific help: ds-load-hubspot fetch --help
.
Parameters can also be passed by environment, as seen in the help message of each command, but the ones from config files and command line take precedence.
config files are in yaml format:
---
ds-load-arg: value
ds-load-another-arg: value
hubspot:
arg: value
When passing custom config files to both the cli and the plugin, use ds-load -c <config-path> <plugin-name> <command>
or ds-load-hubspot -c <config-path> <command>
.
default location: ~/.config/ds-load/cfg/config.yaml
can be overridden using -c/--config
---
host: directory.eng.aserto.com:8443
api-key: secretapikey
tenant-id: your-tenant-id
hubspot:
private-access-token: your-access-token
contacts: false
companies: true
default location: ~/.config/ds-load/cfg/hubspot.yaml
can be overridden using -c/--config
---
hubspot:
private-access-token: your-access-token
contacts: false
companies: true
The data received from the fetcher is being transformed using a transformation template, which is written as a go template and it outputs objects and relations.
The default transformation template can be exported using ds-load-hubspot export-transform
.
A custom transformation file can be provided when running the plugin in exec
or transform
mode via the --template-file
parameter.
Logs are printed to stdout
. You can increase detail using the verbosity flag (e.g. -vvv
).
ds-load --host=<directory-host> --api-key=<directory-api-key> --tenant-id=<tenant-id> hubspot --private-access-token=<PAT> --contacts --companies
ds-load --host=<directory-host> --api-key=<directory-api-key> --tenant-id=<tenant-id> hubspot --private-access-token=<PAT> --contacts --companies --template-file=<template-path>
ds-load-hubspot fetch --private-access-token=<PAT> --contacts
ds-load-hubspot fetch --private-access-token=<PAT> --contacts > hubspot.json
cat hubspot.json | ds-load-hubspot transform
ds-load hubspot fetch --private-access-token=<PAT> --contacts --companies > hubspot.json
cat hubspot.json | ds-load --host=<directory-host> --api-key=<directory-api-key> --tenant-id=<tenant-id> hubspot transform
ds-load-hubspot fetch --private-access-token=<PAT> --contacts | ds-load-hubspot transform
config.yaml
---
host: "directory.eng.aserto.com:8443"
api-key: "secretapikey"
tenant-id: "your-tenant-id"
hubspot:
private-access-token: "your-PAT"
contacts: true
ds-load -c ./config.yaml hubspot