|
| 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 | +// FlakyTestHistory A single history entry representing a status change for a flaky test. |
| 14 | +type FlakyTestHistory struct { |
| 15 | + // The commit SHA associated with this status change. Will be an empty string if the commit SHA is not available. |
| 16 | + CommitSha string `json:"commit_sha"` |
| 17 | + // The test status at this point in history. |
| 18 | + Status string `json:"status"` |
| 19 | + // Unix timestamp in milliseconds when this status change occurred. |
| 20 | + Timestamp int64 `json:"timestamp"` |
| 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 | +// NewFlakyTestHistory instantiates a new FlakyTestHistory 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 NewFlakyTestHistory(commitSha string, status string, timestamp int64) *FlakyTestHistory { |
| 31 | + this := FlakyTestHistory{} |
| 32 | + this.CommitSha = commitSha |
| 33 | + this.Status = status |
| 34 | + this.Timestamp = timestamp |
| 35 | + return &this |
| 36 | +} |
| 37 | + |
| 38 | +// NewFlakyTestHistoryWithDefaults instantiates a new FlakyTestHistory object. |
| 39 | +// This constructor will only assign default values to properties that have it defined, |
| 40 | +// but it doesn't guarantee that properties required by API are set. |
| 41 | +func NewFlakyTestHistoryWithDefaults() *FlakyTestHistory { |
| 42 | + this := FlakyTestHistory{} |
| 43 | + return &this |
| 44 | +} |
| 45 | + |
| 46 | +// GetCommitSha returns the CommitSha field value. |
| 47 | +func (o *FlakyTestHistory) GetCommitSha() string { |
| 48 | + if o == nil { |
| 49 | + var ret string |
| 50 | + return ret |
| 51 | + } |
| 52 | + return o.CommitSha |
| 53 | +} |
| 54 | + |
| 55 | +// GetCommitShaOk returns a tuple with the CommitSha field value |
| 56 | +// and a boolean to check if the value has been set. |
| 57 | +func (o *FlakyTestHistory) GetCommitShaOk() (*string, bool) { |
| 58 | + if o == nil { |
| 59 | + return nil, false |
| 60 | + } |
| 61 | + return &o.CommitSha, true |
| 62 | +} |
| 63 | + |
| 64 | +// SetCommitSha sets field value. |
| 65 | +func (o *FlakyTestHistory) SetCommitSha(v string) { |
| 66 | + o.CommitSha = v |
| 67 | +} |
| 68 | + |
| 69 | +// GetStatus returns the Status field value. |
| 70 | +func (o *FlakyTestHistory) GetStatus() string { |
| 71 | + if o == nil { |
| 72 | + var ret string |
| 73 | + return ret |
| 74 | + } |
| 75 | + return o.Status |
| 76 | +} |
| 77 | + |
| 78 | +// GetStatusOk returns a tuple with the Status field value |
| 79 | +// and a boolean to check if the value has been set. |
| 80 | +func (o *FlakyTestHistory) GetStatusOk() (*string, bool) { |
| 81 | + if o == nil { |
| 82 | + return nil, false |
| 83 | + } |
| 84 | + return &o.Status, true |
| 85 | +} |
| 86 | + |
| 87 | +// SetStatus sets field value. |
| 88 | +func (o *FlakyTestHistory) SetStatus(v string) { |
| 89 | + o.Status = v |
| 90 | +} |
| 91 | + |
| 92 | +// GetTimestamp returns the Timestamp field value. |
| 93 | +func (o *FlakyTestHistory) GetTimestamp() int64 { |
| 94 | + if o == nil { |
| 95 | + var ret int64 |
| 96 | + return ret |
| 97 | + } |
| 98 | + return o.Timestamp |
| 99 | +} |
| 100 | + |
| 101 | +// GetTimestampOk returns a tuple with the Timestamp field value |
| 102 | +// and a boolean to check if the value has been set. |
| 103 | +func (o *FlakyTestHistory) GetTimestampOk() (*int64, bool) { |
| 104 | + if o == nil { |
| 105 | + return nil, false |
| 106 | + } |
| 107 | + return &o.Timestamp, true |
| 108 | +} |
| 109 | + |
| 110 | +// SetTimestamp sets field value. |
| 111 | +func (o *FlakyTestHistory) SetTimestamp(v int64) { |
| 112 | + o.Timestamp = v |
| 113 | +} |
| 114 | + |
| 115 | +// MarshalJSON serializes the struct using spec logic. |
| 116 | +func (o FlakyTestHistory) MarshalJSON() ([]byte, error) { |
| 117 | + toSerialize := map[string]interface{}{} |
| 118 | + if o.UnparsedObject != nil { |
| 119 | + return datadog.Marshal(o.UnparsedObject) |
| 120 | + } |
| 121 | + toSerialize["commit_sha"] = o.CommitSha |
| 122 | + toSerialize["status"] = o.Status |
| 123 | + toSerialize["timestamp"] = o.Timestamp |
| 124 | + |
| 125 | + for key, value := range o.AdditionalProperties { |
| 126 | + toSerialize[key] = value |
| 127 | + } |
| 128 | + return datadog.Marshal(toSerialize) |
| 129 | +} |
| 130 | + |
| 131 | +// UnmarshalJSON deserializes the given payload. |
| 132 | +func (o *FlakyTestHistory) UnmarshalJSON(bytes []byte) (err error) { |
| 133 | + all := struct { |
| 134 | + CommitSha *string `json:"commit_sha"` |
| 135 | + Status *string `json:"status"` |
| 136 | + Timestamp *int64 `json:"timestamp"` |
| 137 | + }{} |
| 138 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 139 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 140 | + } |
| 141 | + if all.CommitSha == nil { |
| 142 | + return fmt.Errorf("required field commit_sha missing") |
| 143 | + } |
| 144 | + if all.Status == nil { |
| 145 | + return fmt.Errorf("required field status missing") |
| 146 | + } |
| 147 | + if all.Timestamp == nil { |
| 148 | + return fmt.Errorf("required field timestamp missing") |
| 149 | + } |
| 150 | + additionalProperties := make(map[string]interface{}) |
| 151 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 152 | + datadog.DeleteKeys(additionalProperties, &[]string{"commit_sha", "status", "timestamp"}) |
| 153 | + } else { |
| 154 | + return err |
| 155 | + } |
| 156 | + o.CommitSha = *all.CommitSha |
| 157 | + o.Status = *all.Status |
| 158 | + o.Timestamp = *all.Timestamp |
| 159 | + |
| 160 | + if len(additionalProperties) > 0 { |
| 161 | + o.AdditionalProperties = additionalProperties |
| 162 | + } |
| 163 | + |
| 164 | + return nil |
| 165 | +} |
0 commit comments