Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/cli. OpenStatus CLI www.openstatus.dev
Something went wrong. Try again.
2.8 kB · 93 lines
Go
at v101
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394package statusreport
import ( "fmt" "net/http"
status_reportv1 "buf.build/gen/go/openstatus/api/protocolbuffers/go/openstatus/status_report/v1" "buf.build/gen/go/openstatus/api/connectrpc/gosimple/openstatus/status_report/v1/status_reportv1connect" "connectrpc.com/connect" "github.com/fatih/color" "github.com/openstatusHQ/cli/internal/api" "github.com/urfave/cli/v3")
func NewStatusReportClient(apiKey string) status_reportv1connect.StatusReportServiceClient { return status_reportv1connect.NewStatusReportServiceClient( api.DefaultHTTPClient, api.ConnectBaseURL, connect.WithInterceptors(api.NewAuthInterceptor(apiKey)), connect.WithProtoJSON(), )}
func NewStatusReportClientWithHTTPClient(httpClient *http.Client, apiKey string) status_reportv1connect.StatusReportServiceClient { return status_reportv1connect.NewStatusReportServiceClient( httpClient, api.ConnectBaseURL, connect.WithInterceptors(api.NewAuthInterceptor(apiKey)), connect.WithProtoJSON(), )}
func statusToSDK(s string) (status_reportv1.StatusReportStatus, error) { switch s { case "investigating": return status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_INVESTIGATING, nil case "identified": return status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_IDENTIFIED, nil case "monitoring": return status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_MONITORING, nil case "resolved": return status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_RESOLVED, nil default: return status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_UNSPECIFIED, fmt.Errorf("invalid status %q: must be one of investigating, identified, monitoring, resolved", s) }}
func statusToString(s status_reportv1.StatusReportStatus) string { switch s { case status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_INVESTIGATING: return "investigating" case status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_IDENTIFIED: return "identified" case status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_MONITORING: return "monitoring" case status_reportv1.StatusReportStatus_STATUS_REPORT_STATUS_RESOLVED: return "resolved" default: return "unknown" }}
func statusColor(s string) string { switch s { case "investigating": return color.RedString(s) case "identified": return color.YellowString(s) case "monitoring": return color.BlueString(s) case "resolved": return color.GreenString(s) default: return s }}
func StatusReportCmd() *cli.Command { return &cli.Command{ Name: "status-report", Aliases: []string{"sr"}, Usage: "Manage status reports", Commands: []*cli.Command{ GetStatusReportListCmd(), GetStatusReportInfoCmd(), GetStatusReportCreateCmd(), GetStatusReportUpdateCmd(), GetStatusReportDeleteCmd(), GetStatusReportAddUpdateCmd(), }, }}