コード例 #1
0
ファイル: agents.go プロジェクト: iwarsong/bearded
func (m *AgentManager) Create(raw *agent.Agent) (*agent.Agent, error) {
	// TODO (m0sth8): add validattion
	raw.Id = bson.NewObjectId()
	raw.Created = time.Now().UTC()
	raw.Updated = raw.Created
	if err := m.col.Insert(raw); err != nil {
		return nil, err
	}
	return raw, nil
}
コード例 #2
0
ファイル: agent.go プロジェクト: iwarsong/bearded
func (a *Agent) Retrieve(ctx context.Context, agnt *agent.Agent) error {
	logrus.Info("Retrieve")
	if agnt.Id == "" {
		agnt.Status = agent.StatusUndefined
		return fmt.Errorf("ageng.Id shouldn't be empty")
	}
	got, err := a.api.Agents.Get(ctx, client.FromId(agnt.Id))
	if err != nil {
		return err
	}
	*agnt = *got
	return nil
}
コード例 #3
0
ファイル: agents.go プロジェクト: iwarsong/bearded
func (m *AgentManager) Update(obj *agent.Agent) error {
	obj.Updated = time.Now().UTC()
	return m.col.UpdateId(obj.Id, obj)
}