Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ start.
| ------- | ----------------------------------------------------- | ----------------------------- | ------------------------------------ |
| Node | Hostname, disk, memory, load, uptime, OS info, status | [docs](docs/osapi/node.md) | [`node.go`](pkg/osapi/node.go) |
| Network | DNS get/update, ping | [docs](docs/osapi/node.md) | [`node.go`](pkg/osapi/node.go) |
| File | Upload, list, get, delete, deploy, status | [docs](docs/osapi/file.md) | [`file.go`](pkg/osapi/file.go) |
| File | Upload, changed, list, get, delete, deploy, status | [docs](docs/osapi/file.md) | [`file.go`](pkg/osapi/file.go) |
| Command | exec, shell | [docs](docs/osapi/node.md) | [`node.go`](pkg/osapi/node.go) |
| Job | Create, get, list, delete, retry, stats | [docs](docs/osapi/job.md) | [`job.go`](pkg/osapi/job.go) |
| Agent | List, get (discovery + heartbeat data) | [docs](docs/osapi/agent.md) | [`agent.go`](pkg/osapi/agent.go) |
Expand Down Expand Up @@ -101,7 +101,7 @@ Each example is a standalone Go program you can read and run.
| [agent](examples/osapi/agent/main.go) | Agent discovery, details, and facts |
| [audit](examples/osapi/audit/main.go) | Audit log listing, get, and export |
| [command](examples/osapi/command/main.go) | Command exec and shell execution |
| [file](examples/osapi/file/main.go) | File upload, deploy, status, and delete |
| [file](examples/osapi/file/main.go) | File upload, changed, force, deploy, status, delete |
| [health](examples/osapi/health/main.go) | Liveness, readiness, and status checks |
| [job](examples/osapi/job/main.go) | Job create, get, list, delete, and retry |
| [metrics](examples/osapi/metrics/main.go) | Prometheus metrics retrieval |
Expand All @@ -115,7 +115,7 @@ Each example is a standalone Go program you can read and run.
| [basic](examples/orchestration/basic/main.go) | Simple DAG with dependencies |
| [broadcast](examples/orchestration/broadcast/main.go) | Multi-target operations with per-host results |
| [error-strategy](examples/orchestration/error-strategy/main.go) | StopAll vs Continue error handling |
| [file-deploy](examples/orchestration/file-deploy/main.go) | Upload, deploy template, verify status |
| [file-deploy](examples/orchestration/file-deploy/main.go) | Upload template, deploy with vars, verify status |
| [guards](examples/orchestration/guards/main.go) | When predicates for conditional execution |
| [hooks](examples/orchestration/hooks/main.go) | Lifecycle callbacks for logging and progress |
| [only-if-changed](examples/orchestration/only-if-changed/main.go) | Skip tasks when dependencies report no changes |
Expand Down
639 changes: 329 additions & 310 deletions docs/gen/gen.md

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions docs/gen/osapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ resp, err := client.Node.Exec(ctx, osapi.ExecRequest{
- [func \(e \*NotFoundError\) Unwrap\(\) error](<#NotFoundError.Unwrap>)
- [type OSInfo](<#OSInfo>)
- [type OSInfoResult](<#OSInfoResult>)
- [type ObjectStoreInfo](<#ObjectStoreInfo>)
- [type Option](<#Option>)
- [func WithHTTPTransport\(transport http.RoundTripper\) Option](<#WithHTTPTransport>)
- [func WithLogger\(logger \*slog.Logger\) Option](<#WithLogger>)
Expand Down Expand Up @@ -289,7 +290,7 @@ type AgentState struct {
```

<a name="AgentStats"></a>
## type [AgentStats](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L65-L69>)
## type [AgentStats](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L66-L70>)

AgentStats represents agent statistics from the health endpoint.

Expand All @@ -302,7 +303,7 @@ type AgentStats struct {
```

<a name="AgentSummary"></a>
## type [AgentSummary](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L72-L76>)
## type [AgentSummary](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L73-L77>)

AgentSummary represents a summary of an agent from the health endpoint.

Expand Down Expand Up @@ -475,7 +476,7 @@ type CommandResult struct {
```

<a name="ComponentHealth"></a>
## type [ComponentHealth](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L53-L56>)
## type [ComponentHealth](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L54-L57>)

ComponentHealth represents a component's health.

Expand Down Expand Up @@ -521,7 +522,7 @@ func (e *ConflictError) Unwrap() error
Unwrap returns the underlying APIError.

<a name="ConsumerDetail"></a>
## type [ConsumerDetail](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L95-L100>)
## type [ConsumerDetail](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L96-L101>)

ConsumerDetail represents a single consumer's details.

Expand All @@ -535,7 +536,7 @@ type ConsumerDetail struct {
```

<a name="ConsumerStats"></a>
## type [ConsumerStats](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L89-L92>)
## type [ConsumerStats](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L90-L93>)

ConsumerStats represents JetStream consumer statistics.

Expand Down Expand Up @@ -999,7 +1000,7 @@ func (s *JobService) Retry(ctx context.Context, id string, target string) (*Resp
Retry retries a failed job by ID, optionally on a different target.

<a name="JobStats"></a>
## type [JobStats](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L79-L86>)
## type [JobStats](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L80-L87>)

JobStats represents job queue statistics from the health endpoint.

Expand All @@ -1015,7 +1016,7 @@ type JobStats struct {
```

<a name="KVBucketInfo"></a>
## type [KVBucketInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L111-L115>)
## type [KVBucketInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L112-L116>)

KVBucketInfo represents a KV bucket's info.

Expand Down Expand Up @@ -1130,7 +1131,7 @@ func (s *MetricsService) Get(ctx context.Context) (string, error)
Get fetches the raw Prometheus metrics text from the /metrics endpoint.

<a name="NATSInfo"></a>
## type [NATSInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L59-L62>)
## type [NATSInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L60-L63>)

NATSInfo represents NATS connection info.

Expand Down Expand Up @@ -1355,6 +1356,18 @@ type OSInfoResult struct {
}
```

<a name="ObjectStoreInfo"></a>
## type [ObjectStoreInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L119-L122>)

ObjectStoreInfo represents an Object Store bucket's info.

```go
type ObjectStoreInfo struct {
Name string
Size int
}
```

<a name="Option"></a>
## type [Option](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/osapi.go#L76>)

Expand Down Expand Up @@ -1516,7 +1529,7 @@ type ShellRequest struct {
```

<a name="StreamInfo"></a>
## type [StreamInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L103-L108>)
## type [StreamInfo](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L104-L109>)

StreamInfo represents a JetStream stream's info.

Expand All @@ -1530,7 +1543,7 @@ type StreamInfo struct {
```

<a name="SystemStatus"></a>
## type [SystemStatus](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L38-L50>)
## type [SystemStatus](<https://github.com/osapi-io/osapi-sdk/blob/main/pkg/osapi/health_types.go#L38-L51>)

SystemStatus represents detailed system status.

Expand All @@ -1547,6 +1560,7 @@ type SystemStatus struct {
Consumers *ConsumerStats
Streams []StreamInfo
KVBuckets []KVBucketInfo
ObjectStores []ObjectStoreInfo
}
```

Expand Down
19 changes: 19 additions & 0 deletions pkg/osapi/gen/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,20 @@ components:
- name
- keys
- bytes
ObjectStoreInfo:
type: object
properties:
name:
type: string
description: Object Store bucket name.
example: file-objects
size:
type: integer
description: Total bytes in the store.
example: 5242880
required:
- name
- size
JobStats:
type: object
properties:
Expand Down Expand Up @@ -2415,6 +2429,11 @@ components:
items:
$ref: '#/components/schemas/KVBucketInfo'
description: KV bucket statistics.
object_stores:
type: array
items:
$ref: '#/components/schemas/ObjectStoreInfo'
description: Object Store statistics.
jobs:
$ref: '#/components/schemas/JobStats'
agents:
Expand Down
12 changes: 12 additions & 0 deletions pkg/osapi/gen/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pkg/osapi/health_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type SystemStatus struct {
Consumers *ConsumerStats
Streams []StreamInfo
KVBuckets []KVBucketInfo
ObjectStores []ObjectStoreInfo
}

// ComponentHealth represents a component's health.
Expand Down Expand Up @@ -114,6 +115,12 @@ type KVBucketInfo struct {
Bytes int
}

// ObjectStoreInfo represents an Object Store bucket's info.
type ObjectStoreInfo struct {
Name string
Size int
}

// healthStatusFromGen converts a gen.HealthResponse to a HealthStatus.
func healthStatusFromGen(
g *gen.HealthResponse,
Expand Down Expand Up @@ -263,5 +270,17 @@ func systemStatusFromGen(
s.KVBuckets = buckets
}

if g.ObjectStores != nil {
stores := make([]ObjectStoreInfo, 0, len(*g.ObjectStores))
for _, o := range *g.ObjectStores {
stores = append(stores, ObjectStoreInfo{
Name: o.Name,
Size: o.Size,
})
}

s.ObjectStores = stores
}

return s
}
11 changes: 11 additions & 0 deletions pkg/osapi/health_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ func (suite *HealthTypesTestSuite) TestSystemStatusFromGen() {
Bytes: 2097152,
},
},
ObjectStores: &[]gen.ObjectStoreInfo{
{
Name: "file-objects",
Size: 5242880,
},
},
}
}(),
serviceUnavailable: false,
Expand Down Expand Up @@ -246,6 +252,10 @@ func (suite *HealthTypesTestSuite) TestSystemStatusFromGen() {
suite.Equal("audit-log", s.KVBuckets[1].Name)
suite.Equal(200, s.KVBuckets[1].Keys)
suite.Equal(2097152, s.KVBuckets[1].Bytes)

suite.Require().Len(s.ObjectStores, 1)
suite.Equal("file-objects", s.ObjectStores[0].Name)
suite.Equal(5242880, s.ObjectStores[0].Size)
},
},
{
Expand All @@ -269,6 +279,7 @@ func (suite *HealthTypesTestSuite) TestSystemStatusFromGen() {
suite.Nil(s.Consumers)
suite.Nil(s.Streams)
suite.Nil(s.KVBuckets)
suite.Nil(s.ObjectStores)
},
},
{
Expand Down