-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtemplates.go
58 lines (48 loc) · 1.51 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package coze
import (
"context"
"fmt"
"net/http"
)
// templates provides access to template-related operations
type templates struct {
core *core
}
// newTemplates creates a new Templates client
func newTemplates(core *core) *templates {
return &templates{core: core}
}
// Duplicate creates a copy of an existing template
func (c *templates) Duplicate(ctx context.Context, templateID string, req *DuplicateTemplateReq) (*TemplateDuplicateResp, error) {
url := fmt.Sprintf("/v1/templates/%s/duplicate", templateID)
var resp templateDuplicateResp
err := c.core.Request(ctx, http.MethodPost, url, req, &resp)
if err != nil {
return nil, err
}
result := resp.Data
result.setHTTPResponse(resp.HTTPResponse)
return result, nil
}
// TemplateEntityType represents the type of template entity
type TemplateEntityType string
const (
// TemplateEntityTypeAgent represents an agent template
TemplateEntityTypeAgent TemplateEntityType = "agent"
)
// TemplateDuplicateResp represents the response from duplicating a template
type TemplateDuplicateResp struct {
baseModel
EntityID string `json:"entity_id"`
EntityType TemplateEntityType `json:"entity_type"`
}
// templateDuplicateResp represents response for creating document
type templateDuplicateResp struct {
baseResponse
Data *TemplateDuplicateResp `json:"data"`
}
// DuplicateTemplateReq represents the request to duplicate a template
type DuplicateTemplateReq struct {
WorkspaceID string `json:"workspace_id"`
Name *string `json:"name,omitempty"`
}