Skip to content

Commit cec059f

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit af0cd40 of spec repo
1 parent 47be67e commit cec059f

File tree

10 files changed

+942
-0
lines changed

10 files changed

+942
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17289,6 +17289,76 @@ components:
1728917289
- score
1729017290
- severity
1729117291
type: object
17292+
Email:
17293+
description: On-Call User Email.
17294+
example:
17295+
data:
17296+
attributes:
17297+
active: true
17298+
17299+
alias: ''
17300+
blocked: false
17301+
created_at: '2024-04-16T23:38:50.388642Z'
17302+
formats:
17303+
- html
17304+
modified_at: '2024-04-16T23:38:50.388642Z'
17305+
id: 45cd9fe5-dd96-42ad-83de-2242ea9f6efd
17306+
type: emails
17307+
properties:
17308+
data:
17309+
$ref: '#/components/schemas/EmailData'
17310+
type: object
17311+
EmailAttributes:
17312+
description: Attributes for an on-call email.
17313+
properties:
17314+
active:
17315+
description: Whether the email is currently active.
17316+
type: boolean
17317+
address:
17318+
description: Email address.
17319+
type: string
17320+
alias:
17321+
description: Optional display alias for the email.
17322+
type: string
17323+
blocked:
17324+
description: Whether the email is blocked.
17325+
type: boolean
17326+
created_at:
17327+
description: Creation time of the email resource.
17328+
format: date-time
17329+
type: string
17330+
formats:
17331+
description: Preferred content formats for notifications.
17332+
items:
17333+
type: string
17334+
type: array
17335+
modified_at:
17336+
description: Last modification time of the email resource.
17337+
format: date-time
17338+
type: string
17339+
type: object
17340+
EmailData:
17341+
description: Data for an on-call email resource.
17342+
properties:
17343+
attributes:
17344+
$ref: '#/components/schemas/EmailAttributes'
17345+
id:
17346+
description: The email's unique identifier.
17347+
type: string
17348+
type:
17349+
$ref: '#/components/schemas/EmailType'
17350+
required:
17351+
- type
17352+
type: object
17353+
EmailType:
17354+
default: emails
17355+
description: Indicates that the resource is of type 'emails'.
17356+
enum:
17357+
- emails
17358+
example: emails
17359+
type: string
17360+
x-enum-varnames:
17361+
- EMAILS
1729217362
Enabled:
1729317363
description: Field used to enable or disable the rule.
1729417364
example: true
@@ -70837,6 +70907,48 @@ paths:
7083770907
operator: AND
7083870908
permissions:
7083970909
- on_call_write
70910+
/api/v2/on-call/users/{user_id}/notification-channels/emails:
70911+
post:
70912+
description: Create a new email notification channel for an on-call user
70913+
operationId: CreateUserEmailNotificationChannel
70914+
parameters:
70915+
- description: The user ID
70916+
in: path
70917+
name: user_id
70918+
required: true
70919+
schema:
70920+
example: 00000000-0000-0000-0000-000000000000
70921+
type: string
70922+
requestBody:
70923+
content:
70924+
application/json:
70925+
schema:
70926+
$ref: '#/components/schemas/Email'
70927+
required: true
70928+
responses:
70929+
'201':
70930+
description: Created
70931+
'400':
70932+
$ref: '#/components/responses/BadRequestResponse'
70933+
'401':
70934+
$ref: '#/components/responses/UnauthorizedResponse'
70935+
'403':
70936+
$ref: '#/components/responses/ForbiddenResponse'
70937+
'404':
70938+
$ref: '#/components/responses/NotFoundResponse'
70939+
'429':
70940+
$ref: '#/components/responses/TooManyRequestsResponse'
70941+
security:
70942+
- apiKeyAuth: []
70943+
appKeyAuth: []
70944+
- AuthZ: []
70945+
summary: Create email notification channel for user
70946+
tags:
70947+
- On-Call
70948+
x-permission:
70949+
operator: AND
70950+
permissions:
70951+
- on_call_admin
7084070952
/api/v2/org_configs:
7084170953
get:
7084270954
description: Returns all Org Configs (name, description, and value).

api/datadogV2/api_on_call.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,77 @@ func (a *OnCallApi) CreateOnCallSchedule(ctx _context.Context, body ScheduleCrea
231231
return localVarReturnValue, localVarHTTPResponse, nil
232232
}
233233

