diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4f6aeaf --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +.PHONY: all build test test-verbose vet fmt fmt-check lint tidy clean + +PACKAGES := ./... +FMT_FILES := $(shell find . -name "*.go") +BINARY := terraform-provider-chatbotkit + +all: vet build test + +build: + go build -o $(BINARY) . + +test: + go test -race -count=1 $(PACKAGES) + +test-verbose: + go test -race -count=1 -v $(PACKAGES) + +vet: + go vet $(PACKAGES) + +fmt: + gofmt -w $(FMT_FILES) + +fmt-check: + @test -z "$$(gofmt -l $(FMT_FILES))" || (echo "Files not formatted:"; gofmt -l $(FMT_FILES); exit 1) + +lint: vet fmt-check + @if command -v golangci-lint > /dev/null 2>&1; then \ + golangci-lint run $(PACKAGES); \ + else \ + echo "golangci-lint not installed — skipping (run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)"; \ + fi + +tidy: + go mod tidy + +clean: + go clean -testcache + rm -f $(BINARY) diff --git a/VERSION b/VERSION index 7dea76e..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 +1.1.0 diff --git a/docs/resources/trigger_integration.md b/docs/resources/trigger_integration.md index 5b41933..0a93106 100644 --- a/docs/resources/trigger_integration.md +++ b/docs/resources/trigger_integration.md @@ -35,7 +35,7 @@ resource "chatbotkit_trigger_integration" "scheduled" { description = "Run bot check every hour" bot_id = chatbotkit_bot.assistant.id - trigger_schedule = "0 * * * *" # Every hour + schedule = "0 * * * *" # Every hour session_duration = 300000 # 5 minutes } ``` @@ -64,7 +64,7 @@ resource "chatbotkit_trigger_integration" "from_template" { description = "Created from template" blueprint_id = chatbotkit_blueprint.trigger_template.id bot_id = chatbotkit_bot.assistant.id - trigger_schedule = "*/30 * * * *" # Every 30 minutes + schedule = "*/30 * * * *" # Every 30 minutes } ``` @@ -76,7 +76,7 @@ resource "chatbotkit_trigger_integration" "full" { description = "Complete trigger setup" bot_id = chatbotkit_bot.assistant.id - trigger_schedule = "0 9 * * 1-5" # 9 AM on weekdays + schedule = "0 9 * * 1-5" # 9 AM on weekdays session_duration = 600000 # 10 minutes authenticate = true @@ -94,7 +94,7 @@ The following arguments are supported: - `name` - (Optional) The name of the integration. This is displayed in the ChatBotKit dashboard. - `description` - (Optional) A description of the integration's purpose. - `bot_id` - (Optional) The ID of the ChatBotKit bot to connect. -- `trigger_schedule` - (Optional) A cron expression for scheduled trigger execution. +- `schedule` - (Optional) A cron expression for scheduled trigger execution. - `session_duration` - (Optional) The duration of a trigger session in milliseconds. - `authenticate` - (Optional) Whether to require authentication for webhook triggers. - `blueprint_id` - (Optional) The ID of a blueprint to associate with this integration. diff --git a/examples/complete/README.md b/examples/complete/README.md index 1016c88..77f300b 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -161,7 +161,7 @@ resource "chatbotkit_trigger_integration" "scheduled_trigger" { name = "Daily Report Trigger" description = "Runs daily to generate reports" bot_id = chatbotkit_bot.assistant.id - trigger_schedule = "daily" + schedule = "daily" } ``` diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 16a0404..5b411bc 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -110,7 +110,7 @@ resource "chatbotkit_trigger_integration" "bot_trigger" { bot_id = chatbotkit_bot.assistant.id # Optional: Set a schedule (e.g., "hourly", "daily", "weekly") - # trigger_schedule = "never" + # schedule = "never" } # ============================================================================ diff --git a/examples/dual-agent-programmable-workflows/main.tf b/examples/dual-agent-programmable-workflows/main.tf index 33355d5..bafe95d 100644 --- a/examples/dual-agent-programmable-workflows/main.tf +++ b/examples/dual-agent-programmable-workflows/main.tf @@ -249,7 +249,7 @@ resource "chatbotkit_trigger_integration" "scheduled_trigger" { description = "Automated trigger for scheduled workflow execution by the Task Runner" authenticate = true session_duration = 1800000 - trigger_schedule = "hourly" + schedule = "hourly" } # ============================================================================ diff --git a/examples/system-diagnostics-agent/main.tf b/examples/system-diagnostics-agent/main.tf index c11c424..dfabb10 100644 --- a/examples/system-diagnostics-agent/main.tf +++ b/examples/system-diagnostics-agent/main.tf @@ -146,7 +146,7 @@ resource "chatbotkit_trigger_integration" "diagnostic_schedule" { description = "Automated trigger for periodic system diagnostics and health checks" authenticate = true session_duration = 1800000 - trigger_schedule = "daily" + schedule = "daily" } # ============================================================================ diff --git a/examples/workflow-orchestrator/main.tf b/examples/workflow-orchestrator/main.tf index 20f451a..ac05386 100644 --- a/examples/workflow-orchestrator/main.tf +++ b/examples/workflow-orchestrator/main.tf @@ -276,7 +276,7 @@ resource "chatbotkit_trigger_integration" "workflow_trigger" { description = "Manual or scheduled trigger for workflow execution" authenticate = true session_duration = 3600000 - trigger_schedule = "never" + schedule = "never" } # ============================================================================ diff --git a/internal/provider/client.go b/internal/provider/client.go index f1aebdd..d9f2174 100644 --- a/internal/provider/client.go +++ b/internal/provider/client.go @@ -3264,7 +3264,7 @@ type CreateTriggerIntegrationInput struct { Meta map[string]interface{} `json:"meta,omitempty"` Name *string `json:"name,omitempty"` SessionDuration *int64 `json:"sessionDuration,omitempty"` - TriggerSchedule *string `json:"triggerSchedule,omitempty"` + Schedule *string `json:"schedule,omitempty"` } // CreateTriggerIntegrationResponse represents the response from creating a triggerintegration. @@ -3306,7 +3306,7 @@ type UpdateTriggerIntegrationInput struct { Meta map[string]interface{} `json:"meta,omitempty"` Name *string `json:"name,omitempty"` SessionDuration *int64 `json:"sessionDuration,omitempty"` - TriggerSchedule *string `json:"triggerSchedule,omitempty"` + Schedule *string `json:"schedule,omitempty"` } // UpdateTriggerIntegrationResponse represents the response from updating a triggerintegration. @@ -3380,7 +3380,7 @@ type GetTriggerIntegrationResponse struct { Meta map[string]interface{} `json:"meta,omitempty"` Name *string `json:"name,omitempty"` SessionDuration *int64 `json:"sessionDuration,omitempty"` - TriggerSchedule *string `json:"triggerSchedule,omitempty"` + Schedule *string `json:"schedule,omitempty"` CreatedAt *string `json:"createdAt,omitempty"` UpdatedAt *string `json:"updatedAt,omitempty"` } @@ -3401,7 +3401,7 @@ func (c *Client) GetTriggerIntegration(ctx context.Context, id string) (*GetTrig meta name sessionDuration - triggerSchedule + schedule createdAt updatedAt } diff --git a/internal/provider/resource_trigger_integration.go b/internal/provider/resource_trigger_integration.go index d9a9cf3..d691deb 100644 --- a/internal/provider/resource_trigger_integration.go +++ b/internal/provider/resource_trigger_integration.go @@ -39,7 +39,7 @@ type TriggerIntegrationResourceModel struct { Meta types.Map `tfsdk:"meta"` Name types.String `tfsdk:"name"` SessionDuration types.Int64 `tfsdk:"session_duration"` - TriggerSchedule types.String `tfsdk:"trigger_schedule"` + Schedule types.String `tfsdk:"schedule"` CreatedAt types.String `tfsdk:"created_at"` UpdatedAt types.String `tfsdk:"updated_at"` } @@ -91,7 +91,7 @@ func (r *TriggerIntegrationResource) Schema(ctx context.Context, req resource.Sc MarkdownDescription: "The duration of the session in milliseconds", Optional: true, }, - "trigger_schedule": schema.StringAttribute{ + "schedule": schema.StringAttribute{ MarkdownDescription: "The schedule for automatic trigger execution", Optional: true, }, @@ -146,7 +146,7 @@ func (r *TriggerIntegrationResource) Create(ctx context.Context, req resource.Cr Meta: convertMapToInterface(ctx, data.Meta), Name: data.Name.ValueStringPointer(), SessionDuration: data.SessionDuration.ValueInt64Pointer(), - TriggerSchedule: data.TriggerSchedule.ValueStringPointer(), + Schedule: data.Schedule.ValueStringPointer(), }) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to create triggerintegration: %s", err)) @@ -211,8 +211,8 @@ func (r *TriggerIntegrationResource) Read(ctx context.Context, req resource.Read if result.SessionDuration != nil { data.SessionDuration = types.Int64PointerValue(result.SessionDuration) } - if result.TriggerSchedule != nil { - data.TriggerSchedule = types.StringPointerValue(result.TriggerSchedule) + if result.Schedule != nil { + data.Schedule = types.StringPointerValue(result.Schedule) } if result.CreatedAt != nil { data.CreatedAt = types.StringPointerValue(result.CreatedAt) @@ -246,7 +246,7 @@ func (r *TriggerIntegrationResource) Update(ctx context.Context, req resource.Up Meta: convertMapToInterface(ctx, data.Meta), Name: data.Name.ValueStringPointer(), SessionDuration: data.SessionDuration.ValueInt64Pointer(), - TriggerSchedule: data.TriggerSchedule.ValueStringPointer(), + Schedule: data.Schedule.ValueStringPointer(), }) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update triggerintegration: %s", err)) diff --git a/types/types.go b/types/types.go index 83b8909..69abe6f 100644 --- a/types/types.go +++ b/types/types.go @@ -2823,7 +2823,7 @@ type TriggerIntegration struct { // The session duration for the trigger integration SessionDuration *float64 `json:"sessionDuration,omitempty"` // The schedule for the trigger integration - TriggerSchedule *string `json:"triggerSchedule,omitempty"` + Schedule *string `json:"schedule,omitempty"` // The date and time when the trigger integration was last updated UpdatedAt *string `json:"updatedAt,omitempty"` } @@ -2849,7 +2849,7 @@ type TriggerIntegrationCreateRequest struct { // The duration of the session in milliseconds SessionDuration *int64 `json:"sessionDuration,omitempty"` // The schedule for automatic trigger execution - TriggerSchedule *string `json:"triggerSchedule,omitempty"` + Schedule *string `json:"schedule,omitempty"` } // TriggerIntegrationCreateResponse Response containing the ID of a newly created Trigger integration @@ -2885,7 +2885,7 @@ type TriggerIntegrationUpdateRequest struct { // The duration of the session in milliseconds SessionDuration *int64 `json:"sessionDuration,omitempty"` // The schedule for automatic trigger execution - TriggerSchedule *string `json:"triggerSchedule,omitempty"` + Schedule *string `json:"schedule,omitempty"` } // TriggerIntegrationUpdateResponse Response containing the ID of an updated Trigger integration