package conduit import ( "context" "encoding/json" "io" "net/http" "net/url" ) type UpdateConduitsRequest struct { // Conduit ID. ID string `json:"id"` // The new number of shards for this conduit. ShardCount int `json:"shard_count"` } type UpdateConduitsResponse struct { // List of information about the client’s conduits. Data []ConduitData `json:"data"` } // Updates a conduit’s shard count. To delete shards, update the count to a lower number, and the shards above the count will be deleted. // For example, if the existing shard count is 100, by resetting shard count to 50, shards 50-99 are disabled. // // Requires an app access token. func (c *Conduit) UpdateConduits(ctx context.Context, body *UpdateConduitsRequest) (*UpdateConduitsResponse, error) { endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits"}) r, w := io.Pipe() go func() { if err := json.NewEncoder(w).Encode(body); err != nil { w.CloseWithError(err) } else { w.Close() } }() req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r) if err != nil { return nil, err } res, err := c.client.Do(req) if err != nil { return nil, err } defer res.Body.Close() var data UpdateConduitsResponse if err := json.NewDecoder(res.Body).Decode(&data); err != nil { return nil, err } return &data, nil }