feat: funciones Go para API Metabase y tipo MetabaseClient
Añade funciones Go stub para la API de Metabase en dominio infra: auth, CRUD de cards, dashboards y users, execute_query y execute_card. Incluye tipo MetabaseClient y helper HTTP compartido. Todas las funciones son impuras con stubs not-implemented.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package infra
|
||||
|
||||
import "fmt"
|
||||
|
||||
// MetabaseCreateUser crea un nuevo usuario en Metabase.
|
||||
// firstName, lastName y email son obligatorios.
|
||||
// password es opcional: si esta vacio, Metabase envia email de invitacion.
|
||||
// groupIDs es opcional: IDs de grupos a asignar (nil = solo grupo default).
|
||||
func MetabaseCreateUser(client MetabaseClient, firstName, lastName, email, password string, groupIDs []int) (map[string]any, error) {
|
||||
body := map[string]any{
|
||||
"first_name": firstName,
|
||||
"last_name": lastName,
|
||||
"email": email,
|
||||
}
|
||||
if password != "" {
|
||||
body["password"] = password
|
||||
}
|
||||
if len(groupIDs) > 0 {
|
||||
body["group_ids"] = groupIDs
|
||||
}
|
||||
|
||||
result, err := metabaseRequest("POST", client.BaseURL, client.Token, "/api/user", body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("metabase create user: %w", err)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user