// flatten (API --> terraform)
354765
func flattenAzureArmSchedulerJobActionRequest(d *schema.ResourceData, blockName string, request *scheduler.HTTPRequest) []interface{} {

	block := map[string]interface{}{}

	if v := request.URI; v != nil {
		block["url"] = *v
	}
	if v := request.Method; v != nil {
		block["method"] = *v
	}
	if v := request.Body; v != nil {
		block["body"] = *v
	}

	if v := request.Headers; v != nil {
		headers := map[string]interface{}{}
		for k, v := range v {
			headers[k] = *v
		}

		block["headers"] = headers
	}

	if auth := request.Authentication; auth != nil {

		authBlock := map[string]interface{}{}

		if basic, ok := auth.AsBasicAuthentication(); ok {
			block["authentication_basic"] = []interface{}{authBlock}

			if v := basic.Username; v != nil {
				authBlock["username"] = *v
			}

			//password is not returned so lets fetch it
			if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_basic.0.password", blockName)); ok {
				authBlock["password"] = v.(string)
			}

		} else if cert, ok := auth.AsClientCertAuthentication(); ok {
			block["authentication_certificate"] = []interface{}{authBlock}

			if v := cert.CertificateThumbprint; v != nil {
				authBlock["thumbprint"] = *v
			}
			if v := cert.CertificateExpirationDate; v != nil {
				authBlock["expiration"] = (*v).Format(time.RFC3339)
			}
			if v := cert.CertificateSubjectName; v != nil {
				authBlock["subject_name"] = *v
			}

			//these properties not returned, so lets grab them
			if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_certificate.0.pfx", blockName)); ok {
				authBlock["pfx"] = v.(string)
			}
			if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_certificate.0.password", blockName)); ok {
				authBlock["password"] = v.(string)
			}

		} else if oauth, ok := auth.AsOAuthAuthentication(); ok {
			block["authentication_active_directory"] = []interface{}{authBlock}

			if v := oauth.Audience; v != nil {
				authBlock["audience"] = *v
			}
			if v := oauth.ClientID; v != nil {
				authBlock["client_id"] = *v
			}
			if v := oauth.Tenant; v != nil {
				authBlock["tenant_id"] = *v
			}

			//secret is not returned
			if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_active_directory.0.secret", blockName)); ok {
				authBlock["secret"] = v.(string)
			}
		}
	}

	return []interface{}{block}
}
230363
func (n *Node) Flatten() []*Node {
	nodes := make([]*Node, 0)
	for _, node := range n.Node.Nodes {
		if node.Dir {
			nodes = append(nodes, NewNode(node).Flatten()...)
			continue
		}

		nodes = append(nodes, NewNode(node))
	}

	return nodes
}
438461
func (m *MonitorValues) FlattenTotalDisk1SizeValue() ([]FlatMonitorValue, error) {
	return m.flattenValue(func(v *MonitorValue) *float64 { return v.TotalDisk1Size })
}
550391
func (r RadialGeoReducer) Reduce(path *geo.Path) *geo.Path {
	return RadialGeo(path, r.Threshold)
}
573721
func (m *txSortedMap) Flatten() types.Transactions {
	// If the sorting was not cached yet, create and cache it
	if m.cache == nil {
		m.cache = make(types.Transactions, 0, len(m.items))
		for _, tx := range m.items {
			m.cache = append(m.cache, tx)
		}
		sort.Sort(types.TxByNonce(m.cache))
	}
	// Copy the cache to prevent accidental modifications
	txs := make(types.Transactions, len(m.cache))
	copy(txs, m.cache)
	return txs
}
253282
func flattenStringList(list []*string) []interface{} {
	vs := make([]interface{}, 0, len(list))
	for _, v := range list {
		vs = append(vs, *v)
	}
	return vs
}
501032
func flattenGroupIdentifiers(dtos []*ec2.GroupIdentifier) []string {
	ids := make([]string, 0, len(dtos))
	for _, v := range dtos {
		group_id := *v.GroupId
		ids = append(ids, group_id)
	}
	return ids
}
716926
func (def *Synthdef) flattenInput(params Params, ugen *Ugen, input Input) {
	switch v := input.(type) {
	case *Ugen:
		_, idx, _ := def.addUgen(v)

		// In has different behavior than other ugens when it is multichannel expanded.
		// Each channel of its output gets mapped to a single channel of the expression
		// tree above it. [briansorahan]
		if v.Name == "In" {
			ugen.Inputs = append(ugen.Inputs, UgenInput{
				UgenIndex:   int32(idx),
				OutputIndex: int32(def.inidx),
			})
			def.inidx++
			break
		}
		for outputIndex := range v.Outputs {
			ugen.Inputs = append(ugen.Inputs, UgenInput{
				UgenIndex:   int32(idx),
				OutputIndex: int32(outputIndex),
			})
		}
	case C:
		idx := def.addConstant(v)
		ugen.Inputs = append(ugen.Inputs, UgenInput{
			UgenIndex:   -1,
			OutputIndex: int32(idx),
		})
	case *param:
		idx := v.Index()
		ugen.Inputs = append(ugen.Inputs, UgenInput{
			UgenIndex:   0,
			OutputIndex: idx,
		})
	case MultiInput:
		for _, min := range v.InputArray() {
			switch x := min.(type) {
			case *Ugen:
				_, idx, _ := def.addUgen(x)
				// will we ever need to use a different output index? [bps]
				for outputIndex := range x.Outputs {
					ugen.Inputs = append(ugen.Inputs, UgenInput{
						UgenIndex:   int32(idx),
						OutputIndex: int32(outputIndex),
					})
				}
			case C:
				ugen.Inputs = append(ugen.Inputs, UgenInput{
					UgenIndex:   -1,
					OutputIndex: int32(def.addConstant(x)),
				})
			case *param:
				ugen.Inputs = append(ugen.Inputs, UgenInput{
					UgenIndex:   0,
					OutputIndex: x.Index(),
				})
			}
		}
	}
}
106999
func FlattenConfig(config *Config) error {
	for key, authInfo := range config.AuthInfos {
		baseDir, err := MakeAbs(path.Dir(authInfo.LocationOfOrigin), "")
		if err != nil {
			return err
		}

		if err := FlattenContent(&authInfo.ClientCertificate, &authInfo.ClientCertificateData, baseDir); err != nil {
			return err
		}
		if err := FlattenContent(&authInfo.ClientKey, &authInfo.ClientKeyData, baseDir); err != nil {
			return err
		}

		config.AuthInfos[key] = authInfo
	}
	for key, cluster := range config.Clusters {
		baseDir, err := MakeAbs(path.Dir(cluster.LocationOfOrigin), "")
		if err != nil {
			return err
		}

		if err := FlattenContent(&cluster.CertificateAuthority, &cluster.CertificateAuthorityData, baseDir); err != nil {
			return err
		}

		config.Clusters[key] = cluster
	}

	return nil
}
88541
func FlattenJsonMapIntoQs(uv url.Values, jsonMap map[string]interface{}, pre string) error {
	for k, v := range jsonMap {
		if err := flattenJsonValue(uv, v, pre+k); err != nil {
			return err
		}
	}
	return nil
}
951960
func flatten(key string, value interface{}, vars map[string]string) {
	switch value.(type) {
	case string:
		log.Debug("setting key %s to: %s", key, value)
		vars[key] = value.(string)
	case map[string]interface{}:
		inner := value.(map[string]interface{})
		for innerKey, innerValue := range inner {
			innerKey = path.Join(key, "/", innerKey)
			flatten(innerKey, innerValue, vars)
		}
	default: // we don't know how to handle non string or maps of strings
		log.Warning("type of '%s' is not supported (%T)", key, value)
	}
}
1367834
func (s *StatsiteSink) flattenKeyLabels(parts []string, labels []Label) string {
	for _, label := range labels {
		parts = append(parts, label.Value)
	}
	return s.flattenKey(parts)
}
81179
func flattener(finalList []ast.Variable, flattenList []ast.Variable) []ast.Variable {
	for _, val := range flattenList {
		if val.Type == ast.TypeList {
			finalList = flattener(finalList, val.Value.([]ast.Variable))
		} else {
			finalList = append(finalList, val)
		}
	}
	return finalList
}
986578
func (image *Image) Flatten() error {
	if image.image == nil {
		return errors.New(fmt.Sprintf("RBD image %s is not open", image.name))
	}

	return GetError(C.rbd_flatten(image.image))
}
988579
func Flatten(agg Aggregate) Aggregate {
	result := []error{}
	if agg == nil {
		return nil
	}
	for _, err := range agg.Errors() {
		if a, ok := err.(Aggregate); ok {
			r := Flatten(a)
			if r != nil {
				result = append(result, r.Errors()...)
			}
		} else {
			if err != nil {
				result = append(result, err)
			}
		}
	}
	return NewAggregate(result)
}
769941
func flattenRedshiftParameters(list []*redshift.Parameter) []map[string]interface{} {
	result := make([]map[string]interface{}, 0, len(list))
	for _, i := range list {
		result = append(result, map[string]interface{}{
			"name":  strings.ToLower(*i.ParameterName),
			"value": strings.ToLower(*i.ParameterValue),
		})
	}
	return result
}
773710
func (g Gen) FlatMap(f func(interface{}) Gen, resultType reflect.Type) Gen {
	return func(genParams *GenParameters) *GenResult {
		result := g(genParams)
		value, ok := result.Retrieve()
		if ok {
			return f(value)(genParams)
		}
		return &GenResult{
			Shrinker:   NoShrinker,
			Result:     nil,
			Labels:     result.Labels,
			ResultType: resultType,
		}
	}
}