// UpdateState updates the room's current state with the given Event. This will clobber events based
// on the type/state_key combination.
421598
func (room Room) UpdateState(event *Event) {
	_, exists := room.State[event.Type]
	if !exists {
		room.State[event.Type] = make(map[string]*Event)
	}
	room.State[event.Type][*event.StateKey] = event
}
753978
func (s *DescribeGroupOutput) SetState(v string) *DescribeGroupOutput {
	s.State = &v
	return s
}
902737
func (s *StopChannelOutput) SetState(v string) *StopChannelOutput {
	s.State = &v
	return s
}
1205258
func (s *InstanceFleetStatus) SetState(v string) *InstanceFleetStatus {
	s.State = &v
	return s
}
1171762
func (s *PutRuleInput) SetState(v string) *PutRuleInput {
	s.State = &v
	return s
}
847321
func (s *DescribeSessionsInput) SetState(v string) *DescribeSessionsInput {
	s.State = &v
	return s
}
1045948
func (s *InstanceGroupStatus) SetState(v string) *InstanceGroupStatus {
	s.State = &v
	return s
}
217509
func (s *AvailBlanking) SetState(v string) *AvailBlanking {
	s.State = &v
	return s
}
537395
func (s *GetVaultLockOutput) SetState(v string) *GetVaultLockOutput {
	s.State = &v
	return s
}
269513
func UpdateState(conn client.Connection, req StateRequest, mutate func(*State) bool) error {
	logger := plog.WithFields(log.Fields{
		"hostid":     req.HostID,
		"serviceid":  req.ServiceID,
		"instanceid": req.InstanceID,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	// Get the current host state
	hspth := path.Join(basepth, "/hosts", req.HostID, "instances", req.StateID())
	hsdat := &HostState{}
	if err := conn.Get(hspth, hsdat); err != nil {

		logger.WithError(err).Debug("Could not look up host state")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not look up host state",
		}
	}

	// Get the current service state
	sspth := path.Join(basepth, "/services", req.ServiceID, req.StateID())
	ssdat := &ServiceState{}
	if err := conn.Get(sspth, ssdat); err != nil {

		logger.WithError(err).Debug("Could not look up service state")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not look up service state",
		}
	}

	// Get the current state (status)
	cspth := path.Join(sspth, "current")
	cstate := &CurrentStateContainer{}
	if err := conn.Get(cspth, cstate); err != nil {
		logger.WithError(err).Debug("Could not look up current state (status)")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not look up current state (status)",
		}
	}

	// mutate the states
	hsver, ssver, cstatever := hsdat.Version(), ssdat.Version(), cstate.Version()
	state := &State{
		HostState:             *hsdat,
		ServiceState:          *ssdat,
		CurrentStateContainer: *cstate,
		HostID:                req.HostID,
		ServiceID:             req.ServiceID,
		InstanceID:            req.InstanceID,
	}

	// only commit the transaction if mutate returns true
	if !mutate(state) {
		logger.Debug("Transaction aborted")
		return nil
	}

	// set the version object on the respective states
	*hsdat = state.HostState
	hsdat.SetVersion(hsver)
	*ssdat = state.ServiceState
	ssdat.SetVersion(ssver)
	*cstate = state.CurrentStateContainer
	cstate.SetVersion(cstatever)

	if err := conn.NewTransaction().Set(hspth, hsdat).Set(sspth, ssdat).Set(cspth, cstate).Commit(); err != nil {
		logger.WithError(err).Debug("Could not commit transaction")
		return &StateError{
			Request:   req,
			Operation: "update",
			Message:   "could not commit transaction",
		}
	}

	logger.Debug("Updated state")
	return nil
}
474451
func (s *InputSecurityGroup) SetState(v string) *InputSecurityGroup {
	s.State = &v
	return s
}
45945
func (s *AvailabilityZone) SetState(v string) *AvailabilityZone {
	s.State = &v
	return s
}
259936
func (s *DiskSnapshot) SetState(v string) *DiskSnapshot {
	s.State = &v
	return s
}
1141614
func (s *InstanceGroupDetail) SetState(v string) *InstanceGroupDetail {
	s.State = &v
	return s
}
892859
func (s *WorkGroup) SetState(v string) *WorkGroup {
	s.State = &v
	return s
}
756962
func (s *ClusterStatus) SetState(v string) *ClusterStatus {
	s.State = &v
	return s
}
923434
func (r *Resolver) UpdateState(s resolver.State) {
	r.cc.UpdateState(s)
}