Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7255,6 +7255,12 @@ components:
Monitor:
description: Object describing a monitor.
properties:
assets:
description: The list of monitor assets tied to a monitor, which represents
key links for users to take action on monitor alerts (for example, runbooks).
items:
$ref: '#/components/schemas/MonitorAsset'
type: array
created:
description: Timestamp of the monitor creation.
format: date-time
Expand Down Expand Up @@ -7338,6 +7344,52 @@ components:
- type
- query
type: object
MonitorAsset:
description: 'Represents key links tied to a monitor to help users take action
on alerts.

This feature is in Preview and only available to users with the feature enabled.'
properties:
category:
$ref: '#/components/schemas/MonitorAssetCategory'
name:
description: Name for the monitor asset
example: Monitor Runbook
type: string
resource_key:
description: Represents the identifier of the internal Datadog resource
that this asset represents. IDs in this field should be passed in as strings.
example: '12345'
type: string
resource_type:
$ref: '#/components/schemas/MonitorAssetResourceType'
url:
description: URL link for the asset. For links with an internal resource
type set, this should be the relative path to where the Datadog domain
is appended internally. For external links, this should be the full URL
path.
example: /notebooks/12345
type: string
required:
- name
- url
- category
type: object
MonitorAssetCategory:
description: Indicates the type of asset this entity represents on a monitor.
enum:
- runbook
example: runbook
type: string
x-enum-varnames:
- RUNBOOK
MonitorAssetResourceType:
description: Type of internal Datadog resource associated with a monitor asset.
enum:
- notebook
type: string
x-enum-varnames:
- NOTEBOOK
MonitorDeviceID:
description: ID of the device the Synthetics monitor is running on. Same as
`SyntheticsDeviceID`.
Expand Down Expand Up @@ -8452,6 +8504,13 @@ components:
MonitorUpdateRequest:
description: Object describing a monitor update request.
properties:
assets:
description: The list of monitor assets tied to a monitor, which represents
key links for users to take action on monitor alerts (for example, runbooks).
items:
$ref: '#/components/schemas/MonitorAsset'
nullable: true
type: array
created:
description: Timestamp of the monitor creation.
format: date-time
Expand Down Expand Up @@ -31584,6 +31643,13 @@ paths:
required: false
schema:
type: boolean
- description: If this argument is set to `true`, the returned data includes
all assets tied to this monitor.
in: query
name: with_assets
required: false
schema:
type: boolean
responses:
'200':
content:
Expand Down
10 changes: 10 additions & 0 deletions api/datadogV1/api_monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ func (a *MonitorsApi) DeleteMonitor(ctx _context.Context, monitorId int64, o ...
type GetMonitorOptionalParameters struct {
GroupStates *string
WithDowntimes *bool
WithAssets *bool
}

// NewGetMonitorOptionalParameters creates an empty struct for parameters.
Expand All @@ -532,6 +533,12 @@ func (r *GetMonitorOptionalParameters) WithWithDowntimes(withDowntimes bool) *Ge
return r
}

// WithWithAssets sets the corresponding parameter name and returns the struct.
func (r *GetMonitorOptionalParameters) WithWithAssets(withAssets bool) *GetMonitorOptionalParameters {
r.WithAssets = &withAssets
return r
}

// GetMonitor Get a monitor's details.
// Get details about the specified monitor from your organization.
func (a *MonitorsApi) GetMonitor(ctx _context.Context, monitorId int64, o ...GetMonitorOptionalParameters) (Monitor, *_nethttp.Response, error) {
Expand Down Expand Up @@ -566,6 +573,9 @@ func (a *MonitorsApi) GetMonitor(ctx _context.Context, monitorId int64, o ...Get
if optionalParams.WithDowntimes != nil {
localVarQueryParams.Add("with_downtimes", datadog.ParameterToString(*optionalParams.WithDowntimes, ""))
}
if optionalParams.WithAssets != nil {
localVarQueryParams.Add("with_assets", datadog.ParameterToString(*optionalParams.WithAssets, ""))
}
localVarHeaderParams["Accept"] = "application/json"

if a.Client.Cfg.DelegatedTokenConfig != nil {
Expand Down
37 changes: 36 additions & 1 deletion api/datadogV1/model_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

// Monitor Object describing a monitor.
type Monitor struct {
// The list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks).
Assets []MonitorAsset `json:"assets,omitempty"`
// Timestamp of the monitor creation.
Created *time.Time `json:"created,omitempty"`
// Object describing the creator of the shared element.
Expand Down Expand Up @@ -82,6 +84,34 @@ func NewMonitorWithDefaults() *Monitor {
return &this
}

// GetAssets returns the Assets field value if set, zero value otherwise.
func (o *Monitor) GetAssets() []MonitorAsset {
if o == nil || o.Assets == nil {
var ret []MonitorAsset
return ret
}
return o.Assets
}

// GetAssetsOk returns a tuple with the Assets field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Monitor) GetAssetsOk() (*[]MonitorAsset, bool) {
if o == nil || o.Assets == nil {
return nil, false
}
return &o.Assets, true
}

// HasAssets returns a boolean if a field has been set.
func (o *Monitor) HasAssets() bool {
return o != nil && o.Assets != nil
}

// SetAssets gets a reference to the given []MonitorAsset and assigns it to the Assets field.
func (o *Monitor) SetAssets(v []MonitorAsset) {
o.Assets = v
}

// GetCreated returns the Created field value if set, zero value otherwise.
func (o *Monitor) GetCreated() time.Time {
if o == nil || o.Created == nil {
Expand Down Expand Up @@ -615,6 +645,9 @@ func (o Monitor) MarshalJSON() ([]byte, error) {
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.Assets != nil {
toSerialize["assets"] = o.Assets
}
if o.Created != nil {
if o.Created.Nanosecond() == 0 {
toSerialize["created"] = o.Created.Format("2006-01-02T15:04:05Z07:00")
Expand Down Expand Up @@ -683,6 +716,7 @@ func (o Monitor) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *Monitor) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Assets []MonitorAsset `json:"assets,omitempty"`
Created *time.Time `json:"created,omitempty"`
Creator *Creator `json:"creator,omitempty"`
Deleted datadog.NullableTime `json:"deleted,omitempty"`
Expand Down Expand Up @@ -713,12 +747,13 @@ func (o *Monitor) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"created", "creator", "deleted", "draft_status", "id", "matching_downtimes", "message", "modified", "multi", "name", "options", "overall_state", "priority", "query", "restricted_roles", "state", "tags", "type"})
datadog.DeleteKeys(additionalProperties, &[]string{"assets", "created", "creator", "deleted", "draft_status", "id", "matching_downtimes", "message", "modified", "multi", "name", "options", "overall_state", "priority", "query", "restricted_roles", "state", "tags", "type"})
} else {
return err
}

hasInvalidField := false
o.Assets = all.Assets
o.Created = all.Created
if all.Creator != nil && all.Creator.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
Expand Down
Loading