Documentation
¶
Index ¶
- Variables
- func InitDefaultFormsHandlerDeps(appDeps *common.Deps)
- func RegisterTools(s *server.MCPServer)
- func TestableFormsBatchUpdate(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
- func TestableFormsCreate(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
- func TestableFormsGet(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
- func TestableFormsGetResponse(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
- func TestableFormsListResponses(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
- type FormsHandlerDeps
- type FormsService
- type FormsTestFixtures
- type MockFormsService
- func (m *MockFormsService) BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)
- func (m *MockFormsService) CreateForm(ctx context.Context, title string) (*forms.Form, error)
- func (m *MockFormsService) GetForm(ctx context.Context, formID string) (*forms.Form, error)
- func (m *MockFormsService) GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)
- func (m *MockFormsService) ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)
- type RealFormsService
- func (s *RealFormsService) BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)
- func (s *RealFormsService) CreateForm(ctx context.Context, title string) (*forms.Form, error)
- func (s *RealFormsService) GetForm(ctx context.Context, formID string) (*forms.Form, error)
- func (s *RealFormsService) GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)
- func (s *RealFormsService) ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( HandleFormsGet = common.WrapHandler[FormsService](TestableFormsGet) HandleFormsCreate = common.WrapHandler[FormsService](TestableFormsCreate) HandleFormsBatchUpdate = common.WrapHandler[FormsService](TestableFormsBatchUpdate) HandleFormsListResponses = common.WrapHandler[FormsService](TestableFormsListResponses) HandleFormsGetResponse = common.WrapHandler[FormsService](TestableFormsGetResponse) )
var DefaultFormsHandlerDeps = common.NewDefaultHandlerDeps(NewFormsService)
DefaultFormsHandlerDeps holds the default dependencies for production use.
Functions ¶
func InitDefaultFormsHandlerDeps ¶ added in v0.1.7
InitDefaultFormsHandlerDeps initializes the default Forms handler deps with explicit deps.
func RegisterTools ¶
RegisterTools registers all Forms tools with the MCP server.
func TestableFormsBatchUpdate ¶
func TestableFormsBatchUpdate(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
TestableFormsBatchUpdate performs a batch update on a form.
func TestableFormsCreate ¶
func TestableFormsCreate(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
TestableFormsCreate creates a new form.
func TestableFormsGet ¶
func TestableFormsGet(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
TestableFormsGet retrieves a form's metadata, items, and structure.
func TestableFormsGetResponse ¶
func TestableFormsGetResponse(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
TestableFormsGetResponse retrieves a single form response by ID.
func TestableFormsListResponses ¶
func TestableFormsListResponses(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)
TestableFormsListResponses lists all responses for a form.
Types ¶
type FormsHandlerDeps ¶
type FormsHandlerDeps = common.HandlerDeps[FormsService]
Type alias using generic types from common package.
type FormsService ¶
type FormsService interface {
// GetForm retrieves a form by ID.
GetForm(ctx context.Context, formID string) (*forms.Form, error)
// CreateForm creates a new form with the given title.
CreateForm(ctx context.Context, title string) (*forms.Form, error)
// BatchUpdate performs a batch update on a form.
BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)
// ListResponses lists responses for a form.
ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)
// GetResponse retrieves a single form response by ID.
GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)
}
FormsService defines the interface for Google Forms API operations. This interface enables dependency injection and testing with mocks.
func NewFormsService ¶
NewFormsService creates a FormsService from an authenticated HTTP client.
func ResolveFormsServiceOrError ¶
func ResolveFormsServiceOrError(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (FormsService, *mcp.CallToolResult, bool)
ResolveFormsServiceOrError resolves a Forms service, returning an MCP error result on failure.
type FormsTestFixtures ¶
type FormsTestFixtures struct {
DefaultEmail string
MockService *MockFormsService
Deps *FormsHandlerDeps
}
FormsTestFixtures contains test fixtures for Forms tool testing.
func NewFormsTestFixtures ¶
func NewFormsTestFixtures() *FormsTestFixtures
NewFormsTestFixtures creates a new set of test fixtures.
type MockFormsService ¶
type MockFormsService struct {
// Forms stores mock form data keyed by ID.
Forms map[string]*forms.Form
// Responses stores mock response data keyed by form ID.
Responses map[string][]*forms.FormResponse
// Errors allows tests to configure specific errors for methods.
Errors struct {
GetForm error
Create error
BatchUpdate error
ListResponses error
GetResponse error
}
// Calls tracks method invocations for verification.
Calls struct {
GetForm []string
Create []string
BatchUpdate []struct {
FormID string
Requests []*forms.Request
}
ListResponses []string
GetResponse []struct{ FormID, ResponseID string }
}
}
MockFormsService implements FormsService for testing.
func NewMockFormsService ¶
func NewMockFormsService() *MockFormsService
NewMockFormsService creates a new mock Forms service with default test data.
func (*MockFormsService) BatchUpdate ¶
func (m *MockFormsService) BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)
BatchUpdate performs a mock batch update.
func (*MockFormsService) CreateForm ¶
CreateForm creates a mock form.
func (*MockFormsService) GetResponse ¶
func (m *MockFormsService) GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)
GetResponse retrieves a mock form response by ID.
func (*MockFormsService) ListResponses ¶
func (m *MockFormsService) ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)
ListResponses lists mock responses for a form.
type RealFormsService ¶
type RealFormsService struct {
// contains filtered or unexported fields
}
RealFormsService wraps the Forms API client and implements FormsService.
func NewRealFormsService ¶
func NewRealFormsService(service *forms.Service) *RealFormsService
NewRealFormsService creates a new RealFormsService wrapping the given API service.
func (*RealFormsService) BatchUpdate ¶
func (s *RealFormsService) BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)
BatchUpdate performs a batch update on a form.
func (*RealFormsService) CreateForm ¶
CreateForm creates a new form with the given title.
func (*RealFormsService) GetResponse ¶
func (s *RealFormsService) GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)
GetResponse retrieves a single form response by ID.
func (*RealFormsService) ListResponses ¶
func (s *RealFormsService) ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)
ListResponses lists responses for a form (up to maxResponsePages pages).