// Action triggers the action passed to it.
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
}
246592
func (mod *JenkinsBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}
	switch action.Name {
	case "trigger":
		jobname := ""
		action.Options.Bind("job", &jobname)

		mod.triggerBuild(jobname)

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}
	return outs
}
807263
func (sf *ShardFixer) Action(ctx context.Context, name string) error {
	if name == "Create" {
		return sf.ts.CreateShard(ctx, sf.keyspace, sf.shard)
	}
	if name == "Delete" {
		return sf.ts.DeleteShard(ctx, sf.keyspace, sf.shard)
	}
	return fmt.Errorf("unknown ShardFixer action: %v", name)
}
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
}
1025440
func (r *ActionResponse) AddAction(action *bees.Action) {
	r.actions = append(r.actions, action)
	r.Actions = append(r.Actions, prepareActionResponse(r.Context, action))
}
836376
func (m *Broadcaster) Action(action EventType, obj runtime.Object) {
	m.incoming <- Event{action, obj}
}
261234
func (mod *GitHubBee) Action(action bees.Action) []bees.Placeholder {
	ctx := context.Background()
	outs := []bees.Placeholder{}
	switch action.Name {
	case "follow":
		var user string
		action.Options.Bind("username", &user)

		if _, err := mod.client.Users.Follow(ctx, user); err != nil {
			mod.LogErrorf("Failed to follow user: %v", err)
		}

	case "unfollow":
		var user string
		action.Options.Bind("username", &user)

		if _, err := mod.client.Users.Unfollow(ctx, user); err != nil {
			mod.LogErrorf("Failed to follow user: %v", err)
		}

	case "star":
		var user string
		var repo string
		action.Options.Bind("owner", &user)
		action.Options.Bind("repository", &repo)

		if _, err := mod.client.Activity.Star(ctx, user, repo); err != nil {
			mod.LogErrorf("Failed to star repository: %v", err)
		}

	case "unstar":
		var user string
		var repo string
		action.Options.Bind("owner", &user)
		action.Options.Bind("repository", &repo)

		if _, err := mod.client.Activity.Unstar(ctx, user, repo); err != nil {
			mod.LogErrorf("Failed to unstar repository: %v", err)
		}

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

	return outs
}
418078
func (t *transaction) sendAction(a *action) error {
	switch a.kind {
	case actionCommand:
		return t.conn.Send(a.name, a.args...)
	case actionScript:
		return a.script.Send(t.conn, a.args...)
	}
	return nil
}
749019
func (mod *HueBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "setcolor":
		var lightID int
		var color string
		brightness := 254
		action.Options.Bind("light", &lightID)
		action.Options.Bind("color", &color)
		action.Options.Bind("brightness", &brightness)

		light, err := mod.client.FindLightById(strconv.Itoa(lightID))
		if err != nil {
			panic(err)
		}

		state := hue.SetLightState{
			On:  "true",
			Bri: strconv.FormatInt(int64(brightness), 10),
			Sat: "254",
		}

		switch strings.ToLower(color) {
		case "coolwhite":
			state.Ct = strconv.FormatInt(150, 10)
			state.Sat = ""
		case "warmwhite":
			state.Ct = strconv.FormatInt(500, 10)
			state.Sat = ""
		case "green":
			state.Hue = strconv.FormatInt(182*140, 10)
		case "red":
			state.Hue = strconv.FormatInt(0, 10)
		case "blue":
			state.Hue = strconv.FormatInt(182*250, 10)
		case "orange":
			state.Hue = strconv.FormatInt(182*25, 10)
		case "yellow":
			state.Hue = strconv.FormatInt(182*85, 10)
		case "pink":
			state.Hue = strconv.FormatInt(182*300, 10)
		case "purple":
			state.Hue = strconv.FormatInt(182*270, 10)
		}
		light.SetState(state)

	case "switch":
		var lightId int
		var state bool
		action.Options.Bind("light", &lightId)
		action.Options.Bind("state", &state)

		light, err := mod.client.FindLightById(strconv.Itoa(lightId))
		if err != nil {
			panic(err)
		}

		if state {
			light.On()
		} else {
			light.Off()
		}

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

	return outs
}
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
}
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
}
964850
func (s *TasksCancelService) Actions(actions ...string) *TasksCancelService {
	s.actions = append(s.actions, actions...)
	return s
}
1173681
func (a *Application) PreAction(action Action) *Application {
	a.addPreAction(action)
	return a
}
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
}
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
}
1250393
func (s *SampledHTTPRequest) SetAction(v string) *SampledHTTPRequest {
	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())
}