From 68a5ffce1adba7a0fca91f862eec878818fd9338 Mon Sep 17 00:00:00 2001 From: shkaruna Date: Fri, 27 Mar 2026 16:16:17 +0530 Subject: [PATCH 1/3] feat: add ACLP list entities method Add entity envelope in AlertDefinition GET, POST and PUT API responses. Add new method to list entities. Update tests. --- monitor_alert_definitions.go | 77 ++++- .../fixtures/TestMonitorAlertDefinition.yaml | 219 ++++++++---- ...stMonitorAlertDefinitionEntities_List.yaml | 152 +++++++++ ...AlertDefinition_CreateWithIdempotency.yaml | 59 ++-- .../TestMonitorAlertDefinitions_List.yaml | 107 +++--- .../monitor_alert_definitions_test.go | 26 ++ test/unit/monitor_alert_definitions_test.go | 316 ++++++++++++++++-- 7 files changed, 749 insertions(+), 207 deletions(-) create mode 100644 test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml diff --git a/monitor_alert_definitions.go b/monitor_alert_definitions.go index d744175ce..730665655 100644 --- a/monitor_alert_definitions.go +++ b/monitor_alert_definitions.go @@ -19,25 +19,54 @@ const ( AlertDefinitionStatusFailed AlertDefinitionStatus = "failed" ) +// AlertDefinitionScope represents the scope of an alert definition: "account", "entity", or "region". Defaults to "entity". +type AlertDefinitionScope string + +const ( + AlertDefinitionScopeAccount AlertDefinitionScope = "account" + AlertDefinitionScopeEntity AlertDefinitionScope = "entity" + AlertDefinitionScopeRegion AlertDefinitionScope = "region" +) + +// AlertDefinitionEntities represents entity metadata for an alert definition. +// For entity scoped alerts, entities contains the URL to list entities, a count, and a has_more_resources flag. +// For region/account scoped alerts, the entities are returned as an empty object. +type AlertDefinitionEntities struct { + URL string `json:"url"` + Count int `json:"count"` + HasMoreResources bool `json:"has_more_resources"` +} + +// AlertDefinitionEntity represents a single entity associated with an alert definition. +type AlertDefinitionEntity struct { + ID string `json:"id"` + Label string `json:"label"` + URL string `json:"url"` + Type string `json:"type"` +} + // AlertDefinition represents an ACLP Alert Definition object type AlertDefinition struct { - ID int `json:"id"` - Label string `json:"label"` - Severity int `json:"severity"` - Type string `json:"type"` - ServiceType string `json:"service_type"` - Status AlertDefinitionStatus `json:"status"` - HasMoreResources bool `json:"has_more_resources"` - RuleCriteria RuleCriteria `json:"rule_criteria"` - TriggerConditions TriggerConditions `json:"trigger_conditions"` - AlertChannels []AlertChannelEnvelope `json:"alert_channels"` - Created *time.Time `json:"-"` - Updated *time.Time `json:"-"` - UpdatedBy string `json:"updated_by"` - CreatedBy string `json:"created_by"` - EntityIDs []string `json:"entity_ids"` - Description string `json:"description"` - Class string `json:"class"` + ID int `json:"id"` + Label string `json:"label"` + Severity int `json:"severity"` + Type string `json:"type"` + ServiceType string `json:"service_type"` + Status AlertDefinitionStatus `json:"status"` + HasMoreResources bool `json:"has_more_resources"` // Deprecated: use Entities.HasMoreResources. + RuleCriteria RuleCriteria `json:"rule_criteria"` + TriggerConditions TriggerConditions `json:"trigger_conditions"` + AlertChannels []AlertChannelEnvelope `json:"alert_channels"` + Created *time.Time `json:"-"` + Updated *time.Time `json:"-"` + UpdatedBy string `json:"updated_by"` + CreatedBy string `json:"created_by"` + EntityIDs []string `json:"entity_ids"` // Deprecated: use Entities.url to list associated entities. + Description string `json:"description"` + Class string `json:"class"` + Scope AlertDefinitionScope `json:"scope"` + Regions []string `json:"regions"` + Entities AlertDefinitionEntities `json:"entities"` } // Backwards-compatible alias @@ -143,6 +172,8 @@ type AlertDefinitionCreateOptions struct { TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"` EntityIDs []string `json:"entity_ids,omitempty"` Description *string `json:"description,omitempty"` + Scope AlertDefinitionScope `json:"scope,omitempty"` + Regions []string `json:"regions,omitzero"` } // AlertDefinitionUpdateOptions are the options used to update an alert definition. @@ -155,6 +186,7 @@ type AlertDefinitionUpdateOptions struct { EntityIDs []string `json:"entity_ids,omitempty"` Description *string `json:"description,omitempty"` Status *AlertDefinitionStatus `json:"status,omitempty"` + Regions []string `json:"regions,omitzero"` } // UnmarshalJSON implements the json.Unmarshaler interface @@ -268,3 +300,14 @@ func (c *Client) DeleteMonitorAlertDefinition(ctx context.Context, serviceType s e := formatAPIPath("monitor/services/%s/alert-definitions/%d", serviceType, alertID) return doDELETERequest(ctx, c, e) } + +// ListMonitorAlertDefinitionEntities gets the entities associated with an ACLP Monitor Alert Definition. +func (c *Client) ListMonitorAlertDefinitionEntities( + ctx context.Context, + serviceType string, + alertID int, + opts *ListOptions, +) ([]AlertDefinitionEntity, error) { + e := formatAPIPath("monitor/services/%s/alert-definitions/%d/entities", serviceType, alertID) + return getPaginatedResults[AlertDefinitionEntity](ctx, c, e, opts) +} diff --git a/test/integration/fixtures/TestMonitorAlertDefinition.yaml b/test/integration/fixtures/TestMonitorAlertDefinition.yaml index 7102062bd..d02b3b171 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinition.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinition.yaml @@ -14,80 +14,58 @@ interactions: url: https://api.linode.com/v4beta/monitor/alert-definitions?page=1 method: GET response: - body: '{"pages": 1, "page": 1, "results": 6, "data": [{"id": 10000, "label": "High - Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated + body: '{"pages": 1, "page": 1, "results": 4, "data": [{"id": 10000, "label": + "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["423214"], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10001, "label": "High Memory Usage - Plan Shared", "description": "Alert triggers when shared plan nodes consistently - reach critical memory usage, risking application performance degradation.", - "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", - "regions": [], "status": "enabled", "entity_ids": ["189690", "313392", "324828", - "340839", "380969"], "has_more_resources": false, "severity": 2, "rule_criteria": - {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": - []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": - "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}, {"id": - 10002, "label": "High CPU Usage Plan Dedicated", "description": "Alert triggers - when dedicated nodes consistently exceed 95% CPU usage across three consecutive - 5-minute intervals.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["187468", - "188020", "188680", "188691", "423214"], "has_more_resources": false, "severity": - 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["324478", + "324480", "324483", "324486", "394528"], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", - "updated_by": "system"}, {"id": 10003, "label": "High CPU Usage Plan Shared", - "description": "Alert triggers when shared plan nodes consistently exceed high - CPU utilization, indicating potential performance issues.", "service_type": - "dbaas", "type": "system", "scope": "entity", "class": "shared", "regions": - [], "status": "enabled", "entity_ids": ["189690", "313392", "324828", "340839", - "380969"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": - [{"label": "CPU Usage", "metric": "cpu_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10004, "label": "High Disk Usage Plan - Dedicated", "description": "Alert triggers when dedicated plan nodes experience - sustained high disk usage, risking immediate resource exhaustion.", "service_type": - "dbaas", "type": "system", "scope": "entity", "class": "dedicated", "regions": - [], "status": "enabled", "entity_ids": ["187468", "188020", "188680", "188691", - "423214"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": - [{"label": "Disk Space Usage", "metric": "disk_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10000/entities", + "has_more_resources": false, "count": 5}}, {"id": 10001, "label": "High Memory + Usage Plan Shared", "description": "Alert triggers when shared plan nodes consistently + reach critical memory usage, risking application performance degradation.", + "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", + "regions": [], "status": "enabled", "entity_ids": ["190003", "257626"], "has_more_resources": + false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": + "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": + 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10005, "label": "High Disk Usage Plan - Shared", "description": "Alert triggers when shared plan nodes experience sustained - high disk usage, risking immediate resource exhaustion.", "service_type": "dbaas", - "type": "system", "scope": "entity", "class": "shared", "regions": [], "status": - "enabled", "entity_ids": ["189690", "313392", "324828", "340839", "380969"], + "system", "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10001/entities", + "has_more_resources": false, "count": 2}}, {"id": 11001, "label": "test_alert_logs_prod", + "description": "some desc1", "service_type": "logs", "type": "user", "scope": + "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": ["100"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Disk Space Usage", "metric": "disk_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "Successful Upload Count", "metric": "success_upload_count", "unit": "count", + "aggregate_function": "sum", "operator": "lt", "threshold": 100000, "dimension_filters": + []}]}, "alert_channels": [{"id": 10004, "label": "Alert Channel", "url": + "/monitor/alert-channels/10004", "type": "alert-channels"}], "trigger_conditions": + {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": + 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "tester", "updated_by": + "tester", "entities": {"url": "/monitor/services/logs/alert-definitions/11001/entities", + "has_more_resources": false, "count": 1}}, {"id": 11021, "label": "Test Alert", "description": "Test Alert", "service_type": + "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": + "enabled", "entity_ids": ["257626", "394528"], "has_more_resources": false, + "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": + "memory_usage", "unit": "percent", "aggregate_function": "sum", "operator": + "gt", "threshold": 100, "dimension_filters": []}]}, "alert_channels": [{"id": + 10004, "label": "Alert Channel", "url": "/monitor/alert-channels/10004", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}]}' + "polling_interval_seconds": 1800, "evaluation_period_seconds": 900, "trigger_occurrences": + 10}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "tester", "updated_by": "tester", "entities": + {"url": "/monitor/services/dbaas/alert-definitions/11021/entities", "has_more_resources": + false, "count": 2}}]}' headers: Access-Control-Allow-Credentials: - "true" @@ -110,7 +88,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:26:10 GMT + - Wed, 08 Apr 2026 06:05:05 GMT Pragma: - no-cache Strict-Transport-Security: @@ -127,7 +105,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: @@ -149,7 +130,7 @@ interactions: url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions method: POST response: - body: '{"id": 10855, "label": "go-test-alert-definition-create", "description": + body: '{"id": 11022, "label": "go-test-alert-definition-create", "description": "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": "provisioning", "entity_ids": [], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": @@ -160,7 +141,9 @@ interactions: "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "srinidhi_gemini", "updated_by": "srinidhi_gemini"}' + "tester", "updated_by": "tester", "entities": + {"url": "/monitor/services/dbaas/alert-definitions/11022/entities", "has_more_resources": + false, "count": 0}}' headers: Access-Control-Allow-Credentials: - "true" @@ -183,7 +166,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:26:11 GMT + - Wed, 08 Apr 2026 06:05:06 GMT Pragma: - no-cache Strict-Transport-Security: @@ -199,7 +182,87 @@ interactions: - DENY - DENY X-Oauth-Scopes: + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11022 + method: GET + response: + body: '{"id": 11022, "label": "go-test-alert-definition-create", "description": + "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": + "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": [], + "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": + "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node + Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, + "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "tester", "updated_by": "tester", "entities": + {"url": "/monitor/services/dbaas/alert-definitions/11022/entities", "has_more_resources": + false, "count": 0}}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Wed, 08 Apr 2026 06:05:22 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: @@ -218,10 +281,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10855 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11022 method: PUT response: - body: '{"id": 10855, "label": "go-test-alert-definition-create-updated", "description": + body: '{"id": 11022, "label": "go-test-alert-definition-create-updated", "description": "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": @@ -232,7 +295,9 @@ interactions: "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "srinidhi_gemini", "updated_by": "srinidhi_gemini"}' + "tester", "updated_by": "tester", "entities": + {"url": "/monitor/services/dbaas/alert-definitions/11022/entities", "has_more_resources": + false, "count": 0}}' headers: Access-Control-Allow-Credentials: - "true" @@ -255,7 +320,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:13 GMT + - Wed, 08 Apr 2026 06:05:24 GMT Pragma: - no-cache Strict-Transport-Security: @@ -271,7 +336,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: @@ -289,7 +357,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10855 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11022 method: DELETE response: body: '{}' @@ -317,7 +385,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:14 GMT + - Wed, 08 Apr 2026 06:05:25 GMT Pragma: - no-cache Strict-Transport-Security: @@ -332,7 +400,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: diff --git a/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml b/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml new file mode 100644 index 000000000..8e2a96872 --- /dev/null +++ b/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml @@ -0,0 +1,152 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/alert-definitions?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 1, "data": [{"id": 10000, "label": + "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated + plan nodes consistently reach critical memory usage, risking application performance + degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", + "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["324478", + "324480", "324483", "324486", "394528"], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", + "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": + 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], + "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", + "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10000/entities", + "has_more_resources": false, "count": 5}}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Wed, 08 Apr 2026 05:55:13 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10000/entities?page=1 + method: GET + response: + body: '{"data": [{"id": "324478", "label": "test-label-1", "url": "/v4/databases/mysql/instances/324478", + "type": "dbaas"}, {"id": "324480", "label": "test-label-2", "url": "/v4/databases/postgresql/instances/324480", + "type": "dbaas"}, {"id": "324483", "label": "test-label-3", "url": + "/v4/databases/postgresql/instances/324483", "type": "dbaas"}, {"id": "324486", + "label": "test-label-4", "url": "/v4/databases/postgresql/instances/324486", + "type": "dbaas"}, {"id": "394528", "label": "test-label-5", "url": "/v4/databases/mysql/instances/394528", + "type": "dbaas"}], "page": 1, "pages": 1, "results": 5}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "641" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Wed, 08 Apr 2026 05:55:14 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml b/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml index 032520c0c..13e0e8681 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml @@ -14,12 +14,17 @@ interactions: url: https://api.linode.com/v4beta/monitor/alert-channels?page=1 method: GET response: - body: '{"pages": 1, "page": 1, "results": 1, "data": [{"id": 10000, "label": "Read-Write - Channel", "channel_type": "email", "type": "system", "content": {"email": {"email_addresses": - ["Users-with-read-write-access-to-resources"]}}, "details": {"email": {"usernames": + body: '{"pages": 1, "page": 1, "results": 2, "data": [{"id": 10000, "label": "Read-Write + Channel", "channel_type": "email", "type": "system", "details": {"email": {"usernames": [], "recipient_type": "read_write_users"}}, "alerts": {"url": "/monitor/alert-channels/10000/alerts", - "type": "alerts-definitions", "alert_count": 6}, "created": "2018-01-02T03:04:05", - "updated": "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}]}' + "type": "alerts-definitions", "alert_count": 9}, "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}, + {"id": 10118, "label": "notification channel", "channel_type": "email", "type": "user", + "details": {"email": {"usernames": ["tester"], "recipient_type": + "user"}}, "alerts": {"url": "/monitor/alert-channels/10118/alerts", "type": + "alerts-definitions", "alert_count": 0}, "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "tester", "updated_by": + "tester"}]}' headers: Access-Control-Allow-Credentials: - "true" @@ -37,14 +42,12 @@ interactions: - max-age=0, no-cache, no-store Connection: - keep-alive - Content-Length: - - "528" Content-Security-Policy: - default-src 'none' Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:16 GMT + - Wed, 08 Apr 2026 06:27:41 GMT Pragma: - no-cache Strict-Transport-Security: @@ -52,6 +55,7 @@ interactions: Vary: - Authorization, X-Filter - Authorization, X-Filter + - Accept-Encoding X-Accepted-Oauth-Scopes: - monitor:read_only X-Content-Type-Options: @@ -60,7 +64,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: @@ -69,7 +76,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-alert-definition-idempotency-1771216030885216000","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + body: '{"label":"go-test-alert-definition-idempotency-1775629661986967956","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test alert definition creation with idempotency"}' form: {} headers: @@ -82,7 +89,7 @@ interactions: url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions method: POST response: - body: '{"id": 10856, "label": "go-test-alert-definition-idempotency-1771216030885216000", + body: '{"id": 11023, "label": "go-test-alert-definition-idempotency-1775629661986967956", "description": "Test alert definition creation with idempotency", "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": "provisioning", "entity_ids": [], "has_more_resources": false, "severity": 2, @@ -93,8 +100,9 @@ interactions: "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": - "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "srinidhi_gemini", - "updated_by": "srinidhi_gemini"}' + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "tester", + "updated_by": "tester", "entities": {"url": "/monitor/services/dbaas/alert-definitions/11023/entities", + "has_more_resources": false, "count": 0}}' headers: Access-Control-Allow-Credentials: - "true" @@ -117,7 +125,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:18 GMT + - Wed, 08 Apr 2026 06:27:43 GMT Pragma: - no-cache Strict-Transport-Security: @@ -133,7 +141,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: @@ -142,7 +153,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-alert-definition-idempotency-1771216030885216000","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + body: '{"label":"go-test-alert-definition-idempotency-1775629661986967956","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test alert definition creation with idempotency"}' form: {} headers: @@ -173,7 +184,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:18 GMT + - Wed, 08 Apr 2026 06:27:43 GMT Pragma: - no-cache Strict-Transport-Security: @@ -183,7 +194,10 @@ interactions: X-Frame-Options: - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" status: 400 Bad Request @@ -199,7 +213,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10856 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11023 method: DELETE response: body: '{}' @@ -227,7 +241,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:19 GMT + - Wed, 08 Apr 2026 06:27:44 GMT Pragma: - no-cache Strict-Transport-Security: @@ -242,7 +256,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: diff --git a/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml b/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml index 9827d96f3..7179797d6 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml @@ -14,80 +14,58 @@ interactions: url: https://api.linode.com/v4beta/monitor/alert-definitions?page=1 method: GET response: - body: '{"pages": 1, "page": 1, "results": 6, "data": [{"id": 10000, "label": "High - Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated + body: '{"pages": 1, "page": 1, "results": 4, "data": [{"id": 10000, "label": + "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["423214"], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10001, "label": "High Memory Usage - Plan Shared", "description": "Alert triggers when shared plan nodes consistently - reach critical memory usage, risking application performance degradation.", - "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", - "regions": [], "status": "enabled", "entity_ids": ["189690", "313392", "324828", - "340839", "380969"], "has_more_resources": false, "severity": 2, "rule_criteria": - {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": - []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": - "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}, {"id": - 10002, "label": "High CPU Usage Plan Dedicated", "description": "Alert triggers - when dedicated nodes consistently exceed 95% CPU usage across three consecutive - 5-minute intervals.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["187468", - "188020", "188680", "188691", "423214"], "has_more_resources": false, "severity": - 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["324478", + "324480", "324483", "324486", "394528"], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", - "updated_by": "system"}, {"id": 10003, "label": "High CPU Usage Plan Shared", - "description": "Alert triggers when shared plan nodes consistently exceed high - CPU utilization, indicating potential performance issues.", "service_type": - "dbaas", "type": "system", "scope": "entity", "class": "shared", "regions": - [], "status": "enabled", "entity_ids": ["189690", "313392", "324828", "340839", - "380969"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": - [{"label": "CPU Usage", "metric": "cpu_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10004, "label": "High Disk Usage Plan - Dedicated", "description": "Alert triggers when dedicated plan nodes experience - sustained high disk usage, risking immediate resource exhaustion.", "service_type": - "dbaas", "type": "system", "scope": "entity", "class": "dedicated", "regions": - [], "status": "enabled", "entity_ids": ["187468", "188020", "188680", "188691", - "423214"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": - [{"label": "Disk Space Usage", "metric": "disk_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10000/entities", + "has_more_resources": false, "count": 5}}, {"id": 10001, "label": "High Memory + Usage Plan Shared", "description": "Alert triggers when shared plan nodes consistently + reach critical memory usage, risking application performance degradation.", + "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", + "regions": [], "status": "enabled", "entity_ids": ["190003", "257626"], "has_more_resources": + false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": + "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": + 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10005, "label": "High Disk Usage Plan - Shared", "description": "Alert triggers when shared plan nodes experience sustained - high disk usage, risking immediate resource exhaustion.", "service_type": "dbaas", - "type": "system", "scope": "entity", "class": "shared", "regions": [], "status": - "enabled", "entity_ids": ["189690", "313392", "324828", "340839", "380969"], + "system", "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10001/entities", + "has_more_resources": false, "count": 2}}, {"id": 11001, "label": "test_alert_logs_prod", + "description": "some desc1", "service_type": "logs", "type": "user", "scope": + "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": ["100"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Disk Space Usage", "metric": "disk_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "Successful Upload Count", "metric": "success_upload_count", "unit": "count", + "aggregate_function": "sum", "operator": "lt", "threshold": 100000, "dimension_filters": + []}]}, "alert_channels": [{"id": 10004, "label": "Alert Channel", "url": + "/monitor/alert-channels/10004", "type": "alert-channels"}], "trigger_conditions": + {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": + 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "tester", "updated_by": + "tester", "entities": {"url": "/monitor/services/logs/alert-definitions/11001/entities", + "has_more_resources": false, "count": 1}}, {"id": 11021, "label": "Test Alert", "description": "Test Alert", "service_type": + "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": + "enabled", "entity_ids": ["257626", "394528"], "has_more_resources": false, + "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": + "memory_usage", "unit": "percent", "aggregate_function": "sum", "operator": + "gt", "threshold": 100, "dimension_filters": []}]}, "alert_channels": [{"id": + 10004, "label": "Alert Channel", "url": "/monitor/alert-channels/10004", "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}]}' + "polling_interval_seconds": 1800, "evaluation_period_seconds": 900, "trigger_occurrences": + 10}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "tester", "updated_by": "tester", "entities": + {"url": "/monitor/services/dbaas/alert-definitions/11021/entities", "has_more_resources": + false, "count": 2}}]}' headers: Access-Control-Allow-Credentials: - "true" @@ -110,7 +88,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 16 Feb 2026 04:27:15 GMT + - Wed, 08 Apr 2026 06:19:02 GMT Pragma: - no-cache Strict-Transport-Security: @@ -127,7 +105,10 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - '*' + - account:read_only databases:read_only domains:read_only events:read_only firewall:read_only + images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only + monitor:read_write nodebalancers:read_only object_storage:read_only stackscripts:read_only + volumes:read_only X-Ratelimit-Limit: - "1840" X-Xss-Protection: diff --git a/test/integration/monitor_alert_definitions_test.go b/test/integration/monitor_alert_definitions_test.go index 420e18af2..37eee17f1 100644 --- a/test/integration/monitor_alert_definitions_test.go +++ b/test/integration/monitor_alert_definitions_test.go @@ -304,3 +304,29 @@ func TestMonitorAlertDefinition_CreateWithIdempotency(t *testing.T) { _ = client.DeleteMonitorAlertDefinition(context.Background(), testMonitorAlertDefinitionServiceType, createdAlert.ID) } } + +func TestMonitorAlertDefinitionEntities_List(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinitionEntities_List") + defer teardown() + + alerts, err := client.ListAllMonitorAlertDefinitions(context.Background(), nil) + assert.NoError(t, err) + assert.NotEmpty(t, alerts) + + entities, err := client.ListMonitorAlertDefinitionEntities( + context.Background(), + testMonitorAlertDefinitionServiceType, + alerts[0].ID, + nil, + ) + + assert.NoError(t, err) + assert.NotEmpty(t, entities, "Expected at least one entity") + + for _, entity := range entities { + assert.NotZero(t, entity.ID) + assert.NotEmpty(t, entity.Label) + assert.NotEmpty(t, entity.Type) + assert.NotEmpty(t, entity.URL) + } +} diff --git a/test/unit/monitor_alert_definitions_test.go b/test/unit/monitor_alert_definitions_test.go index 8af141688..c8e742db8 100644 --- a/test/unit/monitor_alert_definitions_test.go +++ b/test/unit/monitor_alert_definitions_test.go @@ -14,47 +14,217 @@ const ( testMonitorAlertDefinitionID = 123 monitorAlertDefinitionGetResponse = `{ - "id": 123, - "label": "test-alert-definition", - "severity": 1, - "type": "some_type", - "service_type": "dbaas", - "status": "enabled", - "entity_ids": ["12345"], - "channel_ids": [1], - "is_enabled": true + "id": 123, + "label": "test-alert-definition", + "severity": 1, + "type": "user", + "service_type": "dbaas", + "description": "A test alert for dbaas service", + "scope": "entity", + "regions": [], + "entity_ids": [ + "12345" + ], + "has_more_resources": false, + "alert_channels": [ + { + "id": 10000, + "label": "Read-Write Channel", + "type": "email", + "url": "/monitor/alert-channels/10000" + } + ], + "rule_criteria": { + "rules": [ + { + "aggregate_function": "avg", + "dimension_filters": [ + { + "dimension_label": "node_type", + "label": "Node Type", + "operator": "eq", + "value": "primary" + } + ], + "label": "High CPU Usage", + "metric": "cpu_usage", + "operator": "gt", + "threshold": 90, + "unit": "percent" + } + ] + }, + "trigger_conditions": { + "criteria_condition": "ALL", + "evaluation_period_seconds": 300, + "polling_interval_seconds": 60, + "trigger_occurrences": 3 + }, + "class": "", + "status": "enabled", + "entities": { + "url": "/monitor/services/dbaas/alert-definitions/123/entities", + "count": 0, + "has_more_resources": false + }, + "created": "2024-01-01T00:00:00", + "updated": "2024-01-01T00:00:00", + "updated_by": "tester" }` monitorAlertDefinitionListResponse = `{ - "data": [{ - "id": 123, - "label": "test-alert-definition", - "severity": 1, - "type": "some_type", - "service_type": "dbaas", - "status": "enabled", - "entity_ids": ["12345"], - "channel_ids": [1], - "is_enabled": true - }], - "page": 1, - "pages": 1, - "results": 1 + "data": [ + { + "id": 123, + "label": "test-alert-definition", + "severity": 1, + "type": "user", + "service_type": "dbaas", + "description": "A test alert for dbaas service", + "status": "enabled", + "scope": "entity", + "regions": [], + "entity_ids": [ + "12345" + ], + "has_more_resources": true, + "alert_channels": [ + { + "id": 10000, + "label": "Read-Write Channel", + "type": "email", + "url": "/monitor/alert-channels/10000" + } + ], + "rule_criteria": { + "rules": [ + { + "aggregate_function": "avg", + "dimension_filters": [ + { + "dimension_label": "node_type", + "label": "Node Type", + "operator": "eq", + "value": "primary" + } + ], + "label": "High CPU Usage", + "metric": "cpu_usage", + "operator": "gt", + "threshold": 90, + "unit": "percent" + } + ] + }, + "trigger_conditions": { + "criteria_condition": "ALL", + "evaluation_period_seconds": 300, + "polling_interval_seconds": 60, + "trigger_occurrences": 3 + }, + "class": "", + "entities": { + "url": "/monitor/services/dbaas/alert-definitions/123/entities", + "count": 2, + "has_more_resources": true + }, + "created": "2024-01-01T00:00:00", + "updated": "2024-01-01T00:00:00", + "updated_by": "tester" + } + ], + "page": 1, + "pages": 1, + "results": 1 }` monitorAlertDefinitionUpdateResponse = `{ - "id": 123, - "label": "test-alert-definition-renamed", - "severity": 2, - "type": "some_type", - "service_type": "dbaas", - "status": "disabled", - "entity_ids": ["12345"], - "channel_ids": [1, 2], - "is_enabled": false + "id": 123, + "label": "test-alert-definition-renamed", + "severity": 2, + "type": "user", + "service_type": "dbaas", + "status": "disabled", + "scope": "entity", + "description": "A test alert for dbaas service", + "regions": [], + "entity_ids": [ + "12345", + "45678" + ], + "has_more_resources": true, + "alert_channels": [ + { + "id": 10000, + "label": "Read-Write Channel", + "type": "email", + "url": "/monitor/alert-channels/10000" + } + ], + "rule_criteria": { + "rules": [ + { + "aggregate_function": "avg", + "dimension_filters": [ + { + "dimension_label": "node_type", + "label": "Node Type", + "operator": "eq", + "value": "primary" + } + ], + "label": "High CPU Usage", + "metric": "cpu_usage", + "operator": "gt", + "threshold": 90, + "unit": "percent" + } + ] + }, + "trigger_conditions": { + "criteria_condition": "ALL", + "evaluation_period_seconds": 300, + "polling_interval_seconds": 60, + "trigger_occurrences": 3 + }, + "class": "", + "entities": { + "url": "/monitor/services/dbaas/alert-definitions/123/entities", + "count": 2, + "has_more_resources": true + }, + "created": "2024-01-01T00:00:00", + "updated": "2024-01-01T00:00:00", + "updated_by": "tester" }` monitorAlertDefinitionUpdateLabelOnlyResponseSingleLine = `{"id": 123, "label": "test-alert-definition-renamed-one-line", "severity": 1, "type": "some_type", "service_type": "dbaas", "status": "enabled", "entity_ids": ["12345"], "channel_ids": [1], "is_enabled": true}` + + monitorAlertDefinitionEntitiesListResponse = `{ + "data": [ + { + "id": "1", + "label": "mydatabase-1", + "url": "/v4/databases/mysql/instances/1", + "type": "dbaas" + }, + { + "id": "2", + "label": "mydatabase-2", + "url": "/v4/databases/mysql/instances/2", + "type": "dbaas" + }, + { + "id": "3", + "label": "mydatabase-3", + "url": "/v4/databases/mysql/instances/3", + "type": "dbaas" + } + ], + "page": 1, + "pages": 1, + "results": 3 + }` ) func TestCreateMonitorAlertDefinition(t *testing.T) { @@ -67,6 +237,8 @@ func TestCreateMonitorAlertDefinition(t *testing.T) { createOpts := linodego.AlertDefinitionCreateOptions{ Label: "test-alert-definition", Severity: int(linodego.SeverityLow), + Scope: linodego.AlertDefinitionScopeEntity, + Regions: []string{}, ChannelIDs: []int{1}, EntityIDs: []string{"12345"}, } @@ -76,6 +248,17 @@ func TestCreateMonitorAlertDefinition(t *testing.T) { assert.NotNil(t, alert) assert.Equal(t, "test-alert-definition", alert.Label) assert.Equal(t, testMonitorAlertDefinitionID, alert.ID) + assert.Equal(t, linodego.AlertDefinitionScopeEntity, alert.Scope) + assert.Empty(t, alert.Regions) + assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) + assert.Equal(t, 0, alert.Entities.Count) + assert.False(t, alert.Entities.HasMoreResources) + assert.Equal(t, []string{"12345"}, alert.EntityIDs) + assert.False(t, alert.HasMoreResources) + assert.NotNil(t, alert.AlertChannels) + assert.NotNil(t, alert.RuleCriteria) + assert.NotNil(t, alert.RuleCriteria.Rules) + assert.NotNil(t, alert.TriggerConditions) } func TestCreateMonitorAlertDefinitionWithIdempotency(t *testing.T) { @@ -88,6 +271,8 @@ func TestCreateMonitorAlertDefinitionWithIdempotency(t *testing.T) { createOpts := linodego.AlertDefinitionCreateOptions{ Label: "test-alert-definition", Severity: int(linodego.SeverityLow), + Scope: linodego.AlertDefinitionScopeEntity, + Regions: []string{}, ChannelIDs: []int{1}, EntityIDs: []string{"12345"}, } @@ -102,6 +287,11 @@ func TestCreateMonitorAlertDefinitionWithIdempotency(t *testing.T) { assert.NotNil(t, alert) assert.Equal(t, "test-alert-definition", alert.Label) assert.Equal(t, testMonitorAlertDefinitionID, alert.ID) + assert.Equal(t, linodego.AlertDefinitionScopeEntity, alert.Scope) + assert.Empty(t, alert.Regions) + assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) + assert.Equal(t, 0, alert.Entities.Count) + assert.False(t, alert.Entities.HasMoreResources) } func TestGetMonitorAlertDefinition(t *testing.T) { @@ -116,6 +306,17 @@ func TestGetMonitorAlertDefinition(t *testing.T) { assert.NotNil(t, alert) assert.Equal(t, "test-alert-definition", alert.Label) assert.Equal(t, testMonitorAlertDefinitionID, alert.ID) + assert.Equal(t, linodego.AlertDefinitionScopeEntity, alert.Scope) + assert.Empty(t, alert.Regions) + assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) + assert.Equal(t, 0, alert.Entities.Count) + assert.False(t, alert.Entities.HasMoreResources) + assert.Equal(t, []string{"12345"}, alert.EntityIDs) + assert.False(t, alert.HasMoreResources) + assert.NotNil(t, alert.AlertChannels) + assert.NotNil(t, alert.RuleCriteria) + assert.NotNil(t, alert.RuleCriteria.Rules) + assert.NotNil(t, alert.TriggerConditions) } func TestListMonitorAlertDefinitions(t *testing.T) { @@ -130,6 +331,17 @@ func TestListMonitorAlertDefinitions(t *testing.T) { assert.Len(t, alerts, 1) assert.Equal(t, "test-alert-definition", alerts[0].Label) assert.Equal(t, testMonitorAlertDefinitionID, alerts[0].ID) + assert.Equal(t, linodego.AlertDefinitionScopeEntity, alerts[0].Scope) + assert.Empty(t, alerts[0].Regions) + assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alerts[0].Entities.URL) + assert.Equal(t, 2, alerts[0].Entities.Count) + assert.True(t, alerts[0].Entities.HasMoreResources) + assert.Equal(t, []string{"12345"}, alerts[0].EntityIDs) + assert.True(t, alerts[0].HasMoreResources) + assert.NotNil(t, alerts[0].AlertChannels) + assert.NotNil(t, alerts[0].RuleCriteria) + assert.NotNil(t, alerts[0].RuleCriteria.Rules) + assert.NotNil(t, alerts[0].TriggerConditions) } func TestUpdateMonitorAlertDefinition(t *testing.T) { @@ -155,6 +367,12 @@ func TestUpdateMonitorAlertDefinition(t *testing.T) { assert.NotNil(t, alert) assert.Equal(t, "test-alert-definition-renamed", alert.Label) assert.Equal(t, 2, alert.Severity) + assert.Equal(t, linodego.AlertDefinitionScopeEntity, alert.Scope) + assert.Empty(t, alert.Regions) + assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) + assert.Equal(t, 2, alert.Entities.Count) + assert.True(t, alert.Entities.HasMoreResources) + assert.True(t, alert.HasMoreResources) } func TestUpdateMonitorAlertDefinition_LabelOnly(t *testing.T) { @@ -191,3 +409,37 @@ func TestDeleteMonitorAlertDefinition(t *testing.T) { err := base.Client.DeleteMonitorAlertDefinition(context.Background(), testMonitorAlertDefinitionServiceType, testMonitorAlertDefinitionID) assert.NoError(t, err) } + +func TestListMonitorAlertDefinitionEntities(t *testing.T) { + var base ClientBaseCase + base.SetUp(t) + defer base.TearDown(t) + + base.MockGet( + "monitor/services/dbaas/alert-definitions/123/entities", + json.RawMessage(monitorAlertDefinitionEntitiesListResponse), + ) + + entities, err := base.Client.ListMonitorAlertDefinitionEntities( + context.Background(), + testMonitorAlertDefinitionServiceType, + testMonitorAlertDefinitionID, nil, + ) + assert.NoError(t, err) + assert.Len(t, entities, 3) + + assert.Equal(t, "1", entities[0].ID) + assert.Equal(t, "mydatabase-1", entities[0].Label) + assert.Equal(t, "/v4/databases/mysql/instances/1", entities[0].URL) + assert.Equal(t, "dbaas", entities[0].Type) + + assert.Equal(t, "2", entities[1].ID) + assert.Equal(t, "mydatabase-2", entities[1].Label) + assert.Equal(t, "/v4/databases/mysql/instances/2", entities[1].URL) + assert.Equal(t, "dbaas", entities[1].Type) + + assert.Equal(t, "3", entities[2].ID) + assert.Equal(t, "mydatabase-3", entities[2].Label) + assert.Equal(t, "/v4/databases/mysql/instances/3", entities[2].URL) + assert.Equal(t, "dbaas", entities[2].Type) +} From 6068e81d5719a8e2e370d3037b1338c5fe77ff13 Mon Sep 17 00:00:00 2001 From: shkaruna Date: Thu, 9 Apr 2026 11:42:31 +0530 Subject: [PATCH 2/3] Cleanup entity related response fields from alert definition Remove entity_ids and has_more_resources response fields --- monitor_alert_definitions.go | 2 - .../monitor_alert_definitions_test.go | 2 - test/unit/monitor_alert_definitions_test.go | 47 +------------------ 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/monitor_alert_definitions.go b/monitor_alert_definitions.go index 730665655..bc057e8d9 100644 --- a/monitor_alert_definitions.go +++ b/monitor_alert_definitions.go @@ -53,7 +53,6 @@ type AlertDefinition struct { Type string `json:"type"` ServiceType string `json:"service_type"` Status AlertDefinitionStatus `json:"status"` - HasMoreResources bool `json:"has_more_resources"` // Deprecated: use Entities.HasMoreResources. RuleCriteria RuleCriteria `json:"rule_criteria"` TriggerConditions TriggerConditions `json:"trigger_conditions"` AlertChannels []AlertChannelEnvelope `json:"alert_channels"` @@ -61,7 +60,6 @@ type AlertDefinition struct { Updated *time.Time `json:"-"` UpdatedBy string `json:"updated_by"` CreatedBy string `json:"created_by"` - EntityIDs []string `json:"entity_ids"` // Deprecated: use Entities.url to list associated entities. Description string `json:"description"` Class string `json:"class"` Scope AlertDefinitionScope `json:"scope"` diff --git a/test/integration/monitor_alert_definitions_test.go b/test/integration/monitor_alert_definitions_test.go index 566fc4f6f..eb3f11ba4 100644 --- a/test/integration/monitor_alert_definitions_test.go +++ b/test/integration/monitor_alert_definitions_test.go @@ -113,8 +113,6 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) { assert.Equal(t, createOpts.Label, createdAlert.Label) assert.Equal(t, createOpts.Severity, createdAlert.Severity) assert.Equal(t, *createOpts.Description, createdAlert.Description) - assert.ElementsMatch(t, createOpts.EntityIDs, createdAlert.EntityIDs) - // assert.Equal(t, fetchedChannel.Label, createdAlert.AlertChannels[0].Label) // More thorough assertions on the created alert's nested fields // TriggerConditions is a struct, so it is never nil diff --git a/test/unit/monitor_alert_definitions_test.go b/test/unit/monitor_alert_definitions_test.go index c8e742db8..b512c8599 100644 --- a/test/unit/monitor_alert_definitions_test.go +++ b/test/unit/monitor_alert_definitions_test.go @@ -22,10 +22,6 @@ const ( "description": "A test alert for dbaas service", "scope": "entity", "regions": [], - "entity_ids": [ - "12345" - ], - "has_more_resources": false, "alert_channels": [ { "id": 10000, @@ -84,10 +80,6 @@ const ( "status": "enabled", "scope": "entity", "regions": [], - "entity_ids": [ - "12345" - ], - "has_more_resources": true, "alert_channels": [ { "id": 10000, @@ -148,11 +140,6 @@ const ( "scope": "entity", "description": "A test alert for dbaas service", "regions": [], - "entity_ids": [ - "12345", - "45678" - ], - "has_more_resources": true, "alert_channels": [ { "id": 10000, @@ -198,8 +185,6 @@ const ( "updated_by": "tester" }` - monitorAlertDefinitionUpdateLabelOnlyResponseSingleLine = `{"id": 123, "label": "test-alert-definition-renamed-one-line", "severity": 1, "type": "some_type", "service_type": "dbaas", "status": "enabled", "entity_ids": ["12345"], "channel_ids": [1], "is_enabled": true}` - monitorAlertDefinitionEntitiesListResponse = `{ "data": [ { @@ -253,8 +238,6 @@ func TestCreateMonitorAlertDefinition(t *testing.T) { assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) assert.Equal(t, 0, alert.Entities.Count) assert.False(t, alert.Entities.HasMoreResources) - assert.Equal(t, []string{"12345"}, alert.EntityIDs) - assert.False(t, alert.HasMoreResources) assert.NotNil(t, alert.AlertChannels) assert.NotNil(t, alert.RuleCriteria) assert.NotNil(t, alert.RuleCriteria.Rules) @@ -311,8 +294,6 @@ func TestGetMonitorAlertDefinition(t *testing.T) { assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) assert.Equal(t, 0, alert.Entities.Count) assert.False(t, alert.Entities.HasMoreResources) - assert.Equal(t, []string{"12345"}, alert.EntityIDs) - assert.False(t, alert.HasMoreResources) assert.NotNil(t, alert.AlertChannels) assert.NotNil(t, alert.RuleCriteria) assert.NotNil(t, alert.RuleCriteria.Rules) @@ -336,8 +317,6 @@ func TestListMonitorAlertDefinitions(t *testing.T) { assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alerts[0].Entities.URL) assert.Equal(t, 2, alerts[0].Entities.Count) assert.True(t, alerts[0].Entities.HasMoreResources) - assert.Equal(t, []string{"12345"}, alerts[0].EntityIDs) - assert.True(t, alerts[0].HasMoreResources) assert.NotNil(t, alerts[0].AlertChannels) assert.NotNil(t, alerts[0].RuleCriteria) assert.NotNil(t, alerts[0].RuleCriteria.Rules) @@ -365,6 +344,7 @@ func TestUpdateMonitorAlertDefinition(t *testing.T) { ) assert.NoError(t, err) assert.NotNil(t, alert) + assert.Equal(t, testMonitorAlertDefinitionID, alert.ID) assert.Equal(t, "test-alert-definition-renamed", alert.Label) assert.Equal(t, 2, alert.Severity) assert.Equal(t, linodego.AlertDefinitionScopeEntity, alert.Scope) @@ -372,31 +352,6 @@ func TestUpdateMonitorAlertDefinition(t *testing.T) { assert.Equal(t, "/monitor/services/dbaas/alert-definitions/123/entities", alert.Entities.URL) assert.Equal(t, 2, alert.Entities.Count) assert.True(t, alert.Entities.HasMoreResources) - assert.True(t, alert.HasMoreResources) -} - -func TestUpdateMonitorAlertDefinition_LabelOnly(t *testing.T) { - var base ClientBaseCase - base.SetUp(t) - defer base.TearDown(t) - - // Mock a PUT that returns the single-line fixture - base.MockPut("monitor/services/dbaas/alert-definitions/123", json.RawMessage(monitorAlertDefinitionUpdateLabelOnlyResponseSingleLine)) - - updateOpts := linodego.AlertDefinitionUpdateOptions{ - Label: "test-alert-definition-renamed-one-line", - } - - alert, err := base.Client.UpdateMonitorAlertDefinition( - context.Background(), - testMonitorAlertDefinitionServiceType, - testMonitorAlertDefinitionID, - updateOpts, - ) - assert.NoError(t, err) - assert.NotNil(t, alert) - assert.Equal(t, "test-alert-definition-renamed-one-line", alert.Label) - assert.Equal(t, testMonitorAlertDefinitionID, alert.ID) } func TestDeleteMonitorAlertDefinition(t *testing.T) { From 2132610f04113f3e7752ddf8002c8e10c36b02e7 Mon Sep 17 00:00:00 2001 From: shkaruna Date: Mon, 27 Apr 2026 19:01:22 +0530 Subject: [PATCH 3/3] ref: Updated integration tests for cleanup of deprecated response fields --- .../fixtures/TestMonitorAlertDefinition.yaml | 49 ++++++++----------- ...stMonitorAlertDefinitionEntities_List.yaml | 7 ++- ...AlertDefinition_CreateWithIdempotency.yaml | 21 ++++---- .../TestMonitorAlertDefinitions_List.yaml | 14 ++---- 4 files changed, 39 insertions(+), 52 deletions(-) diff --git a/test/integration/fixtures/TestMonitorAlertDefinition.yaml b/test/integration/fixtures/TestMonitorAlertDefinition.yaml index d02b3b171..8ae0739a2 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinition.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinition.yaml @@ -18,8 +18,7 @@ interactions: "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["324478", - "324480", "324483", "324486", "394528"], "has_more_resources": false, "severity": + "class": "dedicated", "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write @@ -32,8 +31,7 @@ interactions: Usage Plan Shared", "description": "Alert triggers when shared plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", - "regions": [], "status": "enabled", "entity_ids": ["190003", "257626"], "has_more_resources": - false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", + "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", @@ -43,8 +41,7 @@ interactions: "system", "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10001/entities", "has_more_resources": false, "count": 2}}, {"id": 11001, "label": "test_alert_logs_prod", "description": "some desc1", "service_type": "logs", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": ["100"], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "entity", "class": null, "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Successful Upload Count", "metric": "success_upload_count", "unit": "count", "aggregate_function": "sum", "operator": "lt", "threshold": 100000, "dimension_filters": []}]}, "alert_channels": [{"id": 10004, "label": "Alert Channel", "url": @@ -55,8 +52,7 @@ interactions: "tester", "entities": {"url": "/monitor/services/logs/alert-definitions/11001/entities", "has_more_resources": false, "count": 1}}, {"id": 11021, "label": "Test Alert", "description": "Test Alert", "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": - "enabled", "entity_ids": ["257626", "394528"], "has_more_resources": false, - "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": + "enabled", "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "sum", "operator": "gt", "threshold": 100, "dimension_filters": []}]}, "alert_channels": [{"id": 10004, "label": "Alert Channel", "url": "/monitor/alert-channels/10004", @@ -88,7 +84,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:05:05 GMT + - Mon, 27 Apr 2026 12:32:17 GMT Pragma: - no-cache Strict-Transport-Security: @@ -130,10 +126,9 @@ interactions: url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions method: POST response: - body: '{"id": 11022, "label": "go-test-alert-definition-create", "description": + body: '{"id": 11072, "label": "go-test-alert-definition-create", "description": "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "provisioning", "entity_ids": - [], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "entity", "class": null, "regions": [], "status": "provisioning", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, @@ -142,7 +137,7 @@ interactions: "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "tester", "updated_by": "tester", "entities": - {"url": "/monitor/services/dbaas/alert-definitions/11022/entities", "has_more_resources": + {"url": "/monitor/services/dbaas/alert-definitions/11072/entities", "has_more_resources": false, "count": 0}}' headers: Access-Control-Allow-Credentials: @@ -166,7 +161,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:05:06 GMT + - Mon, 27 Apr 2026 12:32:18 GMT Pragma: - no-cache Strict-Transport-Security: @@ -203,13 +198,12 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11022 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11072 method: GET response: - body: '{"id": 11022, "label": "go-test-alert-definition-create", "description": + body: '{"id": 11072, "label": "go-test-alert-definition-create", "description": "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": [], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "entity", "class": null, "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, @@ -218,7 +212,7 @@ interactions: "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "tester", "updated_by": "tester", "entities": - {"url": "/monitor/services/dbaas/alert-definitions/11022/entities", "has_more_resources": + {"url": "/monitor/services/dbaas/alert-definitions/11072/entities", "has_more_resources": false, "count": 0}}' headers: Access-Control-Allow-Credentials: @@ -242,7 +236,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:05:22 GMT + - Mon, 27 Apr 2026 12:32:35 GMT Pragma: - no-cache Strict-Transport-Security: @@ -281,13 +275,12 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11022 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11072 method: PUT response: - body: '{"id": 11022, "label": "go-test-alert-definition-create-updated", "description": + body: '{"id": 11072, "label": "go-test-alert-definition-create-updated", "description": "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": [], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "entity", "class": null, "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, @@ -296,7 +289,7 @@ interactions: "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "tester", "updated_by": "tester", "entities": - {"url": "/monitor/services/dbaas/alert-definitions/11022/entities", "has_more_resources": + {"url": "/monitor/services/dbaas/alert-definitions/11072/entities", "has_more_resources": false, "count": 0}}' headers: Access-Control-Allow-Credentials: @@ -320,7 +313,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:05:24 GMT + - Mon, 27 Apr 2026 12:32:36 GMT Pragma: - no-cache Strict-Transport-Security: @@ -357,7 +350,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11022 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11072 method: DELETE response: body: '{}' @@ -385,7 +378,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:05:25 GMT + - Mon, 27 Apr 2026 12:32:37 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml b/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml index 8e2a96872..00eea72af 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinitionEntities_List.yaml @@ -18,8 +18,7 @@ interactions: "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["324478", - "324480", "324483", "324486", "394528"], "has_more_resources": false, "severity": + "class": "dedicated", "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write @@ -51,7 +50,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 05:55:13 GMT + - Mon, 27 Apr 2026 12:32:51 GMT Pragma: - no-cache Strict-Transport-Security: @@ -123,7 +122,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 05:55:14 GMT + - Mon, 27 Apr 2026 12:32:52 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml b/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml index 13e0e8681..3a2630f41 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml @@ -47,7 +47,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:27:41 GMT + - Mon, 27 Apr 2026 12:32:45 GMT Pragma: - no-cache Strict-Transport-Security: @@ -76,7 +76,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-alert-definition-idempotency-1775629661986967956","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + body: '{"label":"go-test-alert-definition-idempotency-1777293165535535919","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test alert definition creation with idempotency"}' form: {} headers: @@ -89,11 +89,10 @@ interactions: url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions method: POST response: - body: '{"id": 11023, "label": "go-test-alert-definition-idempotency-1775629661986967956", + body: '{"id": 11073, "label": "go-test-alert-definition-idempotency-1777293165535535919", "description": "Test alert definition creation with idempotency", "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": - "provisioning", "entity_ids": [], "has_more_resources": false, "severity": 2, - "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", + "provisioning", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": 10000, @@ -101,7 +100,7 @@ interactions: "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "tester", - "updated_by": "tester", "entities": {"url": "/monitor/services/dbaas/alert-definitions/11023/entities", + "updated_by": "tester", "entities": {"url": "/monitor/services/dbaas/alert-definitions/11073/entities", "has_more_resources": false, "count": 0}}' headers: Access-Control-Allow-Credentials: @@ -125,7 +124,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:27:43 GMT + - Mon, 27 Apr 2026 12:32:46 GMT Pragma: - no-cache Strict-Transport-Security: @@ -153,7 +152,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-alert-definition-idempotency-1775629661986967956","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + body: '{"label":"go-test-alert-definition-idempotency-1777293165535535919","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test alert definition creation with idempotency"}' form: {} headers: @@ -184,7 +183,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:27:43 GMT + - Mon, 27 Apr 2026 12:32:47 GMT Pragma: - no-cache Strict-Transport-Security: @@ -213,7 +212,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11023 + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/11073 method: DELETE response: body: '{}' @@ -241,7 +240,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:27:44 GMT + - Mon, 27 Apr 2026 12:32:48 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml b/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml index 7179797d6..7fa1c7992 100644 --- a/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml +++ b/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml @@ -18,8 +18,7 @@ interactions: "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": ["324478", - "324480", "324483", "324486", "394528"], "has_more_resources": false, "severity": + "class": "dedicated", "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write @@ -32,8 +31,7 @@ interactions: Usage Plan Shared", "description": "Alert triggers when shared plan nodes consistently reach critical memory usage, risking application performance degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", - "regions": [], "status": "enabled", "entity_ids": ["190003", "257626"], "has_more_resources": - false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", + "regions": [], "status": "enabled", "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", @@ -43,8 +41,7 @@ interactions: "system", "updated_by": "system", "entities": {"url": "/monitor/services/dbaas/alert-definitions/10001/entities", "has_more_resources": false, "count": 2}}, {"id": 11001, "label": "test_alert_logs_prod", "description": "some desc1", "service_type": "logs", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": ["100"], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "entity", "class": null, "regions": [], "status": "enabled", "severity": 2, "rule_criteria": {"rules": [{"label": "Successful Upload Count", "metric": "success_upload_count", "unit": "count", "aggregate_function": "sum", "operator": "lt", "threshold": 100000, "dimension_filters": []}]}, "alert_channels": [{"id": 10004, "label": "Alert Channel", "url": @@ -55,8 +52,7 @@ interactions: "tester", "entities": {"url": "/monitor/services/logs/alert-definitions/11001/entities", "has_more_resources": false, "count": 1}}, {"id": 11021, "label": "Test Alert", "description": "Test Alert", "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": - "enabled", "entity_ids": ["257626", "394528"], "has_more_resources": false, - "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": + "enabled", "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": "sum", "operator": "gt", "threshold": 100, "dimension_filters": []}]}, "alert_channels": [{"id": 10004, "label": "Alert Channel", "url": "/monitor/alert-channels/10004", @@ -88,7 +84,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Apr 2026 06:19:02 GMT + - Mon, 27 Apr 2026 12:32:41 GMT Pragma: - no-cache Strict-Transport-Security: