// Action triggers the action passed to it.
437692
func (mod *HTTPBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	u := ""
	action.Options.Bind("url", &u)

	switch action.Name {
	case "get":
		resp, err := http.Get(u)
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}
		defer resp.Body.Close()

		b, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}

		ev, err := mod.prepareResponseEvent(b)
		if err == nil {
			ev.Name = "get"
			ev.Options.SetValue("url", "url", u)
			mod.eventChan <- ev
		}

	case "post":
		var err error
		var b []byte
		var j string
		var form url.Values
		var resp *http.Response

		action.Options.Bind("json", &j)
		action.Options.Bind("form", &form)

		if j != "" {
			buf := strings.NewReader(j)
			resp, err = http.Post(u, "application/json", buf)
		} else {
			resp, err = http.PostForm(u, form)
		}
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}
		defer resp.Body.Close()

		b, err = ioutil.ReadAll(resp.Body)
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}

		ev, err := mod.prepareResponseEvent(b)
		if err == nil {
			ev.Name = "post"
			ev.Options.SetValue("url", "url", u)
			mod.eventChan <- ev
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
488570
func (t *Transaction) doAction(a *Action) (interface{}, error) {
	switch a.kind {
	case commandAction:
		return t.conn.Do(a.name, a.args...)
	case scriptAction:
		return a.script.Do(t.conn, a.args...)
	}
	return nil, nil
}
788925
func (t *Tree) action() (n Node) {
	switch token := t.nextNonSpace(); token.typ {
	case itemElse:
		return t.elseControl()
	case itemEnd:
		return t.endControl()
	case itemIf:
		return t.ifControl()
	case itemRange:
		return t.rangeControl()
	case itemTemplate:
		return t.templateControl()
	case itemWith:
		return t.withControl()
	}
	t.backup()
	// Do not pop variables; they persist until "end".
	return t.newAction(t.peek().pos, t.lex.lineNumber(), t.pipeline("command"))
}
1041802
func (mod *AnelPowerCtrlBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "switch":
		socket := 0
		state := false
		action.Options.Bind("socket", &socket)
		action.Options.Bind("state", &state)

		mod.anelSwitch(socket, state)

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
920783
func (s *SizeConstraintSetUpdate) SetAction(v string) *SizeConstraintSetUpdate {
	s.Action = &v
	return s
}
1025440
func (r *ActionResponse) AddAction(action *bees.Action) {
	r.actions = append(r.actions, action)
	r.Actions = append(r.Actions, prepareActionResponse(r.Context, action))
}
1364680
func (mod *AlertOverBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		var receiver, title, content, weburl, priority string
		action.Options.Bind("receiver", &receiver)
		action.Options.Bind("title", &title)
		action.Options.Bind("content", &content)
		action.Options.Bind("url", &weburl)
		action.Options.Bind("priority", &priority)

		if priority == "" {
			priority = "0"
		}

		// the message must be plain text, so
		// remove the HTML tags, such as <html></html> and so on
		re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
		content = re.ReplaceAllString(content, "\n")

		data := url.Values{
			"source":   {mod.source},
			"receiver": {receiver},
			"title":    {title},
			"content":  {content},
			"url":      {weburl},
			"priority": {priority},
		}
		resp, err := http.PostForm("https://api.alertover.com/v1/alert", data)
		if err != nil {
			panic(err)
		}
		defer resp.Body.Close()
		if resp.StatusCode == 200 {
			mod.Logln("AlertOver send message success.")
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
592993
func NewAction(name string, params map[string]interface{}) *Action {
	return &Action{name: name, params: params}
}
452475
func (mod *PrometheusBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}
	switch action.Name {
	case "counter_inc":
		var label string
		action.Options.Bind("label", &label)
		c, err := mod.counter.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error incrementing counter: %v", err)
		} else {
			c.Inc()
		}
	case "counter_add":
		var label string
		var value float64
		action.Options.Bind("label", &label)
		action.Options.Bind("value", &value)
		c, err := mod.counter.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error adding to counter: %v", err)
		} else {
			c.Add(value)
		}
	case "gauge_set":
		var label string
		var value float64
		action.Options.Bind("label", &label)
		action.Options.Bind("value", &value)
		g, err := mod.gauge.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error setting gauge: %v", err)
		} else {
			g.Set(value)
		}
	case "gauge_inc":
		var label string
		action.Options.Bind("label", &label)
		g, err := mod.gauge.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error incrementing gauge: %v", err)
		} else {
			g.Inc()
		}
	case "gauge_dec":
		var label string
		action.Options.Bind("label", &label)
		g, err := mod.gauge.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error decrementing gauge: %v", err)
		} else {
			g.Dec()
		}
	case "gauge_add":
		var label string
		var value float64
		action.Options.Bind("label", &label)
		action.Options.Bind("value", &value)
		g, err := mod.gauge.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error adding to gauge: %v", err)
		} else {
			g.Add(value)
		}
	case "gauge_sub":
		var label string
		var value float64
		action.Options.Bind("label", &label)
		action.Options.Bind("value", &value)
		g, err := mod.gauge.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error subtracting from gauge: %v", err)
		} else {
			g.Sub(value)
		}
	case "gauge_set_to_current_time":
		var label string
		action.Options.Bind("label", &label)
		g, err := mod.gauge.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error setting gauge to current time: %v", err)
		} else {
			g.SetToCurrentTime()
		}
	case "histogram_observe":
		var label string
		var value float64
		action.Options.Bind("label", &label)
		action.Options.Bind("value", &value)
		h, err := mod.histogram.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error observing value for histogram: %v", err)
		} else {
			h.Observe(value)
		}
	case "summary_observe":
		var label string
		var value float64
		action.Options.Bind("label", &label)
		action.Options.Bind("value", &value)
		s, err := mod.summary.GetMetricWithLabelValues(label)
		if err != nil {
			mod.LogErrorf("Error observing value for summary: %v", err)
		} else {
			s.Observe(value)
		}
	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
