//Transforms a rule string(i.e. "latest=100") to a proper JSON object(i.e. {"latest":100}
196021
func transformRules(rules *[]string) map[string]int {
	rule := map[string]int{}

	for _, v := range *rules {
		r := strings.Split(v, "=")
		weight, err := strconv.Atoi(r[1])
		rule[r[0]] = weight

		if err != nil {
			log.Fatalf("Error converting weight in rule %s to int", v)
		}
	}

	return rule
}
577364
func (r *Ruler) Rule(path string) *RulerRule {
	rule := &Rule{
		"",
		path,
		nil,
	}

	r.rules = append(r.rules, rule)

	return &RulerRule{
		r,
		rule,
	}
}
164953
func (a *ACL) RulesTranslateToken(tokenID string) (string, error) {
	r := a.c.newRequest("GET", "/v1/acl/rules/translate/"+tokenID)
	rtt, resp, err := requireOK(a.c.doRequest(r))
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()
	qm := &QueryMeta{}
	parseQueryMeta(resp, qm)
	qm.RequestTime = rtt

	ruleBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", fmt.Errorf("Failed to read translated rule body: %v", err)
	}

	return string(ruleBytes), nil
}
945706
func (ac *APIController) RuleUpdate(rule, params *contivModel.Rule) error {
	log.Infof("Received RuleUpdate: %+v, params: %+v", rule, params)
	return errors.New("can not update a rule after its created")
}
865300
func (f *DataFuncs) ToJSONPretty(indent string, in interface{}) (string, error) {
	return data.ToJSONPretty(indent, in)
}
82069
func HelperString(w expr.DialectWriter, jh u.JsonHelper) {

	// isJson := false
	// for k, v := range jh {
	// 	switch lvt := lv.(type) {
	// 	case int, int64, int32, string, bool, float64:
	// 		//
	// 	case []string, []int, []int32, []int64, []float64:
	// 		//
	// 	case u.JsonHelper, map[string]interface{}:
	// 		isJson = true
	// 		break
	// 	default:
	// 		u.Warnf("unhandled type comparison: %T", lv)
	// 	}
	// }
	pos := 0
	keys := jh.Keys()
	sort.Strings(keys)

	for _, k := range keys {
		val := jh[k]
		if pos > 0 {
			io.WriteString(w, ", ")
		}
		w.WriteIdentity(k)
		io.WriteString(w, " = ")
		switch v := val.(type) {
		case string:
			w.WriteLiteral(v)
		case int, int64, int32, bool, float64:
			io.WriteString(w, fmt.Sprintf("%v", v))
		default:
			u.Warnf("unhandled type comparison: %T", val)
		}
		pos++
	}
}
876077
func (ruleFormats *RuleFormats) GetRuleFormats() error {
	req, err := client.NewRequest(
		Config,
		"GET",
		"/papi/v1/rule-formats",
		nil,
	)
	if err != nil {
		return err
	}

	res, err := client.Do(Config, req)
	if err != nil {
		return err
	}

	if client.IsError(res) {
		return client.NewAPIError(res)
	}

	if err := client.BodyJSON(res, ruleFormats); err != nil {
		return err
	}

	sort.Strings(ruleFormats.RuleFormats.Items)

	return nil
}
138580
func NewRules() *rules {
	rules := &rules{namesKeys: nameToKey, phoneDevices: phoneDevices, tabletDevices: tabletDevices, operatingSystems: operatingSystems, browsers: browsers}
	rules.setMobileDetectionRules(nameToKey)
	return rules
}
1117421
func (r *Rule) Strings() (strs []String) {
	var size C.int
	C.rule_strings(r.cptr, nil, &size)
	if size == 0 {
		return
	}
	ptrs := make([]*C.YR_STRING, int(size))
	C.rule_strings(r.cptr, &ptrs[0], &size)
	for _, ptr := range ptrs {
		strs = append(strs, String{ptr})
	}
	return
}
244443
func (h *ClientHandler) Rule(r rule.Rule) *ClientHandler {
	if r == nil {
		// if nothing passed then use the allow-everything rule
		r = rule.Satisfied()
	}
	h.rule = r

	return h
}
267878
func (i FillRule) String() string {
	switch i {
	case FillRuleWinding:
		return "FillRuleWinding"
	case FillRuleEvenOdd:
		return "FillRuleEvenOdd"
	default:
		return fmt.Sprintf("FillRule(%d)", i)
	}
}
71822
func FilterString(data map[string][]string) string {
	// I can't imagine this would ever fail
	bytes, _ := json.Marshal(data)
	return string(bytes)
}
969303
func NewRule(basePath string, status int) *Rule {
	return &Rule{
		Base:           basePath,
		StatusCode:     status,
		RequestMatcher: httpserver.PathMatcher(basePath),
	}
}
1247487
func (s *StageInstance) JSONString() (string, error) {
	err := s.Validate()
	if err != nil {
		return "", err
	}
	bdy, err := json.MarshalIndent(s, "", "  ")
	return string(bdy), err
}
1245947
func NewSimpleRule(from, to string, negate bool) (*SimpleRule, error) {
	r, err := regexp.Compile(from)
	if err != nil {
		return nil, err
	}
	return &SimpleRule{
		Regexp: r,
		To:     to,
		Negate: negate,
	}, nil
}
942457
func (chr *chr_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
	return locales.PluralRuleUnknown
}
682476
func NewRule(resource string, verbs []string) Rule {
	return Rule{
		Resources: []string{resource},
		Verbs:     verbs,
	}
}