Skip to content
Draft
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
9 changes: 9 additions & 0 deletions machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ type MachineEvent struct {
Timestamp int64 `json:"timestamp,omitempty"`
}

type GqlMachineEvent struct {
Kind string `json:"kind,omitempty"`
Status string `json:"status,omitempty"`
Source string `json:"source,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
Body map[string]interface{} `json:"body,omitempty"`
MachineVersion map[string]string `json:"machineVersion,omitempty"`
}

func (e *MachineEvent) Time() time.Time {
return time.Unix(e.Timestamp/1000, e.Timestamp%1000*1000000)
}
Expand Down
33 changes: 33 additions & 0 deletions resource_machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,36 @@ func (client *Client) GetMachine(ctx context.Context, machineId string) (*GqlMac

return &data.GqlMachine, nil
}

func (client *Client) GetMachineWithEvents(ctx context.Context, machineId string) (*GqlMachine, error) {
query := `
query ($machineId: String!) {
gqlmachine:machine(machineId: $machineId) {
instanceId
events {
nodes {
body
kind
machineVersion {
id
}
source
status
timestamp
}
}
}
}
`

req := client.NewRequest(query)
req.Var("machineId", machineId)
ctx = ctxWithAction(ctx, "get_machine_with_events")

data, err := client.RunWithContext(ctx, req)
if err != nil {
return nil, err
}

return &data.GqlMachine, nil
}
4 changes: 4 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,10 @@ type GqlMachine struct {
IPs struct {
Nodes []*MachineIP
}

Events struct {
Nodes []*GqlMachineEvent
}
}

type Logger interface {
Expand Down