// RenameEvent implements the RenameEvent method of the eventhorizon.EventStore interface.
496526
func (s *EventStore) RenameEvent(ctx context.Context, from, to eh.EventType) error {
	sess := s.session.Copy()
	defer sess.Close()

	// Find and rename all events.
	// TODO: Maybe use change info.
	if _, err := sess.DB(s.dbName(ctx)).C("events").UpdateAll(
		bson.M{
			"events.event_type": string(from),
		},
		bson.M{
			"$set": bson.M{"events.$.event_type": string(to)},
		},
	); err != nil {
		return eh.EventStoreError{
			BaseErr:   err,
			Err:       ErrCouldNotSaveAggregate,
			Namespace: eh.NamespaceFromContext(ctx),
		}
	}

	return nil
}
1181785
func (s *Application) AddEvent(eventName string, handler interface{}) *Application {
	if h, ok := handler.(func(func(bool), ...interface{})); ok {
		events.AddEvent(eventName, h)
		return s
	}
	if h, ok := handler.(func(...interface{}) bool); ok {
		events.AddEvent(eventName, func(next func(bool), sessions ...interface{}) {
			next(h(sessions...))
		})
		return s
	}
	s.Core.Logger().Warnf(`Invalid event function: %T`, handler)
	return s
}
34273
func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest,
	newDir fs.Node) (err error) {
	ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Rename",
		fmt.Sprintf("%s %s -> %s", d.node.GetBasename(),
			req.OldName, req.NewName))
	defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	d.folder.fs.vlog.CLogf(
		ctx, libkb.VLog1, "Dir Rename %s -> %s", req.OldName, req.NewName)
	defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }()

	var realNewDir *Dir
	switch newDir := newDir.(type) {
	case *Dir:
		realNewDir = newDir
	case *TLF:
		var err error
		realNewDir, err = newDir.loadDir(ctx)
		if err != nil {
			return err
		}
	case *FolderList, *Root:
		// This normally wouldn't happen since a presumably pre-check on
		// destination permissions would have failed. But in case it happens, it
		// should be a EACCES according to rename() man page.
		return fuse.Errno(syscall.EACCES)
	default:
		// This shouldn't happen unless we add other nodes. EIO is not in the error
		// codes listed in rename(), but there doesn't seem to be any suitable
		// error code listed for this situation either.
		return fuse.Errno(syscall.EIO)
	}

	err = d.folder.fs.config.KBFSOps().Rename(ctx,
		d.node, req.OldName, realNewDir.node, req.NewName)

	switch e := err.(type) {
	case nil:
		return nil
	case libkbfs.RenameAcrossDirsError:
		var execPathErr error
		e.ApplicationExecPath, execPathErr = sysutils.GetExecPathFromPID(req.Pid)
		if execPathErr != nil {
			d.folder.fs.log.CDebugf(ctx,
				"Dir Rename: getting exec path for PID %d error: %v",
				req.Pid, execPathErr)
		}
		return e
	default:
		return err
	}
}
1289346
func (e EventBuilder) Name() string {
	strs := make([]string, len(e.fields))
	for i, field := range e.fields {
		strs[i] = field.value
	}

	return strings.Join(strs, "")
}
992248
func (c *Context) SSEvent(name string, message interface{}) {
	c.Render(-1, sse.Event{
		Event: name,
		Data:  message,
	})
}
1034711
func (s *CreateConfigurationSetEventDestinationInput) SetEventDestinationName(v string) *CreateConfigurationSetEventDestinationInput {
	s.EventDestinationName = &v
	return s
}
327313
func (s *EventSubscription) SetEvent(v string) *EventSubscription {
	s.Event = &v
	return s
}
624700
func NewEvent(name string, data interface{}) *Event {
	return &Event{Name: name, Data: data}
}
66540
func (c *Client) Rename(from, to string) error {
	pconn, err := c.getIdleConn()
	if err != nil {
		return err
	}

	defer c.returnConn(pconn)

	err = pconn.sendCommandExpected(replyFileActionPending, "RNFR %s", from)
	if err != nil {
		return err
	}

	return pconn.sendCommandExpected(replyFileActionOkay, "RNTO %s", to)
}
1214541
func (p *Pipeline) TransformEvent(transformers ...EventTransformer) *Pipeline {
	return &Pipeline{
		prior:       p,
		transformer: filterNilEvent(transformEvent(transformers...)),
	}
}
1371843
func (s *Record) SetEventName(v string) *Record {
	s.EventName = &v
	return s
}
696278
func transformEvent(event *APIEvents) {
	// if event version is <= 1.21 there will be no Action and no Type
	if event.Action == "" && event.Type == "" {
		event.Action = event.Status
		event.Actor.ID = event.ID
		event.Actor.Attributes = map[string]string{}
		switch event.Status {
		case "delete", "import", "pull", "push", "tag", "untag":
			event.Type = "image"
		default:
			event.Type = "container"
			if event.From != "" {
				event.Actor.Attributes["image"] = event.From
			}
		}
	} else {
		if event.Status == "" {
			if event.Type == "image" || event.Type == "container" {
				event.Status = event.Action
			} else {
				// Because just the Status has been overloaded with different Types
				// if an event is not for an image or a container, we prepend the type
				// to avoid problems for people relying on actions being only for
				// images and containers
				event.Status = event.Type + ":" + event.Action
			}
		}
		if event.ID == "" {
			event.ID = event.Actor.ID
		}
		if event.From == "" {
			event.From = event.Actor.Attributes["image"]
		}
	}
}
502912
func (c *Client) RenameContainer(opts RenameContainerOptions) error {
	resp, err := c.do("POST", fmt.Sprintf("/containers/"+opts.ID+"/rename?%s", queryString(opts)), doOptions{
		context: opts.Context,
	})
	if err != nil {
		return err
	}
	resp.Body.Close()
	return nil
}
750260
func (s *UpdateConfigurationSetEventDestinationInput) SetEventDestinationName(v string) *UpdateConfigurationSetEventDestinationInput {
	s.EventDestinationName = &v
	return s
}
97267
func (self *events) updateEventStore(e *Event) {
	self.eventsLock.Lock()
	defer self.eventsLock.Unlock()
	if _, ok := self.eventStore[e.EventType]; !ok {
		maxAge := self.storagePolicy.DefaultMaxAge
		maxNumEvents := self.storagePolicy.DefaultMaxNumEvents
		if age, ok := self.storagePolicy.PerTypeMaxAge[e.EventType]; ok {
			maxAge = age
		}
		if numEvents, ok := self.storagePolicy.PerTypeMaxNumEvents[e.EventType]; ok {
			maxNumEvents = numEvents
		}

		self.eventStore[e.EventType] = utils.NewTimedStore(maxAge, maxNumEvents)
	}
	self.eventStore[e.EventType].Add(e.Timestamp, e)
}
173301
func (ftp *FTP) Rename(from string, to string) (err error) {
	if _, err = ftp.cmd(StatusActionPending, "RNFR %s", from); err != nil {
		return
	}

	if _, err = ftp.cmd(StatusActionOK, "RNTO %s", to); err != nil {
		return
	}

	return
}
389458
func (em *EventManager) RemoveEvent(event string) {
	if !em.HasEvent(event) {
		return
	}

	ev, _ := em.GetEvent(event)
	ev.Offload()

	em.wo.Lock()
	delete(em.events, event)
	em.wo.Unlock()
}