26 lines
927 B
Go
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)
|
|
}
|