// DeleteFlaggedMessages deletes messages marked with the Delete flag and
// returns them.
500547
func (m *DummyMailbox) DeleteFlaggedMessages() ([]Message, error) {
	var delIDs []int
	var delMsgs []Message

	// Find messages to be deleted.
	for i, msg := range m.messages {
		if msg.Flags().HasFlags(types.FlagDeleted) {
			delIDs = append(delIDs, i)
			delMsgs = append(delMsgs, msg)
		}
	}

	// Delete message from slice. Run this backward because otherwise it would
	// fail if we have multiple items to remove.
	for x := len(delIDs) - 1; x >= 0; x-- {
		i := delIDs[x]
		// From: https://github.com/golang/go/wiki/SliceTricks
		m.messages, m.messages[len(m.messages)-1] = append(m.messages[:i],
			m.messages[i+1:]...), nil
	}

	// Update sequence numbers.
	for i, msg := range m.messages {
		dmsg := msg.(*DummyMessage)
		dmsg.sequenceNumber = uint32(i) + 1
	}

	return delMsgs, nil
}
123310
func (api *Client) GetMessages(query ...*GetMessagesQuery) ([]*Message, error) {
	var options *GetMessagesQuery
	if len(query) > 0 {
		options = query[0]
	}
	result, _, err := api.makeRequest(http.MethodGet, api.concatUserPath(messagesPath), &[]*Message{}, options)
	if err != nil {
		return nil, err
	}
	return *(result.(*[]*Message)), nil
}
1083015
func (c *legacyNovaFirewaller) DeleteAllModelGroups(ctx context.ProviderCallContext) error {
	return deleteSecurityGroupsMatchingName(ctx, c.deleteSecurityGroups, c.jujuGroupRegexp())
}
817685
func (s *DeleteSubnetGroupOutput) SetDeletionMessage(v string) *DeleteSubnetGroupOutput {
	s.DeletionMessage = &v
	return s
}
93589
func (api *Client) DeleteMessageContext(ctx context.Context, channel, messageTimestamp string) (string, string, error) {
	respChannel, respTimestamp, _, err := api.SendMessageContext(ctx, channel, MsgOptionDelete(messageTimestamp))
	return respChannel, respTimestamp, err
}
1179167
func DiscardMessage(msg *Message, pluginID string, comment string) {
	GetStreamMetric(msg.GetStreamID()).Discarded.Inc(1)
	MessageTrace(msg, pluginID, comment)
}
485783
func (s *BatchPutMessageInput) SetMessages(v []*Message) *BatchPutMessageInput {
	s.Messages = v
	return s
}
903629
func GetFromFlags() log.Logger {
	if logger != nil {
		return logger
	}
	if !flag.Parsed() {
		flag.Parse()
	}

	threshold := getLevelFromName(*thresholdName)
	thresholdName = nil

	out := getStream(*logToStderr)
	logToStderr = nil

	flushThreshold := getLevelFromName(*flushThresholdName)
	flushThresholdName = nil

	if flushThreshold == log.None {
		logger = golog.New(out, threshold)
	} else {
		logger = buflog.New(out, threshold, flushThreshold)
	}

	return logger
}
380907
func NewSendMessageToTargetArgs(message string) *SendMessageToTargetArgs {
	args := new(SendMessageToTargetArgs)
	args.Message = message
	return args
}
344823
func (s *UsersService) DeleteEmails(ctx context.Context, emails []string) (*Response, error) {
	u := "user/emails"
	req, err := s.client.NewRequest("DELETE", u, emails)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}
239156
func (c *Command) ParseFlags(args []string) error {
	if c.DisableFlagParsing {
		return nil
	}

	if c.flagErrorBuf == nil {
		c.flagErrorBuf = new(bytes.Buffer)
	}
	beforeErrorBufLen := c.flagErrorBuf.Len()
	c.mergePersistentFlags()

	//do it here after merging all flags and just before parse
	c.Flags().ParseErrorsWhitelist = flag.ParseErrorsWhitelist(c.FParseErrWhitelist)

	err := c.Flags().Parse(args)
	// Print warnings if they occurred (e.g. deprecated flag messages).
	if c.flagErrorBuf.Len()-beforeErrorBufLen > 0 && err == nil {
		c.Print(c.flagErrorBuf.String())
	}

	return err
}
816998
func NewDeleteCommandFlags(usage string) *DeleteFlags {
	cascade := true
	gracePeriod := -1

	// setup command defaults
	all := false
	allNamespaces := false
	force := false
	ignoreNotFound := false
	now := false
	output := ""
	labelSelector := ""
	fieldSelector := ""
	timeout := time.Duration(0)
	wait := true

	filenames := []string{}
	recursive := false
	kustomize := ""

	return &DeleteFlags{
		// Not using helpers.go since it provides function to add '-k' for FileNameOptions, but not FileNameFlags
		FileNameFlags: &genericclioptions.FileNameFlags{Usage: usage, Filenames: &filenames, Kustomize: &kustomize, Recursive: &recursive},
		LabelSelector: &labelSelector,
		FieldSelector: &fieldSelector,

		Cascade:     &cascade,
		GracePeriod: &gracePeriod,

		All:            &all,
		AllNamespaces:  &allNamespaces,
		Force:          &force,
		IgnoreNotFound: &ignoreNotFound,
		Now:            &now,
		Timeout:        &timeout,
		Wait:           &wait,
		Output:         &output,
	}
}
240041
func (e Envflag) unsetFlags() map[string]struct{} {

	flags := make(map[string]struct{})

	// get all flag-names.
	e.Cli.VisitAll(func(f *flag.Flag) {
		flags[f.Name] = struct{}{}
	})

	// MINUS from set flag-names.
	e.Cli.Visit(func(f *flag.Flag) {
		delete(flags, f.Name)
	})

	return flags
}
771096
func (c *conn) SendMessages(messages []Message) error {
	var buf []byte
	for _, m := range messages {
		b, err := m.MarshalBinary()
		if err != nil {
			return err
		}

		buf = append(buf, b...)
	}

	addr := &unix.SockaddrNetlink{
		Family: unix.AF_NETLINK,
	}

	return os.NewSyscallError("sendmsg", c.s.Sendmsg(buf, nil, addr, 0))
}
233244
func (c *Client) DeleteTags(p *DeleteTagsParameter) (*Result, error) {
	obj, err := c.Request("deleteTags", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}
261669
func successMessage(didAdd bool, isGroup bool, usersToAdd, groupsToAdd []string) string {
	verb := "removed from"
	allTargets := fmt.Sprintf("%q", usersToAdd)

	if isGroup {
		allTargets = fmt.Sprintf("%q", groupsToAdd)
	}
	if didAdd {
		verb = "added to"
	}
	if isGroup {
		verb += " groups"
	}

	return fmt.Sprintf("%s: %s", verb, allTargets)
}
128635
func (s *Statement) SetMessages(v []*Message) *Statement {
	s.Messages = v
	return s
}