domoapi

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 8 Imported by: 0

README

go-domo-api

CircleCI

This library suppor-ts Domo api endpoints to administer your data and users, giving you the power and flexibility to get the most out of Domo. It is built with go version go1.14

Reference: https://developer.domo.com/docs/api-overview/api-overview

Installing

*go get
    go get -u github.com/rakutentech/go-domo-api

Configurations

  • This package use golang environmrnt variable as setting. It uses os.Getenv to get the configuration values. You can use any enivronment setting package. One of the common package is godotenv from https://github.com/joho/godotenv.
General Configs
No Environment Variable default Required Explanation
1 DOMO_API_URL "" Yes Domo api url
2 DOMO_CLIENT_ID "" Yes Domo ClientID
3 DOMO_CLIENT_SECRET "" Yes Domo Client Secret
4 DOMO_PROXY_URL "" No Proxy URL to access to DOMO from a proxied environment
5 DOMO_AUTH_SCOPE "data" No Domo Auth token scopes. (data, user, workflow, datasboard, account, audit, buzz) It can be specified with multiple values. Separated by comma(,).

Usage

 //import
 import domoapi "github.com/rakutentech/go-domo-api"

 //Create DomoAPI
d := domoapi.NewDomoAPI()

//Create accessToken
 tk, _ := d.CreateAccessToken()

// Create Domo dataset
dataset := &DomoDataset{
		Name:        "Leonhard Euler Party",
		Description: "Mathematician Guest List",
		Rows:        0,
		Schema: &Schema{
			Columns: []Column{
				{
					Type: "STRING",
					Name: "Friend",
				}, {
					Type: "STRING",
					Name: "Attending",
				},
			},
		},
		Owner: &Owner{
			Name: "DomoSupport",
			ID:   27,
		},
	}
ds, _ := d.CreateDataset(dataset, tk)

//Get DatasetID
dID, _ := d.GetDatasetID("dataset_name", tk)

// Get Data from dataset
data, _ :=d.GetDataByDatasetID(tk, "dataset_id", true)

//List all datasets
datasetList, _ := d.ListDatasets(tk)

Sample Configuration
  • Create a .env file and add the setting value
DOMO_API_URL=https://rakuten-training.domo.com
DOMO_CLIENT_ID=dummy_id
DOMO_CLIENT_SECRET=dummy_secret
DOMO_PROXY_URL=https://proxy_dummy.example.com:8080

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
}

Column is schema's column

type DomoAPI

type DomoAPI struct {
	// contains filtered or unexported fields
}

func NewDomoAPI

func NewDomoAPI() *DomoAPI

func (*DomoAPI) AddDataToDataset

func (d *DomoAPI) AddDataToDataset(datasetID string, data string, replace bool, token string) error

AddDataToDataset adds data to the given dataset. Use replace=true to reset dataset's data with the given data.

func (*DomoAPI) CreateAccessToken

func (d *DomoAPI) CreateAccessToken() (*Token, error)

CreateAccessToken create domo accessToken using key clientKey and clientSecrete in .env file.

func (*DomoAPI) CreateDataset

func (d *DomoAPI) CreateDataset(dds DomoDataset, token string) (*DomoDataset, error)

CreateDataset create dataset on domo instance

func (*DomoAPI) GetDataByDatasetID

func (d *DomoAPI) GetDataByDatasetID(token string, datasetID string, header bool) (string, error)

GetDataByDatasetID fetch data given domo's datasetID. Use header=true to include header in the response

func (*DomoAPI) GetDatasetIDByName

func (d *DomoAPI) GetDatasetIDByName(datasetName string, token string) ([]string, error)

GetDatasetIDByName get domo datasetID using domo dataset name

func (*DomoAPI) ListDatasets

func (d *DomoAPI) ListDatasets(token string) ([]DomoDataset, error)

ListDatasets list all domo datasets in the belonging domo instance

type DomoDataset

type DomoDataset struct {
	ID          string     `json:"id,omitempty"`
	Name        string     `json:"name,omitempty"`
	Description string     `json:"description,omitempty"`
	Rows        int        `json:"rows,omitempty"`
	Columns     int        `json:"columns,omitempty"`
	Schema      *Schema    `json:"schema,omitempty"`
	Owner       *Owner     `json:"owner,omitempty"`
	CreatedAt   *time.Time `json:"createdAt,omitempty"`
	UpdatedAt   *time.Time `json:"updatedAt,omitempty"`
}

DomoDataset

type Owner

type Owner struct {
	ID   int64  `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Owner is domo dataset's owner

type RequestHandler

type RequestHandler struct{}

func (*RequestHandler) Handler

func (r *RequestHandler) Handler(req *http.Request) (*http.Response, error)

Handler handles http client request.

type RequestHandlerService

type RequestHandlerService interface {
	Handler(req *http.Request) (*http.Response, error)
}

type Schema

type Schema struct {
	Columns []Column `json:"columns,omitempty"`
}

Schema is data's schema

type Token

type Token struct {
	AccessToken string `json:"access_token,omitempty"`
	ExpiresIn   int    `json:"expires_in,omitempty"`
	ExpiresAt   time.Time
}

Directories

Path Synopsis
Package mock_domoapi is a generated GoMock package.
Package mock_domoapi is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL