Documentation
¶
Index ¶
- Constants
- func BuildOperationResponse(deviceID, name, id, resultCode, description string) []byte
- func CheckResponse(data []byte, statusCode int) error
- func ConfigureTLS(insecure bool, caFile string) errordeprecated
- func ExtractFlatAt(raw json.RawMessage, field string) string
- func ExtractFlatSub(raw json.RawMessage, field, sub string) string
- func ExtractFlatValue(raw json.RawMessage, field string) string
- func GenerateTOTPCode(secret string) (string, error)
- func Is2FAChallenge(err error) bool
- func IsEmptyResponse(data []byte, statusCode int) bool
- func JobIDFilter(jobID string) json.RawMessage
- func MQTTDataTopic(deviceID string) string
- func MQTTHostFromProfile(host string) string
- func MQTTRequestTopic(deviceID string) string
- func MQTTResponseTopic(deviceID string) string
- func NewHTTPClient() *http.Clientdeprecated
- func Ptr[T any](v T) *T
- func SetFilterPage(filter json.RawMessage, page, size int) (json.RawMessage, error)
- type APIError
- type Alarm
- type AlarmActionRequest
- type AlarmActionResponse
- type AlarmSummary
- type AlarmSummaryEntry
- type AlarmSummaryGroup
- type AlarmSummaryResponse
- type Category
- type Client
- func (c *Client) AttendAlarms(ctx context.Context, ids []string, notes string) (*AlarmActionResponse, error)
- func (c *Client) CancelJob(ctx context.Context, jobID string) error
- func (c *Client) CancelTask(ctx context.Context, taskID string) error
- func (c *Client) CloseAlarms(ctx context.Context, ids []string, notes string) (*AlarmActionResponse, error)
- func (c *Client) CollectFunctionLogs(ctx context.Context, apiKey, kind, org, channel, id, level string, max int, ...) ([]LogMessage, error)
- func (c *Client) CollectIoT(ctx context.Context, apiKey, deviceID string, payload IoTPayload) error
- func (c *Client) CollectRaw(ctx context.Context, apiKey, deviceID, route string, body []byte, ...) ([]byte, int, error)
- func (c *Client) CollectSimple(ctx context.Context, apiKey, deviceID, datastreamID string, value any) error
- func (c *Client) ConnectorFunctionsCatalog(ctx context.Context) (json.RawMessage, error)
- func (c *Client) CreateConnectorFunction(ctx context.Context, org, channel string, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) CreateDashboard(ctx context.Context, body json.RawMessage, workspaceOverride string) ([]byte, error)
- func (c *Client) CreateDatamodel(ctx context.Context, orgName string, body json.RawMessage) error
- func (c *Client) CreateDataset(ctx context.Context, orgName string, body json.RawMessage) error
- func (c *Client) CreateDevice(ctx context.Context, orgName string, body json.RawMessage) error
- func (c *Client) CreateJob(ctx context.Context, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) CreateJobRequest(ctx context.Context, req JobRequest) (string, JobTargetRejections, error)
- func (c *Client) CreateOpType(ctx context.Context, org string, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) CreateProvisionProcessor(ctx context.Context, org string, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) CreateRule(ctx context.Context, org, channel string, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) CreateTask(ctx context.Context, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) CreateTimeSeries(ctx context.Context, orgName string, body json.RawMessage) error
- func (c *Client) CreateWorkspace(ctx context.Context, body json.RawMessage) ([]byte, error)
- func (c *Client) Delete(ctx context.Context, path string) ([]byte, int, error)
- func (c *Client) DeleteConnectorFunction(ctx context.Context, org, channel, id string) error
- func (c *Client) DeleteDashboard(ctx context.Context, id string) error
- func (c *Client) DeleteDatamodel(ctx context.Context, orgName, id string) error
- func (c *Client) DeleteDataset(ctx context.Context, orgName, id string) error
- func (c *Client) DeleteDevice(ctx context.Context, orgName, id string) error
- func (c *Client) DeleteOpType(ctx context.Context, org, name string) error
- func (c *Client) DeleteProvisionProcessor(ctx context.Context, org, id string) error
- func (c *Client) DeleteRule(ctx context.Context, org, channel, id string) error
- func (c *Client) DeleteTimeSeries(ctx context.Context, orgName, id string) error
- func (c *Client) DeleteWorkspace(ctx context.Context, id string) error
- func (c *Client) Err() error
- func (c *Client) ExportDashboard(ctx context.Context, id string) ([]byte, error)
- func (c *Client) ExportTimeSeries(ctx context.Context, orgName, id string, filter json.RawMessage) error
- func (c *Client) ExportWorkspace(ctx context.Context, id string) ([]byte, error)
- func (c *Client) Get(ctx context.Context, path string) ([]byte, int, error)
- func (c *Client) GetConnectorFunction(ctx context.Context, org, channel, id string) (json.RawMessage, error)
- func (c *Client) GetDashboard(ctx context.Context, id string) (*Dashboard, error)
- func (c *Client) GetDatamodel(ctx context.Context, orgName, id string) (*Datamodel, error)
- func (c *Client) GetDataset(ctx context.Context, orgName, id string) (*Dataset, error)
- func (c *Client) GetDevice(ctx context.Context, orgName, id string) (json.RawMessage, error)
- func (c *Client) GetJob(ctx context.Context, jobID string) (json.RawMessage, error)
- func (c *Client) GetJobOperations(ctx context.Context, jobID string) (*JobOperationsResponse, error)
- func (c *Client) GetJobOperationsAll(ctx context.Context, jobID string) iter.Seq2[Operation, error]
- func (c *Client) GetJobOperationsPage(ctx context.Context, jobID string, page, size int) (*JobOperationsResponse, error)
- func (c *Client) GetOpType(ctx context.Context, org, name string) (json.RawMessage, error)
- func (c *Client) GetProvisionBulkDetails(ctx context.Context, org, bulkID string) (data []byte, ready bool, err error)
- func (c *Client) GetProvisionBulkStatus(ctx context.Context, org, bulkID string) (json.RawMessage, error)
- func (c *Client) GetProvisionProcessor(ctx context.Context, org, id string) (json.RawMessage, error)
- func (c *Client) GetRule(ctx context.Context, org, channel, id string) (json.RawMessage, error)
- func (c *Client) GetTask(ctx context.Context, taskID string) (json.RawMessage, error)
- func (c *Client) GetTaskJobs(ctx context.Context, taskID string) (*SearchJobsResponse, error)
- func (c *Client) GetTimeSeries(ctx context.Context, orgName, id string) (*TimeSeries, error)
- func (c *Client) GetWithAccept(ctx context.Context, path, accept string) ([]byte, int, error)
- func (c *Client) GetWorkspace(ctx context.Context, id string, full bool) (*Workspace, error)
- func (c *Client) ImportWorkspaceDeep(ctx context.Context, w *Workspace) error
- func (c *Client) LaunchJob(ctx context.Context, req JobRequest, entities []string, opts LaunchOptions) (LaunchResult, error)
- func (c *Client) ListConnectorFunctions(ctx context.Context, org, channel string) (*ListConnectorFunctionsResponse, error)
- func (c *Client) ListDatasets(ctx context.Context, orgName string) (*DatasetListResponse, error)
- func (c *Client) ListProvisionProcessors(ctx context.Context, org string) ([]json.RawMessage, error)
- func (c *Client) ListTimeSeries(ctx context.Context, orgName string) (*TimeSeriesListResponse, error)
- func (c *Client) ListWorkspaces(ctx context.Context, full bool) ([]Workspace, error)
- func (c *Client) Login(ctx context.Context, email, password, twoFaCode string) (*LoginResult, error)
- func (c *Client) OpTypesCatalog(ctx context.Context) (json.RawMessage, error)
- func (c *Client) PlanProvisionBulk(ctx context.Context, org, id, filePath string, rows int) (json.RawMessage, error)
- func (c *Client) Post(ctx context.Context, path string, body io.Reader) ([]byte, int, error)
- func (c *Client) PostAccepting(ctx context.Context, path string, body io.Reader, accept string) ([]byte, int, error)
- func (c *Client) PostMultipartFile(ctx context.Context, path, fieldName, filePath, accept string) (body []byte, status int, location string, err error)
- func (c *Client) Put(ctx context.Context, path string, body io.Reader) ([]byte, int, error)
- func (c *Client) QueryDatasetData(ctx context.Context, orgName, id string, filter json.RawMessage) (*DatasetDataResponse, error)
- func (c *Client) QueryTimeSeriesData(ctx context.Context, orgName, id string, filter json.RawMessage) (*TimeSeriesDataResponse, error)
- func (c *Client) RulesCatalog(ctx context.Context) (json.RawMessage, error)
- func (c *Client) RunProvisionBulk(ctx context.Context, org, id, filePath string) (string, error)
- func (c *Client) SearchAlarms(ctx context.Context, filter json.RawMessage) (*SearchAlarmsResponse, error)
- func (c *Client) SearchDatamodels(ctx context.Context, filter json.RawMessage) (*SearchDatamodelsResponse, error)
- func (c *Client) SearchDevices(ctx context.Context, filter json.RawMessage) (*SearchDevicesResponse, error)
- func (c *Client) SearchDevicesAll(ctx context.Context, filter json.RawMessage) iter.Seq2[json.RawMessage, error]
- func (c *Client) SearchDevicesPage(ctx context.Context, filter json.RawMessage, page, size int) (*SearchDevicesResponse, error)
- func (c *Client) SearchJobs(ctx context.Context, filter json.RawMessage) (*SearchJobsResponse, error)
- func (c *Client) SearchOpTypes(ctx context.Context, filter json.RawMessage) (json.RawMessage, error)
- func (c *Client) SearchOperationsHistory(ctx context.Context, filter json.RawMessage) (*SearchOperationsResponse, error)
- func (c *Client) SearchOperationsHistoryAll(ctx context.Context, filter json.RawMessage) iter.Seq2[Operation, error]
- func (c *Client) SearchRules(ctx context.Context, filter json.RawMessage) (*SearchRulesResponse, error)
- func (c *Client) SearchTasks(ctx context.Context, filter json.RawMessage) (*SearchTasksResponse, error)
- func (c *Client) SetConnectorFunctionStatus(ctx context.Context, org, channel, id, status string) error
- func (c *Client) SetRuleActive(ctx context.Context, org, channel, id string, active bool) error
- func (c *Client) ShareDashboard(ctx context.Context, id string, users, domains []string) (json.RawMessage, error)
- func (c *Client) ShareWorkspace(ctx context.Context, id string, users, domains []string) (json.RawMessage, error)
- func (c *Client) StreamFunctionLogs(ctx context.Context, apiKey, kind, org, channel, id, level string, ...) error
- func (c *Client) SummaryAlarms(ctx context.Context, filter json.RawMessage) (*AlarmSummaryResponse, error)
- func (c *Client) UpdateConnectorFunction(ctx context.Context, org, channel, id string, body json.RawMessage) error
- func (c *Client) UpdateDashboard(ctx context.Context, id string, body json.RawMessage) error
- func (c *Client) UpdateDatamodel(ctx context.Context, orgName, id string, body json.RawMessage) error
- func (c *Client) UpdateDataset(ctx context.Context, orgName, id string, body json.RawMessage) error
- func (c *Client) UpdateDevice(ctx context.Context, orgName, id string, body json.RawMessage) error
- func (c *Client) UpdateJob(ctx context.Context, jobID string, body json.RawMessage) (json.RawMessage, error)
- func (c *Client) UpdateOpType(ctx context.Context, org, name string, body json.RawMessage) error
- func (c *Client) UpdateProvisionProcessor(ctx context.Context, org, id string, body json.RawMessage) error
- func (c *Client) UpdateRule(ctx context.Context, org, channel, id string, body json.RawMessage) error
- func (c *Client) UpdateTimeSeries(ctx context.Context, orgName, id string, body json.RawMessage) error
- func (c *Client) UpdateWorkspace(ctx context.Context, id string, body json.RawMessage) error
- func (c *Client) UpdateWorkspaceDeep(ctx context.Context, w *Workspace) error
- func (c *Client) WebDelete(ctx context.Context, path string) ([]byte, int, error)
- func (c *Client) WebGet(ctx context.Context, path string) ([]byte, int, error)
- func (c *Client) WebPost(ctx context.Context, path string, body io.Reader) ([]byte, int, error)
- func (c *Client) WebPut(ctx context.Context, path string, body io.Reader) ([]byte, int, error)
- func (c *Client) WebSignIn(ctx context.Context, req WebSignInRequest) (*WebSignInResult, error)
- func (c *Client) WithWebRefresh(req WebSignInRequest, onRefresh func(string)) *Client
- func (c *Client) WithWebToken(token string) *Client
- type ConnectorFunctionSummary
- type DSColumn
- type Dashboard
- type DashboardExtraConfig
- type DashboardSimplified
- type Datamodel
- type Dataset
- type DatasetDataResponse
- type DatasetListResponse
- type Datastream
- type DeviceSummary
- type GridItem
- type IoTDatapoint
- type IoTDatastream
- type IoTPayload
- type Job
- type JobBody
- type JobContainer
- type JobOperationsResponse
- type JobRequest
- type JobScattering
- type JobScatteringStrategy
- type JobSchedule
- type JobScheduleTime
- type JobTarget
- type JobTargetRejections
- type JobTargetSet
- type LaunchOptions
- type LaunchProgress
- type LaunchResult
- type ListConnectorFunctionsResponse
- type ListProvisionProcessorsResponse
- type LogMessage
- type LoginRequest
- type LoginResponse
- type LoginResult
- type LoginUser
- type MQTTClient
- type Millis
- type OpTypeSummary
- type Operation
- type OperationAttempts
- type OperationExecution
- type OperationParams
- type OperationRequest
- type OperationStep
- type Option
- type Page
- type ProvisionProcessorSummary
- type RetryPolicy
- type RuleSummary
- type SearchAlarmsResponse
- type SearchDatamodelsResponse
- type SearchDevicesResponse
- type SearchJobsResponse
- type SearchOperationsResponse
- type SearchRulesResponse
- type SearchTasksResponse
- type ShareRequest
- type Storage
- type TSColumn
- type TSSort
- type TSSortColumn
- type Task
- type TimeSeries
- type TimeSeriesDataResponse
- type TimeSeriesListResponse
- type Unit
- type WebSignInRequest
- type WebSignInResult
- type WidgetDefinition
- type Workspace
- type WorkspaceDashboard
- type WorkspaceMenuCategory
- type WorkspaceMenuCfg
- type WorkspaceMenuItem
- type WorkspaceOthers
Constants ¶
const ( MaxJobTargetEntities = 100 // MaxScatteringSpread is a self-imposed ceiling, not a platform one. // // maxSpread is the percentage of the job's effective time over which the // operations are spread. At 100 the last operations are launched exactly as // the job's window expires, leaving them no time to run: they die without // being executed. The platform does not measure execution durations to // regress a safe last-launch instant, so a tail margin has to be reserved by // hand — and going above 90 spends margin we cannot prove we have. MaxScatteringSpread = 90 // DefaultScatteringSpread leaves a 20% tail for in-flight operations to // drain. Two constraints pull in opposite directions: // // dispatch rate < capacity: window x maxSpread > N x timeout / threads // drain margin: window x (1-maxSpread) >= 10% and >> timeout // // Raising maxSpread smooths the dispatch rate (kinder to a mobile cell) but // eats the drain margin. So when the real per-device timeout turns out to be // larger, grow the window — never shrink the tail. DefaultScatteringSpread = 80 // DefaultScatteringFactor is the value used by every scattering example in // the platform documentation. DefaultScatteringFactor = 75 // DefaultWarningMaxRate is the platform examples' value, in operations per // second. It is a speed check, so it only needs to sit above the real // dispatch rate. DefaultWarningMaxRate = 3 // ScatteringFieldCellInfo is the only field scattering accepts today. ScatteringFieldCellInfo = "subscription.collected.cellInfo" )
Job limits and scattering defaults.
MaxJobTargetEntities is the documented ceiling for one target list ("there is a limit in the number of entities in the array, by default the value is 100"). A job body also has a size limit, 300 KBytes by default, which 100 identifiers never approach.
The scattering values are ASSUMPTIONS, not facts: they are the platform's own example values plus the reasoning below, pending a real job body from the customer. Treat them as a starting point and revisit when one arrives.
const ( LoggerConnectorFunctions = "connectorFunctions" LoggerRules = "rules" )
Functions-logger kinds.
const ( DefaultMQTTPort = 1883 DefaultMQTTTLSPort = 8883 )
Default OpenGate MQTT broker settings (South plane).
const ( StepResultSuccessful = "SUCCESSFUL" StepResultError = "ERROR" StepResultSkipped = "SKIPPED" StepResultNotExecuted = "NOT_EXECUTED" )
Step result values.
const ( DefaultPageSize = 1000 MaxPageSize = 2000 )
Page size bounds for search requests.
MaxPageSize is what the platform's limit schema documents as the ceiling for limit.size; a larger value is rejected by the server. DefaultPageSize is what the iterators request when the caller expresses no preference — deliberately below the maximum, since a huge page is a large response to buffer and a long request to lose on a timeout.
const ( DefaultRetryAttempts = 3 DefaultRetryBase = 500 * time.Millisecond DefaultRetryMaxDelay = 30 * time.Second )
Retry defaults. Three attempts covers a transient blip without turning a genuine outage into a long stall, and the delay cap keeps a Retry-After of "come back in an hour" from hanging a request for an hour.
const DefaultAPIVersion = "v80"
DefaultAPIVersion is the North API version segment used when WithAPIVersion is not passed. Every path constant carries a version placeholder that is resolved against this value.
const MaxJobOperationsPageSize = 1000
MaxJobOperationsPageSize is the page-size ceiling of the per-job operations endpoint. It is lower than MaxPageSize, which applies to the filter-based searches: the platform documents "the top margin for the page size ... is 1000. If you setup a size attribute over this limit, you'll receive a server error response."
Variables ¶
This section is empty.
Functions ¶
func BuildOperationResponse ¶
BuildOperationResponse builds the odm/response payload acknowledging an operation. resultCode is typically SUCCESSFUL or ERROR; description is a human-readable step description (may be empty).
func CheckResponse ¶
CheckResponse returns an APIError if the status code indicates failure.
func ConfigureTLS
deprecated
ConfigureTLS sets the process-wide TLS defaults inherited by clients created afterwards and by the MQTT transport. insecure skips server certificate verification entirely — the escape hatch for self-signed certs. caFile, when non-empty, appends an extra CA/chain PEM to the system pool. The caFile is validated eagerly so a bad path/PEM fails fast at startup rather than on first request.
Deprecated: this is process-wide mutable state, so two clients talking to endpoints with different certificate authorities cannot both be configured correctly. Pass WithTLS to New instead. It remains for the CLI, which does have exactly one endpoint per invocation.
func ExtractFlatAt ¶
func ExtractFlatAt(raw json.RawMessage, field string) string
ExtractFlatAt extracts the "at" timestamp of a field's current value.
func ExtractFlatSub ¶
func ExtractFlatSub(raw json.RawMessage, field, sub string) string
ExtractFlatSub extracts an arbitrary current-value sub-field (value, at, date or source) of a field from the flattened format.
func ExtractFlatValue ¶
func ExtractFlatValue(raw json.RawMessage, field string) string
ExtractFlatValue extracts the value from the flattened OpenGate format. In flattened format, each field is a root-level dotted key with structure: { "_value": { "_current": { "value": <val>, "at": <ts> } } }
func GenerateTOTPCode ¶
GenerateTOTPCode derives the current 6-digit TOTP code from a base32 secret (the seed shown when enabling 2FA in the web UI). It lets og log in non-interactively when the secret is stored in the profile or supplied via OG_2FA_SECRET. Spaces are stripped and the secret is upper-cased to tolerate the way authenticator apps display it.
func Is2FAChallenge ¶
Is2FAChallenge reports whether err means the server wants a TOTP 2FA code — either none was sent (the account has 2FA enabled) or the one sent was wrong/expired. Callers should prompt for a code and retry Login.
func IsEmptyResponse ¶
IsEmptyResponse returns true when the API returned no content (204 or empty body).
func JobIDFilter ¶
func JobIDFilter(jobID string) json.RawMessage
JobIDFilter builds the operations history filter for one job — the shape used to read back the per-device outcome of a job.
func MQTTDataTopic ¶
MQTTDataTopic is the default topic to publish collected data for a device.
func MQTTHostFromProfile ¶
MQTTHostFromProfile strips the scheme (and any trailing slash) from a profile host so it can be used as an MQTT broker host. "https://api.opengate.es" → "api.opengate.es".
func MQTTRequestTopic ¶
MQTTRequestTopic is the default topic a device subscribes to for incoming operations.
func MQTTResponseTopic ¶
MQTTResponseTopic is the default topic a device publishes operation responses to.
func NewHTTPClient
deprecated
NewHTTPClient returns an HTTP client honouring the process-wide TLS settings. Exported so other transports (e.g. the MCP server's shared client) can build a client that matches the CLI's TLS behaviour.
Deprecated: prefer New with WithTLS, which keeps TLS per client. This helper cannot express more than one CA per process.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to v.
Several job fields are pointers because their zero value is meaningful and would otherwise be dropped by omitempty — active:false and retries:0 in particular. This spares every caller a temporary variable:
req.Active = opengate.Ptr(false)
func SetFilterPage ¶
func SetFilterPage(filter json.RawMessage, page, size int) (json.RawMessage, error)
SetFilterPage returns filter with its limit block set to the requested page, preserving every other key. Use it to page a filter you built elsewhere — for example JobIDFilter — without hand-editing JSON.
page is a 1-based page number for the filter-based search endpoints. The name deliberately avoids the With prefix, which in this package marks the functional options accepted by New.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Code string // OpenGate error code (e.g. "0x000065"), when present
Message string
Fields []string // offending field names from the error context, when present
}
APIError represents an error response from the OpenGate API.
type Alarm ¶
type Alarm struct {
Identifier string `json:"identifier"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Severity string `json:"severity"`
Status string `json:"status"`
Priority string `json:"priority,omitempty"`
Rule string `json:"rule,omitempty"`
Organization string `json:"organization,omitempty"`
Channel string `json:"channel,omitempty"`
EntityIdentifier string `json:"entityIdentifier,omitempty"`
SubEntityIdentifier string `json:"subEntityIdentifier,omitempty"`
ResourceType string `json:"resourceType,omitempty"`
OpeningDate string `json:"openingDate,omitempty"`
AttentionDate string `json:"attentionDate,omitempty"`
ClosureDate string `json:"closureDate,omitempty"`
AttentionUser string `json:"attentionUser,omitempty"`
AttentionNote string `json:"attentionNote,omitempty"`
ClosureUser string `json:"closureUser,omitempty"`
ClosureNote string `json:"closureNote,omitempty"`
}
Alarm represents an OpenGate alarm instance.
type AlarmActionRequest ¶
type AlarmActionRequest struct {
Action string `json:"action"`
Alarms []string `json:"alarms"`
Notes string `json:"notes,omitempty"`
}
AlarmActionRequest is the body for attend/close operations.
type AlarmActionResponse ¶
type AlarmActionResponse struct {
Result struct {
Count int `json:"count"`
Successful int `json:"succesfull"`
Error struct {
Count int `json:"count"`
NotExist struct {
Count int `json:"count"`
List []string `json:"list"`
} `json:"notExist"`
} `json:"error"`
} `json:"result"`
}
AlarmActionResponse is the response from an alarm action.
type AlarmSummary ¶
type AlarmSummary struct {
Date string `json:"date"`
Count int `json:"count"`
SummaryGroup []map[string]AlarmSummaryGroup `json:"summaryGroup"`
}
AlarmSummary is the response from the alarms summary endpoint.
type AlarmSummaryEntry ¶
AlarmSummaryEntry is a name/count pair within a summary group.
type AlarmSummaryGroup ¶
type AlarmSummaryGroup struct {
Count int `json:"count"`
List []AlarmSummaryEntry `json:"list"`
}
AlarmSummaryGroup is a single group entry in a summary.
type AlarmSummaryResponse ¶
type AlarmSummaryResponse struct {
Summary AlarmSummary `json:"summary"`
}
AlarmSummaryResponse wraps the summary.
type Category ¶
type Category struct {
Identifier string `json:"identifier"`
Name string `json:"name,omitempty"`
Datastreams []Datastream `json:"datastreams,omitempty"`
}
Category groups datastream templates within a data model.
type Client ¶
type Client struct {
BaseURL string
Token string
WebToken string
APIKey string // when set, North API calls use X-ApiKey instead of the bearer token
HTTPClient *http.Client
// contains filtered or unexported fields
}
Client is the OpenGate REST API client.
The OpenGate platform exposes two REST surfaces:
- North API (/north/v80/...) — IoT plane, authenticated with Token (JWT).
- Web API (/api/...) — UI plane (workspaces, dashboards), authenticated with a separate WebToken obtained via WebSignIn.
Both share host and HTTP transport.
The Web API invalidates a WebToken whenever a fresh signin happens (e.g. the user logs into the OpenGate web UI in parallel). When a refresh request is configured via WithWebRefresh, the client will transparently re-signin on HTTP 401 and retry the original request once.
func New ¶
New creates a Client from a host URL and an optional JWT token.
Without options the client inherits the process-wide TLS settings configured via ConfigureTLS and targets North API DefaultAPIVersion. Pass WithHTTPClient, WithTLS, WithAPIVersion or WithAPIKey to configure it independently of any other client in the process.
New never returns nil and never fails: a bad configuration (e.g. an unreadable --ca-file) is recorded and returned by Err and by every request the client makes. Long-running consumers should check Err right after construction.
func (*Client) AttendAlarms ¶
func (c *Client) AttendAlarms(ctx context.Context, ids []string, notes string) (*AlarmActionResponse, error)
AttendAlarms marks alarms as attended.
func (*Client) CancelTask ¶
CancelTask cancels (deletes) a task.
func (*Client) CloseAlarms ¶
func (c *Client) CloseAlarms(ctx context.Context, ids []string, notes string) (*AlarmActionResponse, error)
CloseAlarms marks alarms as closed.
func (*Client) CollectFunctionLogs ¶
func (c *Client) CollectFunctionLogs(ctx context.Context, apiKey, kind, org, channel, id, level string, max int, stop <-chan struct{}) ([]LogMessage, error)
CollectFunctionLogs streams logs and accumulates them until stop is signalled or max messages are collected (max <= 0 means unbounded until stop). Returns the messages gathered. Convenience for non-interactive callers (MCP tools).
func (*Client) CollectIoT ¶
CollectIoT sends IoT data to a device via the South API.
South calls authenticate with the device/server API key rather than a JWT, so apiKey is a parameter instead of coming from the client: the key belongs to the device, while the client's credential belongs to the user.
These are Client methods rather than package functions so the South plane inherits the client's API version, TLS settings and retry policy — as package functions they had the version hardcoded.
func (*Client) CollectRaw ¶
func (c *Client) CollectRaw(ctx context.Context, apiKey, deviceID, route string, body []byte, contentType string) ([]byte, int, error)
CollectRaw posts a raw body to a connector function's custom south route (its HTTP southCriteria path), i.e. POST /south/{v}/devices/{id}/{route}. Unlike CollectIoT (which posts a structured collection payload to collect/iot and bypasses connector functions), this triggers a COLLECTION/RESPONSE connector function that matches the route.
Returns the response body (a CF may return content) and the status code.
func (*Client) CollectSimple ¶
func (c *Client) CollectSimple(ctx context.Context, apiKey, deviceID, datastreamID string, value any) error
CollectSimple sends a single value to a single datastream.
func (*Client) ConnectorFunctionsCatalog ¶
ConnectorFunctionsCatalog returns the platform connector functions catalog (predefined templates, not scoped to an organization channel).
func (*Client) CreateConnectorFunction ¶
func (c *Client) CreateConnectorFunction(ctx context.Context, org, channel string, body json.RawMessage) (json.RawMessage, error)
CreateConnectorFunction creates a connector function in an organization channel.
func (*Client) CreateDashboard ¶
func (c *Client) CreateDashboard(ctx context.Context, body json.RawMessage, workspaceOverride string) ([]byte, error)
CreateDashboard posts a dashboard definition. If workspaceOverride is non-empty, the "workspaces" field of the body is replaced with that value before sending — useful for cross-tenant migrations.
func (*Client) CreateDatamodel ¶
CreateDatamodel creates a new datamodel in the given organization. The body should be the full JSON datamodel payload.
func (*Client) CreateDataset ¶
CreateDataset creates a new dataset.
func (*Client) CreateDevice ¶
CreateDevice creates a new device in the given organization.
func (*Client) CreateJob ¶
func (c *Client) CreateJob(ctx context.Context, body json.RawMessage) (json.RawMessage, error)
CreateJob creates a new operation job.
func (*Client) CreateJobRequest ¶
func (c *Client) CreateJobRequest(ctx context.Context, req JobRequest) (string, JobTargetRejections, error)
CreateJobRequest creates a job from a typed request, returning the assigned id and any entities the platform refused.
func (*Client) CreateOpType ¶
func (c *Client) CreateOpType(ctx context.Context, org string, body json.RawMessage) (json.RawMessage, error)
CreateOpType creates a new operation type definition in an organization.
func (*Client) CreateProvisionProcessor ¶
func (c *Client) CreateProvisionProcessor(ctx context.Context, org string, body json.RawMessage) (json.RawMessage, error)
CreateProvisionProcessor creates a provision processor in an organization.
func (*Client) CreateRule ¶
func (c *Client) CreateRule(ctx context.Context, org, channel string, body json.RawMessage) (json.RawMessage, error)
CreateRule creates a rule in an organization channel.
func (*Client) CreateTask ¶
func (c *Client) CreateTask(ctx context.Context, body json.RawMessage) (json.RawMessage, error)
CreateTask creates a new operation task.
func (*Client) CreateTimeSeries ¶
CreateTimeSeries creates a new time series.
func (*Client) CreateWorkspace ¶
CreateWorkspace posts a workspace definition. The body is the full JSON (typically produced by ExportWorkspace).
func (*Client) DeleteConnectorFunction ¶
DeleteConnectorFunction deletes a connector function.
func (*Client) DeleteDashboard ¶
DeleteDashboard deletes a dashboard by ID. The Web API exposes DELETE /dashboards with the id in the body, so we send a minimal payload.
func (*Client) DeleteDatamodel ¶
DeleteDatamodel deletes a datamodel by organization and identifier.
func (*Client) DeleteDataset ¶
DeleteDataset deletes a dataset.
func (*Client) DeleteDevice ¶
DeleteDevice deletes a device by organization and identifier.
func (*Client) DeleteOpType ¶
DeleteOpType deletes an operation type definition.
func (*Client) DeleteProvisionProcessor ¶
DeleteProvisionProcessor deletes a provision processor.
func (*Client) DeleteRule ¶
DeleteRule deletes a rule.
func (*Client) DeleteTimeSeries ¶
DeleteTimeSeries deletes a time series.
func (*Client) DeleteWorkspace ¶
DeleteWorkspace deletes a workspace by ID.
func (*Client) Err ¶
Err reports a configuration error captured during New, if any. Every request the client makes fails with the same error until it is fixed.
func (*Client) ExportDashboard ¶
ExportDashboard fetches the export payload for a dashboard as raw JSON.
func (*Client) ExportTimeSeries ¶
func (c *Client) ExportTimeSeries(ctx context.Context, orgName, id string, filter json.RawMessage) error
ExportTimeSeries triggers a Parquet export of a time series.
func (*Client) ExportWorkspace ¶
ExportWorkspace fetches the export payload for a workspace as raw JSON. Use this for backups or migrations; the returned bytes can be passed back to ImportWorkspace on a different tenant.
func (*Client) GetConnectorFunction ¶
func (c *Client) GetConnectorFunction(ctx context.Context, org, channel, id string) (json.RawMessage, error)
GetConnectorFunction retrieves a connector function by identifier.
func (*Client) GetDashboard ¶
GetDashboard retrieves a single dashboard by ID.
func (*Client) GetDatamodel ¶
GetDatamodel retrieves a single datamodel by organization and identifier.
func (*Client) GetDataset ¶
GetDataset retrieves a single dataset by org and identifier.
func (*Client) GetDevice ¶
GetDevice retrieves a single device by organization and identifier (flattened format).
func (*Client) GetJobOperations ¶
func (c *Client) GetJobOperations(ctx context.Context, jobID string) (*JobOperationsResponse, error)
GetJobOperations lists operations within a job.
func (*Client) GetJobOperationsAll ¶
GetJobOperationsAll walks every page of a job's operations.
It starts by letting the platform serve its own first page and then follows the page numbers the platform reports, because the start parameter is documented with a default of 0 while the search endpoints count from 1.
Beware: this endpoint has been observed returning HTTP 204 for jobs whose operations do exist — see SearchOperationsHistory, which is the dependable way to read results back.
func (*Client) GetJobOperationsPage ¶
func (c *Client) GetJobOperationsPage(ctx context.Context, jobID string, page, size int) (*JobOperationsResponse, error)
GetJobOperationsPage lists one page of a job's operations. Unlike the search endpoints, this one pages with start/size query parameters rather than a body limit, and its size ceiling is MaxJobOperationsPageSize.
A page < 0 omits the start parameter and lets the platform serve its first page, whichever number that is.
func (*Client) GetProvisionBulkDetails ¶
func (c *Client) GetProvisionBulkDetails(ctx context.Context, org, bulkID string) (data []byte, ready bool, err error)
GetProvisionBulkDetails downloads the result Excel of a finished bulk process. ready is false (with nil data) when the process has not finished yet (HTTP 204).
func (*Client) GetProvisionBulkStatus ¶
func (c *Client) GetProvisionBulkStatus(ctx context.Context, org, bulkID string) (json.RawMessage, error)
GetProvisionBulkStatus reads the status summary of a bulk process.
func (*Client) GetProvisionProcessor ¶
func (c *Client) GetProvisionProcessor(ctx context.Context, org, id string) (json.RawMessage, error)
GetProvisionProcessor retrieves a provision processor by identifier.
func (*Client) GetTaskJobs ¶
GetTaskJobs lists jobs within a task.
func (*Client) GetTimeSeries ¶
GetTimeSeries retrieves a single time series by org and identifier.
func (*Client) GetWithAccept ¶
GetWithAccept performs a GET request with an explicit Accept header. Used by endpoints that return a non-JSON body (e.g. an Excel file) and reject the request with HTTP 409 when Accept does not match the response content type.
func (*Client) GetWorkspace ¶
GetWorkspace retrieves a single workspace by ID. When full is true, embedded dashboards are included (?full=1).
func (*Client) ImportWorkspaceDeep ¶
ImportWorkspaceDeep replays the OpenGate web UI's import-wizard flow:
- POST /api/workspaces with the workspace shell (no dashboards inline)
- POST /api/dashboards once per dashboard (full body with grid + widgets)
- PUT /api/workspaces/{id} with the shell + dashboards[] as layout refs
Single-shot POST /api/workspaces persists the shell but discards the dashboard bodies that ride inside the array, so workspace import has to be done in this multi-phase manner.
func (*Client) LaunchJob ¶
func (c *Client) LaunchJob(ctx context.Context, req JobRequest, entities []string, opts LaunchOptions) (LaunchResult, error)
LaunchJob runs the pattern the platform prescribes for a fleet larger than one target list: create the job inactive, append the entities in batches, and activate it.
Activation is merged into the last batch's PUT, so the job is never active with a partial target — a job that goes live early runs the operation on whichever entities happened to be attached at that moment, and there is no undo for an operation already sent to a device.
The id is reported through OnProgress as soon as it exists, before the first batch, so a caller can persist it and resume instead of orphaning a half-populated job on restart.
Entities the platform refuses are collected in the result: they arrive inside successful responses, so a caller checking only for errors would silently operate on fewer devices than it asked for.
func (*Client) ListConnectorFunctions ¶
func (c *Client) ListConnectorFunctions(ctx context.Context, org, channel string) (*ListConnectorFunctionsResponse, error)
ListConnectorFunctions lists every connector function in an organization channel.
func (*Client) ListDatasets ¶
ListDatasets returns all datasets in an organization.
func (*Client) ListProvisionProcessors ¶
func (c *Client) ListProvisionProcessors(ctx context.Context, org string) ([]json.RawMessage, error)
ListProvisionProcessors lists every provision processor in an organization.
func (*Client) ListTimeSeries ¶
func (c *Client) ListTimeSeries(ctx context.Context, orgName string) (*TimeSeriesListResponse, error)
ListTimeSeries returns all time series in an organization.
func (*Client) ListWorkspaces ¶
ListWorkspaces returns all workspaces accessible to the current user. When full is true, the response includes embedded dashboards (?full=1).
func (*Client) Login ¶
func (c *Client) Login(ctx context.Context, email, password, twoFaCode string) (*LoginResult, error)
Login authenticates against OpenGate and returns JWT token, API key, and domain. twoFaCode is the 6-digit TOTP code for accounts with 2FA enabled; pass "" when the account has no 2FA. When 2FA is required but the code is missing or invalid, the returned error satisfies Is2FAChallenge.
func (*Client) OpTypesCatalog ¶
OpTypesCatalog returns the catalog of predefined operation types.
func (*Client) PlanProvisionBulk ¶
func (c *Client) PlanProvisionBulk(ctx context.Context, org, id, filePath string, rows int) (json.RawMessage, error)
PlanProvisionBulk runs a dry-run plan for the first `rows` entries of an Excel file against a provision processor and returns the computed action plan as JSON. No data is mutated. rows defaults to 1 when <= 0.
func (*Client) PostAccepting ¶
func (c *Client) PostAccepting(ctx context.Context, path string, body io.Reader, accept string) ([]byte, int, error)
PostAccepting performs a POST with an explicit Accept header, for endpoints that can serve more than one representation of the same result.
func (*Client) PostMultipartFile ¶
func (c *Client) PostMultipartFile(ctx context.Context, path, fieldName, filePath, accept string) (body []byte, status int, location string, err error)
PostMultipartFile uploads a local file as multipart/form-data to the north API and returns the response body, status code, and the Location response header (used by endpoints that report a created resource via Location). The part's content type is derived from the file extension.
accept sets the request's Accept header when non-empty. Some endpoints (e.g. the provision bulk execution) reject the request with HTTP 409 unless Accept matches the uploaded file's content type.
func (*Client) QueryDatasetData ¶
func (c *Client) QueryDatasetData(ctx context.Context, orgName, id string, filter json.RawMessage) (*DatasetDataResponse, error)
QueryDatasetData searches data in a dataset with filter/sort/limit.
func (*Client) QueryTimeSeriesData ¶
func (c *Client) QueryTimeSeriesData(ctx context.Context, orgName, id string, filter json.RawMessage) (*TimeSeriesDataResponse, error)
QueryTimeSeriesData searches data in a time series with filter/sort/limit.
func (*Client) RulesCatalog ¶
RulesCatalog returns the platform rules catalog (predefined rule templates).
func (*Client) RunProvisionBulk ¶
RunProvisionBulk executes a full bulk from an Excel file against a provision processor and returns the created bulk process id (parsed from the Location header).
func (*Client) SearchAlarms ¶
func (c *Client) SearchAlarms(ctx context.Context, filter json.RawMessage) (*SearchAlarmsResponse, error)
SearchAlarms searches for alarms using a filter body.
func (*Client) SearchDatamodels ¶
func (c *Client) SearchDatamodels(ctx context.Context, filter json.RawMessage) (*SearchDatamodelsResponse, error)
SearchDatamodels searches for datamodels using a filter body. If filter is nil, all datamodels are returned.
func (*Client) SearchDevices ¶
func (c *Client) SearchDevices(ctx context.Context, filter json.RawMessage) (*SearchDevicesResponse, error)
SearchDevices searches for devices using a filter body.
func (*Client) SearchDevicesAll ¶
func (c *Client) SearchDevicesAll(ctx context.Context, filter json.RawMessage) iter.Seq2[json.RawMessage, error]
SearchDevicesAll walks every page of a device search and yields devices one by one, so a caller never has to know how many pages there are — nor request them all at once, which is how a large fleet turns into an unbounded response.
The page size comes from filter's limit.size when set, otherwise DefaultPageSize. Cancelling ctx stops the walk and yields the context error, so a truncated iteration is distinguishable from a complete one:
for dev, err := range c.SearchDevicesAll(ctx, filter) {
if err != nil {
return err
}
...
}
func (*Client) SearchDevicesPage ¶
func (c *Client) SearchDevicesPage(ctx context.Context, filter json.RawMessage, page, size int) (*SearchDevicesResponse, error)
SearchDevicesPage searches for devices restricted to one page, overriding any limit already present in filter. page is 1-based; size is capped at MaxPageSize. Use it when you want to drive paging yourself; use SearchDevicesAll to walk every page.
func (*Client) SearchJobs ¶
func (c *Client) SearchJobs(ctx context.Context, filter json.RawMessage) (*SearchJobsResponse, error)
SearchJobs searches for jobs.
func (*Client) SearchOpTypes ¶
func (c *Client) SearchOpTypes(ctx context.Context, filter json.RawMessage) (json.RawMessage, error)
SearchOpTypes searches operation types using a filter body.
func (*Client) SearchOperationsHistory ¶
func (c *Client) SearchOperationsHistory(ctx context.Context, filter json.RawMessage) (*SearchOperationsResponse, error)
SearchOperationsHistory searches closed operations across jobs.
This is the endpoint to use for reading results back. Verified against a live instance: GetJobOperations returned HTTP 204 (no content) for a FINISHED job whose operation this endpoint returned complete with its steps. Do not read an empty per-job listing as "the job had no operations".
It also takes a filter, so an entire job's outcome can be pulled with JobIDFilter and paged with limit, or many operations selected at once.
Filter field names are inconsistent and do not match the response field names. Confirmed by the OpenGate team and verified live:
identifiers, unprefixed: jobId, entityId, operationId, resourceType
the rest, prefixed: operationName (or operation.name)
operationStatus
operationResult (or operation.result)
operationDate, operationNotify
Everything else is rejected with HTTP 400 "Field in filter unknown" — including the bare name, status, result, user, date, notify and description, any "operations." prefix (those are the projection/CSV names, not filter names), and the near-misses operation.status, operation.entityId, operationUser, operationEntityId and operationJobId.
So outcome IS filterable server-side: use operationResult to ask only for the failures rather than pulling the whole result set.
It requests JSON explicitly. The endpoint can also emit text/plain CSV, but that format is unusable here: the separator collides with the contents of steps[].description, so rows break on any step whose description contains one.
func (*Client) SearchOperationsHistoryAll ¶
func (c *Client) SearchOperationsHistoryAll(ctx context.Context, filter json.RawMessage) iter.Seq2[Operation, error]
SearchOperationsHistoryAll walks every page of an operations history search. The page size comes from filter's limit.size, otherwise DefaultPageSize.
func (*Client) SearchRules ¶
func (c *Client) SearchRules(ctx context.Context, filter json.RawMessage) (*SearchRulesResponse, error)
SearchRules searches for rules using a filter body.
func (*Client) SearchTasks ¶
func (c *Client) SearchTasks(ctx context.Context, filter json.RawMessage) (*SearchTasksResponse, error)
SearchTasks searches for tasks.
func (*Client) SetConnectorFunctionStatus ¶
func (c *Client) SetConnectorFunctionStatus(ctx context.Context, org, channel, id, status string) error
SetConnectorFunctionStatus changes a connector function's operationalStatus (GET + patch operationalStatus + PUT). Valid values: DISABLED, PRODUCTION, TEST.
func (*Client) SetRuleActive ¶
SetRuleActive enables or disables a rule (GET + patch active + PUT).
func (*Client) ShareDashboard ¶
func (c *Client) ShareDashboard(ctx context.Context, id string, users, domains []string) (json.RawMessage, error)
ShareDashboard shares a single dashboard with the given users/domains.
func (*Client) ShareWorkspace ¶
func (c *Client) ShareWorkspace(ctx context.Context, id string, users, domains []string) (json.RawMessage, error)
ShareWorkspace shares a workspace with the given users/domains. This is the ONLY mechanism that grants visibility to other users — setting users[] via the regular workspace PUT does not.
func (*Client) StreamFunctionLogs ¶
func (c *Client) StreamFunctionLogs(ctx context.Context, apiKey, kind, org, channel, id, level string, onMessage func(LogMessage), stop <-chan struct{}) error
StreamFunctionLogs connects to the OpenGate functions-logger WebSocket and invokes onMessage for each trace until the connection closes or stop is signalled (close the stop channel to disconnect).
kind is LoggerConnectorFunctions or LoggerRules. Authentication uses the X-ApiKey URL parameter (the device/server API key, not the JWT). level is one of ERROR, WARN, INFO, DEBUG, TRACE; empty defaults to the server's INFO.
func (*Client) SummaryAlarms ¶
func (c *Client) SummaryAlarms(ctx context.Context, filter json.RawMessage) (*AlarmSummaryResponse, error)
SummaryAlarms returns a summary of alarms grouped by severity, status, rule, name.
func (*Client) UpdateConnectorFunction ¶
func (c *Client) UpdateConnectorFunction(ctx context.Context, org, channel, id string, body json.RawMessage) error
UpdateConnectorFunction updates an existing connector function.
func (*Client) UpdateDashboard ¶
UpdateDashboard updates an existing dashboard.
func (*Client) UpdateDatamodel ¶
func (c *Client) UpdateDatamodel(ctx context.Context, orgName, id string, body json.RawMessage) error
UpdateDatamodel updates an existing datamodel.
func (*Client) UpdateDataset ¶
UpdateDataset updates an existing dataset.
func (*Client) UpdateDevice ¶
UpdateDevice updates an existing device.
func (*Client) UpdateJob ¶
func (c *Client) UpdateJob(ctx context.Context, jobID string, body json.RawMessage) (json.RawMessage, error)
UpdateJob updates an existing job (add/remove targets, pause/resume, etc).
func (*Client) UpdateOpType ¶
UpdateOpType updates an existing operation type definition.
func (*Client) UpdateProvisionProcessor ¶
func (c *Client) UpdateProvisionProcessor(ctx context.Context, org, id string, body json.RawMessage) error
UpdateProvisionProcessor updates an existing provision processor.
func (*Client) UpdateRule ¶
func (c *Client) UpdateRule(ctx context.Context, org, channel, id string, body json.RawMessage) error
UpdateRule updates an existing rule.
func (*Client) UpdateTimeSeries ¶
func (c *Client) UpdateTimeSeries(ctx context.Context, orgName, id string, body json.RawMessage) error
UpdateTimeSeries updates an existing time series.
func (*Client) UpdateWorkspace ¶
UpdateWorkspace updates an existing workspace.
func (*Client) UpdateWorkspaceDeep ¶
UpdateWorkspaceDeep is the symmetric in-place variant for re-deploying an existing workspace (post-edit cycle):
- PUT /api/dashboards/{id} for every dashboard with its current body
- PUT /api/workspaces/{id} with the shell + dashboards[] as layout refs
func (*Client) WebSignIn ¶
func (c *Client) WebSignIn(ctx context.Context, req WebSignInRequest) (*WebSignInResult, error)
WebSignIn exchanges the north-API bearer token (already set on the Client) for a Web API JWT. The body fields email/domain/profile/workgroup are all required by the server.
func (*Client) WithWebRefresh ¶
func (c *Client) WithWebRefresh(req WebSignInRequest, onRefresh func(string)) *Client
WithWebRefresh enables transparent re-signin on 401 from the Web API. req carries the credentials needed to call WebSignIn again. onRefresh is called with the new token after a successful refresh so the caller can persist it (typically into ~/.og/config.yaml).
func (*Client) WithWebToken ¶
WithWebToken returns the client with WebToken set. Used for Web API calls.
type ConnectorFunctionSummary ¶
type ConnectorFunctionSummary struct {
Identifier string `json:"identifier,omitempty"`
Name string `json:"name,omitempty"`
ConnectorFunctionName string `json:"connectorFunctionName,omitempty"`
Type string `json:"type,omitempty"` // COLLECTION | REQUEST | RESPONSE
OperationalStatus string `json:"operationalStatus,omitempty"`
OperationName string `json:"operationName,omitempty"`
PayloadType string `json:"payloadType,omitempty"`
Description string `json:"description,omitempty"`
}
ConnectorFunctionSummary extracts key fields from a connector function for display.
The API is inconsistent about the name field: create/update bodies use "name" while list/get responses sometimes echo "connectorFunctionName". We accept both.
func ParseConnectorFunctionSummary ¶
func ParseConnectorFunctionSummary(raw json.RawMessage) ConnectorFunctionSummary
ParseConnectorFunctionSummary extracts display fields from a raw connector function.
func (ConnectorFunctionSummary) DisplayName ¶
func (s ConnectorFunctionSummary) DisplayName() string
DisplayName returns the most reliable name field available.
type DSColumn ¶
type DSColumn struct {
Path string `json:"path"`
Name string `json:"name"`
Filter string `json:"filter,omitempty"`
Sort bool `json:"sort,omitempty"`
Type string `json:"type,omitempty"`
}
DSColumn represents a column in a dataset.
type Dashboard ¶
type Dashboard struct {
ID string `json:"_id,omitempty"`
AltID string `json:"id,omitempty"`
Title string `json:"title"`
Description *string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
IconType string `json:"iconType,omitempty"`
Owner string `json:"owner,omitempty"`
Workspaces string `json:"workspaces,omitempty"`
Users []string `json:"users,omitempty"`
Workgroups []string `json:"workgroups,omitempty"`
AllowedProfiles []string `json:"allowedProfiles,omitempty"`
Domains []string `json:"domains,omitempty"`
LastAccess string `json:"lastAccess,omitempty"`
Editable *bool `json:"editable,omitempty"`
BackgroundImage *string `json:"backgroundImage,omitempty"`
BannerImage *string `json:"bannerImage,omitempty"`
Version int `json:"__v,omitempty"`
ExtraConfig *DashboardExtraConfig `json:"extraConfig,omitempty"`
Grid []GridItem `json:"grid,omitempty"`
TemplateConfig json.RawMessage `json:"templateConfig,omitempty"`
}
Dashboard represents a full OpenGate Web API dashboard. Every dashboard belongs to exactly one workspace, referenced by the Workspaces field.
type DashboardExtraConfig ¶
type DashboardExtraConfig struct {
CellsWidth string `json:"cellsWidth,omitempty"`
CellHeight int `json:"cellHeight,omitempty"`
DashboardRefreshInterval string `json:"dashboardRefreshInterval,omitempty"`
ShowBanner bool `json:"showBanner,omitempty"`
Favourite bool `json:"favourite,omitempty"`
}
DashboardExtraConfig holds display options for a dashboard.
type DashboardSimplified ¶
type DashboardSimplified struct {
ID string `json:"_id,omitempty"`
AltID string `json:"id,omitempty"`
Title string `json:"title"`
Description *string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
IconType string `json:"iconType,omitempty"`
Owner string `json:"owner,omitempty"`
Workspaces string `json:"workspaces,omitempty"`
Users []string `json:"users,omitempty"`
Workgroups []string `json:"workgroups,omitempty"`
AllowedProfiles []string `json:"allowedProfiles,omitempty"`
Domains []string `json:"domains,omitempty"`
LastAccess string `json:"lastAccess,omitempty"`
Editable *bool `json:"editable,omitempty"`
BackgroundImage *string `json:"backgroundImage,omitempty"`
BannerImage *string `json:"bannerImage,omitempty"`
Version int `json:"__v,omitempty"`
ExtraConfig *DashboardExtraConfig `json:"extraConfig,omitempty"`
Grid []GridItem `json:"grid,omitempty"`
TemplateConfig json.RawMessage `json:"templateConfig,omitempty"`
}
DashboardSimplified is the dashboard payload returned inside a workspace's embedded dashboards array. Some endpoints omit the grid (workspaces?full=1), others include it (workspaces/export/{id}). Grid is therefore optional.
type Datamodel ¶
type Datamodel struct {
Identifier string `json:"identifier"`
OrganizationName string `json:"organizationName,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
AllowedResourceTypes []string `json:"allowedResourceTypes,omitempty"`
Categories []Category `json:"categories,omitempty"`
}
Datamodel represents an OpenGate data model.
type Dataset ¶
type Dataset struct {
Identifier string `json:"identifier,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
OrganizationID string `json:"organizationId,omitempty"`
IdentifierColumn string `json:"identifierColumn,omitempty"`
Columns []DSColumn `json:"columns,omitempty"`
}
Dataset represents a dataset definition.
type DatasetDataResponse ¶
type DatasetDataResponse struct {
Columns []string `json:"columns"`
Data [][]any `json:"data"`
Page *Page `json:"page,omitempty"`
}
DatasetDataResponse is the tabular response from the data endpoint.
type DatasetListResponse ¶
type DatasetListResponse struct {
Datasets []Dataset `json:"datasets"`
}
DatasetListResponse is the response from the list endpoint.
type Datastream ¶
type Datastream struct {
Identifier string `json:"identifier"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Period string `json:"period,omitempty"`
Access string `json:"access,omitempty"`
Schema json.RawMessage `json:"schema,omitempty"`
Storage *Storage `json:"storage,omitempty"`
Unit *Unit `json:"unit,omitempty"`
Tags []string `json:"tags,omitempty"`
Modifiable *bool `json:"modifiable,omitempty"`
Calculated *bool `json:"calculated,omitempty"`
Required *bool `json:"required,omitempty"`
QRating json.RawMessage `json:"qrating,omitempty"`
Encryption json.RawMessage `json:"encryption,omitempty"`
Views json.RawMessage `json:"views,omitempty"`
Icon json.RawMessage `json:"icon,omitempty"`
}
Datastream defines a data stream template.
type DeviceSummary ¶
DeviceSummary extracts key fields from a flattened device for display.
func ParseDeviceSummary ¶
func ParseDeviceSummary(raw json.RawMessage) DeviceSummary
ParseDeviceSummary extracts key display fields from a raw flattened device.
type GridItem ¶
type GridItem struct {
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
X int `json:"x"`
Y int `json:"y"`
W int `json:"w"`
H int `json:"h"`
I string `json:"i,omitempty"`
Moved bool `json:"moved,omitempty"`
Definition *WidgetDefinition `json:"definition,omitempty"`
}
GridItem is a single cell in the dashboard grid, holding one widget.
type IoTDatapoint ¶
IoTDatapoint is a single measurement.
type IoTDatastream ¶
type IoTDatastream struct {
ID string `json:"id"`
Feed string `json:"feed,omitempty"`
Datapoints []IoTDatapoint `json:"datapoints"`
}
IoTDatastream is a single datastream with datapoints.
type IoTPayload ¶
type IoTPayload struct {
Version string `json:"version"`
Device string `json:"device,omitempty"`
Datastreams []IoTDatastream `json:"datastreams"`
}
IoTPayload is the body for the data collection endpoint.
type Job ¶
type Job struct {
ID string `json:"id,omitempty"`
TaskID string `json:"taskId,omitempty"`
Request json.RawMessage `json:"request,omitempty"`
Report json.RawMessage `json:"report,omitempty"`
}
Job represents an OpenGate operation job.
type JobBody ¶
type JobBody struct {
Request JobRequest `json:"request"`
}
JobBody wraps a job request.
type JobContainer ¶
type JobContainer struct {
Job JobBody `json:"job"`
}
JobContainer is the top-level body of a job request: {"job":{"request":{...}}}.
type JobOperationsResponse ¶
type JobOperationsResponse struct {
Operations []Operation `json:"operations"`
Page *Page `json:"page,omitempty"`
}
JobOperationsResponse is the response listing operations within a job.
type JobRequest ¶
type JobRequest struct {
// Name is omitted when empty so the same struct can build a PUT, which only
// accepts active, notify, callback, userNotes, schedule.start, schedule.stop
// and target — sending name there risks a "Forbidden field" rejection.
Name string `json:"name,omitempty"`
Active *bool `json:"active,omitempty"`
Notify *bool `json:"notify,omitempty"`
Callback string `json:"callback,omitempty"`
UserNotes string `json:"userNotes,omitempty"`
Parameters json.RawMessage `json:"parameters,omitempty"`
Schedule *JobSchedule `json:"schedule,omitempty"`
OperationParameters *OperationParams `json:"operationParameters,omitempty"`
Target *JobTarget `json:"target,omitempty"`
// Extra carries fields the platform accepts but these structs do not model,
// so a new API field never forces a library change. Its keys are merged into
// the request object and lose to the typed fields on collision.
Extra map[string]json.RawMessage `json:"-"`
}
JobRequest is a job definition.
Active and Notify are pointers on purpose: false is a meaningful value and would vanish under omitempty. Getting that wrong on Active is not a cosmetic bug — a job meant to be created inactive would go live immediately, running the operation on whatever partial target it had at that moment.
func (JobRequest) MarshalJSON ¶
func (r JobRequest) MarshalJSON() ([]byte, error)
MarshalJSON merges Extra into the request object.
func (JobRequest) Validate ¶
func (r JobRequest) Validate() error
Validate checks a job request for the mistakes that only surface against a live platform.
type JobScattering ¶
type JobScattering struct {
MaxSpread int `json:"maxSpread"`
// Strategy is lowercase on the wire. The published schema names it
// "Strategy" with a capital S, but the examples and the running platform use
// "strategy" — a mismatch that only shows up as a silently ignored strategy.
Strategy *JobScatteringStrategy `json:"strategy,omitempty"`
}
JobScattering disperses a job's operations over its effective time.
func DefaultScattering ¶
func DefaultScattering() *JobScattering
DefaultScattering returns the documented-assumption scattering block: spread over 80% of the window, leaving a 20% tail for operations to drain.
func (*JobScattering) Validate ¶
func (s *JobScattering) Validate() error
Validate rejects a scattering configuration that cannot work.
type JobScatteringStrategy ¶
type JobScatteringStrategy struct {
Factor int `json:"factor"`
Field string `json:"field,omitempty"`
WarningMaxRate int `json:"warningMaxRate,omitempty"`
}
JobScatteringStrategy defines how the dispersion is grouped.
type JobSchedule ¶
type JobSchedule struct {
Start *JobScheduleTime `json:"start,omitempty"`
Stop *JobScheduleTime `json:"stop,omitempty"`
Scattering *JobScattering `json:"scattering,omitempty"`
Window json.RawMessage `json:"window,omitempty"`
}
JobSchedule is the scheduling block of a job request.
type JobScheduleTime ¶
type JobScheduleTime struct {
Delayed Millis `json:"delayed,omitempty"`
Date string `json:"date,omitempty"`
}
JobScheduleTime is a schedule bound: a delay or an absolute date.
type JobTarget ¶
type JobTarget struct {
Append *JobTargetSet `json:"append,omitempty"`
Remove *JobTargetSet `json:"remove,omitempty"`
}
JobTarget selects the entities a job acts on.
type JobTargetRejections ¶
type JobTargetRejections struct {
NotProvisioned []string `json:"notProvisioned,omitempty"`
NotAllowed []string `json:"notAllowed,omitempty"`
Duplicated []string `json:"duplicated,omitempty"`
}
JobTargetRejections lists the entities the platform refused to associate with a job. They are reported inside a successful response, so a caller that only checks the status code launches a job on fewer entities than it asked for and never finds out.
func (JobTargetRejections) Empty ¶
func (r JobTargetRejections) Empty() bool
Empty reports whether the platform accepted every entity.
func (JobTargetRejections) Total ¶
func (r JobTargetRejections) Total() int
Total counts every rejected entity.
type JobTargetSet ¶
type JobTargetSet struct {
Entities []string `json:"entities,omitempty"`
Tags []string `json:"tags,omitempty"`
}
JobTargetSet is a set of entities or tags. Entities and tags cannot be mixed.
type LaunchOptions ¶
type LaunchOptions struct {
// BatchSize caps each append; it is clamped to MaxJobTargetEntities.
BatchSize int
// OnProgress, when set, is called after the job is created — before the
// first batch, so the id can be persisted and a restart can resume — and
// after every batch.
OnProgress func(LaunchProgress)
}
LaunchOptions configures LaunchJob.
type LaunchProgress ¶
type LaunchProgress struct {
JobID string `json:"jobId"`
Appended int `json:"appended"` // entities appended so far
Total int `json:"total"` // entities requested
Batch int `json:"batch"` // 1-based batch number, 0 for the creation step
Active bool `json:"active"`
}
LaunchProgress reports the state of a batched launch.
type LaunchResult ¶
type LaunchResult struct {
JobID string `json:"jobId"`
Appended int `json:"appended"`
Rejected JobTargetRejections `json:"rejected,omitzero"`
}
LaunchResult reports the outcome of a batched launch.
type ListConnectorFunctionsResponse ¶
type ListConnectorFunctionsResponse struct {
ConnectorFunctions []json.RawMessage `json:"connectorFunctions"`
}
ListConnectorFunctionsResponse is the response from the connector functions list endpoint.
type ListProvisionProcessorsResponse ¶
type ListProvisionProcessorsResponse struct {
ProvisionProcessors []json.RawMessage `json:"provisionProcessors"`
Processors []json.RawMessage `json:"processors"`
}
ListProvisionProcessorsResponse is the response from the provision processors list endpoint. The API is inconsistent about the array key: the schema names it "processors" while live responses use "provisionProcessors" — we accept both.
func (*ListProvisionProcessorsResponse) Items ¶
func (r *ListProvisionProcessorsResponse) Items() []json.RawMessage
Items returns whichever array the API populated.
type LogMessage ¶
type LogMessage struct {
Message string `json:"message"`
Level string `json:"level"`
Timestamp int64 `json:"timestamp"` // UTC milliseconds
}
LogMessage is a single trace emitted by the functions-logger WebSocket.
type LoginRequest ¶
type LoginRequest struct {
Email string `json:"email"`
Password string `json:"password"`
TwoFaCode string `json:"2FaCode,omitempty"`
}
LoginRequest holds credentials for JWT authentication.
type LoginResponse ¶
type LoginResponse struct {
User LoginUser `json:"user"`
}
LoginResponse holds the response from the login endpoint.
type LoginResult ¶
LoginResult holds the credentials returned by a successful login.
type LoginUser ¶
type LoginUser struct {
Email string `json:"email"`
Name string `json:"name"`
Surname string `json:"surname"`
JWT string `json:"jwt"`
APIKey string `json:"apiKey"`
Profile string `json:"profile"`
Domain string `json:"domain"`
TwoFaType string `json:"2FaType"` // "TOTP" when 2FA is enabled, "NONE" otherwise
}
LoginUser holds user info returned after login.
type MQTTClient ¶
type MQTTClient struct {
// contains filtered or unexported fields
}
MQTTClient is a thin wrapper over the paho MQTT client for the OpenGate South plane. Authentication uses username = device id, password = API key.
func NewMQTTClient ¶
func NewMQTTClient(host string, port int, useTLS, insecure bool, caFile, deviceID, apiKey string) (*MQTTClient, error)
NewMQTTClient connects to the OpenGate MQTT broker as the given device. useTLS switches to ssl:// (default TLS port when port is 0/default plaintext). The broker presents a public Let's Encrypt chain, so TLS verifies against the system root store by default. insecure skips verification entirely (escape hatch). caFile, when set, supplies an extra CA/chain PEM (e.g. for a site whose broker still omits the intermediate) appended to the system pool.
func (*MQTTClient) Disconnect ¶
func (m *MQTTClient) Disconnect()
Disconnect cleanly closes the connection.
type Millis ¶
type Millis int64
Millis is a duration in milliseconds.
It marshals as a JSON number, which is what the platform schema declares and what the jobs this client already launches successfully use. It unmarshals from either a number or a string, because quoted values have been reported in the wild and a type error on a response would be a pointless failure.
func (Millis) MarshalJSON ¶
func (*Millis) UnmarshalJSON ¶
type OpTypeSummary ¶
type OpTypeSummary struct {
Name string `json:"name,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
ApplicableTo []string `json:"applicableTo,omitempty"`
FromCatalog string `json:"fromCatalog,omitempty"`
}
OpTypeSummary extracts key fields from an operation type for display.
func ParseOpTypeSummary ¶
func ParseOpTypeSummary(raw json.RawMessage) OpTypeSummary
ParseOpTypeSummary extracts display fields from a raw operation type.
type Operation ¶
type Operation struct {
OperationID string `json:"operationId,omitempty"`
JobID string `json:"jobId,omitempty"`
Name string `json:"name,omitempty"`
EntityID string `json:"entityId,omitempty"`
ResourceType string `json:"resourceType,omitempty"`
Status string `json:"status,omitempty"`
Result string `json:"result,omitempty"`
Description string `json:"description,omitempty"`
User string `json:"user,omitempty"`
// Notify has no omitempty: a false value must stay visible in the output
// rather than looking like a field the platform never sent.
Notify bool `json:"notify"`
Date string `json:"date,omitempty"`
Attempts *OperationAttempts `json:"attempts,omitempty"`
Execution *OperationExecution `json:"execution,omitempty"`
Steps []OperationStep `json:"steps,omitempty"`
Parameters json.RawMessage `json:"parameters,omitempty"`
}
Operation is a single operation executed on one entity, as returned by the per-job operations listing and by the operations history search.
Status is the lifecycle state (e.g. FINISHED) and Result the outcome (e.g. SUCCESSFUL); Steps carries the per-step detail.
type OperationAttempts ¶
type OperationAttempts struct {
Current int `json:"current,omitempty"`
Total int `json:"total,omitempty"`
}
OperationAttempts counts an operation's delivery attempts.
type OperationExecution ¶
type OperationExecution struct {
ActivatedDate string `json:"activatedDate,omitempty"`
StartedDate string `json:"startedDate,omitempty"`
FinishedDate string `json:"finishedDate,omitempty"`
}
OperationExecution holds an operation's execution timestamps.
type OperationParams ¶
type OperationParams struct {
Timeout Millis `json:"timeout,omitempty"`
AckTimeout Millis `json:"ackTimeout,omitempty"`
Retries *int `json:"retries,omitempty"`
RetriesDelay Millis `json:"retriesDelay,omitempty"`
RetryResultList []string `json:"retryResultList,omitempty"`
}
OperationParams configures the operation sent to each target.
Retries is a pointer because 0 — do not retry — is both meaningful and the value you usually want on unreachable devices, where a retry only doubles the wall-clock to reach the same answer.
type OperationRequest ¶
type OperationRequest struct {
Operation struct {
Request struct {
Timestamp int64 `json:"timestamp"`
Name string `json:"name"`
Parameters map[string]any `json:"parameters"`
ID string `json:"id"`
} `json:"request"`
} `json:"operation"`
}
OperationRequest is the message OpenGate publishes to odm/request/{deviceId}.
func ParseOperationRequest ¶
func ParseOperationRequest(payload []byte) (*OperationRequest, error)
ParseOperationRequest decodes an odm/request payload.
type OperationStep ¶
type OperationStep struct {
Name string `json:"name,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Result string `json:"result,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Response json.RawMessage `json:"response,omitempty"`
}
OperationStep is one step of an operation's execution.
Result is the step's outcome — note the field is result, not status; status belongs to the Operation. Names are operation-specific: a DIAGNOSIS reports PROVISION, PRESENCE, MODEM and REGISTER, while a REBOOT_EQUIPMENT reports REBOOT, so this is deliberately a plain string and not an enumeration.
type Option ¶
type Option func(*clientOptions)
Option configures a Client at construction time. Options are applied in order, so a later one wins over an earlier one.
func WithAPIKey ¶
WithAPIKey authenticates North API calls with an API key (X-ApiKey header) instead of the JWT bearer token. An API key does not expire, which makes it the right credential for a service account driving long-running work: a JWT obtained at start-up may well be dead by the time a deferred phase runs.
It takes precedence over the token passed to New.
func WithAPIVersion ¶
WithAPIVersion overrides the North API version segment (default "v80"), for talking to an on-premises instance pinned to another version.
func WithHTTPClient ¶
WithHTTPClient makes the client use hc for every HTTP call. Use it to control connection pooling and timeouts, to install instrumentation, or to point the client at a test server's transport.
It takes precedence over WithTLS: when both are given, hc's own transport is used as-is and the TLS settings are ignored.
func WithRetry ¶
func WithRetry(p RetryPolicy) Option
WithRetry retries rate-limited and failing requests with exponential backoff and jitter, honouring a Retry-After header when the server sends one.
Pass DefaultRetryPolicy() for the recommended settings. Only requests that cannot gain an effect by being repeated are retried after a 5xx — see RetryPolicy, which explains why creating a job is not one of them.
Retrying is OFF unless this option is given: a library must not silently multiply a caller's write.
func WithTLS ¶
WithTLS sets the TLS behaviour of this client only, leaving other clients in the process untouched. insecure skips server certificate verification entirely — the escape hatch for self-signed certs. caFile, when non-empty, appends an extra CA/chain PEM to the system pool.
A bad caFile is reported by Err and by every request the client makes.
func WithoutRetry ¶
func WithoutRetry() Option
WithoutRetry disables retrying explicitly. It is the default, and exists so a caller can be unambiguous about it.
type Page ¶
Page is the pagination block OpenGate returns alongside search results.
Number is the 1-based index of the page being returned. Of is the total number of pages, but **not every endpoint reports it** — the alarms search documents only number — so treat Of == 0 as "unknown" rather than "no pages".
type ProvisionProcessorSummary ¶
type ProvisionProcessorSummary struct {
ProvisionProcessorID string `json:"provisionProcessorId,omitempty"`
Name string `json:"name,omitempty"`
SheetName string `json:"-"`
HeaderRow string `json:"-"`
ResultColumnName string `json:"-"`
}
ProvisionProcessorSummary extracts key fields from a provision processor for display.
A provision processor has no status field. Its identifier is provisionProcessorId (not "identifier"), and its spreadsheet config is nested under configurationParams.spreadsheet.
func ParseProvisionProcessorSummary ¶
func ParseProvisionProcessorSummary(raw json.RawMessage) ProvisionProcessorSummary
ParseProvisionProcessorSummary extracts display fields from a raw provision processor.
type RetryPolicy ¶
type RetryPolicy struct {
// Attempts is the total number of tries, not the number of retries. 1 or
// less means no retrying.
Attempts int
// Base is the first backoff delay; it doubles each attempt.
Base time.Duration
// MaxDelay caps a single wait, including one derived from Retry-After.
MaxDelay time.Duration
// RetryNonIdempotent allows retrying 5xx and transport failures on requests
// that may have already changed something — creating a job, launching an
// operation, running a bulk provision.
//
// Leave it off. A 500 does not say whether the server acted before failing,
// so retrying a create can produce two jobs, and an operation already sent
// to a device cannot be recalled. HTTP 429 is retried regardless, because a
// rate-limited request was by definition not processed.
RetryNonIdempotent bool
}
RetryPolicy configures automatic retries.
The zero value disables retrying. Use DefaultRetryPolicy for the recommended settings, or WithoutRetry to turn it off explicitly.
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() RetryPolicy
DefaultRetryPolicy returns the recommended policy: three attempts with exponential backoff and jitter, honouring Retry-After, and no retrying of requests that may have already had an effect.
type RuleSummary ¶
type RuleSummary struct {
Identifier string `json:"identifier,omitempty"`
Name string `json:"name,omitempty"`
Mode string `json:"mode,omitempty"` // EASY | ADVANCED
Active bool `json:"active,omitempty"`
Description string `json:"description,omitempty"`
ChannelID string `json:"channelId,omitempty"`
OrgID string `json:"organizationId,omitempty"`
Type json.RawMessage `json:"type,omitempty"`
}
RuleSummary extracts key fields from a rule for display.
func ParseRuleSummary ¶
func ParseRuleSummary(raw json.RawMessage) RuleSummary
ParseRuleSummary extracts display fields from a raw rule.
func (RuleSummary) RuleTriggerName ¶
func (r RuleSummary) RuleTriggerName() string
RuleTriggerName extracts the trigger type name (DATASTREAM, EVENT, OPERATION) from a rule's type field.
type SearchAlarmsResponse ¶
type SearchAlarmsResponse struct {
Alarms []Alarm `json:"alarms"`
Page *Page `json:"page,omitempty"`
}
SearchAlarmsResponse is the response from the alarms search endpoint.
type SearchDatamodelsResponse ¶
type SearchDatamodelsResponse struct {
Datamodels []Datamodel `json:"datamodels"`
Page *Page `json:"page,omitempty"`
}
SearchDatamodelsResponse is the response from the search endpoint.
type SearchDevicesResponse ¶
type SearchDevicesResponse struct {
Devices []json.RawMessage `json:"devices"`
Page *Page `json:"page,omitempty"`
}
SearchDevicesResponse is the response from the devices search endpoint.
type SearchJobsResponse ¶
type SearchJobsResponse struct {
Jobs []json.RawMessage `json:"jobs"`
Page *Page `json:"page,omitempty"`
}
SearchJobsResponse is the response from the jobs search endpoint.
type SearchOperationsResponse ¶
type SearchOperationsResponse struct {
Operations []Operation `json:"operations"`
Page *Page `json:"page,omitempty"`
Summary json.RawMessage `json:"summary,omitempty"`
}
SearchOperationsResponse is the response from the operations history search.
type SearchRulesResponse ¶
type SearchRulesResponse struct {
Rules []json.RawMessage `json:"rules"`
Page *Page `json:"page,omitempty"`
}
SearchRulesResponse is the response from the rules search endpoint.
type SearchTasksResponse ¶
type SearchTasksResponse struct {
Tasks []json.RawMessage `json:"tasks"`
Page *Page `json:"page,omitempty"`
}
SearchTasksResponse is the response from the tasks search endpoint.
type ShareRequest ¶
type ShareRequest struct {
}
ShareRequest is the body of the workspace/dashboard share endpoints. The PUT REPLACES both lists; empty lists unshare. (Captured live from the web UI — the wapi spec documents the endpoints without a body schema.)
type TSColumn ¶
type TSColumn struct {
Path string `json:"path"`
Name string `json:"name"`
Filter string `json:"filter,omitempty"`
Type string `json:"type,omitempty"`
AggregationFunction string `json:"aggregationFunction,omitempty"`
}
TSColumn represents a context or data column in a time series.
type TSSort ¶
type TSSort struct {
Identifier string `json:"identifier"`
Columns []TSSortColumn `json:"columns"`
}
TSSort represents a sort definition.
type TSSortColumn ¶
TSSortColumn is a column reference within a sort.
type Task ¶
type Task struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
State string `json:"state,omitempty"`
Domain string `json:"domain,omitempty"`
Workgroup string `json:"workgroup,omitempty"`
Schedule json.RawMessage `json:"schedule,omitempty"`
Job json.RawMessage `json:"job,omitempty"`
}
Task represents an OpenGate operation task.
type TimeSeries ¶
type TimeSeries struct {
Identifier string `json:"identifier,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
OrganizationID string `json:"organizationId,omitempty"`
TimeBucket int `json:"timeBucket,omitempty"`
Retention int `json:"retention,omitempty"`
Origin string `json:"origin,omitempty"`
BucketColumn string `json:"bucketColumn,omitempty"`
BucketInitColumn string `json:"bucketInitColumn,omitempty"`
IdentifierColumn string `json:"identifierColumn,omitempty"`
Context []TSColumn `json:"context,omitempty"`
Columns []TSColumn `json:"columns,omitempty"`
Sorts []TSSort `json:"sorts,omitempty"`
}
TimeSeries represents a time series definition.
type TimeSeriesDataResponse ¶
type TimeSeriesDataResponse struct {
Columns []string `json:"columns"`
Data [][]any `json:"data"`
Page *Page `json:"page,omitempty"`
}
TimeSeriesDataResponse is the tabular response from the data endpoint.
type TimeSeriesListResponse ¶
type TimeSeriesListResponse struct {
Timeseries []TimeSeries `json:"timeseries"`
}
TimeSeriesListResponse is the response from the list endpoint.
type Unit ¶
type Unit struct {
Type string `json:"type,omitempty"`
Label string `json:"label,omitempty"`
Symbol string `json:"symbol,omitempty"`
}
Unit describes measurement units.
type WebSignInRequest ¶
type WebSignInRequest struct {
Email string `json:"email"`
Domain string `json:"domain"`
Profile string `json:"profile"`
Workgroup string `json:"workgroup"`
}
WebSignInRequest is the body sent to /api/auth/signin/internal.
type WebSignInResult ¶
type WebSignInResult struct {
JWT string `json:"jwt"`
Email string `json:"email"`
Domain string `json:"domain"`
Profile string `json:"profile"`
Workgroup string `json:"workgroup"`
}
WebSignInResult holds the credentials returned by a successful web signin.
type WidgetDefinition ¶
type WidgetDefinition struct {
Type string `json:"type,omitempty"`
Ftype string `json:"Ftype,omitempty"`
Wid string `json:"wid,omitempty"`
Config json.RawMessage `json:"config,omitempty"`
}
WidgetDefinition describes the widget rendered in a grid cell.
Ftype is an OpenGate platform field paired with Type: Type is the visual component (e.g. FullDevicesList, OperationsList) and Ftype is its data domain (entities, jobs, operations, alarms). og does not interpret it — it is preserved verbatim so the unwrap → wrap → import round-trip keeps the widget's data-source binding intact.
type Workspace ¶
type Workspace struct {
ID string `json:"_id,omitempty"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Owner string `json:"owner,omitempty"`
Image *string `json:"image,omitempty"`
Icon string `json:"icon,omitempty"`
Users []string `json:"users,omitempty"`
Domains []string `json:"domains,omitempty"`
Workgroups []string `json:"workgroups,omitempty"`
Actions []string `json:"actions,omitempty"`
Widgets []string `json:"widgets,omitempty"`
WidgetAction map[string]string `json:"widget_action,omitempty"`
AllowedProfiles []string `json:"allowedProfiles,omitempty"`
Dashboards []WorkspaceDashboard `json:"dashboards,omitempty"`
Priority int `json:"priority,omitempty"`
Color string `json:"color,omitempty"`
LastAccess string `json:"lastAccess,omitempty"`
Editable *bool `json:"editable,omitempty"`
Version int `json:"__v,omitempty"`
EditMode *bool `json:"_editMode,omitempty"`
Others *WorkspaceOthers `json:"others,omitempty"`
Menu []WorkspaceMenuItem `json:"menu,omitempty"`
MenuTree map[string]WorkspaceMenuCategory `json:"menu_tree,omitempty"`
}
Workspace represents an OpenGate Web API workspace. A workspace groups dashboards together and is the top-level container in the UI configuration hierarchy (workspace 1 → N dashboards).
type WorkspaceDashboard ¶
type WorkspaceDashboard struct {
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
W int `json:"w"`
H int `json:"h"`
I string `json:"i,omitempty"`
Moved bool `json:"moved,omitempty"`
ID string `json:"id,omitempty"`
MongoID string `json:"_id,omitempty"`
Dashboard *DashboardSimplified `json:"dashboard,omitempty"`
}
WorkspaceDashboard is a dashboard embedded inside a workspace (with grid layout).
type WorkspaceMenuCategory ¶
type WorkspaceMenuCategory struct {
Config *WorkspaceMenuCfg `json:"config,omitempty"`
Actions []WorkspaceMenuItem `json:"actions,omitempty"`
}
WorkspaceMenuCategory groups menu items under a category.
type WorkspaceMenuCfg ¶
type WorkspaceMenuCfg struct {
Icon string `json:"icon,omitempty"`
Title string `json:"title,omitempty"`
}
WorkspaceMenuCfg describes the parent menu group config.
type WorkspaceMenuItem ¶
type WorkspaceMenuItem struct {
Title string `json:"title,omitempty"`
Action string `json:"action,omitempty"`
Permission string `json:"permission,omitempty"`
Icon string `json:"icon,omitempty"`
Menu string `json:"menu,omitempty"`
MenuCfg *WorkspaceMenuCfg `json:"menuCfg,omitempty"`
}
WorkspaceMenuItem is an action entry in the workspace side menu.
type WorkspaceOthers ¶
type WorkspaceOthers struct {
ShowInHome bool `json:"showInHome,omitempty"`
Mode string `json:"mode,omitempty"`
BannerImage *string `json:"bannerImage,omitempty"`
}
WorkspaceOthers holds workspace display options.