func flattenApmResources()

in ec/ecdatasource/deploymentdatasource/flatteners_apm.go [34:88]


func flattenApmResources(ctx context.Context, in []*models.ApmResourceInfo) (types.List, diag.Diagnostics) {
	var diagnostics diag.Diagnostics
	var result = make([]apmResourceInfoModelV0, 0, len(in))

	for _, res := range in {
		model := apmResourceInfoModelV0{
			Topology: types.ListNull(types.ObjectType{AttrTypes: apmTopologyAttrTypes()}),
		}

		if res.ElasticsearchClusterRefID != nil {
			model.ElasticsearchClusterRefID = types.StringValue(*res.ElasticsearchClusterRefID)
		}

		if res.RefID != nil {
			model.RefID = types.StringValue(*res.RefID)
		}

		if res.Info != nil {
			if res.Info.Healthy != nil {
				model.Healthy = types.BoolValue(*res.Info.Healthy)
			}

			if res.Info.ID != nil {
				model.ResourceID = types.StringValue(*res.Info.ID)
			}

			if res.Info.Status != nil {
				model.Status = types.StringValue(*res.Info.Status)
			}

			if !util.IsCurrentApmPlanEmpty(res) {
				var plan = res.Info.PlanInfo.Current.Plan

				if plan.Apm != nil {
					model.Version = types.StringValue(plan.Apm.Version)
				}

				var diags diag.Diagnostics
				model.Topology, diags = flattenApmTopology(ctx, plan)
				diagnostics.Append(diags...)
			}

			if res.Info.Metadata != nil {
				model.HttpEndpoint, model.HttpsEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata)
			}
		}

		result = append(result, model)
	}

	target, diags := types.ListValueFrom(ctx, types.ObjectType{AttrTypes: apmResourceInfoAttrTypes()}, result)
	diagnostics.Append(diags...)

	return target, diagnostics
}