// generateConvertMeta constructs the meta value we pass to Convert.
509268
func (s *Scheme) generateConvertMeta(srcGroupVersion, destGroupVersion unversioned.GroupVersion, in interface{}) (conversion.FieldMatchingFlags, *conversion.Meta) {
	flags, meta := s.converter.DefaultMeta(reflect.TypeOf(in))
	meta.SrcVersion = srcGroupVersion.String()
	meta.DestVersion = destGroupVersion.String()
	return flags, meta
}
79598
func (s *ExtendedStatsBucketAggregation) Meta(metaData map[string]interface{}) *ExtendedStatsBucketAggregation {
	s.meta = metaData
	return s
}
19833
func Metadatify(i interface{}) (Metadata, error) {
	value := reflect.ValueOf(i)
	if value.Kind() == reflect.Map {
		m := map[string]interface{}{}
		for _, k := range value.MapKeys() {
			m[k.String()] = value.MapIndex(k).Interface()
		}
		return Metadata(m), nil
	}
	return nil, errors.New("is not a map")
}
38856
func (a *MissingAggregation) Meta(metaData map[string]interface{}) *MissingAggregation {
	a.meta = metaData
	return a
}
1337068
func (a *AdjacencyMatrixAggregation) Meta(metaData map[string]interface{}) *AdjacencyMatrixAggregation {
	a.meta = metaData
	return a
}
273903
func (c *Pods) Meta() *CollectionMeta {
	return &CollectionMeta{
		DomainName: "",
		APIGroup:   "api",
		APIVersion: "v1",
		APIName:    "pods",
		Kind:       "Pod",
	}
}
247951
func (h *handler) ConvertMetadata(ctx ttnlog.Interface, ttnUp *pb_broker.DeduplicatedUplinkMessage, appUp *types.UplinkMessage, dev *device.Device) error {
	ctx = ctx.WithField("NumGateways", len(ttnUp.GatewayMetadata))

	// Transform Metadata
	appUp.Metadata.Time = types.BuildTime(ttnUp.ServerTime)
	if lorawan := ttnUp.ProtocolMetadata.GetLoRaWAN(); lorawan != nil {
		appUp.Metadata.Modulation = lorawan.Modulation.String()
		appUp.Metadata.DataRate = lorawan.DataRate
		appUp.Metadata.Bitrate = lorawan.BitRate
		appUp.Metadata.CodingRate = lorawan.CodingRate

		switch lorawan.Modulation {
		case pb_lorawan.Modulation_LORA:
			appUp.Metadata.Airtime, _ = toa.ComputeLoRa(uint(len(ttnUp.Payload)), lorawan.DataRate, lorawan.CodingRate)
		case pb_lorawan.Modulation_FSK:
			appUp.Metadata.Airtime, _ = toa.ComputeFSK(uint(len(ttnUp.Payload)), int(lorawan.BitRate))
		}
	}

	// Transform Gateway Metadata
	appUp.Metadata.Gateways = make([]types.GatewayMetadata, 0, len(ttnUp.GatewayMetadata))
	for i, in := range ttnUp.GatewayMetadata {

		// Same for all gateways, take first one
		if i == 0 {
			appUp.Metadata.Frequency = float32(float64(in.Frequency) / 1000000)
		}

		gatewayMetadata := types.GatewayMetadata{
			GtwID:      in.GatewayID,
			GtwTrusted: in.GatewayTrusted,
			Timestamp:  in.Timestamp,
			Time:       types.BuildTime(in.Time),
			Channel:    in.Channel,
			RFChain:    in.RfChain,
			RSSI:       in.RSSI,
			SNR:        in.SNR,
		}

		if location := in.GetLocation(); location != nil {
			gatewayMetadata.Altitude = location.Altitude
			gatewayMetadata.Longitude = location.Longitude
			gatewayMetadata.Latitude = location.Latitude
			gatewayMetadata.Accuracy = location.Accuracy
			if location.Source != pb_gateway.LocationMetadata_UNKNOWN {
				gatewayMetadata.Source = strings.ToLower(location.Source.String())
			}
		}

		if antennas := in.GetAntennas(); len(antennas) > 0 {
			for _, antenna := range antennas {
				gatewayMetadata.Antenna = uint8(antenna.Antenna)
				gatewayMetadata.FineTimestamp = uint64(antenna.FineTime)
				gatewayMetadata.FineTimestampEncrypted = antenna.EncryptedTime
				gatewayMetadata.Channel = antenna.Channel
				gatewayMetadata.RSSI = antenna.RSSI
				gatewayMetadata.SNR = antenna.SNR
				appUp.Metadata.Gateways = append(appUp.Metadata.Gateways, gatewayMetadata)
			}
		} else {
			appUp.Metadata.Gateways = append(appUp.Metadata.Gateways, gatewayMetadata)
		}
	}

	// Inject Device Metadata
	if dev.Latitude != 0 || dev.Longitude != 0 {
		appUp.Metadata.LocationMetadata.Latitude = dev.Latitude
		appUp.Metadata.LocationMetadata.Longitude = dev.Longitude
		appUp.Metadata.LocationMetadata.Altitude = dev.Altitude
		appUp.Metadata.LocationMetadata.Source = "registry"
	}

	return nil
}
655722
func parseMetadata(md map[string]string) map[string]interface{} {
	m := make(map[string]interface{}, len(md))
	for key, value := range md {
		m[key] = value
	}
	return m
}
841235
func (res *Resource) GetMeta(name string) *Meta {
	for _, meta := range res.Metas {
		if meta.Header == name {
			return meta
		}
	}
	return nil
}
520280
func NewMetaLink(href string, meta map[string]interface{}) *Link {
	return &Link{
		HREF: href,
		Meta: meta,
	}
}
514905
func (a *CumulativeSumAggregation) Meta(metaData map[string]interface{}) *CumulativeSumAggregation {
	a.meta = metaData
	return a
}
943953
func (mad MaterialAttributesDependency) GenerateGeneric() (ma map[string]interface{}) {
	ma = make(map[string]interface{})
	if mad.Name != "" {
		ma["name"] = mad.Name
	}

	if mad.Pipeline != "" {
		ma["pipeline"] = mad.Pipeline
	}

	if mad.Stage != "" {
		ma["stage"] = mad.Stage
	}

	if mad.AutoUpdate {
		ma["auto_update"] = mad.AutoUpdate
	}
	return
}
609401
func (a *IPRangeAggregation) Meta(metaData map[string]interface{}) *IPRangeAggregation {
	a.meta = metaData
	return a
}
1214989
func validateMetadata(meta map[string]string) error {
	if len(meta) > metaMaxKeyPairs {
		return fmt.Errorf("metadata cannot contain more than %d key/value pairs", metaMaxKeyPairs)
	}

	for key, value := range meta {
		if err := validateMetaPair(key, value); err != nil {
			return errwrap.Wrapf(fmt.Sprintf("failed to load metadata pair (%q, %q): {{err}}", key, value), err)
		}
	}

	return nil
}
1079284
func (a *DerivativeAggregation) Meta(metaData map[string]interface{}) *DerivativeAggregation {
	a.meta = metaData
	return a
}
440359
func (a *SignificantTextAggregation) Meta(metaData map[string]interface{}) *SignificantTextAggregation {
	a.meta = metaData
	return a
}
1345533
func (a *ScriptedMetricAggregation) Meta(metaData map[string]interface{}) *ScriptedMetricAggregation {
	a.meta = metaData
	return a
}