Skip to content

Commit 0200aa3

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Maintenances and minor updates to Status Pages API (DataDog#3726)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 57ebae9 commit 0200aa3

88 files changed

Lines changed: 7351 additions & 410 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.generator/schemas/v2/openapi.yaml

Lines changed: 764 additions & 73 deletions
Large diffs are not rendered by default.

api/datadogV2/api_status_pages.go

Lines changed: 511 additions & 0 deletions
Large diffs are not rendered by default.

api/datadogV2/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,18 +780,22 @@
780780
// - [StaticAnalysisApi.UpdateCustomRuleset]
781781
// - [StatusPagesApi.CreateComponent]
782782
// - [StatusPagesApi.CreateDegradation]
783+
// - [StatusPagesApi.CreateMaintenance]
783784
// - [StatusPagesApi.CreateStatusPage]
784785
// - [StatusPagesApi.DeleteComponent]
785786
// - [StatusPagesApi.DeleteDegradation]
786787
// - [StatusPagesApi.DeleteStatusPage]
787788
// - [StatusPagesApi.GetComponent]
788789
// - [StatusPagesApi.GetDegradation]
790+
// - [StatusPagesApi.GetMaintenance]
789791
// - [StatusPagesApi.GetStatusPage]
790792
// - [StatusPagesApi.ListComponents]
791793
// - [StatusPagesApi.ListDegradations]
794+
// - [StatusPagesApi.ListMaintenances]
792795
// - [StatusPagesApi.ListStatusPages]
793796
// - [StatusPagesApi.UpdateComponent]
794797
// - [StatusPagesApi.UpdateDegradation]
798+
// - [StatusPagesApi.UpdateMaintenance]
795799
// - [StatusPagesApi.UpdateStatusPage]
796800
// - [SyntheticsApi.CreateSyntheticsNetworkTest]
797801
// - [SyntheticsApi.CreateSyntheticsSuite]
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
9+
)
10+
11+
// CreateMaintenanceRequest
12+
type CreateMaintenanceRequest struct {
13+
//
14+
Data *CreateMaintenanceRequestData `json:"data,omitempty"`
15+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
16+
UnparsedObject map[string]interface{} `json:"-"`
17+
AdditionalProperties map[string]interface{} `json:"-"`
18+
}
19+
20+
// NewCreateMaintenanceRequest instantiates a new CreateMaintenanceRequest object.
21+
// This constructor will assign default values to properties that have it defined,
22+
// and makes sure properties required by API are set, but the set of arguments
23+
// will change when the set of required properties is changed.
24+
func NewCreateMaintenanceRequest() *CreateMaintenanceRequest {
25+
this := CreateMaintenanceRequest{}
26+
return &this
27+
}
28+
29+
// NewCreateMaintenanceRequestWithDefaults instantiates a new CreateMaintenanceRequest object.
30+
// This constructor will only assign default values to properties that have it defined,
31+
// but it doesn't guarantee that properties required by API are set.
32+
func NewCreateMaintenanceRequestWithDefaults() *CreateMaintenanceRequest {
33+
this := CreateMaintenanceRequest{}
34+
return &this
35+
}
36+
37+
// GetData returns the Data field value if set, zero value otherwise.
38+
func (o *CreateMaintenanceRequest) GetData() CreateMaintenanceRequestData {
39+
if o == nil || o.Data == nil {
40+
var ret CreateMaintenanceRequestData
41+
return ret
42+
}
43+
return *o.Data
44+
}
45+
46+
// GetDataOk returns a tuple with the Data field value if set, nil otherwise
47+
// and a boolean to check if the value has been set.
48+
func (o *CreateMaintenanceRequest) GetDataOk() (*CreateMaintenanceRequestData, bool) {
49+
if o == nil || o.Data == nil {
50+
return nil, false
51+
}
52+
return o.Data, true
53+
}
54+
55+
// HasData returns a boolean if a field has been set.
56+
func (o *CreateMaintenanceRequest) HasData() bool {
57+
return o != nil && o.Data != nil
58+
}
59+
60+
// SetData gets a reference to the given CreateMaintenanceRequestData and assigns it to the Data field.
61+
func (o *CreateMaintenanceRequest) SetData(v CreateMaintenanceRequestData) {
62+
o.Data = &v
63+
}
64+
65+
// MarshalJSON serializes the struct using spec logic.
66+
func (o CreateMaintenanceRequest) MarshalJSON() ([]byte, error) {
67+
toSerialize := map[string]interface{}{}
68+
if o.UnparsedObject != nil {
69+
return datadog.Marshal(o.UnparsedObject)
70+
}
71+
if o.Data != nil {
72+
toSerialize["data"] = o.Data
73+
}
74+
75+
for key, value := range o.AdditionalProperties {
76+
toSerialize[key] = value
77+
}
78+
return datadog.Marshal(toSerialize)
79+
}
80+
81+
// UnmarshalJSON deserializes the given payload.
82+
func (o *CreateMaintenanceRequest) UnmarshalJSON(bytes []byte) (err error) {
83+
all := struct {
84+
Data *CreateMaintenanceRequestData `json:"data,omitempty"`
85+
}{}
86+
if err = datadog.Unmarshal(bytes, &all); err != nil {
87+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
88+
}
89+
additionalProperties := make(map[string]interface{})
90+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
91+
datadog.DeleteKeys(additionalProperties, &[]string{"data"})
92+
} else {
93+
return err
94+
}
95+
96+
hasInvalidField := false
97+
if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil {
98+
hasInvalidField = true
99+
}
100+
o.Data = all.Data
101+
102+
if len(additionalProperties) > 0 {
103+
o.AdditionalProperties = additionalProperties
104+
}
105+
106+
if hasInvalidField {
107+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
108+
}
109+
110+
return nil
111+
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
// CreateMaintenanceRequestData
14+
type CreateMaintenanceRequestData struct {
15+
// The supported attributes for creating a maintenance.
16+
Attributes CreateMaintenanceRequestDataAttributes `json:"attributes"`
17+
// Maintenances resource type.
18+
Type PatchMaintenanceRequestDataType `json:"type"`
19+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
20+
UnparsedObject map[string]interface{} `json:"-"`
21+
AdditionalProperties map[string]interface{} `json:"-"`
22+
}
23+
24+
// NewCreateMaintenanceRequestData instantiates a new CreateMaintenanceRequestData object.
25+
// This constructor will assign default values to properties that have it defined,
26+
// and makes sure properties required by API are set, but the set of arguments
27+
// will change when the set of required properties is changed.
28+
func NewCreateMaintenanceRequestData(attributes CreateMaintenanceRequestDataAttributes, typeVar PatchMaintenanceRequestDataType) *CreateMaintenanceRequestData {
29+
this := CreateMaintenanceRequestData{}
30+
this.Attributes = attributes
31+
this.Type = typeVar
32+
return &this
33+
}
34+
35+
// NewCreateMaintenanceRequestDataWithDefaults instantiates a new CreateMaintenanceRequestData object.
36+
// This constructor will only assign default values to properties that have it defined,
37+
// but it doesn't guarantee that properties required by API are set.
38+
func NewCreateMaintenanceRequestDataWithDefaults() *CreateMaintenanceRequestData {
39+
this := CreateMaintenanceRequestData{}
40+
var typeVar PatchMaintenanceRequestDataType = PATCHMAINTENANCEREQUESTDATATYPE_MAINTENANCES
41+
this.Type = typeVar
42+
return &this
43+
}
44+
45+
// GetAttributes returns the Attributes field value.
46+
func (o *CreateMaintenanceRequestData) GetAttributes() CreateMaintenanceRequestDataAttributes {
47+
if o == nil {
48+
var ret CreateMaintenanceRequestDataAttributes
49+
return ret
50+
}
51+
return o.Attributes
52+
}
53+
54+
// GetAttributesOk returns a tuple with the Attributes field value
55+
// and a boolean to check if the value has been set.
56+
func (o *CreateMaintenanceRequestData) GetAttributesOk() (*CreateMaintenanceRequestDataAttributes, bool) {
57+
if o == nil {
58+
return nil, false
59+
}
60+
return &o.Attributes, true
61+
}
62+
63+
// SetAttributes sets field value.
64+
func (o *CreateMaintenanceRequestData) SetAttributes(v CreateMaintenanceRequestDataAttributes) {
65+
o.Attributes = v
66+
}
67+
68+
// GetType returns the Type field value.
69+
func (o *CreateMaintenanceRequestData) GetType() PatchMaintenanceRequestDataType {
70+
if o == nil {
71+
var ret PatchMaintenanceRequestDataType
72+
return ret
73+
}
74+
return o.Type
75+
}
76+
77+
// GetTypeOk returns a tuple with the Type field value
78+
// and a boolean to check if the value has been set.
79+
func (o *CreateMaintenanceRequestData) GetTypeOk() (*PatchMaintenanceRequestDataType, bool) {
80+
if o == nil {
81+
return nil, false
82+
}
83+
return &o.Type, true
84+
}
85+
86+
// SetType sets field value.
87+
func (o *CreateMaintenanceRequestData) SetType(v PatchMaintenanceRequestDataType) {
88+
o.Type = v
89+
}
90+
91+
// MarshalJSON serializes the struct using spec logic.
92+
func (o CreateMaintenanceRequestData) MarshalJSON() ([]byte, error) {
93+
toSerialize := map[string]interface{}{}
94+
if o.UnparsedObject != nil {
95+
return datadog.Marshal(o.UnparsedObject)
96+
}
97+
toSerialize["attributes"] = o.Attributes
98+
toSerialize["type"] = o.Type
99+
100+
for key, value := range o.AdditionalProperties {
101+
toSerialize[key] = value
102+
}
103+
return datadog.Marshal(toSerialize)
104+
}
105+
106+
// UnmarshalJSON deserializes the given payload.
107+
func (o *CreateMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) {
108+
all := struct {
109+
Attributes *CreateMaintenanceRequestDataAttributes `json:"attributes"`
110+
Type *PatchMaintenanceRequestDataType `json:"type"`
111+
}{}
112+
if err = datadog.Unmarshal(bytes, &all); err != nil {
113+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
114+
}
115+
if all.Attributes == nil {
116+
return fmt.Errorf("required field attributes missing")
117+
}
118+
if all.Type == nil {
119+
return fmt.Errorf("required field type missing")
120+
}
121+
additionalProperties := make(map[string]interface{})
122+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
123+
datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"})
124+
} else {
125+
return err
126+
}
127+
128+
hasInvalidField := false
129+
if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil {
130+
hasInvalidField = true
131+
}
132+
o.Attributes = *all.Attributes
133+
if !all.Type.IsValid() {
134+
hasInvalidField = true
135+
} else {
136+
o.Type = *all.Type
137+
}
138+
139+
if len(additionalProperties) > 0 {
140+
o.AdditionalProperties = additionalProperties
141+
}
142+
143+
if hasInvalidField {
144+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
145+
}
146+
147+
return nil
148+
}

0 commit comments

Comments
 (0)