feat: resource rows batch operations, drop removed domains, regenerated models

This commit is contained in:
edmand46
2026-09-17 12:08:03 +03:00
parent a217f255b8
commit f3eda1e8b7
46 changed files with 197 additions and 590 deletions
+55
View File
@@ -0,0 +1,55 @@
package rudder
import (
"context"
"fmt"
"net/http"
)
type ResourcesService struct {
transport *transport
}
type ResourceBatchItem struct {
PlayerID string `json:"playerId"`
ID string `json:"id,omitempty"`
Data map[string]any `json:"data,omitempty"`
Version int64 `json:"version,omitempty"`
}
type ResourceRowsPage struct {
Items []any `json:"items"`
Total int `json:"total"`
}
func (s *ResourcesService) List(ctx context.Context, slug string) (*ResourceRowsPage, error) {
var page ResourceRowsPage
path := fmt.Sprintf("/resources/%s/rows", slug)
if err := s.transport.do(ctx, http.MethodGet, path, nil, nil, &page); err != nil {
return nil, err
}
return &page, nil
}
func (s *ResourcesService) Create(ctx context.Context, slug string, items []ResourceBatchItem) (*ResourceRowsPage, error) {
var page ResourceRowsPage
path := fmt.Sprintf("/resources/%s/rows", slug)
if err := s.transport.do(ctx, http.MethodPost, path, nil, map[string]any{"items": items}, &page); err != nil {
return nil, err
}
return &page, nil
}
func (s *ResourcesService) Update(ctx context.Context, slug string, items []ResourceBatchItem) (*ResourceRowsPage, error) {
var page ResourceRowsPage
path := fmt.Sprintf("/resources/%s/rows", slug)
if err := s.transport.do(ctx, http.MethodPatch, path, nil, map[string]any{"items": items}, &page); err != nil {
return nil, err
}
return &page, nil
}
func (s *ResourcesService) Delete(ctx context.Context, slug string, items []ResourceBatchItem) error {
path := fmt.Sprintf("/resources/%s/rows", slug)
return s.transport.do(ctx, http.MethodDelete, path, nil, map[string]any{"items": items}, nil)
}