Implement verified Lightdash API clients with documentation research and live schema verification.
This skill implements a new Lightdash API operation in the internal/lightdash/api directory, along with necessary models in internal/lightdash/models. It relies on the research-lightdash-api skill for researching and verifying the API schema before implementation.
The user should provide:
/api/v1/projects/:projectUuid/spaces)GetSpaceV1, CreateDashboardV1)LIGHTDASH_API_KEY is available).internal/lightdash/models for existing structs that match the resource.internal/lightdash/models/<resource>.go.json tags.internal/lightdash/api/<verb>_<resource>_v1.go (snake_case).Client struct: func (c *Client) <FunctionName>(...) (*<ReturnType>, error).http.NewRequest.fmt.Sprintf and c.HostUrl.c.doRequest(req).Results field if the API wraps the response in a Results envelope.internal/lightdash/api/<verb>_<resource>_v1_test.go to test unmarshaling logic with sample JSON.Ref: internal/lightdash/api/get_space_v1.go
package api
import (
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/ubie-oss/terraform-provider-lightdash/internal/lightdash/models"
)
type GetResourceV1Response struct {
Results models.Resource `json:"results"`
Status string `json:"status"`
}
func (c *Client) GetResourceV1(id string) (*models.Resource, error) {
if len(strings.TrimSpace(id)) == 0 {
return nil, fmt.Errorf("id is empty")
}
path := fmt.Sprintf("%s/api/v1/resource/%s", c.HostUrl, id)
req, err := http.NewRequest("GET", path, nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %w", err)
}
body, err := c.doRequest(req)
if err != nil {
return nil, fmt.Errorf("error performing request: %w", err)
}
var response GetResourceV1Response
if err := json.Unmarshal(body, &response); err != nil {
return nil, fmt.Errorf("error unmarshaling response: %w", err)
}
return &response.Results, nil
}