| 137 | } |
| 138 | |
| 139 | func (c *Client) ValidateMachine(ctx context.Context, machineID string) error { |
| 140 | rets, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetIsValidated(true).Save(ctx) |
| 141 | if err != nil { |
| 142 | return fmt.Errorf("validating machine: %w: %w", err, UpdateFail) |
| 143 | } |
| 144 | |
| 145 | if rets == 0 { |
| 146 | return errors.New("machine not found") |
| 147 | } |
| 148 | |
| 149 | return nil |
| 150 | } |
| 151 | |
| 152 | func (c *Client) QueryPendingMachine(ctx context.Context) ([]*ent.Machine, error) { |
| 153 | machines, err := c.Ent.Machine.Query().Where(machine.IsValidatedEQ(false)).All(ctx) |