// Actions is a list of actions that should be cancelled. Leave empty to cancel all.
964850
func (s *TasksCancelService) Actions(actions ...string) *TasksCancelService {
	s.actions = append(s.actions, actions...)
	return s
}
247032
func (c *Context) Action(ctl string, act string) (err error) {
	a := c.Module.Wrapper(`controller.` + ctl)
	if a == nil {
		return c.Atoe(`Controller "` + ctl + `" does not exist.`)
	}
	k := `webx.controller.reflect.type:` + ctl
	var e reflect.Type
	if t, ok := c.Get(k).(reflect.Type); ok {
		e = t
	} else {
		e = reflect.Indirect(reflect.ValueOf(a.Controller)).Type()
		c.Set(k, e)
	}
	return a.Exec(c, e, act)
}
331483
func (mod *SocketBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	var data string
	var addr string
	var port int

	action.Options.Bind("address", &addr)
	action.Options.Bind("port", &port)
	action.Options.Bind("data", &data)

	switch action.Name {
	case "send":
		// log.Println("Sending", data, "to", addr, port)

		sa, err := net.ResolveUDPAddr("udp", addr+":"+strconv.Itoa(port))
		if err != nil {
			log.Panicln(err)
		}

		conn, err := net.DialUDP("udp", nil, sa)
		if err != nil {
			log.Panicln(err)
		}

		defer conn.Close()
		_, err = conn.Write([]byte(data))
		if err != nil {
			log.Panicln(err)
		}

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

	return outs
}
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
}
480428
func (m *Martini) Action(handler Handler) {
	validateHandler(handler)
	m.action = handler
}
387281
func (mod *TransmissionBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}
	switch action.Name {
	case "add_torrent":
		torrentMsg := ""
		action.Options.Bind("torrent", &torrentMsg)

		_, err := mod.client.Add(torrentMsg)
		if err != nil {
			mod.LogErrorf("Error adding torrent/magnet: %s", err)
		}
	}
	return outs
}
215625
func (factory *SpaceAPIBeeFactory) Actions() []bees.ActionDescriptor {
	actions := []bees.ActionDescriptor{
		{
			Namespace:   factory.Name(),
			Name:        "status",
			Description: "Gets the Status of a LabAPI instance",
			Options:     []bees.PlaceholderDescriptor{},
		},
	}
	return actions
}
1211545
func (mod *ExecBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "execute":
		var command string
		var stdin string

		action.Options.Bind("command", &command)
		action.Options.Bind("stdin", &stdin)
		mod.Logln("Executing locally: ", command)

		go func() {
			c := strings.Split(command, " ")
			cmd := exec.Command(c[0], c[1:]...)

			if stdin != "" {
				stdinPipe, err := cmd.StdinPipe()

				if err != nil {
					mod.LogFatal("Error creating stdinPipe for Cmd", err)
					return
				}

				go func() {
					io.WriteString(stdinPipe, stdin)
					stdinPipe.Close()
				}()
			}

			// read and print stdout
			outReader, err := cmd.StdoutPipe()
			if err != nil {
				mod.LogFatal("Error creating StdoutPipe for Cmd", err)
				return
			}
			outBuffer := []string{}
			outScanner := bufio.NewScanner(outReader)
			go func() {
				for outScanner.Scan() {
					foo := outScanner.Text()
					mod.Logln("execbee: std: | ", foo)
					outBuffer = append(outBuffer, foo)
				}
			}()

			// read and print stderr
			errReader, err := cmd.StderrPipe()
			if err != nil {
				mod.LogFatal("Error creating StderrPipe for Cmd", err)
				return
			}
			errBuffer := []string{}
			errScanner := bufio.NewScanner(errReader)
			go func() {
				for errScanner.Scan() {
					foo := errScanner.Text()
					mod.Logln("Err: | ", foo)
					errBuffer = append(errBuffer, foo)
				}
			}()

			err = cmd.Start()
			if err != nil {
				mod.LogFatal("Error starting Cmd", err)
			}

			err = cmd.Wait()
			if err != nil {
				mod.LogFatal("Error waiting for Cmd", err)
			}

			ev := bees.Event{
				Bee:  mod.Name(),
				Name: "result",
				Options: []bees.Placeholder{
					{
						Name:  "stdout",
						Type:  "string",
						Value: strings.Join(outBuffer, "\n"),
					},
					{
						Name:  "stderr",
						Type:  "string",
						Value: strings.Join(errBuffer, "\n"),
					},
				},
			}
			mod.eventChan <- ev
		}()

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

	return outs
}
2391
func Action(a func(*cli.Context)) Option {
	return func(o *Options) {
		o.Action = a
	}
}
1168958
func (mod *HelloBee) Action(action bees.Action) []bees.Placeholder {
	return []bees.Placeholder{}
}
822407
func (t Modules) Actions(usedModules ...Module) Actions {
	actions := Actions{}
	modules := t.DependOnce(usedModules...)
	for _, module := range modules {
		actions.Add(module.Action)
	}
	return actions
}
781112
func (mod *PushoverBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		var message, title, nurl, urlTitle string
		action.Options.Bind("message", &message)
		action.Options.Bind("title", &title)
		action.Options.Bind("url", &nurl)
		action.Options.Bind("url_title", &urlTitle)

		msg := url.Values{}
		msg.Set("token", mod.token)
		msg.Set("user", mod.userToken)
		msg.Set("message", message)

		if nurl != "" {
			msg.Set("url", nurl)
		}
		if urlTitle != "" {
			msg.Set("url_title", urlTitle)
		}
		if title != "" {
			msg.Set("title", title)
		}

		mod.Logln(msg)
		resp, err := http.PostForm("https://api.pushover.net/1/messages.json", msg)
		if err != nil {
			panic(err)
		}
		defer resp.Body.Close()
		if resp.StatusCode == 200 {
			mod.Logln("Pushover send message success.")
		}

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

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

	switch action.Name {
	case "status":
		type SpaceAPIResult struct {
			State struct {
				Open bool `json:"open"`
			} `json:"state"`
		}
		apiState := new(SpaceAPIResult)

		// get json data
		resp, err := http.Get(mod.url)
		if err != nil {
			mod.Logln("Error: SpaceAPI instance @ " + mod.url + " not reachable")
		} else {
			defer resp.Body.Close()
			body, _ := ioutil.ReadAll(resp.Body)

			err = json.Unmarshal(body, apiState)
			if err != nil {
				mod.Logln("Sorry, couldn't unmarshal the JSON data from SpaceAPI Instance @ " + mod.url)
				apiState.State.Open = false
			}
		}

		ev := bees.Event{
			Bee:  mod.Name(),
			Name: "result",
			Options: []bees.Placeholder{
				{
					Name:  "open",
					Type:  "bool",
					Value: apiState.State.Open,
				},
			},
		}
		mod.evchan <- ev

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

	return outs
}
952601
func (clg *ClientBackedDryRunGetter) HandleListAction(action core.ListAction) (bool, runtime.Object, error) {
	listOpts := metav1.ListOptions{
		LabelSelector: action.GetListRestrictions().Labels.String(),
		FieldSelector: action.GetListRestrictions().Fields.String(),
	}

	unstructuredList, err := clg.dynamicClient.Resource(action.GetResource()).Namespace(action.GetNamespace()).List(listOpts)
	if err != nil {
		return true, nil, err
	}
	newObj, err := decodeUnstructuredIntoAPIObject(action, unstructuredList)
	if err != nil {
		fmt.Printf("error after decode: %v %v\n", unstructuredList, err)
		return true, nil, err
	}
	return true, newObj, err
}
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
}
1346004
func (m *NodeManager) Action(ctx context.Context, ap *ActionParameters) error {
	n, err := m.getNodeByPath(ap.Path)
	if err != nil {
		return err
	}

	m.mu.Lock()

	if n.Listener == nil {
		m.mu.Unlock()
		return fmt.Errorf("Action %v is invoked on a node without listener (node path is %v)", ap.Name, ap.Path)
	}
	nodeListener := n.Listener
	m.mu.Unlock()

	return nodeListener.Action(ctx, ap.Path, ap.Name)
}
881649
func (ca *CoreAdmin) Action(action string, params *url.Values) (*SolrResponse, error) {
	switch strings.ToUpper(action) {
	case "STATUS":
		params.Set("action", "STATUS")
	case "RELOAD":
		params.Set("action", "RELOAD")
	case "CREATE":
		params.Set("action", "CREATE")
	case "RENAME":
		params.Set("action", "RENAME")
	case "SWAP":
		params.Set("action", "SWAP")
	case "UNLOAD":
		params.Set("action", "UNLOAD")
	case "SPLIT":
		params.Set("action", "SPLIT")
	case "MERGEINDEXES":
		params.Set("action", "mergeindexes")
	default:
		return nil, fmt.Errorf("Action '%s' not supported", action)
	}
	return ca.Get("cores", params)
}