brewcommands

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointBrewCommandsJSON          = "/brew_commands.json"
	EndpointBrewCommandsCSV           = "/brew_commands.csv"
	EndpointBrewCommandRunsJSONFormat = "/brew_commands/%s/runs.json" // {brew_command_label}
	EndpointBrewCommandRunsCSVFormat  = "/brew_commands/%s/runs.csv"  // {brew_command_label}
)

API endpoints for brew commands

View Source
const (
	RecurrenceOnce    = "once"
	RecurrenceDaily   = "daily"
	RecurrenceWeekly  = "weekly"
	RecurrenceMonthly = "monthly"
)

Recurrence values per swagger spec

Variables

This section is empty.

Functions

This section is empty.

Types

type BrewCommand

type BrewCommand struct {
	Command           string               `json:"command"`
	Label             string               `json:"label"`
	LastUpdatedByUser string               `json:"last_updated_by_user"`
	StartedAt         devices.TimeOrStatus `json:"started_at"`  // date-time or "Not Started"
	FinishedAt        devices.TimeOrStatus `json:"finished_at"` // date-time or "Not Finished"
	Devices           []string             `json:"devices"`
	RunCount          int                  `json:"run_count"`
}

BrewCommand represents a brew command in the system Matches the schema from swagger specification

type BrewCommandRun

type BrewCommandRun struct {
	Command    string               `json:"command"`
	Label      string               `json:"label"`
	Device     string               `json:"device"`
	CreatedAt  time.Time            `json:"created_at"`
	UpdatedAt  time.Time            `json:"updated_at"`
	Success    bool                 `json:"success"`
	Output     string               `json:"output"`
	StartedAt  devices.TimeOrStatus `json:"started_at"`  // date-time or "Not Started"
	FinishedAt devices.TimeOrStatus `json:"finished_at"` // date-time or "Not Finished"
}

BrewCommandRun represents a single execution of a brew command Matches the schema from swagger specification

type BrewCommandRunsResponse

type BrewCommandRunsResponse []BrewCommandRun

BrewCommandRunsResponse represents the response from the runs.json endpoint

type BrewCommandsResponse

type BrewCommandsResponse []BrewCommand

BrewCommandsResponse represents the response from the brew_commands.json endpoint

type BrewCommandsServiceInterface

type BrewCommandsServiceInterface interface {
	// ListBrewCommands returns a list of brew commands with their configuration and status
	//
	// Returns brew commands with command, label, last updated user, start/finish timestamps, devices, and run count
	ListBrewCommands(ctx context.Context) (*BrewCommandsResponse, *interfaces.Response, error)

	// ListBrewCommandsCSV returns a list of brew commands in CSV format
	//
	// Returns the same brew commands data as ListBrewCommands but formatted as CSV
	ListBrewCommandsCSV(ctx context.Context) ([]byte, *interfaces.Response, error)

	// CreateBrewCommand creates a new brew command with specified arguments and optional device/timing configuration
	//
	// Requires arguments field. Optional fields include device_ids, run_after_datetime, and recurrence (once, daily, weekly, monthly)
	CreateBrewCommand(ctx context.Context, request *CreateBrewCommandRequest) (*CreateBrewCommandResponse, *interfaces.Response, error)

	// ListBrewCommandRuns returns a list of brew command runs for a specific brew command
	//
	// Returns run history including command, label, device, timestamps, success status, and output for the specified brew command label
	ListBrewCommandRuns(ctx context.Context, brewCommandLabel string) (*BrewCommandRunsResponse, *interfaces.Response, error)

	// ListBrewCommandRunsCSV returns a list of brew command runs in CSV format
	//
	// Returns the same run data as ListBrewCommandRuns but formatted as CSV
	ListBrewCommandRunsCSV(ctx context.Context, brewCommandLabel string) ([]byte, *interfaces.Response, error)
}

BrewCommandsServiceInterface defines the interface for brew commands operations

Workbrew API docs: https://console.workbrew.com/documentation/api

type CreateBrewCommandRequest

type CreateBrewCommandRequest struct {
	Arguments        string  `json:"arguments"`                    // Required: brew arguments (e.g., "install wget")
	DeviceIDs        *string `json:"device_ids,omitempty"`         // Optional: comma-separated UUIDs
	RunAfterDatetime *string `json:"run_after_datetime,omitempty"` // Optional: date_time format (e.g., "2025-01-10T10:09")
	Recurrence       *string `json:"recurrence,omitempty"`         // Optional: "once", "daily", "weekly", "monthly"
}

CreateBrewCommandRequest represents the request body for creating a brew command Per swagger spec

type CreateBrewCommandResponse

type CreateBrewCommandResponse struct {
	Message string `json:"message"`
}

CreateBrewCommandResponse represents the successful response from creating a brew command Status code: 201

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles communication with the brew commands related methods of the Workbrew API.

Workbrew API docs: https://console.workbrew.com/documentation/api

func NewService

func NewService(client interfaces.HTTPClient) *Service

NewService creates a new brew commands service

func (*Service) CreateBrewCommand

CreateBrewCommand creates a new brew command URL: POST https://console.workbrew.com/workspaces/{workspace_name}/brew_commands.json

Response codes:

  • 201: Brew Command created successfully
  • 403: On a Free tier plan (requires upgrade)
  • 422: Validation error (e.g., "Arguments cannot include `&&`")

func (*Service) ListBrewCommandRuns

func (s *Service) ListBrewCommandRuns(ctx context.Context, brewCommandLabel string) (*BrewCommandRunsResponse, *interfaces.Response, error)

ListBrewCommandRuns retrieves all runs for a specific brew command in JSON format URL: GET https://console.workbrew.com/workspaces/{workspace_name}/brew_commands/{brew_command_label}/runs.json

func (*Service) ListBrewCommandRunsCSV

func (s *Service) ListBrewCommandRunsCSV(ctx context.Context, brewCommandLabel string) ([]byte, *interfaces.Response, error)

ListBrewCommandRunsCSV retrieves all runs for a specific brew command in CSV format URL: GET https://console.workbrew.com/workspaces/{workspace_name}/brew_commands/{brew_command_label}/runs.csv

func (*Service) ListBrewCommands

func (s *Service) ListBrewCommands(ctx context.Context) (*BrewCommandsResponse, *interfaces.Response, error)

ListBrewCommands retrieves all brew commands in JSON format URL: GET https://console.workbrew.com/workspaces/{workspace_name}/brew_commands.json

func (*Service) ListBrewCommandsCSV

func (s *Service) ListBrewCommandsCSV(ctx context.Context) ([]byte, *interfaces.Response, error)

ListBrewCommandsCSV retrieves all brew commands in CSV format URL: GET https://console.workbrew.com/workspaces/{workspace_name}/brew_commands.csv

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL