// GetUnitCount returns the UnitCount field if it's non-nil, zero value otherwise.
765383
func (m *MarketplacePurchase) GetUnitCount() int {
	if m == nil || m.UnitCount == nil {
		return 0
	}
	return *m.UnitCount
}
827040
func DurationFromUnit(u Unit) (time.Duration, error) {
	if duration, found := unitsToDuration[u]; found {
		return duration, nil
	}

	return 0, errConvertUnitToDuration
}
60462
func ParseByteUnit(str string) (uint64, error) {
	str = strings.TrimSpace(str)
	str = strings.ToLower(str)

	if u, ok := bytesTable[str]; ok {
		return u, nil
	}
	return 0, errors.Errorf("unknown unit: %q", str)
}
661339
func (r *EtcdRegistry) getUnitFromObjectNode(node *etcd.Node, unitHashLookupFunc func(unit.Hash) *unit.UnitFile) (*job.Unit, error) {
	var err error
	var jm jobModel
	if err = unmarshal(node.Value, &jm); err != nil {
		return nil, err
	}

	var unit *unit.UnitFile

	unit = unitHashLookupFunc(jm.UnitHash)
	if unit == nil {
		log.Warningf("No Unit found in Registry for Job(%s)", jm.Name)
		return nil, nil
	}

	ju := &job.Unit{
		Name: jm.Name,
		Unit: *unit,
	}
	return ju, nil

}
1220153
func doesMinUnitsExist(unit *Unit) (bool, error) {
	minUnits, closer := unit.st.db().GetCollection(minUnitsC)
	defer closer()
	var result bson.D
	err := minUnits.FindId(unit.ApplicationName()).Select(bson.M{"_id": 1}).One(&result)
	if err == nil {
		return true, nil
	} else if err == mgo.ErrNotFound {
		return false, nil
	} else {
		return false, errors.Trace(err)
	}
}
25460
func (t *TeamDiscussion) GetCommentsCount() int {
	if t == nil || t.CommentsCount == nil {
		return 0
	}
	return *t.CommentsCount
}
1344178
func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) {
	path := unitPath(unit)
	return c.getProperties(path, "org.freedesktop.systemd1.Unit")
}
17830
func (i *Invitation) GetTeamCount() int {
	if i == nil || i.TeamCount == nil {
		return 0
	}
	return *i.TeamCount
}
336656
func (image *Image) GetStripeUnit() (stripe_unit uint64, err error) {
	if image.image == nil {
		return 0, RbdErrorImageNotOpen
	}

	ret := C.rbd_get_stripe_unit(image.image, (*C.uint64_t)(&stripe_unit))
	if ret < 0 {
		return 0, RBDError(int(ret))
	}

	return stripe_unit, nil
}
1159982
func (r *EtcdRegistry) getUnitByHash(hash unit.Hash) *unit.UnitFile {
	key := r.hashedUnitPath(hash)
	opts := &etcd.GetOptions{
		Recursive: true,
	}
	start := time.Now()
	resp, err := r.kAPI.Get(context.Background(), key, opts)
	if err != nil {
		if isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
			err = nil
		}
		metrics.ReportRegistryOpFailure(metrics.Get)
		return nil
	}
	metrics.ReportRegistryOpSuccess(metrics.Get, start)
	return r.unitFromEtcdNode(hash, resp.Node)
}
1055667
func (s *Storage) GetTotalCount() int64 {
	var count int64
	getInt64(storage.TotalCountKey, &count)

	return count
}
909034
func GetCountCtx(r *http.Request) int {
	count, ok := r.Context().Value(ctxCount).(int)
	if !ok {
		apiLog.Warn("count is not set or is not an int")
		return 20
	}
	return count
}
798689
func (r *UnitStateService) Get(unitName string) *UnitStateGetCall {
	c := &UnitStateGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.unitName = unitName
	return c
}
1121063
func (c *ImportMetricCounter) countRepositoryImport(isi *imagev1.ImageStreamImport, err error) {
	errInfo := getIsImportRepositoryInfo(isi)
	if errInfo == nil {
		return
	}

	c.counterMutex.Lock()
	defer c.counterMutex.Unlock()

	if len(errInfo.Reason) == 0 {
		c.importSuccessCounts[errInfo.Registry]++
	} else {
		c.importErrorCounts[*defaultErrorInfoReason(errInfo, err)]++
	}
}
738870
func (p *PushEventRepository) GetOpenIssuesCount() int {
	if p == nil || p.OpenIssuesCount == nil {
		return 0
	}
	return *p.OpenIssuesCount
}
1207849
func (c *Users) GetCurrentAccount() (out *GetCurrentAccountOutput, err error) {
	body, err := c.call("/users/get_current_account", nil)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}
343391
func (m *MeterStatusAPI) GetMeterStatus(args params.Entities) (params.MeterStatusResults, error) {
	result := params.MeterStatusResults{
		Results: make([]params.MeterStatusResult, len(args.Entities)),
	}
	canAccess, err := m.accessUnit()
	if err != nil {
		return params.MeterStatusResults{}, common.ErrPerm
	}
	for i, entity := range args.Entities {
		unitTag, err := names.ParseUnitTag(entity.Tag)
		if err != nil {
			result.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}
		err = common.ErrPerm
		var status state.MeterStatus
		if canAccess(unitTag) {
			var unit *state.Unit
			unit, err = m.state.Unit(unitTag.Id())
			if err == nil {
				status, err = MeterStatusWrapper(unit.GetMeterStatus)
			}
			result.Results[i].Code = status.Code.String()
			result.Results[i].Info = status.Info
		}
		result.Results[i].Error = common.ServerError(err)
	}
	return result, nil
}