// Sets the current unit to an assertion of the specified type
498606
func (p *parser) addUnitType(t nodeType) {
	p.unit = newRegexNode(t, p.options)
}
1169790
func (s *CurrentMetric) SetUnit(v string) *CurrentMetric {
	s.Unit = &v
	return s
}
255262
func (s *Member) SetType(v string) *Member {
	s.Type = &v
	return s
}
109646
func (mr *MockGenerationMockRecorder) AssignUnit(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignUnit", reflect.TypeOf((*MockGeneration)(nil).AssignUnit), arg0)
}
1029901
func (s *GetInstanceMetricDataInput) SetUnit(v string) *GetInstanceMetricDataInput {
	s.Unit = &v
	return s
}
319125
func (s *HistoricalMetric) SetUnit(v string) *HistoricalMetric {
	s.Unit = &v
	return s
}
788761
func SetIdempotencyToken(v reflect.Value) {
	if v.Kind() == reflect.Ptr {
		if v.IsNil() && v.CanSet() {
			v.Set(reflect.New(v.Type().Elem()))
		}
		v = v.Elem()
	}
	v = reflect.Indirect(v)

	if !v.CanSet() {
		panic(fmt.Sprintf("unable to set idempotnecy token %v", v))
	}

	b := make([]byte, 16)
	_, err := rand.Read(b)
	if err != nil {
		// TODO handle error
		return
	}

	v.Set(reflect.ValueOf(UUIDVersion4(b)))
}
1167873
func (w *Waker) Assert() {
	// Nothing to do if the waker is already asserted. This check allows us
	// to complete this case (already asserted) without any interlocked
	// operations on x86.
	if atomic.LoadPointer(&w.s) == usleeper(&assertedSleeper) {
		return
	}

	// Mark the waker as asserted, and wake up a sleeper if there is one.
	switch s := (*Sleeper)(atomic.SwapPointer(&w.s, usleeper(&assertedSleeper))); s {
	case nil:
	case &assertedSleeper:
	default:
		s.enqueueAssertedWaker(w)
	}
}
1194643
func (u *UnitAgent) SetStatus(unitAgentStatus status.StatusInfo) (err error) {
	unit, err := u.st.Unit(u.name)
	if errors.IsNotFound(err) {
		return errors.Annotate(errors.NotFoundf("agent"), "cannot set status")
	}
	if err != nil {
		return errors.Trace(err)
	}
	isAssigned := unit.doc.MachineId != ""
	shouldBeAssigned := unit.ShouldBeAssigned()
	isPrincipal := unit.doc.Principal == ""

	switch unitAgentStatus.Status {
	case status.Idle, status.Executing, status.Rebooting, status.Failed:
		if !isAssigned && isPrincipal && shouldBeAssigned {
			return errors.Errorf("cannot set status %q until unit is assigned", unitAgentStatus.Status)
		}
	case status.Error:
		if unitAgentStatus.Message == "" {
			return errors.Errorf("cannot set status %q without info", unitAgentStatus.Status)
		}
	case status.Allocating:
		if isAssigned {
			return errors.Errorf("cannot set status %q as unit is already assigned", unitAgentStatus.Status)
		}
	case status.Running:
		// Only CAAS units (those that require assignment) can have a status of running.
		if shouldBeAssigned {
			return errors.Errorf("cannot set invalid status %q", unitAgentStatus.Status)
		}
	case status.Lost:
		return errors.Errorf("cannot set status %q", unitAgentStatus.Status)
	default:
		return errors.Errorf("cannot set invalid status %q", unitAgentStatus.Status)
	}
	return setStatus(u.st.db(), setStatusParams{
		badge:     "agent",
		globalKey: u.globalKey(),
		status:    unitAgentStatus.Status,
		message:   unitAgentStatus.Message,
		rawData:   unitAgentStatus.Data,
		updated:   timeOrNow(unitAgentStatus.Since, u.st.clock()),
	})
}
1168824
func (s *AttackProperty) SetUnit(v string) *AttackProperty {
	s.Unit = &v
	return s
}
308977
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
	if h, ok := a.t.(tHelper); ok {
		h.Helper()
	}
	return Implements(a.t, interfaceObject, object, msgAndArgs...)
}
1096570
func (s *Instance) SetType(v string) *Instance {
	s.Type = &v
	return s
}
652906
func (s *Trigger) SetType(v string) *Trigger {
	s.Type = &v
	return s
}
427178
func (s *LoadBalancer) SetType(v string) *LoadBalancer {
	s.Type = &v
	return s
}
808229
func (s *PutMetricAlarmInput) SetUnit(v string) *PutMetricAlarmInput {
	s.Unit = &v
	return s
}
257074
func (s *StatusAPI) SetUnitStatus(args params.SetStatus) (params.ErrorResults, error) {
	return s.unitSetter.SetStatus(args)
}
1368740
func (s *CustomizedScalingMetricSpecification) SetUnit(v string) *CustomizedScalingMetricSpecification {
	s.Unit = &v
	return s
}