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

	switch action.Name {
	case "send":
		sm := simplepush.Message{
			SimplePushKey: mod.key,
			Encrypt:       mod.password != "",
			Password:      mod.password,
			Salt:          mod.salt,
		}
		action.Options.Bind("title", &sm.Title)
		action.Options.Bind("message", &sm.Message)
		action.Options.Bind("event", &sm.Event)

		simplepush.Send(sm)

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

	return outs
}
379941
func (s *IPSetUpdate) SetAction(v string) *IPSetUpdate {
	s.Action = &v
	return s
}
1173681
func (a *Application) PreAction(action Action) *Application {
	a.addPreAction(action)
	return a
}
435229
func (mod *TumblrBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

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

		state := "published"
		err := mod.client.CreateText(mod.blogname, map[string]string{
			"body":  text,
			"state": state})
		if err != nil {
			mod.LogErrorf("Failed to post text: %v", err)
			return outs
		}
		ev := bees.Event{
			Bee:     mod.Name(),
			Name:    "posted",
			Options: []bees.Placeholder{},
		}
		mod.evchan <- ev

	case "post_quote":
		quote := ""
		source := ""
		action.Options.Bind("quote", &quote)
		action.Options.Bind("source", &source)

		state := "published"
		err := mod.client.CreateQuote(mod.blogname, map[string]string{
			"quote":  quote,
			"source": source,
			"state":  state})
		if err != nil {
			mod.LogErrorf("Failed to post quote: %v", err)
			return outs
		}
		ev := bees.Event{
			Bee:     mod.Name(),
			Name:    "posted",
			Options: []bees.Placeholder{},
		}
		mod.evchan <- ev

	case "follow":
		blogname := ""
		action.Options.Bind("blogname", &blogname)

		if err := mod.client.Follow(blogname); err != nil {
			mod.LogErrorf("Failed to follow blog: %v", err)
			return outs
		}

	case "unfollow":
		blogname := ""
		action.Options.Bind("blogname", &blogname)

		if err := mod.client.Unfollow(blogname); err != nil {
			mod.LogErrorf("Failed to unfollow blog: %v", err)
			return outs
		}

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

	return outs
}
43844
func (m *Model) Action(id string) (Action, error) {
	actionLogger.Tracef("Action() %q", id)
	st := m.st
	actions, closer := st.db().GetCollection(actionsC)
	defer closer()

	doc := actionDoc{}
	err := actions.FindId(id).One(&doc)
	if err == mgo.ErrNotFound {
		return nil, errors.NotFoundf("action %q", id)
	}
	if err != nil {
		return nil, errors.Annotatef(err, "cannot get action %q", id)
	}
	actionLogger.Tracef("Action() %q found %+v", id, doc)
	return newAction(st, doc), nil
}
1053329
func (sw *SleepWorkflow) Action(ctx context.Context, path, name string) error {
	sw.mu.Lock()
	defer sw.mu.Unlock()

	// Change our state.
	log.Infof("SleepWorkflow.Action(%v) called.", name)
	paused := sw.data.Paused
	switch name {
	case pauseAction:
		sw.data.Paused = true
		sw.logger.Infof("Paused")
	case resumeAction:
		sw.data.Paused = false
		sw.logger.Infof("Resumed")
	default:
		sw.logger.Errorf("Unknown action %v called", name)
		return fmt.Errorf("unknown action %v", name)
	}
	if paused == sw.data.Paused {
		// Nothing changed.
		return nil
	}

	// UI update and Checkpoint.
	sw.uiUpdateLocked()
	sw.node.BroadcastChanges(false /* updateChildren */)
	return sw.checkpointLocked(ctx)
}
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
}
118989
func (mod *JabberBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		chat := xmpp.Chat{Type: "chat"}

		action.Options.Bind("user", &chat.Remote)
		action.Options.Bind("text", &chat.Text)

		mod.client.Send(chat)

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

	return outs
}
513155
func (mod *SerialBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}
	text := ""

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

		bufOut := new(bytes.Buffer)
		err := binary.Write(bufOut, binary.LittleEndian, []byte(text))
		if err != nil {
			panic(err)
		}

		_, err = mod.conn.Write(bufOut.Bytes())
		if err != nil {
			panic(err)
		}

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

	return outs
}
1065456
func (c *Client) Action(tag names.ActionTag) (*Action, error) {
	result, err := c.getOneAction(tag)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &Action{
		name:   result.Action.Name,
		params: result.Action.Parameters,
	}, nil
}
1343073
func (s *Change) SetAction(v string) *Change {
	s.Action = &v
	return s
}
69587
func (s *LifecyclePolicyPreviewResult) SetAction(v *LifecyclePolicyRuleAction) *LifecyclePolicyPreviewResult {
	s.Action = v
	return s
}
308154
func (a *PanicOnExceed) Action(t *Tracker) {
	a.mutex.Lock()
	if a.acted {
		a.mutex.Unlock()
		return
	}
	a.acted = true
	a.mutex.Unlock()
	panic(PanicMemoryExceed + t.String())
}
93423
func (mod *OpenweathermapBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

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

		err := mod.current.CurrentByName(location)
		if err != nil {
			mod.LogErrorf("Failed to fetch weather: %v", err)
			return nil
		}

		mod.TriggerCurrentWeatherEvent()

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

	return outs
}
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
}
954159
func (f *FakeWatcher) Action(action EventType, obj runtime.Object) {
	f.result <- Event{action, obj}
}