Create a new tool
client.ToolSets.Tools.New(ctx, toolSetID, body) (*Tool, error)
POST/v1/tool_sets/{toolSetId}/tools
Create a new tool
package main
import (
"context"
"fmt"
"github.com/cadenya/cadenya-go"
"github.com/cadenya/cadenya-go/option"
"github.com/cadenya/cadenya-go/shared"
)
func main() {
client := cadenya.NewClient(
option.WithAPIKey("My API Key"),
)
tool, err := client.ToolSets.Tools.New(
context.TODO(),
"toolSetId",
cadenya.ToolSetToolNewParams{
Metadata: cadenya.F(shared.CreateResourceMetadataParam{
Name: cadenya.F("name"),
}),
Spec: cadenya.F(cadenya.ToolSpecParam{
Config: cadenya.F(cadenya.ToolSpecConfigParam{
}),
Description: cadenya.F("description"),
Parameters: cadenya.F(map[string]interface{}{
"foo": "bar",
}),
Status: cadenya.F(cadenya.ToolSpecStatusToolStatusUnspecified),
}),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", tool.Metadata)
}
{
"metadata": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"config": {
"http": {
"requestMethod": "GET",
"headers": {
"foo": "string"
},
"path": "path",
"query": "query",
"requestBodyContentType": "requestBodyContentType",
"requestBodyTemplate": "requestBodyTemplate",
"toolName": "toolName"
},
"mcp": {
"toolDescription": "toolDescription",
"toolName": "toolName",
"toolTitle": "toolTitle"
}
},
"description": "description",
"parameters": {
"foo": "bar"
},
"status": "TOOL_STATUS_UNSPECIFIED",
"requiresApproval": true
},
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_USER",
"email": "email",
"name": "name"
}
},
"toolSet": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
}
}
}Returns Examples
{
"metadata": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"config": {
"http": {
"requestMethod": "GET",
"headers": {
"foo": "string"
},
"path": "path",
"query": "query",
"requestBodyContentType": "requestBodyContentType",
"requestBodyTemplate": "requestBodyTemplate",
"toolName": "toolName"
},
"mcp": {
"toolDescription": "toolDescription",
"toolName": "toolName",
"toolTitle": "toolTitle"
}
},
"description": "description",
"parameters": {
"foo": "bar"
},
"status": "TOOL_STATUS_UNSPECIFIED",
"requiresApproval": true
},
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_USER",
"email": "email",
"name": "name"
}
},
"toolSet": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
}
}
}