// Extract request params to be sent with event notifiation.
549836
func extractReqParams(r *http.Request) map[string]string {
	if r == nil {
		return nil
	}

	region := globalServerConfig.GetRegion()
	cred := getReqAccessCred(r, region)

	// Success.
	return map[string]string{
		"region":          region,
		"accessKey":       cred.AccessKey,
		"sourceIPAddress": handlers.GetSourceIP(r),
		// Add more fields here.
	}
}
320337
func (json *JSON) GetParams(name string) (Params, bool) {
	if value := json.fetch(name); value.IsObject() {
		return &JSON{Result: value}, true
	}

	return nil, false
}
1101960
func (rl redirectURIList) extractValidRedirectURIStrings() []string {
	var data []string
	for _, u := range rl {
		if u.isValid() {
			data = append(data, u.String())
		}
	}
	return data
}
615131
func ExtractTokenFromCookie(r *http.Request) (string, error) {
	cookie, err := r.Cookie(CookieName)
	if err != nil {
		return "", trace.Wrap(err)
	}

	return cookie.Value, nil
}
177296
func Params(req *http.Request) httprouter.Params {
	if value, ok := httpcontext.GetOk(req, paramsKey); ok {
		if params, ok := value.(httprouter.Params); ok {
			return params
		}
	}
	return httprouter.Params{}
}
420800
func (c *Client) GetEvents(
	severity, eventCode, descRxPatt string) ([]Event, error) {

	events, err := c.api.GetEvents(severity)
	if err != nil {
		return nil, err
	}

	var filtered []Event
	rx, _ := regexp.Compile(descRxPatt)

	for _, e := range events.Events {
		if (eventCode == "" || e.EventCode == eventCode) &&
			(e.Description == "" || rx.MatchString(e.Description)) {
			filtered = append(filtered, e)
		}
	}
	return filtered, nil
}
68698
func (ar avroRecord) extract(pmm *producers.MetricsMessage, ctr *mesosAgent.ContainerTaskRels) error {
	var fieldType string
	if len(ar) > 0 {
		fieldType = ar[0].Name
	} else {
		return fmt.Errorf("no records found for extract")
	}

	switch fieldType {
	case "dcos.metrics.Tag": // Extract tags
		for _, field := range ar {
			if len(field.Fields) != 2 {
				return fmt.Errorf("tags must have 2 fields, got %d", len(field.Fields))
			}
			fwColLog.Debugf("Adding tag %s", field)
			tagName := fmt.Sprintf("%v", field.Fields[0].Datum)
			tagValue := fmt.Sprintf("%v", field.Fields[1].Datum)

			if tagName == "container_id" {
				pmm.Dimensions.ContainerID = tagValue

				info := ctr.Get(tagValue)
				if info != nil {
					pmm.Dimensions.TaskID = info.ID
					pmm.Dimensions.TaskName = info.Name
					pmm.Dimensions.Labels = convertLabels(info.Labels)
				} else {
					fwColLog.Debugf("Container ID %s had no associated task", tagValue)
				}

			} else if tagName == "framework_id" {
				pmm.Dimensions.FrameworkID = tagValue
			} else if tagName == "executor_id" {
				pmm.Dimensions.ExecutorID = tagValue
			} else {
				// Assumes Labels has been initialized already.
				pmm.Dimensions.Labels[tagName] = tagValue
			}
			pmm.Timestamp = time.Now().Unix()
		}
		return nil

	case "dcos.metrics.Datapoint": // Extract datapoints
		datapoints := []producers.Datapoint{}
		for _, field := range ar {
			if len(field.Fields) != 3 {
				return fmt.Errorf("datapoints must have 3 fields, got %d", len(field.Fields))
			}
			fwColLog.Debugf("Adding datapoint %s", field)

			var (
				name = field.Fields[0].Datum
				//time_ms = field.Fields[1].Datum
				value = field.Fields[2].Datum
			)

			// TODO(roger): the datapoint schema does not contain any fields
			// allowing for the sender to specify units. Therefore we default
			// to the zero value, an empty string.
			dp := producers.Datapoint{
				Name: fmt.Sprintf("%v", name),
				//Unit:      fmt.Sprintf("%v", unit),
				Value:     value,
				Timestamp: time.Now().UTC().Format(time.RFC3339),
			}

			datapoints = append(datapoints, dp)
		}
		pmm.Datapoints = datapoints
		return nil
	}

	return fmt.Errorf("must have dcos.metrics.Tags or dcos.metrics.Datapoint in avro record to use .extract()")
}
486196
func extractMetadata(ctx context.Context, r *http.Request) (metadata map[string]string, err error) {
	query := r.URL.Query()
	header := r.Header
	metadata = make(map[string]string)
	// Extract all query values.
	err = extractMetadataFromMap(ctx, query, metadata)
	if err != nil {
		return nil, err
	}

	// Extract all header values.
	err = extractMetadataFromMap(ctx, header, metadata)
	if err != nil {
		return nil, err
	}

	// Set content-type to default value if it is not set.
	if _, ok := metadata["content-type"]; !ok {
		metadata["content-type"] = "application/octet-stream"
	}

	// Success.
	return metadata, nil
}
891009
func (r *LogResource) GetParams() []*restful.Parameter {
	params := []*restful.Parameter{}
	params = append(params, restful.QueryParameter("bee", "id of a bee").DataType("string"))

	return params
}
530172
func GetParams(name string, r *http.Request) []string {
	if params := r.Context().Value(ParamsKey); params != nil {
		params := params.(Params)
		if name != "*" {
			name = ":" + name
		}
		if param := params[name]; param != nil {
			switch param := param.(type) {
			case []string:
				return param
			default:
				return []string{param.(string)}
			}
		}
	}
	return []string{}
}
654606
func extractDetails(msg *bbv1.ApiCommonBuildMessage) (info string, botID string, err error) {
	var resultDetails struct {
		// TODO(nodir,iannucci): define a proto for build UI data
		UI struct {
			Info string `json:"info"`
		} `json:"ui"`
		Swarming struct {
			TaskResult struct {
				BotID string `json:"bot_id"`
			} `json:"task_result"`
			BotDimensions struct {
				ID []string `json:"id"`
			} `json:"bot_dimensions"`
		} `json:"swarming"`
	}
	if msg.ResultDetailsJson != "" {
		err = json.NewDecoder(strings.NewReader(msg.ResultDetailsJson)).Decode(&resultDetails)
		info = resultDetails.UI.Info
		botID = resultDetails.Swarming.TaskResult.BotID
		if botID == "" && len(resultDetails.Swarming.BotDimensions.ID) > 0 {
			botID = resultDetails.Swarming.BotDimensions.ID[0]
		}
	}
	return
}
131153
func GetAllQueries(req *http.Request) map[string][]string {
	if ok, values := extractQueries(req); ok {
		return values
	}
	return nil
}
781199
func extractName(sf reflect.StructField) string {
	name := sf.Tag.Get("param")
	if name == "" {
		name = sf.Tag.Get("json")
		idx := strings.IndexRune(name, ',')
		if idx >= 0 {
			name = name[:idx]
		}
	}
	if name == "" {
		name = sf.Name
	}

	return name
}
365443
func (e *Endpoint) extract(sel *goquery.Selection) Result {
	r := Result{}
	for field, ext := range e.Result {
		if v := ext.execute(sel); v != "" {
			r[field] = v
		} else if e.Debug {
			logf("missing %s", field)
		}
	}
	return r
}
730460
func Find(rType, action, identifier string, wrappedRequest *http.Request) (*http.Response, string, []error) {
	params := "select_by="
	params += fmt.Sprintf("type=%s,", rType)
	params += fmt.Sprintf("action=%s", action)
	if identifier != "" {
		params += fmt.Sprintf(",uuid=%s,", identifier)
	}

	fmt.Println("Params: ", params)

	k := kumoru.New()
	k.Get(fmt.Sprintf("%s/v1/resources/", k.EndPoint.Authorization))
	k.Query(params)
	if wrappedRequest != nil {
		k.ProxyRequest(wrappedRequest)
		if wrappedRequest.Header.Get("X-Kumoru-Context") != "" {
			k.SetHeader("X-Kumoru-Context", wrappedRequest.Header.Get("X-Kumoru-Context"))
		}
	}
	k.SignRequest(true)

	return k.End()
}
807929
func _getResourceParams(r *raml.Resource, params []string) []string {
	if r == nil {
		return params
	}

	matches := reResourceParam.FindAllString(r.URI, -1)
	for _, match := range matches {
		matchEscaped := commons.NormalizeIdentifier(match[1 : len(match)-1])
		params = append(params, matchEscaped)
	}

	return _getResourceParams(r.Parent, params)
}
1126405
func ExtractFromHTTPRequest(req *http.Request, handlerName string) (opentracing.Span, *http.Request) {
	spanContext, err := opentracing.GlobalTracer().Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(req.Header))
	if err != nil {
		span, ctx := opentracing.StartSpanFromContext(req.Context(), handlerName+":"+req.URL.Path)
		LogError(span, err)
		req = req.WithContext(ctx)
		return span, req
	}

	span := opentracing.StartSpan(handlerName+":"+req.URL.Path, opentracing.ChildOf(spanContext), ext.RPCServerOption(spanContext))
	req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span))
	return span, req
}