234+
// CreateUserEmailNotificationChannel Create email notification channel for user.
235+
// Create a new email notification channel for an on-call user
236+
func (a *OnCallApi) CreateUserEmailNotificationChannel(ctx _context.Context, userId string, body Email) (*_nethttp.Response, error) {
237+
var (
238+
localVarHTTPMethod = _nethttp.MethodPost
239+
localVarPostBody interface{}
240+
)
241+
242+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OnCallApi.CreateUserEmailNotificationChannel")
243+
if err != nil {
244+
return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
245+
}
246+
247+
localVarPath := localBasePath + "/api/v2/on-call/users/{user_id}/notification-channels/emails"
248+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{user_id}", _neturl.PathEscape(datadog.ParameterToString(userId, "")))
249+
250+
localVarHeaderParams := make(map[string]string)
251+
localVarQueryParams := _neturl.Values{}
252+
localVarFormParams := _neturl.Values{}
253+
localVarHeaderParams["Content-Type"] = "application/json"
254+
localVarHeaderParams["Accept"] = "*/*"
255+
256+
// body params
257+
localVarPostBody = &body
258+
if a.Client.Cfg.DelegatedTokenConfig != nil {
259+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
260+
if err != nil {
261+
return nil, err
262+
}
263+
} else {
264+
datadog.SetAuthKeys(
265+
ctx,
266+
&localVarHeaderParams,
267+
[2]string{"apiKeyAuth", "DD-API-KEY"},
268+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
269+
)
270+
}
271+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
272+
if err != nil {
273+
return nil, err
274+
}
275+
276+
localVarHTTPResponse, err := a.Client.CallAPI(req)
277+
if err != nil || localVarHTTPResponse == nil {
278+
return localVarHTTPResponse, err
279+
}
280+
281+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
282+
if err != nil {
283+
return localVarHTTPResponse, err
284+
}
285+
286+
if localVarHTTPResponse.StatusCode >= 300 {
287+
newErr := datadog.GenericOpenAPIError{
288+
ErrorBody: localVarBody,
289+
ErrorMessage: localVarHTTPResponse.Status,
290+
}
291+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 {
292+
var v APIErrorResponse
293+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
294+
if err != nil {
295+
return localVarHTTPResponse, newErr
296+
}
297+
newErr.ErrorModel = v
298+
}
299+
return localVarHTTPResponse, newErr
300+
}
301+
302+
return localVarHTTPResponse, nil
303+
}
304+
234305
// DeleteOnCallEscalationPolicy Delete On-Call escalation policy.
235306
// Delete an On-Call escalation policy
236307
func (a *OnCallApi) DeleteOnCallEscalationPolicy(ctx _context.Context, policyId string) (*_nethttp.Response, error) {

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@
406406
// - [OktaIntegrationApi.UpdateOktaAccount]
407407
// - [On-CallApi.CreateOnCallEscalationPolicy]
408408
// - [On-CallApi.CreateOnCallSchedule]
409+
// - [On-CallApi.CreateUserEmailNotificationChannel]
409410
// - [On-CallApi.DeleteOnCallEscalationPolicy]
410411
// - [On-CallApi.DeleteOnCallSchedule]
411412
// - [On-CallApi.GetOnCallEscalationPolicy]

api/datadogV2/model_email.go

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+
// Email On-Call User Email.
12+
type Email struct {
13+
// Data for an on-call email resource.
14+
Data *EmailData `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+
// NewEmail instantiates a new Email 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 NewEmail() *Email {
25+
this := Email{}
26+
return &this
27+
}
28+
29+
// NewEmailWithDefaults instantiates a new Email 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 NewEmailWithDefaults() *Email {
33+
this := Email{}
34+
return &this
35+
}
36+
37+
// GetData returns the Data field value if set, zero value otherwise.
38+
func (o *Email) GetData() EmailData {
39+
if o == nil || o.Data == nil {
40+
var ret EmailData
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 *Email) GetDataOk() (*EmailData, 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 *Email) HasData() bool {
57+
return o != nil && o.Data != nil
58+
}
59+
60+
// SetData gets a reference to the given EmailData and assigns it to the Data field.
61+
func (o *Email) SetData(v EmailData) {
62+
o.Data = &v
63+
}
64+
65+
// MarshalJSON serializes the struct using spec logic.
66+
func (o Email) 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 *Email) UnmarshalJSON(bytes []byte) (err error) {
83+
all := struct {
84+
Data *EmailData `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+
}

0 commit comments

Comments
 (0)