Skip to content

justmike1/goperset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goperset

Golang Apache Superset API Package

This project is mentioned in the Apache Superset official wiki as a Golang API Package.

This project is inspired from: gocloak

For Questions either raise an issue, or come to the gopher-slack into the channel #goperset

SOON: Benchmarks can be found here

Contribution

(WIP) https://github.com/justmike1/goperset/wiki/Contribute

Changelog

For release notes please consult the specific releases here

For tags please consult the specific tags here

Usage

Installation

go install github.com/justmike1/goperset@latest

Importing

 import "github.com/justmike1/goperset"

Connecting to Superset Client

func main() {
    ctx := context.Background()
    client := goperset.NewClient(ctx, "https://superset.domain.net/")
    tokens, err := goperset.GetAccessTokens(client, "admin", "admin")
    if err != nil {
        t.Errorf("Error getting access tokens: %v", err)
        return
    }
}

Example of Creating a new database connection

func createDatabase(client, tokens string) error {
    databaseUri := fmt.Sprintf("postgresql+psycopg2://%s:%s@%s:%s/database", "username", "password", "postgresql", "5432")
    payload := goperset.DatabasePayload{
        ConfigurationMethod: goperset.StringP("sqlalchemy_form"),
        Engine:              goperset.StringP("postgresql+psycopg2"),
        DatabaseName:        goperset.StringP("postgresql"),
        SQLAlchemyURI:       goperset.StringP(databaseUri),
    }
    _, err := goperset.CreateDatabase(client, tokens, payload)
    if err != nil {
        return fmt.Errorf("error sending request: %v", err)
    }
    return nil
}

Features

// GoPerset holds all methods a client should fulfill
type GoPerset interface {
	
 // Client
 NewClient(basePath string) &Goperset
 GetAccessTokens(client *Goperset, username string, password string) (ClientToken, error)
 ClientResty(client *Goperset, token string, csrfToken string, contentType string, method string, endpoint string, payload interface{}) ([]byte, error)
 
 // Database
 CreateDatabase(client *Goperset, tokens ClientToken, payload DatabasePayload) ([]byte, error)
 
 // Dashboard
 CreateDashboard(client *Goperset, tokens ClientToken, payload DashboardPayload) ([]byte, error)
 GetDashboard(client *Goperset, tokens ClientToken, params GetDashboardParams) ([]byte, error)
 GetDashboardInfo(client *Goperset, tokens ClientToken, params DashboardInfoParams) ([]byte, error)

 // Dataset
 CreateDataset(client *Goperset, tokens ClientToken, payload DatasetPayload) ([]byte, error)
 
 // Chart
 CreateChart(client *Goperset, tokens ClientToken, payload DatasetPayload) ([]byte, error)
}

Unit Testing

SUPERSET_BASE_PATH=https://superset.domain.net go test client_test.go -v

About

Go client library for the Apache Superset

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages