|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// ObservabilityPipelineOpentelemetrySource The `opentelemetry` source receives OpenTelemetry data through gRPC or HTTP. |
| 14 | +type ObservabilityPipelineOpentelemetrySource struct { |
| 15 | + // The unique identifier for this component. Used to reference this component in other parts of the pipeline (e.g., as input to downstream components). |
| 16 | + Id string `json:"id"` |
| 17 | + // Configuration for enabling TLS encryption between the pipeline component and external services. |
| 18 | + Tls *ObservabilityPipelineTls `json:"tls,omitempty"` |
| 19 | + // The source type. The value should always be `opentelemetry`. |
| 20 | + Type ObservabilityPipelineOpentelemetrySourceType `json:"type"` |
| 21 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 22 | + UnparsedObject map[string]interface{} `json:"-"` |
| 23 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 24 | +} |
| 25 | + |
| 26 | +// NewObservabilityPipelineOpentelemetrySource instantiates a new ObservabilityPipelineOpentelemetrySource object. |
| 27 | +// This constructor will assign default values to properties that have it defined, |
| 28 | +// and makes sure properties required by API are set, but the set of arguments |
| 29 | +// will change when the set of required properties is changed. |
| 30 | +func NewObservabilityPipelineOpentelemetrySource(id string, typeVar ObservabilityPipelineOpentelemetrySourceType) *ObservabilityPipelineOpentelemetrySource { |
| 31 | + this := ObservabilityPipelineOpentelemetrySource{} |
| 32 | + this.Id = id |
| 33 | + this.Type = typeVar |
| 34 | + return &this |
| 35 | +} |
| 36 | + |
| 37 | +// NewObservabilityPipelineOpentelemetrySourceWithDefaults instantiates a new ObservabilityPipelineOpentelemetrySource object. |
| 38 | +// This constructor will only assign default values to properties that have it defined, |
| 39 | +// but it doesn't guarantee that properties required by API are set. |
| 40 | +func NewObservabilityPipelineOpentelemetrySourceWithDefaults() *ObservabilityPipelineOpentelemetrySource { |
| 41 | + this := ObservabilityPipelineOpentelemetrySource{} |
| 42 | + var typeVar ObservabilityPipelineOpentelemetrySourceType = OBSERVABILITYPIPELINEOPENTELEMETRYSOURCETYPE_OPENTELEMETRY |
| 43 | + this.Type = typeVar |
| 44 | + return &this |
| 45 | +} |
| 46 | + |
| 47 | +// GetId returns the Id field value. |
| 48 | +func (o *ObservabilityPipelineOpentelemetrySource) GetId() string { |
| 49 | + if o == nil { |
| 50 | + var ret string |
| 51 | + return ret |
| 52 | + } |
| 53 | + return o.Id |
| 54 | +} |
| 55 | + |
| 56 | +// GetIdOk returns a tuple with the Id field value |
| 57 | +// and a boolean to check if the value has been set. |
| 58 | +func (o *ObservabilityPipelineOpentelemetrySource) GetIdOk() (*string, bool) { |
| 59 | + if o == nil { |
| 60 | + return nil, false |
| 61 | + } |
| 62 | + return &o.Id, true |
| 63 | +} |
| 64 | + |
| 65 | +// SetId sets field value. |
| 66 | +func (o *ObservabilityPipelineOpentelemetrySource) SetId(v string) { |
| 67 | + o.Id = v |
| 68 | +} |
| 69 | + |
| 70 | +// GetTls returns the Tls field value if set, zero value otherwise. |
| 71 | +func (o *ObservabilityPipelineOpentelemetrySource) GetTls() ObservabilityPipelineTls { |
| 72 | + if o == nil || o.Tls == nil { |
| 73 | + var ret ObservabilityPipelineTls |
| 74 | + return ret |
| 75 | + } |
| 76 | + return *o.Tls |
| 77 | +} |
| 78 | + |
| 79 | +// GetTlsOk returns a tuple with the Tls field value if set, nil otherwise |
| 80 | +// and a boolean to check if the value has been set. |
| 81 | +func (o *ObservabilityPipelineOpentelemetrySource) GetTlsOk() (*ObservabilityPipelineTls, bool) { |
| 82 | + if o == nil || o.Tls == nil { |
| 83 | + return nil, false |
| 84 | + } |
| 85 | + return o.Tls, true |
| 86 | +} |
| 87 | + |
| 88 | +// HasTls returns a boolean if a field has been set. |
| 89 | +func (o *ObservabilityPipelineOpentelemetrySource) HasTls() bool { |
| 90 | + return o != nil && o.Tls != nil |
| 91 | +} |
| 92 | + |
| 93 | +// SetTls gets a reference to the given ObservabilityPipelineTls and assigns it to the Tls field. |
| 94 | +func (o *ObservabilityPipelineOpentelemetrySource) SetTls(v ObservabilityPipelineTls) { |
| 95 | + o.Tls = &v |
| 96 | +} |
| 97 | + |
| 98 | +// GetType returns the Type field value. |
| 99 | +func (o *ObservabilityPipelineOpentelemetrySource) GetType() ObservabilityPipelineOpentelemetrySourceType { |
| 100 | + if o == nil { |
| 101 | + var ret ObservabilityPipelineOpentelemetrySourceType |
| 102 | + return ret |
| 103 | + } |
| 104 | + return o.Type |
| 105 | +} |
| 106 | + |
| 107 | +// GetTypeOk returns a tuple with the Type field value |
| 108 | +// and a boolean to check if the value has been set. |
| 109 | +func (o *ObservabilityPipelineOpentelemetrySource) GetTypeOk() (*ObservabilityPipelineOpentelemetrySourceType, bool) { |
| 110 | + if o == nil { |
| 111 | + return nil, false |
| 112 | + } |
| 113 | + return &o.Type, true |
| 114 | +} |
| 115 | + |
| 116 | +// SetType sets field value. |
| 117 | +func (o *ObservabilityPipelineOpentelemetrySource) SetType(v ObservabilityPipelineOpentelemetrySourceType) { |
| 118 | + o.Type = v |
| 119 | +} |
| 120 | + |
| 121 | +// MarshalJSON serializes the struct using spec logic. |
| 122 | +func (o ObservabilityPipelineOpentelemetrySource) MarshalJSON() ([]byte, error) { |
| 123 | + toSerialize := map[string]interface{}{} |
| 124 | + if o.UnparsedObject != nil { |
| 125 | + return datadog.Marshal(o.UnparsedObject) |
| 126 | + } |
| 127 | + toSerialize["id"] = o.Id |
| 128 | + if o.Tls != nil { |
| 129 | + toSerialize["tls"] = o.Tls |
| 130 | + } |
| 131 | + toSerialize["type"] = o.Type |
| 132 | + |
| 133 | + for key, value := range o.AdditionalProperties { |
| 134 | + toSerialize[key] = value |
| 135 | + } |
| 136 | + return datadog.Marshal(toSerialize) |
| 137 | +} |
| 138 | + |
| 139 | +// UnmarshalJSON deserializes the given payload. |
| 140 | +func (o *ObservabilityPipelineOpentelemetrySource) UnmarshalJSON(bytes []byte) (err error) { |
| 141 | + all := struct { |
| 142 | + Id *string `json:"id"` |
| 143 | + Tls *ObservabilityPipelineTls `json:"tls,omitempty"` |
| 144 | + Type *ObservabilityPipelineOpentelemetrySourceType `json:"type"` |
| 145 | + }{} |
| 146 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 147 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 148 | + } |
| 149 | + if all.Id == nil { |
| 150 | + return fmt.Errorf("required field id missing") |
| 151 | + } |
| 152 | + if all.Type == nil { |
| 153 | + return fmt.Errorf("required field type missing") |
| 154 | + } |
| 155 | + additionalProperties := make(map[string]interface{}) |
| 156 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 157 | + datadog.DeleteKeys(additionalProperties, &[]string{"id", "tls", "type"}) |
| 158 | + } else { |
| 159 | + return err |
| 160 | + } |
| 161 | + |
| 162 | + hasInvalidField := false |
| 163 | + o.Id = *all.Id |
| 164 | + if all.Tls != nil && all.Tls.UnparsedObject != nil && o.UnparsedObject == nil { |
| 165 | + hasInvalidField = true |
| 166 | + } |
| 167 | + o.Tls = all.Tls |
| 168 | + if !all.Type.IsValid() { |
| 169 | + hasInvalidField = true |
| 170 | + } else { |
| 171 | + o.Type = *all.Type |
| 172 | + } |
| 173 | + |
| 174 | + if len(additionalProperties) > 0 { |
| 175 | + o.AdditionalProperties = additionalProperties |
| 176 | + } |
| 177 | + |
| 178 | + if hasInvalidField { |
| 179 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 180 | + } |
| 181 | + |
| 182 | + return nil |
| 183 | +} |
0 commit comments