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

	switch action.Name {
	case "toot":
		var text string
		action.Options.Bind("text", &text)

		// Post status toot on mastodon
		status, err := mod.client.PostStatus(context.Background(), &mastodon.Toot{
			Status: text,
		})
		if err != nil {
			mod.LogErrorf("Error sending toot: %v", err)
		}

		// Handle back 'toot_sent' event
		ev := bees.Event{
			Bee:  mod.Name(),
			Name: "toot_sent",
			Options: []bees.Placeholder{
				{
					Name:  "text",
					Value: status.Content,
					Type:  "string",
				},
			},
		}
		mod.evchan <- ev
	}
	return outs
}
1264283
func (mod *TwilioBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		body := ""
		action.Options.Bind("body", &body)

		_, err := twilio.NewMessage(mod.client, mod.fromNumber, mod.toNumber, twilio.Body(body))
		if err != nil {
			mod.LogErrorf("Error sending twilio SMS: %s", err)
		}

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

	return outs
}
1173681
func (a *Application) PreAction(action Action) *Application {
	a.addPreAction(action)
	return a
}
1127877
func (mod *TelegramBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		chatID := ""
		text := ""
		action.Options.Bind("chat_id", &chatID)
		action.Options.Bind("text", &text)

		cid, err := strconv.ParseInt(chatID, 10, 64)
		if err != nil {
			panic("Invalid telegram chat ID")
		}

		msg := telegram.NewMessage(cid, text)
		_, err = mod.bot.Send(msg)
		if err != nil {
			mod.Logf("Error sending message %v", err)
		}
	}

	return outs
}
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
}
366288
func (mod *NotificationBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "notify":
		text := ""
		u := ""
		urgency := UrgencyNormal

		action.Options.Bind("text", &text)
		action.Options.Bind("urgency", &u)
		text = strings.TrimSpace(text)
		urgency, _ = urgencyMap[u]

		if len(text) > 0 {
			mod.execAction(text, urgency)
		}

	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
}
1343073
func (s *Change) SetAction(v string) *Change {
	s.Action = &v
	return s
}
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)
}
90506
func (f *workflowFixer) Action(ctx context.Context, path, name string) error {
	if len(f.node.Actions) == 0 {
		// Action was already run.
		return nil
	}
	err := f.fixer.Action(ctx, name)
	if err != nil {
		f.node.Log = fmt.Sprintf("action %v failed: %v", name, err)
	} else {
		f.node.Log = fmt.Sprintf("action %v successful", name)
	}
	f.node.Actions = f.node.Actions[:0]
	f.node.State = workflowpb.WorkflowState_Done
	f.node.Message = "Addressed(" + name + "): " + f.node.Message
	f.node.Display = workflow.NodeDisplayNone
	f.node.BroadcastChanges(false /* updateChildren */)
	f.wg.Done()
	return nil
}
69981
func (a *LogOnExceed) Action(t *Tracker) {
	a.mutex.Lock()
	defer a.mutex.Unlock()
	if !a.acted {
		a.acted = true
		logutil.Logger(context.Background()).Warn("memory exceeds quota",
			zap.Error(errMemExceedThreshold.GenWithStackByArgs(t.label, t.BytesConsumed(), t.bytesLimit, t.String())))
	}
}
461771
func (s *Service) SetAction(v *Action) *Service {
	s.Action = v
	return s
}
980125
func (mod *SlackBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		tos := []string{}
		text := ""
		action.Options.Bind("text", &text)

		for _, opt := range action.Options {
			if opt.Name == "channel" {
				cid := mod.findChannelID(opt.Value.(string), false)
				if cid != "" {
					tos = append(tos, cid)
				} else {
					mod.Logf("Error: channel ID for %s not found", opt.Value.(string))
				}
			}
		}

		msgParams := slack.NewPostMessageParameters()
		msgParams.LinkNames = 1
		for _, to := range tos {
			_, _, err := mod.client.PostMessage(to, slack.MsgOptionText(text, false), slack.MsgOptionPostMessageParameters(msgParams))
			if err != nil {
				mod.Logf("Error posting message to the slack channel %s: %s", to, err)
			}
		}
	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
555396
func (mod *PastebinBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "post":
		title := ""
		content := ""
		expire := ""
		exposure := ""

		action.Options.Bind("title", &title)
		action.Options.Bind("content", &content)
		action.Options.Bind("expire", &expire)
		action.Options.Bind("exposure", &exposure)

		ret, err := mod.client.PasteAnonymous(content, title, "text", expire, exposure)
		if err != nil {
			mod.LogErrorf("Error occurred during posting to Pastebin: %v", err)
		} else {
			mod.Logln("Paste URL:", ret)
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}
	return outs
}
804426
func (s *AliasService) Action(action ...AliasAction) *AliasService {
	s.actions = append(s.actions, action...)
	return s
}
244257
func (client *AMIClient) Action(action string, params Params) (*AMIResponse, error) {
	resp, err := client.AsyncAction(action, params)
	if err != nil {
		return nil, err
	}
	response := <-resp

	return response, nil
}
42841
func (schemaSwap *Swap) Action(ctx context.Context, path, name string) error {
	if name != "Retry" {
		return fmt.Errorf("unknown action on schema swap: %v", name)
	}
	schemaSwap.closeRetryChannel()
	schemaSwap.rootUINode.BroadcastChanges(false /* updateChildren */)
	return nil
}