Create a new schedule
client.Agents.Schedules.New(ctx, workspaceID, agentID, body) (*AgentSchedule, error)
POST/v1/workspaces/{workspaceId}/agents/{agentId}/schedules
Create a new schedule
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"),
)
agentSchedule, err := client.Agents.Schedules.New(
context.TODO(),
"workspaceId",
"agentId",
cadenya.AgentScheduleNewParams{
Metadata: cadenya.F(shared.CreateResourceMetadataParam{
Name: cadenya.F("name"),
}),
Spec: cadenya.F(cadenya.AgentScheduleSpecParam{
InitialMessage: cadenya.F("initialMessage"),
Schedule: cadenya.F(cadenya.AgentScheduleSpecScheduleParam{
}),
}),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", agentSchedule.Metadata)
}
{
"metadata": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"bundleKey": "bundleKey",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"initialMessage": "initialMessage",
"schedule": {
"calendars": [
{
"comment": "comment",
"dayOfMonth": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"dayOfWeek": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"hour": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"minute": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"month": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"second": [
{
"end": 0,
"start": 0,
"step": 0
}
]
}
],
"intervals": [
{
"every": "-160513s",
"offset": "-160513s"
}
],
"timezone": "timezone"
},
"data": {},
"overlapPolicy": "OVERLAP_POLICY_UNSPECIFIED",
"status": "AGENT_SCHEDULE_STATUS_UNSPECIFIED",
"variationId": "variationId"
},
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_UNSPECIFIED",
"email": "email",
"name": "name"
}
},
"lastFireAt": "2019-12-27T18:11:19.117Z",
"lastObjectiveId": "lastObjectiveId",
"lastSkippedAt": "2019-12-27T18:11:19.117Z",
"lastSkipReason": "lastSkipReason",
"nextFireAt": "2019-12-27T18:11:19.117Z",
"totalFires": 0
}
}Returns Examples
{
"metadata": {
"id": "id",
"accountId": "accountId",
"createdAt": "2019-12-27T18:11:19.117Z",
"name": "name",
"profileId": "profileId",
"workspaceId": "workspaceId",
"bundleKey": "bundleKey",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"initialMessage": "initialMessage",
"schedule": {
"calendars": [
{
"comment": "comment",
"dayOfMonth": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"dayOfWeek": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"hour": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"minute": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"month": [
{
"end": 0,
"start": 0,
"step": 0
}
],
"second": [
{
"end": 0,
"start": 0,
"step": 0
}
]
}
],
"intervals": [
{
"every": "-160513s",
"offset": "-160513s"
}
],
"timezone": "timezone"
},
"data": {},
"overlapPolicy": "OVERLAP_POLICY_UNSPECIFIED",
"status": "AGENT_SCHEDULE_STATUS_UNSPECIFIED",
"variationId": "variationId"
},
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_UNSPECIFIED",
"email": "email",
"name": "name"
}
},
"lastFireAt": "2019-12-27T18:11:19.117Z",
"lastObjectiveId": "lastObjectiveId",
"lastSkippedAt": "2019-12-27T18:11:19.117Z",
"lastSkipReason": "lastSkipReason",
"nextFireAt": "2019-12-27T18:11:19.117Z",
"totalFires": 0
}
}