// GetValueByDI an abstraction to return key's value in respective type based on dimension info which is provided by user
768235
func (arc *ConfigFactory) GetValueByDI(dimensionInfo, key string) cast.Value {
	if arc.initSuccess == false {
		return nil
	}

	var confValue cast.Value
	val := arc.GetConfigurationByKeyAndDimensionInfo(dimensionInfo, key)
	if val == nil {
		confValue = cast.NewValue(nil, errors.New("key does not exist"))
	} else {
		confValue = cast.NewValue(val, nil)
	}

	return confValue
}
534132
func (mem *memNamedMapping) GetValue(name string) (value interface{}, exists bool) {
	mem.access.RLock()
	defer mem.access.RUnlock()

	item, found := mem.nameToIdx[name]
	if found {
		return item.value, found
	}
	return
}
1214678
func (_class VBDClass) GetVDI(sessionID SessionRef, self VBDRef) (_retval VDIRef, _err error) {
	_method := "VBD.get_VDI"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVBDRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertVDIRefToGo(_method + " -> ", _result.Value)
	return
}
1106315
func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string, opts ...OptionFunc) (*AutoScaleVmProfile, int, error) {
	p := &ListAutoScaleVmProfilesParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListAutoScaleVmProfiles(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.AutoScaleVmProfiles[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for AutoScaleVmProfile UUID: %s!", id)
}
956722
func (s *AutoScaleService) GetAutoScalePolicyByID(id string, opts ...OptionFunc) (*AutoScalePolicy, int, error) {
	p := &ListAutoScalePoliciesParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListAutoScalePolicies(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.AutoScalePolicies[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for AutoScalePolicy UUID: %s!", id)
}
113515
func GetValueByNamespace(object interface{}, ns []string) interface{} {

	if len(ns) == 0 {
		fmt.Fprintf(os.Stderr, "Namespace length equal to zero\n")
		return nil
	}

	if object == nil {
		fmt.Fprintf(os.Stderr, "First parameter cannot be nil!\n")
		return nil
	}

	// current level of namespace
	current := ns[0]

	switch reflect.TypeOf(object).Kind() {
	case reflect.Map:
		if m, ok := object.(map[string]interface{}); ok {
			if val, ok := m[current]; ok {
				if len(ns) == 1 {
					return val
				}
				return GetValueByNamespace(val, ns[1:])
			}
			fmt.Fprintf(os.Stderr, "Key does not exist in map {key %s}\n", current)
			return nil
		}
	case reflect.Slice:
		curr, err := strconv.Atoi(current)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Cannot convert index to integer {idx %v}\n", current)
			return nil
		}

		if a, ok := object.([]interface{}); ok {
			if curr >= len(a) {
				fmt.Fprintf(os.Stderr, "Index out of range {idx %v}\n", current)
				return nil
			}
			if len(ns) == 1 {
				return a[curr]
			}
			return GetValueByNamespace(a[curr], ns[1:])
		}
	case reflect.Ptr:
		// TODO Implementation of handling pointers to objects other than structs
		return GetStructValueByNamespace(object, ns)
	case reflect.Struct:
		return GetStructValueByNamespace(object, ns)
	default:
		fmt.Fprintf(os.Stderr, "Unsupported object type {object %v}", object)
	}

	return nil
}
267509
func (d *DataSource) GetByID(id int64) (Model, bool) {
	return d.GetBy(func(u Model) bool {
		return u.ID == id
	})
}
143569
func (res RPCResponses) GetByID(id int) *RPCResponse {
	for _, r := range res {
		if r.ID == id {
			return r
		}
	}

	return nil
}
1295220
func (m *Manager) GetByID(iyoid string) (*Identifier, error) {
	var idObj Identifier

	if err := m.getIdentifierCollection().Find(bson.M{"iyoids": iyoid}).One(&idObj); err != nil {
		return nil, err
	}

	return &idObj, nil
}
1016902
func (s *GuestOSService) GetOsTypeByID(id string, opts ...OptionFunc) (*OsType, int, error) {
	p := &ListOsTypesParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListOsTypes(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.OsTypes[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for OsType UUID: %s!", id)
}
1292924
func (e *EnumDescriptor) GetNamedValue(name string) *EnumValueDescriptor {
	for _, v := range e.GetValues() {
		if v.GetName() == name {
			return v
		}
	}

	return nil
}
1350805
func (mc MongoClient) ValueDescriptorsByType(t string) ([]contract.ValueDescriptor, error) {
	return mapValueDescriptors(mc.getValueDescriptors(bson.M{"type": t}))
}
274091
func (c *Client) GetLightByID(id uint64) (light common.Light, err error) {
	dev, err := c.GetDeviceByID(id)
	if err != nil {
		return nil, err
	}

	light, ok := dev.(common.Light)
	if !ok {
		return nil, common.ErrDeviceInvalidType
	}

	return light, nil
}
104078
func (s *DiskOfferingService) GetDiskOfferingByID(id string, opts ...OptionFunc) (*DiskOffering, int, error) {
	p := &ListDiskOfferingsParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListDiskOfferings(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.DiskOfferings[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for DiskOffering UUID: %s!", id)
}
664845
func (r *RDBDriver) GetByCpeURI(uri string) ([]models.CveDetail, error) {
	cveIDs, err := r.GetCveIDsByCpeURI(uri)
	if err != nil {
		return nil, err
	}

	cveDetails, err := r.GetMulti(cveIDs)
	if err != nil {
		return nil, err
	}

	// Convert from map to array
	details := make([]models.CveDetail, len(cveDetails))
	i := 0
	for _, d := range cveDetails {
		details[i] = d
		i++
		log.Debugf("%s", d.CveID)
	}
	return details, nil
}
821501
func (c *Client) ValueDescriptorById(id string) (value contract.ValueDescriptor, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	err = getObjectById(conn, id, unmarshalObject, &value)
	if err == redis.ErrNil {
		return value, db.ErrNotFound
	}
	if err != nil {
		return value, err
	}

	return value, nil
}
386537
func (s *KeyGen) GetByKey(key string) (hash string, val interface{}, err error) {
	var r interface{}
	search := fmt.Sprintf("*:%s", key)

	if r, err = s.store().Do("KEYS", search); r != nil && err == nil {

		if _, _, hash, err = parseKeysResponse(r); err == nil {
			val, err = s.getHashMap(hash)
		}
	}
	return
}