### Install StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Installs the StatusGator Go Client library using the go get command. This is the first step to integrating the client into your Go project. ```sh go get github.com/arslanbekov/statusgator-go-client ``` -------------------------------- ### Quick Start: List Boards with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Demonstrates how to initialize the StatusGator client with an API token and list all available boards. It includes error handling and prints the name and ID of each board. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, err := statusgator.NewClient("your-api-token") if err != nil { log.Fatal(err) } ctx := context.Background() // List all boards boards, _, err := client.Boards.List(ctx, nil) if err != nil { log.Fatal(err) } for _, board := range boards { fmt.Printf("Board: %s (%s)\n", board.Name, board.ID) } } ``` -------------------------------- ### Initialize StatusGator Go Client Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Demonstrates how to initialize the StatusGator Go client with basic and custom options. It includes setting API tokens, timeouts, user agents, and base URLs. The example also shows how to verify API connectivity using the Ping method. ```go package main import ( "context" "fmt" "log" "time" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { // Basic client initialization client, err := statusgator.NewClient("your-api-token") if err != nil { log.Fatal(err) } // Client with custom options client, err = statusgator.NewClient("your-api-token", statusgator.WithTimeout(60*time.Second), statusgator.WithUserAgent("my-app/1.0"), statusgator.WithBaseURL("https://statusgator.com/api/v3"), ) if err != nil { log.Fatal(err) } // Verify API connectivity ctx := context.Background() if err := client.Ping(ctx); err != nil { log.Fatalf("API ping failed: %v", err) } fmt.Println("API connection successful!") } ``` -------------------------------- ### Configure Statusgator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Provides an example of how to create a new Statusgator client with custom options. This includes setting the API token, base URL, user agent, request timeout, and a custom HTTP client. Errors during client creation are handled. ```go client, err := statusgator.NewClient("token", statusgator.WithBaseURL("https://custom.api.com/v3"), statusgator.WithUserAgent("my-app/1.0"), statusgator.WithTimeout(60 * time.Second), statusgator.WithHTTPClient(customHTTPClient), ) ``` -------------------------------- ### Manage Website Monitors with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Provides examples for creating, updating, pausing, and unpausing website monitors. This involves specifying details like the monitor's name, URL, check interval, expected status code, and timeout. ```go // Create a website monitor monitor, err := client.WebsiteMonitors.Create(ctx, "board-id", &statusgator.WebsiteMonitorRequest{ Name: "My API", URL: "https://api.example.com/health", CheckInterval: 1, ExpectedStatus: 200, Timeout: 30, }) ``` ```go // Update a monitor monitor, err := client.WebsiteMonitors.Update(ctx, "board-id", "monitor-id", &statusgator.WebsiteMonitorRequest{ CheckInterval: 5, }) ``` ```go // Pause/Unpause err := client.WebsiteMonitors.Pause(ctx, "board-id", "monitor-id") err := client.WebsiteMonitors.Unpause(ctx, "board-id", "monitor-id") ``` -------------------------------- ### Manage Boards with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Provides examples for interacting with boards, including listing all boards with pagination, fetching all boards automatically paginated, retrieving a specific board by its ID, and getting a board's historical status data within a date range. ```go // List all boards boards, pagination, err := client.Boards.List(ctx, &statusgator.ListOptions{ Page: 1, PerPage: 25, }) ``` ```go // Get all boards (auto-pagination) allBoards, err := client.Boards.ListAll(ctx) ``` ```go // Get a specific board board, err := client.Boards.Get(ctx, "board-id") ``` ```go // Get board history history, err := client.Boards.GetHistory(ctx, "board-id", &statusgator.HistoryOptions{ StartDate: "2024-01-01", EndDate: "2024-01-31", }) ``` -------------------------------- ### Manage Monitor Groups with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Provides examples for managing monitor groups, including listing existing groups, creating new groups with a specified name and position, and deleting groups by their ID. ```go // List groups groups, err := client.MonitorGroups.List(ctx, "board-id") ``` ```go // Create a group group, err := client.MonitorGroups.Create(ctx, "board-id", &statusgator.MonitorGroupRequest{ Name: "Production", Position: 1, }) ``` ```go // Delete a group err := client.MonitorGroups.Delete(ctx, "board-id", "group-id") ``` -------------------------------- ### Manage StatusGator Boards Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Provides examples for interacting with the Boards service of the StatusGator API. It covers listing boards with pagination, retrieving all boards using auto-pagination, fetching a specific board by ID, and getting historical data for a board. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // List boards with pagination boards, pagination, err := client.Boards.List(ctx, &statusgator.ListOptions{ Page: 1, PerPage: 25, }) if err != nil { log.Fatal(err) } fmt.Printf("Page %d of %d (Total: %d boards)\n", pagination.CurrentPage, pagination.TotalPages, pagination.TotalCount) for _, board := range boards { fmt.Printf("Board: %s (ID: %s)\n", board.Name, board.ID) } // Get all boards with auto-pagination allBoards, err := client.Boards.ListAll(ctx) if err != nil { log.Fatal(err) } fmt.Printf("Total boards: %d\n", len(allBoards)) // Get a specific board board, err := client.Boards.Get(ctx, "board-id") if err != nil { log.Fatal(err) } fmt.Printf("Board: %s, Public Token: %s\n", board.Name, board.PublicToken) // Get board history history, err := client.Boards.GetHistory(ctx, "board-id", &statusgator.HistoryOptions{ StartDate: "2024-01-01", EndDate: "2024-01-31", MonitorID: "optional-monitor-id", }) if err != nil { log.Fatal(err) } for _, event := range history { fmt.Printf("[%s] %s: %s - %s\n", event.Timestamp.Format("2006-01-02 15:04"), event.MonitorID, event.Event, event.Details) } } ``` -------------------------------- ### Manage Services Catalog with Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Shows how to search for services, list all available services, and list components of a specific service using the Statusgator Go client. Searching requires a query string, while listing all services may require Firehose access. Errors are handled. ```go // Search for services (to subscribe to) services, err := client.Services.Search(ctx, "github") // List all services (requires Firehose access) services, _, err := client.Services.List(ctx, nil) // List service components components, _, err := client.Services.ListComponents(ctx, "service-id", nil) ``` -------------------------------- ### Create and Manage Website Monitors with Statusgator Go Client Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt This Go code snippet illustrates how to use the WebsiteMonitors service of the Statusgator API. It covers creating a new website monitor with detailed configurations (URL, interval, method, headers, regions), updating an existing monitor, and pausing/unpausing it. Requires a Statusgator API token and board ID. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // Create a website monitor followRedirects := true monitor, err := client.WebsiteMonitors.Create(ctx, "board-id", &statusgator.WebsiteMonitorRequest{ Name: "Production API", URL: "https://api.example.com/health", CheckInterval: 1, // minutes HTTPMethod: "GET", ExpectedStatus: 200, ContentMatch: "\"status\":\"healthy\"", Timeout: 30, // seconds FollowRedirects: &followRedirects, Headers: map[string]string{ "Authorization": "Bearer token", "Accept": "application/json", }, Regions: []string{"us-east", "eu-west"}, GroupID: "optional-group-id", }) if err != nil { log.Fatal(err) } fmt.Printf("Created monitor: %s (ID: %s)\n", monitor.Name, monitor.ID) // Update a website monitor monitor, err = client.WebsiteMonitors.Update(ctx, "board-id", monitor.ID, &statusgator.WebsiteMonitorRequest{ CheckInterval: 5, Timeout: 60, }) if err != nil { log.Fatal(err) } fmt.Printf("Updated check interval to %d minutes\n", monitor.CheckInterval) // Pause a monitor err = client.WebsiteMonitors.Pause(ctx, "board-id", monitor.ID) if err != nil { log.Fatal(err) } fmt.Println("Monitor paused") // Unpause a monitor err = client.WebsiteMonitors.Unpause(ctx, "board-id", monitor.ID) if err != nil { log.Fatal(err) } fmt.Println("Monitor resumed") } ``` -------------------------------- ### Manage Ping Monitors with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Shows how to create ping monitors, specifying the monitor's name and the host to ping. This is useful for monitoring network accessibility. ```go monitor, err := client.PingMonitors.Create(ctx, "board-id", &statusgator.PingMonitorRequest{ Name: "Database Server", Host: "db.example.com", CheckInterval: 1, }) ``` -------------------------------- ### Retrieve Users with Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Demonstrates how to list all users using the Statusgator Go client. This operation requires a context and handles potential errors. ```go users, err := client.Users.List(ctx) ``` -------------------------------- ### Manage Monitors with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Demonstrates how to manage monitors within a specific board. This includes listing all monitors, filtering monitors by their status (e.g., 'Down'), and deleting a monitor by its ID. ```go // List monitors for a board monitors, _, err := client.Monitors.List(ctx, "board-id", nil) ``` ```go // List monitors by status downMonitors, err := client.Monitors.ListByStatus(ctx, "board-id", statusgator.MonitorStatusDown) ``` ```go // Delete a monitor err := client.Monitors.Delete(ctx, "board-id", "monitor-id") ``` -------------------------------- ### Manage StatusGator Services using Go Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt This Go code snippet demonstrates how to interact with the Services catalog of the StatusGator API. It covers searching for services, listing all services (requires Firehose access), listing components of a specific service, and retrieving all components for a service with auto-pagination. Ensure you have a valid API token and appropriate permissions. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // Search for services by name services, err := client.Services.Search(ctx, "aws") if err != nil { log.Fatal(err) } fmt.Println("AWS-related services:") for _, svc := range services { fmt.Printf(" - %s (ID: %s)\n Status URL: %s\n", svc.Name, svc.ID, svc.StatusURL) } // List all services (requires Firehose access) allServices, pagination, err := client.Services.List(ctx, &statusgator.ListOptions{ Page: 1, PerPage: 50, }) if err != nil { if statusgator.IsForbidden(err) { fmt.Println("Firehose access required for full service listing") } else { log.Fatal(err) } } else { fmt.Printf("Available services: %d (page %d/%d)\n", pagination.TotalCount, pagination.CurrentPage, pagination.TotalPages) } // List components of a service components, _, err := client.Services.ListComponents(ctx, "github-service-id", nil) if err != nil { log.Fatal(err) } fmt.Println("GitHub components:") for _, comp := range components { fmt.Printf(" - %s [%s]: %s\n", comp.Name, comp.GroupName, comp.Status) } // Get all components with auto-pagination allComponents, err := client.Services.ListAllComponents(ctx, "aws-service-id") if err != nil { log.Fatal(err) } fmt.Printf("Total AWS components: %d\n", len(allComponents)) } ``` -------------------------------- ### Paginate Board Listings (Go) Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Illustrates how to handle paginated results when listing boards using the StatusGator Go client. It covers both manual pagination with explicit page controls and automatic pagination using helper methods. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // Manual pagination opts := &statusgator.ListOptions{Page: 1, PerPage: 50} var allBoards []statusgator.Board for { boards, pagination, err := client.Boards.List(ctx, opts) if err != nil { log.Fatal(err) } allBoards = append(allBoards, boards...) fmt.Printf("Fetched page %d/%d (%d boards)\n", pagination.CurrentPage, pagination.TotalPages, len(boards)) if !pagination.HasNextPage() { break } opts.Page++ } fmt.Printf("Total boards collected: %d\n", len(allBoards)) // Auto-pagination (simpler approach) allBoards, err := client.Boards.ListAll(ctx) if err != nil { log.Fatal(err) } fmt.Printf("Auto-paginated boards: %d\n", len(allBoards)) // Using default options defaultOpts := statusgator.DefaultListOptions() // Page: 1, PerPage: 25 boards, _, _ := client.Boards.List(ctx, defaultOpts) fmt.Printf("Default page size: %d boards\n", len(boards)) } ``` -------------------------------- ### Implement Pagination in Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Demonstrates two methods for handling paginated API responses with the Statusgator Go client: manual pagination by incrementing page numbers and auto-pagination for fetching all results automatically. Both methods involve handling potential errors. ```go // Manual pagination opts := &statusgator.ListOptions{Page: 1, PerPage: 50} for { boards, pagination, err := client.Boards.List(ctx, opts) if err != nil { return err } // Process boards... if !pagination.HasNextPage() { break } opts.Page++ } // Auto-pagination allBoards, err := client.Boards.ListAll(ctx) ``` -------------------------------- ### Retrieve Monitoring Regions with Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Shows how to list available monitoring regions using the Statusgator Go client. This operation requires a context and handles potential errors. ```go regions, err := client.Regions.List(ctx) ``` -------------------------------- ### Manage Service Monitors with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Demonstrates how to subscribe to external status pages by creating a service monitor. This requires providing the `ServiceID` of the external service you want to monitor. ```go // Subscribe to an external status page monitor, err := client.ServiceMonitors.Create(ctx, "board-id", &statusgator.ServiceMonitorRequest{ ServiceID: "github-service-id", }) ``` -------------------------------- ### Manage Incidents with Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Demonstrates how to list, create, and add updates to incidents using the Statusgator Go client. Requires a context, board ID, and incident details for creation and updates. Handles potential errors during these operations. ```go // List incidents incidents, _, err := client.Incidents.List(ctx, "board-id", nil) // Create an incident incident, err := client.Incidents.Create(ctx, "board-id", &statusgator.IncidentRequest{ Title: "API Degradation", Message: "We are investigating elevated error rates", Severity: statusgator.IncidentSeverityMinor, Phase: statusgator.IncidentPhaseInvestigating, MonitorIDs: []string{"monitor-id"}, }) // Add an update update, err := client.Incidents.AddUpdate(ctx, "board-id", "incident-id", &statusgator.IncidentUpdateRequest{ Message: "Issue has been identified", Phase: statusgator.IncidentPhaseIdentified, }) ``` -------------------------------- ### Manage Custom Monitors with StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Illustrates how to create and update custom monitors, which allow for manual status updates. You can set the monitor's name, description, and manually set its status to 'Up' or other defined states. ```go monitor, err := client.CustomMonitors.Create(ctx, "board-id", &statusgator.CustomMonitorRequest{ Name: "Manual Check", Description: "Manually updated status", }) ``` ```go // Update status err := client.CustomMonitors.SetStatus(ctx, "board-id", "monitor-id", statusgator.MonitorStatusUp) ``` -------------------------------- ### Manage Incidents and Maintenance Windows with Statusgator Go Client Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt This Go code snippet demonstrates how to interact with the Incidents service of the statusgator-go-client. It covers listing existing incidents (with and without pagination), creating new incidents and scheduled maintenance, adding updates to incidents, and resolving them. Requires a Statusgator API token and board/monitor IDs. ```go package main import ( "context" "fmt" "log" "time" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // List incidents incidents, pagination, err := client.Incidents.List(ctx, "board-id", &statusgator.ListOptions{ Page: 1, PerPage: 25, }) if err != nil { log.Fatal(err) } fmt.Printf("Found %d incidents\n", pagination.TotalCount) for _, incident := range incidents { fmt.Printf("Incident: %s [%s] - Phase: %s\n", incident.Title, incident.Severity, incident.Phase) } // Get all incidents with auto-pagination allIncidents, err := client.Incidents.ListAll(ctx, "board-id") if err != nil { log.Fatal(err) } fmt.Printf("Total incidents: %d\n", len(allIncidents)) // Create an incident incident, err := client.Incidents.Create(ctx, "board-id", &statusgator.IncidentRequest{ Title: "API Response Latency", Message: "We are investigating elevated response times on the API.", Severity: statusgator.IncidentSeverityMinor, // minor, major, maintenance Phase: statusgator.IncidentPhaseInvestigating, MonitorIDs: []string{"api-monitor-id", "web-monitor-id"}, }) if err != nil { log.Fatal(err) } fmt.Printf("Created incident: %s (ID: %s)\n", incident.Title, incident.ID) // Create a scheduled maintenance scheduledStart := time.Now().Add(24 * time.Hour) scheduledEnd := scheduledStart.Add(2 * time.Hour) maintenance, err := client.Incidents.Create(ctx, "board-id", &statusgator.IncidentRequest{ Title: "Scheduled Database Migration", Message: "We will be performing a database migration. Expect brief interruptions.", Severity: statusgator.IncidentSeverityMaintenance, Phase: statusgator.IncidentPhaseScheduled, MonitorIDs: []string{"database-monitor-id"}, ScheduledFor: &scheduledStart, ScheduledEnd: &scheduledEnd, }) if err != nil { log.Fatal(err) } fmt.Printf("Scheduled maintenance: %s at %s\n", maintenance.Title, scheduledStart.Format(time.RFC3339)) // Add an incident update update, err := client.Incidents.AddUpdate(ctx, "board-id", incident.ID, &statusgator.IncidentUpdateRequest{ Message: "Root cause identified. Deploying fix.", Phase: statusgator.IncidentPhaseIdentified, }) if err != nil { log.Fatal(err) } fmt.Printf("Added update: %s (Phase: %s)\n", update.Message, update.Phase) // Resolve the incident _, err = client.Incidents.AddUpdate(ctx, "board-id", incident.ID, &statusgator.IncidentUpdateRequest{ Message: "Fix deployed. All systems operational.", Phase: statusgator.IncidentPhaseResolved, }) if err != nil { log.Fatal(err) } fmt.Println("Incident resolved") } ``` -------------------------------- ### Authenticate StatusGator Go Client Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Shows how to create a new StatusGator client instance by passing your API token. This token is obtained from the StatusGator dashboard and is essential for authenticating API requests. ```go client, err := statusgator.NewClient("your-api-token") ``` -------------------------------- ### Manage Custom Monitors with Go Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Create and manage custom monitors, which are manually updated status indicators, using the Statusgator Go client. This includes setting and updating monitor status (Up, Warn, Down) and descriptions. Requires an API token and board ID. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // Create a custom monitor monitor, err := client.CustomMonitors.Create(ctx, "board-id", &statusgator.CustomMonitorRequest{ Name: "Payment Processing", Description: "Manual status for payment gateway health", Status: statusgator.MonitorStatusUp, GroupID: "business-critical", }) if err != nil { log.Fatal(err) } fmt.Printf("Created custom monitor: %s (ID: %s)\n", monitor.Name, monitor.ID) // Update status using SetStatus convenience method err = client.CustomMonitors.SetStatus(ctx, "board-id", monitor.ID, statusgator.MonitorStatusWarn) if err != nil { log.Fatal(err) } fmt.Println("Status updated to: warn") // Update with full request for more control monitor, err = client.CustomMonitors.Update(ctx, "board-id", monitor.ID, &statusgator.CustomMonitorRequest{ Description: "Payment gateway experiencing degraded performance", Status: statusgator.MonitorStatusDown, }) if err != nil { log.Fatal(err) } fmt.Printf("Monitor status: %s, Description: %s\n", monitor.Status, monitor.Description) // Set back to operational err = client.CustomMonitors.SetStatus(ctx, "board-id", monitor.ID, statusgator.MonitorStatusUp) if err != nil { log.Fatal(err) } fmt.Println("Status restored to: up") } ``` -------------------------------- ### Manage Monitor Groups with StatusGator Go Client Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt This Go code snippet demonstrates how to use the StatusGator Go Client to manage monitor groups. It covers listing all monitor groups, creating a new group with specified properties, retrieving details of a specific group, updating an existing group's attributes, and finally deleting a group. Ensure you have a valid API token and board ID. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // List all monitor groups groups, err := client.MonitorGroups.List(ctx, "board-id") if err != nil { log.Fatal(err) } for _, group := range groups { fmt.Printf("Group: %s (ID: %s, Position: %d, Collapsed: %v)\n", group.Name, group.ID, group.Position, group.Collapsed) } // Create a monitor group collapsed := false group, err := client.MonitorGroups.Create(ctx, "board-id", &statusgator.MonitorGroupRequest{ Name: "Production Services", Position: 1, Collapsed: &collapsed, }) if err != nil { log.Fatal(err) } fmt.Printf("Created group: %s (ID: %s)\n", group.Name, group.ID) // Get a specific group group, err = client.MonitorGroups.Get(ctx, "board-id", group.ID) if err != nil { log.Fatal(err) } fmt.Printf("Group details: %+v\n", group) // Update a group newCollapsed := true group, err = client.MonitorGroups.Update(ctx, "board-id", group.ID, &statusgator.MonitorGroupRequest{ Name: "Production Infrastructure", Position: 2, Collapsed: &newCollapsed, }) if err != nil { log.Fatal(err) } fmt.Printf("Updated group: %s at position %d\n", group.Name, group.Position) // Delete a group err = client.MonitorGroups.Delete(ctx, "board-id", group.ID) if err != nil { log.Fatal(err) } fmt.Println("Group deleted") } ``` -------------------------------- ### Manage Service Monitors with Go Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Subscribe to external status pages and manage service monitors using the Statusgator Go client. This involves searching for services, creating subscriptions, and updating monitor configurations. Requires an API token and board ID. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // Search for available services services, err := client.Services.Search(ctx, "github") if err != nil { log.Fatal(err) } for _, svc := range services { fmt.Printf("Service: %s (ID: %s) - %s\n", svc.Name, svc.ID, svc.StatusURL) } // Subscribe to an external service status page monitor, err := client.ServiceMonitors.Create(ctx, "board-id", &statusgator.ServiceMonitorRequest{ ServiceID: "github-service-id", Name: "GitHub", // optional custom name GroupID: "dependencies-group", }) if err != nil { log.Fatal(err) } fmt.Printf("Subscribed to: %s (Monitor ID: %s)\n", monitor.ServiceName, monitor.ID) // Update service monitor monitor, err = client.ServiceMonitors.Update(ctx, "board-id", monitor.ID, &statusgator.ServiceMonitorRequest{ Name: "GitHub - Code Repository", GroupID: "critical-dependencies", }) if err != nil { log.Fatal(err) } fmt.Printf("Updated monitor name: %s\n", monitor.Name) } ``` -------------------------------- ### Manage Status Page Subscribers with Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Illustrates how to list, add, and remove subscribers for a status page using the Statusgator Go client. Adding a subscriber requires an email and optional skip confirmation flag. Removing a subscriber uses their email. Errors are handled. ```go // List subscribers subscribers, _, err := client.Subscribers.List(ctx, "board-id", nil) // Add a subscriber subscriber, err := client.Subscribers.Add(ctx, "board-id", &statusgator.SubscriberRequest{ Email: "user@example.com", SkipConfirmation: true, }) // Remove subscriber err := client.Subscribers.DeleteByEmail(ctx, "board-id", "user@example.com") ``` -------------------------------- ### Manage StatusGator Subscribers using Go Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt This Go code snippet demonstrates how to manage email subscribers for your StatusGator status page. It includes functionalities to list subscribers (with pagination and auto-pagination), add new subscribers (with or without confirmation emails), and delete subscribers by email or ID. Ensure you have a valid API token and the correct board ID. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // List subscribers subscribers, pagination, err := client.Subscribers.List(ctx, "board-id", &statusgator.ListOptions{ Page: 1, PerPage: 50, }) if err != nil { log.Fatal(err) } fmt.Printf("Subscribers: %d total\n", pagination.TotalCount) for _, sub := range subscribers { confirmed := "pending" if sub.Confirmed { confirmed = "confirmed" } fmt.Printf(" - %s [%s] (ID: %s)\n", sub.Email, confirmed, sub.ID) } // Get all subscribers with auto-pagination allSubscribers, err := client.Subscribers.ListAll(ctx, "board-id") if err != nil { log.Fatal(err) } fmt.Printf("Total subscribers: %d\n", len(allSubscribers)) // Add a subscriber (with confirmation email) subscriber, err := client.Subscribers.Add(ctx, "board-id", &statusgator.SubscriberRequest{ Email: "user@example.com", SkipConfirmation: false, }) if err != nil { log.Fatal(err) } fmt.Printf("Added subscriber: %s (confirmation pending)\n", subscriber.Email) // Add a subscriber (skip confirmation - auto-confirm) subscriber, err = client.Subscribers.Add(ctx, "board-id", &statusgator.SubscriberRequest{ Email: "admin@example.com", SkipConfirmation: true, }) if err != nil { log.Fatal(err) } fmt.Printf("Added subscriber: %s (auto-confirmed)\n", subscriber.Email) // Delete subscriber by email err = client.Subscribers.DeleteByEmail(ctx, "board-id", "user@example.com") if err != nil { log.Fatal(err) } fmt.Println("Subscriber removed by email") // Delete subscriber by ID err = client.Subscribers.DeleteByID(ctx, "board-id", subscriber.ID) if err != nil { log.Fatal(err) } fmt.Println("Subscriber removed by ID") } ``` -------------------------------- ### List Monitoring Regions (Go) Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Fetches and displays available geographic monitoring regions for website and ping monitors using the StatusGator Go client. Requires an API token for authentication. ```go package main import ( "context" "fmt" "log" "github.com/arslanbekov/statusgator-go-client/statusgator" ) func main() { client, _ := statusgator.NewClient("your-api-token") ctx := context.Background() // List available monitoring regions regions, err := client.Regions.List(ctx) if err != nil { log.Fatal(err) } fmt.Println("Available monitoring regions:") for _, region := range regions { fmt.Printf(" %s (%s)\n", region.Name, region.Code) fmt.Printf(" IPs: %v\n", region.IPAddrs) fmt.Printf(" DNS: %v\n", region.DNSNames) } } ``` -------------------------------- ### Handle API Errors in Go Source: https://github.com/arslanbekov/statusgator-go-client/blob/master/README.md Illustrates robust error handling for API requests made with the Statusgator Go client. It shows how to check for specific error types like Not Found, Unauthorized, and Forbidden, and how to extract detailed API error information including status code and message. ```go board, err := client.Boards.Get(ctx, "board-id") if err != nil { if statusgator.IsNotFound(err) { // Handle 404 } if statusgator.IsUnauthorized(err) { // Handle 401 } if statusgator.IsForbidden(err) { // Handle 403 (e.g., no Firehose access) } // Get detailed error info var apiErr *statusgator.APIError if errors.As(err, &apiErr) { fmt.Printf("Status: %d, Message: %s\n", apiErr.StatusCode, apiErr.Message) } } ``` -------------------------------- ### Website Monitors Service API Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Manages website monitors, which perform HTTP health checks on URLs and support various configurations. ```APIDOC ## Website Monitors Service ### Description Website monitors perform HTTP health checks on URLs. They support custom HTTP methods, status code validation, content matching, authentication, and multi-region monitoring. ## Create a Website Monitor ### Description Creates a new website monitor. ### Method POST ### Endpoint `/boards/{boardId}/website-monitors` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board to create the monitor in. #### Request Body - **name** (string) - Required - The name of the monitor. - **url** (string) - Required - The URL to monitor. - **check_interval** (integer) - Required - The interval in minutes between checks. - **http_method** (string) - Optional - The HTTP method to use (e.g., GET, POST). Defaults to GET. - **expected_status** (integer) - Optional - The expected HTTP status code. Defaults to 200. - **content_match** (string) - Optional - A string that must be present in the response body. - **timeout** (integer) - Optional - The timeout in seconds for the check. Defaults to 10. - **follow_redirects** (boolean) - Optional - Whether to follow HTTP redirects. Defaults to true. - **headers** (object) - Optional - Custom headers to send with the request. - **regions** (array of strings) - Optional - List of regions to perform checks from. - **group_id** (string) - Optional - The ID of the group to assign the monitor to. ### Request Example ```json { "name": "Production API", "url": "https://api.example.com/health", "check_interval": 1, "http_method": "GET", "expected_status": 200, "content_match": "\"status\": \"healthy\"", "timeout": 30, "follow_redirects": true, "headers": { "Authorization": "Bearer token", "Accept": "application/json" }, "regions": ["us-east", "eu-west"], "group_id": "optional-group-id" } ``` ### Response #### Success Response (200) - **monitor** (object) - The created website monitor object. - **id** (string) - The unique ID of the monitor. - **name** (string) - The name of the monitor. - **check_interval** (integer) - The check interval in minutes. - ... (other monitor properties) #### Response Example ```json { "id": "monitor-id", "name": "Production API", "url": "https://api.example.com/health", "check_interval": 1, "http_method": "GET", "expected_status": 200, "content_match": "\"status\": \"healthy\"", "timeout": 30, "follow_redirects": true, "headers": { "Authorization": "Bearer token", "Accept": "application/json" }, "regions": ["us-east", "eu-west"], "group_id": "optional-group-id" } ``` ## Update a Website Monitor ### Description Updates an existing website monitor. ### Method PUT ### Endpoint `/boards/{boardId}/website-monitors/{monitorId}` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board the monitor belongs to. - **monitorId** (string) - Required - The ID of the monitor to update. #### Request Body - **check_interval** (integer) - Optional - The updated interval in minutes between checks. - **timeout** (integer) - Optional - The updated timeout in seconds for the check. - ... (other updatable monitor properties) ### Request Example ```json { "check_interval": 5, "timeout": 60 } ``` ### Response #### Success Response (200) - **monitor** (object) - The updated website monitor object. #### Response Example ```json { "id": "monitor-id", "name": "Production API", "url": "https://api.example.com/health", "check_interval": 5, "timeout": 60, "http_method": "GET", "expected_status": 200, "content_match": "\"status\": \"healthy\"", "follow_redirects": true, "headers": { "Authorization": "Bearer token", "Accept": "application/json" }, "regions": ["us-east", "eu-west"], "group_id": "optional-group-id" } ``` ## Pause a Monitor ### Description Pauses a website monitor, stopping checks temporarily. ### Method POST ### Endpoint `/boards/{boardId}/website-monitors/{monitorId}/pause` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board the monitor belongs to. - **monitorId** (string) - Required - The ID of the monitor to pause. ### Request Example ```go client.WebsiteMonitors.Pause(ctx, "board-id", "monitor-id") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the monitor has been paused. #### Response Example ```json { "message": "Monitor paused" } ``` ## Unpause a Monitor ### Description Resumes a paused website monitor, allowing checks to resume. ### Method POST ### Endpoint `/boards/{boardId}/website-monitors/{monitorId}/unpause` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board the monitor belongs to. - **monitorId** (string) - Required - The ID of the monitor to unpause. ### Request Example ```go client.WebsiteMonitors.Unpause(ctx, "board-id", "monitor-id") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the monitor has been resumed. #### Response Example ```json { "message": "Monitor resumed" } ``` ``` -------------------------------- ### Monitors Service API Source: https://context7.com/arslanbekov/statusgator-go-client/llms.txt Provides operations for managing all types of monitors, including listing, filtering by status, and deletion. ```APIDOC ## Monitors Service ### Description The Monitors service provides operations common to all monitor types, including listing, filtering by status, and deletion. ### Method GET ### Endpoint `/boards/{boardId}/monitors` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board to list monitors from. #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **per_page** (integer) - Optional - The number of items per page. ### Request Example ```go client.Monitors.List(ctx, "board-id", &statusgator.ListOptions{ Page: 1, PerPage: 50 }) ``` ### Response #### Success Response (200) - **monitors** (array) - A list of monitor objects. - **pagination** (object) - Pagination details. - **current_page** (integer) - The current page number. - **total_pages** (integer) - The total number of pages. #### Response Example ```json { "monitors": [ { "id": "monitor-id", "name": "Example Monitor", "type": "website", "status": "up", "paused": false } ], "pagination": { "current_page": 1, "total_pages": 5 } } ``` ## List All Monitors ### Description Retrieves all monitors for a given board, with automatic pagination. ### Method GET ### Endpoint `/boards/{boardId}/monitors` (with auto-pagination) ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board to list monitors from. ### Request Example ```go client.Monitors.ListAll(ctx, "board-id") ``` ### Response #### Success Response (200) - **allMonitors** (array) - A list of all monitor objects. #### Response Example ```json [ { "id": "monitor-id", "name": "Example Monitor", "type": "website", "status": "up", "paused": false } ] ``` ## Filter Monitors by Status ### Description Filters monitors for a given board by their current status. ### Method GET ### Endpoint `/boards/{boardId}/monitors?status={status}` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board to filter monitors from. #### Query Parameters - **status** (string) - Required - The status to filter by (e.g., `up`, `down`, `warn`, `maintenance`, `unknown`). ### Request Example ```go client.Monitors.ListByStatus(ctx, "board-id", statusgator.MonitorStatusDown) ``` ### Response #### Success Response (200) - **downMonitors** (array) - A list of monitor objects matching the specified status. #### Response Example ```json [ { "id": "monitor-id", "name": "Example Monitor", "type": "website", "status": "down", "paused": false } ] ``` ## Delete a Monitor ### Description Deletes a specific monitor from a board. ### Method DELETE ### Endpoint `/boards/{boardId}/monitors/{monitorId}` ### Parameters #### Path Parameters - **boardId** (string) - Required - The ID of the board the monitor belongs to. - **monitorId** (string) - Required - The ID of the monitor to delete. ### Request Example ```go client.Monitors.Delete(ctx, "board-id", "monitor-id") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful deletion. #### Response Example ```json { "message": "Monitor deleted successfully" } ``` ```