// Code generated by mdatagen. DO NOT EDIT.

package metadata

import (
	"go.opentelemetry.io/collector/pdata/pcommon"
	"go.opentelemetry.io/collector/pdata/xpdata/entity"
)

// K8sReplicasetEntity represents a k8s.replicaset entity.
// Create one with NewK8sReplicasetEntity and pass it to EmitForEntity.
type K8sReplicasetEntity struct {
	k8sReplicasetUID  string
	k8sReplicasetName string
}

// NewK8sReplicasetEntity creates a new K8sReplicasetEntity.
// Identity attributes are required and must be provided at construction time.
func NewK8sReplicasetEntity(k8sReplicasetUID string) *K8sReplicasetEntity {
	return &K8sReplicasetEntity{
		k8sReplicasetUID: k8sReplicasetUID,
	}
}

// Description attribute setters for k8s.replicaset.

// SetK8sReplicasetName sets the k8s.replicaset.name description attribute.
func (e *K8sReplicasetEntity) SetK8sReplicasetName(val string) {
	e.k8sReplicasetName = val
}

// copyToResource populates res with the entity's attributes according to cfg.
// If all identity attributes are enabled, an entity ref is produced; otherwise
// the enabled attributes are written directly as plain resource attributes.
func (e *K8sReplicasetEntity) copyToResource(cfg ResourceAttributesConfig, res pcommon.Resource) {
	if cfg.K8sReplicasetUID.Enabled {
		ent := entity.ResourceEntities(res).PutEmpty("k8s.replicaset")
		ent.IdentifyingAttributes().PutStr("k8s.replicaset.uid", e.k8sReplicasetUID)
		if cfg.K8sReplicasetName.Enabled {
			ent.DescriptiveAttributes().PutStr("k8s.replicaset.name", e.k8sReplicasetName)
		}
	} else {
		if cfg.K8sReplicasetUID.Enabled {
			res.Attributes().PutStr("k8s.replicaset.uid", e.k8sReplicasetUID)
		}
		if cfg.K8sReplicasetName.Enabled {
			res.Attributes().PutStr("k8s.replicaset.name", e.k8sReplicasetName)
		}
	}
}

// K8sPodEntity represents a k8s.pod entity.
// Create one with NewK8sPodEntity and pass it to EmitForEntity.
type K8sPodEntity struct {
	k8sPodUID                 string
	k8sPodName                string
	k8sNamespaceName          string
	controlledByK8sReplicaset *K8sReplicasetEntity
}

// NewK8sPodEntity creates a new K8sPodEntity.
// Identity attributes are required and must be provided at construction time.
func NewK8sPodEntity(k8sPodUID string) *K8sPodEntity {
	return &K8sPodEntity{
		k8sPodUID: k8sPodUID,
	}
}

// Description attribute setters for k8s.pod.

// SetK8sPodName sets the k8s.pod.name description attribute.
func (e *K8sPodEntity) SetK8sPodName(val string) {
	e.k8sPodName = val
}

// Extra attribute setters for k8s.pod.
// These attributes are contextually relevant but are not part of the entity's identity or description.

// SetK8sNamespaceName sets the k8s.namespace.name extra attribute on the resource.
func (e *K8sPodEntity) SetK8sNamespaceName(val string) {
	e.k8sNamespaceName = val
}

// Relationship setters for k8s.pod.

// SetControlledByK8sReplicaset sets the controlled_by relationship to a k8s.replicaset entity.
// The related entity will be emitted alongside this entity's metrics.
func (e *K8sPodEntity) SetControlledByK8sReplicaset(target *K8sReplicasetEntity) {
	e.controlledByK8sReplicaset = target
}

