// Return Interval Action(s) by interval name
// UnexpectedError - failed to retrieve interval actions from the database
// Sort the interval actions in descending order by ID
769273
func (mc MongoClient) IntervalActionsByIntervalName(name string) ([]contract.IntervalAction, error) {
	return mapIntervalActions(mc.getIntervalActions(bson.M{"interval": name}))
}
586986
func PruneActions(st *State, maxHistoryTime time.Duration, maxHistoryMB int) error {
	err := pruneCollection(st, maxHistoryTime, maxHistoryMB, actionsC, "completed", GoTime)
	return errors.Trace(err)
}
912508
func (c *ServicedCli) serviceActions(id string) (data []string) {
	svc, err := c.driver.GetService(id)
	if err != nil || svc == nil {
		c.exit(1)
		return
	}

	data = make([]string, len(svc.Actions))
	i := 0
	for a := range svc.Actions {
		data[i] = a
		i++
	}

	return
}
25063
func (t *Template) GetAWSAutoScalingScheduledActionWithName(name string) (*resources.AWSAutoScalingScheduledAction, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAutoScalingScheduledAction:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAutoScalingScheduledAction not found", name)
}
693431
func (l *List) GetActions(args Arguments) (actions ActionCollection, err error) {
	path := fmt.Sprintf("lists/%s/actions", l.ID)
	err = l.client.Get(path, args, &actions)
	return
}
291351
func (b *IrcBot) GetActionnersCmds() []string {
	var cmds []string
	for cmd, _ := range b.handlersUser {
		fmt.Println(cmd)
		cmds = append(cmds, cmd)
	}
	return cmds
}
1067353
func (mc MongoClient) IntervalsWithLimit(limit int) ([]contract.Interval, error) {
	return mapIntervals(mc.getIntervalsLimit(bson.M{}, limit))
}
626882
func addIntervalToSchedulerDB(interval contract.Interval) (string, error) {

	var err error
	var id string

	id, err = dbClient.AddInterval(interval)
	if err != nil {
		LoggingClient.Error("problem trying to add interval to support-scheduler service:" + err.Error())
		return "", err
	}
	interval.ID = id

	LoggingClient.Info("added interval to the support-scheduler database", "name", interval.Name, "id", ID)

	return id, nil
}
1002764
func (_m *DBClient) AddIntervalAction(intervalAction models.IntervalAction) (string, error) {
	ret := _m.Called(intervalAction)

	var r0 string
	if rf, ok := ret.Get(0).(func(models.IntervalAction) string); ok {
		r0 = rf(intervalAction)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(models.IntervalAction) error); ok {
		r1 = rf(intervalAction)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
939021
func (r *RepositoryVulnerabilityAlertEvent) GetAction() string {
	if r == nil || r.Action == nil {
		return ""
	}
	return *r.Action
}
184620
func (mc MongoClient) UpdateIntervalAction(action contract.IntervalAction) error {
	var mapped models.IntervalAction
	id, err := mapped.FromContract(action)
	if err != nil {
		return err
	}

	mapped.TimestampForUpdate()

	return mc.updateId(db.IntervalAction, id, mapped)
}
772992
func intervalActionByIntervalHandler(w http.ResponseWriter, r *http.Request) {
	if r.Body != nil {
		defer r.Body.Close()
	}

	// URL parameters
	vars := mux.Vars(r)
	interval, err := url.QueryUnescape(vars["interval"])
	//Issues un-escaping
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		LoggingClient.Error("Error un-escaping the value interval name: " + err.Error())
		return
	}

	switch r.Method {
	case http.MethodGet:
		intervalActions, err := getIntervalActionsByInterval(interval)
		if err != nil {
			LoggingClient.Error(err.Error())
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
		encode(intervalActions, w)
		break
	}
}
932000
func (c *Client) UpdateInterval(from contract.Interval) (err error) {
	check, err := c.IntervalByName(from.Name)
	if err != nil && err != redis.ErrNil {
		return err
	}
	if err == nil && from.ID != check.ID {
		// IDs are different -> name not unique
		return db.ErrNotUnique
	}

	from.Timestamps.Modified = db.MakeTimestamp()
	err = mergo.Merge(&from, check)
	if err != nil {
		return err
	}

	interval := models.NewInterval(from)
	data, err := json.Marshal(interval)
	if err != nil {
		return err
	}

	conn := c.Pool.Get()
	defer conn.Close()

	_ = conn.Send("MULTI")
	deleteObject(interval, interval.ID, conn)
	addObject(data, interval, interval.ID, conn)
	_, err = conn.Do("EXEC")

	return err
}
482488
func intervalByIdHandler(w http.ResponseWriter, r *http.Request) {
	if r.Body != nil {
		defer r.Body.Close()
	}

	// URL parameters
	vars := mux.Vars(r)
	id, err := url.QueryUnescape(vars["id"])
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		LoggingClient.Error("Error un-escaping the value id: " + err.Error())
		return
	}

	switch r.Method {
	case http.MethodGet:
		// Get the interval
		e, err := getIntervalById(id)
		if err != nil {
			switch x := err.(type) {
			case *errors.ErrIntervalNotFound:
				http.Error(w, x.Error(), http.StatusNotFound)
			default:
				http.Error(w, x.Error(), http.StatusInternalServerError)
			}
			LoggingClient.Error(err.Error())
			return
		}
		encode(e, w)
	case http.MethodDelete:
		if err = deleteIntervalById(id); err != nil {
			switch err.(type) {
			case *errors.ErrDbNotFound:
				http.Error(w, err.Error(), http.StatusNotFound)
				return
			case *errors.ErrIntervalStillUsedByIntervalActions:
				http.Error(w, err.Error(), http.StatusBadRequest)
				return
			default:
				http.Error(w, err.Error(), http.StatusInternalServerError)
				return
			}
		}

		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusOK)
		w.Write([]byte("true"))
	}

}
1118028
func intervalByNameHandler(w http.ResponseWriter, r *http.Request) {
	defer r.Body.Close()

	vars := mux.Vars(r)
	name, err := url.QueryUnescape(vars["name"])

	//Issues un-escaping
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		LoggingClient.Error("Error un-escaping the value name: " + err.Error())
		return
	}

	switch r.Method {
	case http.MethodGet:
		interval, err := dbClient.IntervalByName(name)
		if err != nil {
			switch err := err.(type) {
			case *types.ErrServiceClient:
				http.Error(w, err.Error(), err.StatusCode)
			default:
				http.Error(w, err.Error(), http.StatusInternalServerError)
			}
			LoggingClient.Error(err.Error())
			return
		}
		encode(interval, w)
	case http.MethodDelete:
		if err = deleteIntervalByName(name); err != nil {

			switch err.(type) {
			case *errors.ErrDbNotFound:
				http.Error(w, err.Error(), http.StatusNotFound)
				return
			case *errors.ErrIntervalStillUsedByIntervalActions:
				http.Error(w, err.Error(), http.StatusBadRequest)
				return
			default:
				http.Error(w, err.Error(), http.StatusInternalServerError)
				return
			}
		}

		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusOK)
		w.Write([]byte("true"))
	}
}
1062555
func (m *Manager) HistoricalInterval(ctx context.Context) (IntervalList, error) {
	var pm mo.PerformanceManager

	err := m.Properties(ctx, m.Reference(), []string{"historicalInterval"}, &pm)
	if err != nil {
		return nil, err
	}

	return IntervalList(pm.HistoricalInterval), nil
}
821598
func Action(baseURL string, resourceType string, id string, action string) (*jsh.Document, *http.Response, error) {
	request, err := ActionRequest(baseURL, resourceType, id, action)
	if err != nil {
		return nil, nil, err
	}

	return Do(request, jsh.ObjectMode)
}