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
(WIP) https://github.com/justmike1/goperset/wiki/Contribute
For release notes please consult the specific releases here
For tags please consult the specific tags here
go install github.com/justmike1/goperset@latest
import "github.com/justmike1/goperset"
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
}
}
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
}
// 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)
}
SUPERSET_BASE_PATH=https://superset.domain.net go test client_test.go -v