// copyToResource populates res with the entity's attributes according to cfg.
// If all identity attributes are enabled, an entity ref is produced; otherwise
// the enabled attributes are written directly as plain resource attributes.
func (e *K8sPodEntity) copyToResource(cfg ResourceAttributesConfig, res pcommon.Resource) {
	if cfg.K8sPodUID.Enabled {
		ent := entity.ResourceEntities(res).PutEmpty("k8s.pod")
		ent.IdentifyingAttributes().PutStr("k8s.pod.uid", e.k8sPodUID)
		if cfg.K8sPodName.Enabled {
			ent.DescriptiveAttributes().PutStr("k8s.pod.name", e.k8sPodName)
		}
		if cfg.K8sNamespaceName.Enabled {
			res.Attributes().PutStr("k8s.namespace.name", e.k8sNamespaceName)
		}
	} else {
		if cfg.K8sPodUID.Enabled {
			res.Attributes().PutStr("k8s.pod.uid", e.k8sPodUID)
		}
		if cfg.K8sPodName.Enabled {
			res.Attributes().PutStr("k8s.pod.name", e.k8sPodName)
		}
		if cfg.K8sNamespaceName.Enabled {
			res.Attributes().PutStr("k8s.namespace.name", e.k8sNamespaceName)
		}
	}
}

// K8sReplicasetMetricsBuilder records metrics for the k8s.replicaset entity.
// Obtain one via MetricsBuilder.ForK8sReplicaset().
type K8sReplicasetMetricsBuilder struct {
	mb     *MetricsBuilder
	entity *K8sReplicasetEntity
}

// RecordK8sReplicasetDesiredDataPoint records a data point for the k8s.replicaset.desired metric.
func (eb *K8sReplicasetMetricsBuilder) RecordK8sReplicasetDesiredDataPoint(ts pcommon.Timestamp, val int64) {
	eb.mb.metricK8sReplicasetDesired.recordDataPoint(eb.mb.startTime, ts, val)
}

// Emit emits all pending metrics for the entity. Resource attributes are filtered by config:
// disabled identity attributes suppress the entity (other enabled attributes are added directly
// to the resource); disabled descriptive/extra attributes are omitted entirely.
func (eb *K8sReplicasetMetricsBuilder) Emit() {
	res := pcommon.NewResource()
	cfg := eb.mb.config.ResourceAttributes
	eb.entity.copyToResource(cfg, res)
	eb.mb.EmitForResource(withResourceMoved(res))
}

// K8sPodMetricsBuilder records metrics for the k8s.pod entity.
// Obtain one via MetricsBuilder.ForK8sPod().
type K8sPodMetricsBuilder struct {
	mb     *MetricsBuilder
	entity *K8sPodEntity
}

// RecordK8sPodCPUTimeDataPoint records a data point for the k8s.pod.cpu_time metric.
func (eb *K8sPodMetricsBuilder) RecordK8sPodCPUTimeDataPoint(ts pcommon.Timestamp, val float64) {
	eb.mb.metricK8sPodCPUTime.recordDataPoint(eb.mb.startTime, ts, val)
}

// RecordK8sPodPhaseDataPoint records a data point for the k8s.pod.phase metric.
func (eb *K8sPodMetricsBuilder) RecordK8sPodPhaseDataPoint(ts pcommon.Timestamp, val int64, phaseAttributeValue AttributePhase) {
	eb.mb.metricK8sPodPhase.recordDataPoint(eb.mb.startTime, ts, val, phaseAttributeValue.String())
}

// Emit emits all pending metrics for the entity. Resource attributes are filtered by config:
// disabled identity attributes suppress the entity (other enabled attributes are added directly
// to the resource); disabled descriptive/extra attributes are omitted entirely.
func (eb *K8sPodMetricsBuilder) Emit() {
	res := pcommon.NewResource()
	cfg := eb.mb.config.ResourceAttributes
	eb.entity.copyToResource(cfg, res)
	if eb.entity.controlledByK8sReplicaset != nil {
		eb.entity.controlledByK8sReplicaset.copyToResource(cfg, res)
	}
	eb.mb.EmitForResource(withResourceMoved(res))
}
