// NewRelationIdValue returns a gnuflag.Value for convenient parsing of relation
// ids in ctx.
335777
func NewRelationIdValue(ctx Context, result *int) (*relationIdValue, error) {
	v := &relationIdValue{result: result, ctx: ctx}
	id := -1
	if r, err := ctx.HookRelation(); err == nil {
		id = r.Id()
		v.value = r.FakeId()
	} else if !errors.IsNotFound(err) {
		return nil, errors.Trace(err)
	}
	*result = id
	return v, nil
}
1289094
func (schema *Schema) intValue(v interface{}) *int64 {
	switch v := v.(type) {
	default:
		fmt.Printf("intValue: unexpected type %T\n", v)
	case float64:
		v2 := int64(v)
		return &v2
	case int64:
		return &v
	case int:
		v2 := int64(v)
		return &v2
	}
	return nil
}
269271
func (s *InternalLBService) NewCreateInternalLoadBalancerElementParams(nspid string) *CreateInternalLoadBalancerElementParams {
	p := &CreateInternalLoadBalancerElementParams{}
	p.p = make(map[string]interface{})
	p.p["nspid"] = nspid
	return p
}
428841
func SetBuilderElementValue(elm *etree.Element, data [][]interface{}, basekey string) (*etree.Element, bool) {
	var child *etree.Element

	key := basekey
	ts, tk := spaceDecompose(elm.Tag)
	_, sk := spaceDecompose(elm.Space)

	if elm.Tag != "" && ts != "" && tk != "" {
		key = fmt.Sprintf("%s:%s", elm.Space, basekey)
	} else if sk != "" {
		key = fmt.Sprintf("%s:%s", sk, basekey)
	}

	var values interface{}
	var found bool
	for _, v := range data {
		if v[0] == basekey {
			values = v[1]
			found = true
			break
		}
	}
	if !found {
		return child, false
	}

	switch value := values.(type) {
	case nil:
	default:
		child = elm.CreateElement(key)
		child.SetText(fmt.Sprint(value))
	case int:
		child = elm.CreateElement(key)
		child.SetText(fmt.Sprint(value))
	case string:
		child = elm.CreateElement(key)
		child.SetText(value)
	case float64, float32:
		child = elm.CreateElement(key)
		child.SetText(fmt.Sprint(value))
	case time.Time:
		child = elm.CreateElement(key)
		child.SetText(value.Format(time.RFC3339))
	case bool:
		_ = elm.CreateElement(fmt.Sprintf("%s:%s", key, key))
	case []int:
		for _, v := range value {
			child = elm.CreateElement(key)
			child.SetText(fmt.Sprint(v))
		}
	case []string:
		for _, v := range value {
			child = elm.CreateElement(key)
			child.SetText(v)
		}
	case []Attr:
		for _, attr := range value {
			child = elm.CreateElement(key)
			for k, v := range attr {
				child.CreateAttr(k, v)
			}
		}
	case Attrs:
		val, attrs := value[0], value[1]

		child, _ = SetBuilderElementValue(elm, URL{[]interface{}{basekey, val}}, basekey)
		switch attr := attrs.(type) {
		case map[string]string:
			for k, v := range attr {
				child.CreateAttr(k, v)
			}
		// TODO: gotta remove below
		case Attr:
			for k, v := range attr {
				child.CreateAttr(k, v)
			}
		}

	case interface{}:
		var childkey string
		if sk == "" {
			childkey = fmt.Sprintf("%s:%s", key, key)
		} else {
			childkey = fmt.Sprint(key)
		}

		switch value := values.(type) {
		case []URL:
			for _, val := range value {
				child := elm.CreateElement(childkey)
				for _, v := range val {
					SetBuilderElementValue(child, val, v[0].(string))
				}
			}
		case URL:
			child := elm.CreateElement(childkey)
			for _, v := range value {
				SetBuilderElementValue(child, value, v[0].(string))
			}
		}
	}
	return child, true
}
1219279
func PgRelationIsUpdatable(db XODB, v0 pgtypes.Regclass, v1 bool) (int, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_relation_is_updatable($1, $2)`

	// run query
	var ret int
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return 0, err
	}

	return ret, nil
}
763087
func (qs *QuadStore) AddValue(v quad.Value) (int64, bool) {
	id, exists := qs.resolveVal(v, true)
	return id, !exists
}
1319640
func NewValueI32(v int32) Value {
	return Value{
		typ:     TI32,
		tnumber: uint64(v),
	}
}
265427
func NewBooleanValue(t int64, v bool) Value {
	return BooleanValue{unixnano: t, value: v}
}
1324691
func NewObjectValue(unindexed ...bool) Value {
	return Value{Object, nil, optionalBool(unindexed, false)}
}
1300168
func (u *Unit) NewValue(value int64, explicitSign Sign) (*Value, error) {
	if (value < 0 && explicitSign == Positive) || (value > 0 && explicitSign == Negative) {
		return nil, errors.New("Invalid value/explicitSign combination")
	}

	return &Value{
		unit:         u,
		Value:        value,
		ExplicitSign: explicitSign,
	}, nil
}
363985
func (s *RelationalDatabaseDataSourceConfig) SetRelationalDatabaseSourceType(v string) *RelationalDatabaseDataSourceConfig {
	s.RelationalDatabaseSourceType = &v
	return s
}
459335
func (s *GetRelationalDatabaseOutput) SetRelationalDatabase(v *RelationalDatabase) *GetRelationalDatabaseOutput {
	s.RelationalDatabase = v
	return s
}
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
}
184865
func (s *InternalLBService) GetInternalLoadBalancerElementByID(id string, opts ...OptionFunc) (*InternalLoadBalancerElement, int, error) {
	p := &ListInternalLoadBalancerElementsParams{}
	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.ListInternalLoadBalancerElements(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.InternalLoadBalancerElements[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for InternalLoadBalancerElement UUID: %s!", id)
}
8252
func (c *Client) AddRelation(endpoints, viaCIDRs []string) (*params.AddRelationResults, error) {
	var addRelRes params.AddRelationResults
	args := params.AddRelation{Endpoints: endpoints, ViaCIDRs: viaCIDRs}
	err := c.facade.FacadeCall("AddRelation", args, &addRelRes)
	return &addRelRes, err
}
947373
func NewRelationCache(readSettings SettingsFunc, memberNames []string) *RelationCache {
	cache := &RelationCache{
		readSettings: readSettings,
	}
	cache.Prune(memberNames)
	return cache
}
1336800
func SetCorrelationID(cid string) RequestFunc {
	return func(ctx context.Context, pub *amqp.Publishing, _ *amqp.Delivery) context.Context {
		pub.CorrelationId = cid
		return ctx
	}
}