1023081
func (f *FlagClause) Action(action Action) *FlagClause {
	f.addAction(action)
	return f
}
1339553
func (k *KeyBindings) Action(qc func(key string, operator Op, operand interface{}, match_all bool) bool) (kb *KeyBinding) {
	p := Prof.Enter("key.action")
	defer p.Exit()

	for {
		for i := range k.Bindings {
			if len(k.Bindings[i].Keys) > k.seqIndex {
				// This key binding is of a key sequence longer than what is currently
				// probed for. For example, the binding is for the sequence ['a','b','c'], but
				// the user has only pressed ['a','b'] so far.
				continue
			}
			for _, c := range k.Bindings[i].Context {
				if !qc(c.Key, c.Operator, c.Operand, c.MatchAll) {
					goto skip
				}
			}
			if kb == nil || kb.priority < k.Bindings[i].priority {
				kb = k.Bindings[i]
			}
		skip:
		}
		if kb != nil || k.parent == nil {
			break
		}
		k = k.parent.KeyBindings()
	}
	return
}
804426
func (s *AliasService) Action(action ...AliasAction) *AliasService {
	s.actions = append(s.actions, action...)
	return s
}
1190206
func (mod *MumbleBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send_to_user":

		user, text := "", ""

		action.Options.Bind("user", &user)
		action.Options.Bind("text", &text)

		mod.client.Users.Find(user).Send(text)

	case "send_to_channel":

		channel, text := "", ""

		action.Options.Bind("channel", &channel)
		action.Options.Bind("text", &text)

		if channel != "" {
			mod.client.Channels.Find(channel).Send(text, false)
		} else {
			mod.client.Self.Channel.Send(text, false)
		}
	case "move":

		channel := ""

		action.Options.Bind("channel", &channel)
		mod.move(channel)

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
727233
func (kf *KeyspaceFixer) Action(ctx context.Context, name string) error {
	if name == "Create" {
		return kf.ts.CreateKeyspace(ctx, kf.keyspace, &topodatapb.Keyspace{})
	}
	if name == "Delete" {
		return kf.ts.DeleteKeyspace(ctx, kf.keyspace)
	}
	return fmt.Errorf("unknown KeyspaceFixer action: %v", name)
}
944960
func (b *Bucket) AddAction(act Action) {
	b.Actions = append(b.Actions, act)
}
791239
func (t *transaction) doAction(a *action) (interface{}, error) {
	switch a.kind {
	case actionCommand:
		return t.conn.Do(a.name, a.args...)
	case actionScript:
		return a.script.Do(t.conn, a.args...)
	}
	return nil, nil
}
1196312
func (s *TasksListService) Actions(actions ...string) *TasksListService {
	s.actions = append(s.actions, actions...)
	return s
}