Files
Gardomatic/lib/client/task_template_opt_outs.go
kleiax 904d14b64c
CI / test (push) Canceled after 0s
Initial commit
2026-09-12 22:22:17 +02:00

26 lines
927 B
Go

package client
import (
"context"
"net/http"
"strconv"
)
// TaskTemplateOptOuts lists template IDs suppressed for a plant.
func (c *Client) TaskTemplateOptOuts(ctx context.Context, gardenID, plantID int) ([]int, *Response, error) {
var envelope struct {
TemplateIDs []int `json:"template_ids"`
}
response, err := c.do(ctx, http.MethodGet, gardenPath(gardenID)+"/plants/"+strconv.Itoa(plantID)+"/task-template-opt-outs", nil, &envelope)
return envelope.TemplateIDs, response, err
}
// SetTaskTemplateOptOut enables or disables automatic generation from a template.
func (c *Client) SetTaskTemplateOptOut(ctx context.Context, gardenID, plantID, templateID int, optedOut bool) (*Response, error) {
method := http.MethodPost
if !optedOut {
method = http.MethodDelete
}
return c.do(ctx, method, gardenPath(gardenID)+"/plants/"+strconv.Itoa(plantID)+"/task-template-opt-outs/"+strconv.Itoa(templateID), nil, nil)
}