MCPcopy
hub / github.com/crowdsecurity/crowdsec / QueryMachineByID

Method QueryMachineByID

pkg/database/machines.go:117–128  ·  view source on GitHub ↗
(ctx context.Context, machineID string)

Source from the content-addressed store, hash-verified

115}
116
117func (c *Client) QueryMachineByID(ctx context.Context, machineID string) (*ent.Machine, error) {
118 machine, err := c.Ent.Machine.
119 Query().
120 Where(machine.MachineIdEQ(machineID)).
121 Only(ctx)
122 if err != nil {
123 c.Log.Warningf("QueryMachineByID : %s", err)
124 return &ent.Machine{}, fmt.Errorf("user '%s': %w", machineID, UserNotExists)
125 }
126
127 return machine, nil
128}
129
130func (c *Client) ListMachines(ctx context.Context) ([]*ent.Machine, error) {
131 machines, err := c.Ent.Machine.Query().All(ctx)

Callers 4

CreateAlertMethod · 0.95
CreateMachineMethod · 0.95
TestLPMetricsFunction · 0.95
newInspectCmdMethod · 0.80

Calls 4

MachineIdEQFunction · 0.92
OnlyMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45

Tested by 1

TestLPMetricsFunction · 0.76