diff --git a/test/integration/fixtures/TestInstance_LegacyAlertsWorkflow.yaml b/test/integration/fixtures/TestInstance_LegacyAlertsWorkflow.yaml new file mode 100644 index 000000000..5c206ba2c --- /dev/null +++ b/test/integration/fixtures/TestInstance_LegacyAlertsWorkflow.yaml @@ -0,0 +1,1111 @@ +--- +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/regions?page=1 + method: GET + response: + body: '{"data": [{"id": "pl-labkrk-2", "label": "Krakow, PL", "country": "pl", + "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", "Backups", + "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", + "Cloud Firewall", "Vlans", "VPCs", "VPC Dual Stack", "VPC IPv6 Stack", "Block + Storage Migrations", "Managed Databases", "Metadata", "Premium Plans", "Placement + Group", "StackScripts", "NETINT Quadra T1U", "Maintenance Policy", "Linode Interfaces", + "ACLP Logs Datacenter LKE-E"], "monitors": {"alerts": ["Linodes", "Managed Databases", + "NodeBalancers"], "metrics": ["Linodes", "Managed Databases", "NodeBalancers"]}, + "status": "ok", "resolvers": {"ipv4": "172.24.224.240,172.24.224.229,172.24.224.236,172.24.224.238,172.24.224.235,172.24.224.241,172.24.224.230,172.24.224.239,172.24.224.233,172.24.224.234", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5, "maximum_linodes_per_flexible_pg": 5}, "site_type": "core"}, {"id": "us-labedgeeat-2", + "label": "East Wenatchee, US", "country": "us", "capabilities": ["Linodes", + "Disk Encryption", "Cloud Firewall", "Vlans", "VPCs", "VPC Dual Stack", "VPC + IPv6 Stack", "Metadata", "Distributed Plans", "Linode Interfaces"], "monitors": + {"alerts": [], "metrics": []}, "status": "ok", "resolvers": {"ipv4": "173.223.100.53,173.223.101.53", + "ipv6": "1234::5678,1234::5678"}, "placement_group_limits": {"maximum_pgs_per_customer": + 0, "maximum_linodes_per_pg": 0, "maximum_linodes_per_flexible_pg": 0}, "site_type": + "distributed"}, {"id": "us-labedgeeat-3", "label": "East Wenatchee, US", "country": + "us", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", "Metadata", + "Distributed Plans"], "monitors": {"alerts": [], "metrics": []}, "status": "ok", + "resolvers": {"ipv4": "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0, "maximum_linodes_per_flexible_pg": 0}, "site_type": "distributed"}], "page": + 1, "pages": 1, "results": 3}' + 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: + - private, max-age=900 + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - '*' + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"region":"pl-labkrk-2","type":"g6-nanode-1","label":"go-test-ins-52f558f9cfna","root_pass":"q?+,184bP.VfVe5{\u0026\u003eUAhmr(41xZmETcJ^lJM-65rJB9f4)0:2#36+U1\\Offq\u003cF2","image":"linode/debian12","booted":false}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances + method: POST + response: + body: '{"id": 101512398, "label": "go-test-ins-52f558f9cfna", "group": "", "status": + "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["172.24.220.179"], "ipv6": "1234::5678/128", + "image": "linode/debian12", "region": "pl-labkrk-2", "site_type": "core", "specs": + {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": + 80, "io": 10000, "system_alerts": [], "user_alerts": []}, "backups": {"enabled": + false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": + "01d213c55a2c3ed64a320f2c3bc5edfc343b7edb", "has_user_data": false, "placement_group": + null, "disk_encryption": "enabled", "lke_cluster_id": null, "capabilities": + ["Block Storage Encryption", "SMTP Enabled", "Maintenance Policy"], "interface_generation": + "legacy_config", "maintenance_policy": "linode/migrate", "locks": []}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "8" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_create","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode"}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866836, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 51, "time_remaining": null, "rate": null, + "duration": 16.950058, "action": "linode_create", "username": "psnoch", "entity": + {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", "url": + "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": "linode/debian12", "type": "image", "label": "Debian 12", "url": "/v4/images/linode/debian12"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "562" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_create","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866836}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866836, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 59, "time_remaining": null, "rate": null, + "duration": 31.949474, "action": "linode_create", "username": "psnoch", "entity": + {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", "url": + "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": "linode/debian12", "type": "image", "label": "Debian 12", "url": "/v4/images/linode/debian12"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "562" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_create","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866836}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866836, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 100, "time_remaining": null, "rate": null, + "duration": 37.0, "action": "linode_create", "username": "psnoch", "entity": + {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", "url": + "/v4/linode/instances/101512398"}, "status": "finished", "secondary_entity": + {"id": "linode/debian12", "type": "image", "label": "Debian 12", "url": "/v4/images/linode/debian12"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "559" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-ins-52f558f9cfna","alerts":{"cpu":50,"io":6000,"network_in":20,"network_out":20,"transfer_quota":50},"watchdog_enabled":true,"tags":[],"group":"","maintenance_policy":"linode/migrate"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/101512398 + method: PUT + response: + body: '{"id": 101512398, "label": "go-test-ins-52f558f9cfna", "group": "", "status": + "offline", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["172.24.220.179"], "ipv6": "1234::5678/128", + "image": "linode/debian12", "region": "pl-labkrk-2", "site_type": "core", "specs": + {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 50, "network_in": 20, "network_out": 20, "transfer_quota": + 50, "io": 6000, "system_alerts": [], "user_alerts": []}, "backups": {"enabled": + false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": + "01d213c55a2c3ed64a320f2c3bc5edfc343b7edb", "has_user_data": false, "placement_group": + null, "disk_encryption": "enabled", "lke_cluster_id": null, "capabilities": + ["Block Storage Encryption", "SMTP Enabled", "Maintenance Policy"], "interface_generation": + "legacy_config", "maintenance_policy": "linode/migrate", "locks": []}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"region":"pl-labkrk-2","type":"g6-nanode-1","backups_enabled":false,"alerts":{}}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/101512398/clone + method: POST + response: + body: '{"id": 101512406, "label": "linode101512406", "group": "", "status": "offline", + "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "type": + "g6-nanode-1", "ipv4": ["172.24.218.154"], "ipv6": "1234::5678/128", + "image": "linode/debian12", "region": "pl-labkrk-2", "site_type": "core", "specs": + {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": + 80, "io": 10000, "system_alerts": [], "user_alerts": []}, "backups": {"enabled": + false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": + "19dac8b977a17c7849225d1357e263d62ca66e15", "has_user_data": false, "placement_group": + null, "disk_encryption": "enabled", "lke_cluster_id": null, "capabilities": + ["Block Storage Encryption", "SMTP Enabled", "Maintenance Policy"], "interface_generation": + "legacy_config", "maintenance_policy": "linode/migrate", "locks": []}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "8" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode"}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 33, "time_remaining": null, "rate": null, + "duration": 15.338569, "action": "linode_clone", "username": "psnoch", "entity": + {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", "url": + "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "564" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 35, "time_remaining": "0:1:19", "rate": "311.00 + MB/s", "duration": 30.336636, "action": "linode_clone", "username": "psnoch", + "entity": {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", + "url": "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "577" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 35, "time_remaining": "0:1:19", "rate": "311.00 + MB/s", "duration": 45.333364, "action": "linode_clone", "username": "psnoch", + "entity": {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", + "url": "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "577" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 58, "time_remaining": "0:0:12", "rate": "554.00 + MB/s", "duration": 60.342629, "action": "linode_clone", "username": "psnoch", + "entity": {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", + "url": "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "577" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 58, "time_remaining": "0:0:12", "rate": "554.00 + MB/s", "duration": 75.330909, "action": "linode_clone", "username": "psnoch", + "entity": {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", + "url": "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "577" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 58, "time_remaining": "0:0:12", "rate": "554.00 + MB/s", "duration": 90.342486, "action": "linode_clone", "username": "psnoch", + "entity": {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", + "url": "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "577" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 67, "time_remaining": null, "rate": null, + "duration": 105.338397, "action": "linode_clone", "username": "psnoch", "entity": + {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", "url": + "/v4/linode/instances/101512398"}, "status": "started", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "565" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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 + X-Filter: + - '{"+order":"desc","+order_by":"created","action":"linode_clone","created":{"+gte":"2018-01-02T03:04:05"},"entity.id":101512398,"entity.type":"linode","id":{"+gte":40866912}}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 40866912, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": 100, "time_remaining": null, "rate": null, + "duration": 110.0, "action": "linode_clone", "username": "psnoch", "entity": + {"label": "go-test-ins-52f558f9cfna", "id": 101512398, "type": "linode", "url": + "/v4/linode/instances/101512398"}, "status": "finished", "secondary_entity": + {"id": 101512406, "type": "linode", "label": "linode101512406", "url": "/v4/linode/instances/101512406"}, + "message": "", "details": {}}], "page": 1, "pages": 1, "results": 1}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "562" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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/linode/instances/101512398 + method: DELETE + response: + body: '{}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestInstance_UpdateACLPAlerts.yaml b/test/integration/fixtures/TestInstance_UpdateACLPAlerts.yaml new file mode 100644 index 000000000..10fae74e5 --- /dev/null +++ b/test/integration/fixtures/TestInstance_UpdateACLPAlerts.yaml @@ -0,0 +1,684 @@ +--- +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/regions?page=1 + method: GET + response: + body: '{"data": [{"id": "pl-labkrk-2", "label": "Krakow, PL", "country": "pl", + "capabilities": ["Linodes", "Block Storage Encryption", "Disk Encryption", "Backups", + "NodeBalancers", "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", + "Cloud Firewall", "Vlans", "VPCs", "VPC Dual Stack", "VPC IPv6 Stack", "Block + Storage Migrations", "Managed Databases", "Metadata", "Premium Plans", "Placement + Group", "StackScripts", "NETINT Quadra T1U", "Maintenance Policy", "Linode Interfaces", + "ACLP Logs Datacenter LKE-E"], "monitors": {"alerts": ["Linodes", "Managed Databases", + "NodeBalancers"], "metrics": ["Linodes", "Managed Databases", "NodeBalancers"]}, + "status": "ok", "resolvers": {"ipv4": "172.24.224.240,172.24.224.229,172.24.224.236,172.24.224.238,172.24.224.235,172.24.224.241,172.24.224.230,172.24.224.239,172.24.224.233,172.24.224.234", + "ipv6": "1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": null, "maximum_linodes_per_pg": + 5, "maximum_linodes_per_flexible_pg": 5}, "site_type": "core"}, {"id": "us-labedgeeat-2", + "label": "East Wenatchee, US", "country": "us", "capabilities": ["Linodes", + "Disk Encryption", "Cloud Firewall", "Vlans", "VPCs", "VPC Dual Stack", "VPC + IPv6 Stack", "Metadata", "Distributed Plans", "Linode Interfaces"], "monitors": + {"alerts": [], "metrics": []}, "status": "ok", "resolvers": {"ipv4": "173.223.100.53,173.223.101.53", + "ipv6": "1234::5678,1234::5678"}, "placement_group_limits": {"maximum_pgs_per_customer": + 0, "maximum_linodes_per_pg": 0, "maximum_linodes_per_flexible_pg": 0}, "site_type": + "distributed"}, {"id": "us-labedgeeat-3", "label": "East Wenatchee, US", "country": + "us", "capabilities": ["Linodes", "Disk Encryption", "Cloud Firewall", "Metadata", + "Distributed Plans"], "monitors": {"alerts": [], "metrics": []}, "status": "ok", + "resolvers": {"ipv4": "173.223.100.53,173.223.101.53", "ipv6": "1234::5678,1234::5678"}, + "placement_group_limits": {"maximum_pgs_per_customer": 0, "maximum_linodes_per_pg": + 0, "maximum_linodes_per_flexible_pg": 0}, "site_type": "distributed"}], "page": + 1, "pages": 1, "results": 3}' + 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: + - private, max-age=900 + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - '*' + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"region":"pl-labkrk-2","type":"g6-nanode-1","label":"go-test-ins-th3a924h5i6z","root_pass":"+O1r5~#I2A[M273qh`0i''TKAgFPk4K+4:Ge4{\u003cr#q4\\,{793#mUj8oB7qykNY.Rv","image":"linode/debian12","booted":false}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances + method: POST + response: + body: '{"id": 101511601, "label": "go-test-ins-th3a924h5i6z", "group": "", "status": + "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["172.24.242.248"], "ipv6": "1234::5678/128", + "image": "linode/debian12", "region": "pl-labkrk-2", "site_type": "core", "specs": + {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": + 80, "io": 10000, "system_alerts": [], "user_alerts": []}, "backups": {"enabled": + false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": + "9836b79b7f5984dcf5faa04a7587feffeafa5360", "has_user_data": false, "placement_group": + null, "disk_encryption": "enabled", "lke_cluster_id": null, "capabilities": + ["Block Storage Encryption", "SMTP Enabled", "Maintenance Policy"], "interface_generation": + "legacy_config", "maintenance_policy": "linode/migrate", "locks": []}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "8" + 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?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 6, "data": [{"id": 1, "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": [], + "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": 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", + "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/1/entities", + "has_more_resources": false, "count": 0}}, {"id": 2, "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": ["2671", "2672"], "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": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "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/2/entities", + "has_more_resources": false, "count": 2}}, {"id": 3, "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": [], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": + 95, "dimension_filters": []}]}, "alert_channels": [{"id": 1, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/1", "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/3/entities", "has_more_resources": + false, "count": 0}}, {"id": 4, "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": ["2671", "2672"], "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": 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", + "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/4/entities", + "has_more_resources": false, "count": 2}}, {"id": 5, "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": [], "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": 1, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/1", "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/5/entities", "has_more_resources": + false, "count": 0}}, {"id": 6, "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": + ["2671", "2672"], "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": 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", + "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/6/entities", + "has_more_resources": false, "count": 2}}, {"id": 1194, "label": "test-1777468403486895000-service-definition", + "description": null, "service_type": "dbaas", "type": "user", "scope": "entity", + "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1194/entities", + "has_more_resources": false, "count": 0}}, {"id": 1195, "label": "test-1777468454174738000-service-definition", + "description": null, "service_type": "dbaas", "type": "user", "scope": "entity", + "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1195/entities", + "has_more_resources": false, "count": 0}}, {"id": 1196, "label": "test-1777468663310011000-service-definition", + "description": null, "service_type": "dbaas", "type": "user", "scope": "entity", + "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1196/entities", + "has_more_resources": false, "count": 0}}, {"id": 1197, "label": "test-1777468762836396000-service-definition", + "description": null, "service_type": "dbaas", "type": "user", "scope": "entity", + "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1197/entities", + "has_more_resources": false, "count": 0}}, {"id": 1198, "label": "test-1777468876197440000-service-definition", + "description": null, "service_type": "dbaas", "type": "user", "scope": "entity", + "class": null, "regions": [], "status": "provisioning", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1198/entities", + "has_more_resources": false, "count": 0}}, {"id": 1199, "label": "test-1777469024482975000-service-definition", + "description": null, "service_type": "dbaas", "type": "user", "scope": "entity", + "class": null, "regions": [], "status": "provisioning", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1199/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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + 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: + - '*' + X-Ratelimit-Limit: + - "400" + 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/alert-channels?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 1, "data": [{"id": 1, "label": "Read-Write + Channel", "channel_type": "email", "type": "system", "content": {"email": {"email_addresses": + ["Users-with-read-write-access-to-resources"]}}, "details": {"email": {"usernames": + [], "recipient_type": "read_write_users"}}, "alerts": {"url": "/monitor/alert-channels/1/alerts", + "type": "alerts-definitions", "alert_count": 17}, "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}]}' + 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: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "521" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + 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: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"test-1777469260161278000-service-definition","severity":1,"channel_ids":[1],"rule_criteria":{"rules":[{"aggregate_function":"min","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"eq","threshold":95}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":900,"trigger_occurrences":3}}' + 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 + method: POST + response: + body: '{"id": 1201, "label": "test-1777469260161278000-service-definition", "description": + null, "service_type": "dbaas", "type": "user", "scope": "entity", "class": null, + "regions": [], "status": "provisioning", "entity_ids": [], "has_more_resources": + false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "min", "operator": + "eq", "threshold": 95, "dimension_filters": [{"label": "Node Type", "dimension_label": + "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": + 1, "label": "Read-Write Channel", "url": "/monitor/alert-channels/1", "type": + "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 900, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "psnoch", + "updated_by": "psnoch", "entities": {"url": "/monitor/services/dbaas/alert-definitions/1201/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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-ins-th3a924h5i6z","alerts":{"cpu":0,"io":0,"network_in":0,"network_out":0,"transfer_quota":0,"system_alerts":[1],"user_alerts":[1201]},"watchdog_enabled":true,"tags":[],"group":"","maintenance_policy":"linode/migrate"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/101511601 + method: PUT + response: + body: '{"id": 101511601, "label": "go-test-ins-th3a924h5i6z", "group": "", "status": + "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["172.24.242.248"], "ipv6": "1234::5678/128", + "image": "linode/debian12", "region": "pl-labkrk-2", "site_type": "core", "specs": + {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 0, "network_in": 0, "network_out": 0, "transfer_quota": + 0, "io": 0, "system_alerts": [1], "user_alerts": [1201]}, "backups": {"enabled": + false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": + "9836b79b7f5984dcf5faa04a7587feffeafa5360", "has_user_data": false, "placement_group": + null, "disk_encryption": "enabled", "lke_cluster_id": null, "capabilities": + ["Block Storage Encryption", "SMTP Enabled", "Maintenance Policy"], "interface_generation": + "legacy_config", "maintenance_policy": "linode/migrate", "locks": []}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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/1201 + method: DELETE + response: + body: '{}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + 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/linode/instances/101511601 + method: DELETE + response: + body: '{}' + 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: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/instances_test.go b/test/integration/instances_test.go index e925a71fd..c07f45b89 100644 --- a/test/integration/instances_test.go +++ b/test/integration/instances_test.go @@ -3,12 +3,15 @@ package integration import ( "context" "encoding/base64" + "fmt" "slices" "strconv" "strings" "testing" + "time" "github.com/linode/linodego" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,75 +25,55 @@ func TestInstances_List_smoke(t *testing.T) { defer teardown() - if err != nil { - t.Error(err) - } + require.NoError(t, err) listOpts := linodego.NewListOptions(1, "{\"id\": "+strconv.Itoa(instance.ID)+"}") linodes, err := client.ListInstances(context.Background(), listOpts) - if err != nil { - t.Errorf("Error listing instances, expected struct, got error %v", err) - } - if len(linodes) != 1 { - t.Errorf("Expected a list of instances, but got %v", linodes) - } - - if linodes[0].ID != instance.ID { - t.Errorf("Expected list of instances to include test instance, but got %v", linodes) - } - - if linodes[0].HostUUID == "" { - t.Errorf("failed to get instance HostUUID") - } - - if linodes[0].HasUserData { - t.Errorf("expected instance.HasUserData to be false, got true") - } - - if linodes[0].Specs.GPUs < 0 { - t.Errorf("failed to retrieve number of GPUs") - } + require.NoErrorf(t, err, "Error listing instances, expected struct, got error %v", err) + require.Equalf(t, 1, len(linodes), "Expected a list of instances, but got %v", linodes) + require.Equalf(t, instance.ID, linodes[0].ID, + "Expected list of instances to include test instance, but got %v", linodes) + require.NotEmptyf(t, linodes[0].HostUUID, "failed to get instance HostUUID") + require.Falsef(t, linodes[0].HasUserData, "expected instance.HasUserData to be false, got true") + require.GreaterOrEqualf(t, linodes[0].Specs.GPUs, 0, "failed to retrieve number of GPUs") + + assert.GreaterOrEqual(t, linodes[0].Alerts.CPU, 0) + assert.GreaterOrEqual(t, linodes[0].Alerts.IO, 0) + assert.GreaterOrEqual(t, linodes[0].Alerts.NetworkIn, 0) + assert.GreaterOrEqual(t, linodes[0].Alerts.NetworkOut, 0) + assert.GreaterOrEqual(t, linodes[0].Alerts.TransferQuota, 0) } func TestInstance_Get_smoke(t *testing.T) { client, instance, _, teardown, err := setupInstanceWithoutDisks(t, "fixtures/TestInstance_Get", true) defer teardown() - if err != nil { - t.Error(err) - } + require.NoError(t, err) settings, err := client.GetAccountSettings(context.Background()) - if err != nil { - t.Fatalf("Failed to get account settings: %s", err) - } + require.NoErrorf(t, err, "Failed to get account settings: %s", err) defaultPolicy := settings.MaintenancePolicy _, err = client.UpdateInstance(context.Background(), instance.ID, linodego.InstanceUpdateOptions{ MaintenancePolicy: &defaultPolicy, }) - if err != nil { - t.Fatalf("Error setting maintenance policy: %s", err) - } + require.NoErrorf(t, err, "Error setting maintenance policy: %s", err) instanceGot, err := client.GetInstance(context.Background(), instance.ID) - if err != nil { - t.Errorf("Error getting instance: %s", err) - } - if instanceGot.ID != instance.ID { - t.Errorf("Expected instance ID %d to match %d", instanceGot.ID, instance.ID) - } - if instanceGot.MaintenancePolicy != defaultPolicy { - t.Errorf("Expected maintenance policy %q, got %q", defaultPolicy, instanceGot.MaintenancePolicy) - } - if instanceGot.Specs.Disk <= 0 { - t.Errorf("Error parsing instance spec for disk size: %v", instanceGot.Specs) - } - if instanceGot.HostUUID == "" { - t.Errorf("failed to get instance HostUUID") - } + require.NoError(t, err, "Error getting instance: %s", err) + require.Equal(t, instance.ID, instanceGot.ID) + require.Equal(t, defaultPolicy, instanceGot.MaintenancePolicy) + require.Greaterf(t, instanceGot.Specs.Disk, 0, + "Error parsing instance spec for disk size: %v", instanceGot.Specs) + require.NotEmpty(t, instanceGot.HostUUID, "failed to get instance HostUUID") assertDateSet(t, instanceGot.Created) assertDateSet(t, instanceGot.Updated) + + assert.Greater(t, instanceGot.Alerts.CPU, 0) + assert.Greater(t, instanceGot.Alerts.IO, 0) + assert.GreaterOrEqual(t, instanceGot.Alerts.NetworkIn, 0) + assert.GreaterOrEqual(t, instanceGot.Alerts.NetworkOut, 0) + assert.GreaterOrEqual(t, instanceGot.Alerts.TransferQuota, 0) } func TestInstance_GetTransfer(t *testing.T) { @@ -697,14 +680,10 @@ func TestInstance_Rebuild(t *testing.T) { ) defer teardown() - if err != nil { - t.Error(err) - } + require.NoError(t, err) _, err = client.WaitForEventFinished(context.Background(), instance.ID, linodego.EntityLinode, linodego.ActionLinodeCreate, *instance.Created, 180) - if err != nil { - t.Errorf("Error waiting for instance created: %s", err) - } + require.NoErrorf(t, err, "Error waiting for instance created: %s", err) rebuildOpts := linodego.InstanceRebuildOptions{ Image: "linode/alpine3.19", @@ -715,13 +694,11 @@ func TestInstance_Rebuild(t *testing.T) { Type: "g6-standard-2", } instance, err = client.RebuildInstance(context.Background(), instance.ID, rebuildOpts) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - if !instance.HasUserData { - t.Fatal("expected instance.HasUserData to be true, got false") - } + require.True(t, instance.HasUserData, "expected instance.HasUserData to be true, got false") + assert.GreaterOrEqual(t, instance.Alerts.CPU, 0) + assert.GreaterOrEqual(t, instance.Alerts.IO, 0) } func TestInstance_RebuildWithEncryption(t *testing.T) { @@ -956,6 +933,128 @@ func TestInstance_withPG(t *testing.T) { require.Equal(t, inst.PlacementGroup.PlacementGroupPolicy, pg.PlacementGroupPolicy) } +func TestLinodeLegacyAlertsWorkflow(t *testing.T) { + client, teardown := createTestClient(t, + "fixtures/TestInstance_LegacyAlertsWorkflow") + defer teardown() + + region := getRegionsWithCaps(t, client, []string{"linodes"})[0] + instance, err := createInstance( + t, + client, + false, + func(l *linodego.Client, options *linodego.InstanceCreateOptions) { + options.Region = region + }, + ) + require.NoError(t, err) + defer func() { + err := client.DeleteInstance(context.Background(), instance.ID) + require.NoError(t, err) + }() + assert.Equal(t, 90, instance.Alerts.CPU) + assert.Equal(t, 10000, instance.Alerts.IO) + assert.Equal(t, 10, instance.Alerts.NetworkIn) + assert.Equal(t, 10, instance.Alerts.NetworkOut) + assert.Equal(t, 80, instance.Alerts.TransferQuota) + assert.Empty(t, instance.Alerts.SystemAlerts) + assert.Empty(t, instance.Alerts.UserAlerts) + _, err = client.WaitForEventFinished( + context.Background(), + instance.ID, + linodego.EntityLinode, + linodego.ActionLinodeCreate, + *instance.Created, + 180, + ) + require.NoErrorf(t, err, "Error waiting for instance created: %s", err) + updateOpts := instance.GetUpdateOptions() + alertsUpdateOpts := linodego.InstanceAlert{ + CPU: 50, + IO: 6000, + NetworkIn: 20, + NetworkOut: 20, + TransferQuota: 50, + } + updateOpts.Alerts = &alertsUpdateOpts + updateOpts.Backups = nil + updateResponse, errUpdate := client.UpdateInstance(context.Background(), instance.ID, updateOpts) + require.NoError(t, errUpdate) + assert.Equal(t, 50, updateResponse.Alerts.CPU) + assert.Equal(t, 6000, updateResponse.Alerts.IO) + assert.Equal(t, 20, updateResponse.Alerts.NetworkIn) + assert.Equal(t, 20, updateResponse.Alerts.NetworkOut) + assert.Equal(t, 50, updateResponse.Alerts.TransferQuota) + assert.Empty(t, updateResponse.Alerts.SystemAlerts) + assert.Empty(t, updateResponse.Alerts.UserAlerts) + + cloneOptions := linodego.InstanceCloneOptions{ + Region: region, + Type: "g6-nanode-1", + Alerts: &linodego.InstanceACLPAlertsOptions{ + SystemAlerts: []int{}, + }, + } + clonedInstance, err := client.CloneInstance(context.Background(), instance.ID, cloneOptions) + require.NoError(t, err) + assert.Equal(t, 90, clonedInstance.Alerts.CPU) + assert.Equal(t, 10000, clonedInstance.Alerts.IO) + assert.Equal(t, 10, clonedInstance.Alerts.NetworkIn) + assert.Equal(t, 10, clonedInstance.Alerts.NetworkOut) + assert.Equal(t, 80, clonedInstance.Alerts.TransferQuota) + assert.Empty(t, clonedInstance.Alerts.SystemAlerts) + assert.Empty(t, clonedInstance.Alerts.UserAlerts) + + _, err = client.WaitForEventFinished( + context.Background(), + instance.ID, + linodego.EntityLinode, + linodego.ActionLinodeClone, + *clonedInstance.Created, + 240, + ) + require.NoError(t, err) +} + +func TestUpdateACLPAlerts(t *testing.T) { + client, teardown := createTestClient(t, + "fixtures/TestInstance_UpdateACLPAlerts") + defer teardown() + + region := getRegionsWithCaps(t, client, []string{"linodes"})[0] + instToUpdate, err := createInstance( + t, + client, + false, + func(l *linodego.Client, options *linodego.InstanceCreateOptions) { + options.Region = region + }, + ) + require.NoError(t, err) + defer func() { + err := client.DeleteInstance(context.Background(), instToUpdate.ID) + require.NoError(t, err) + }() + + sampleSystemAlert := getSampleSystemAlert(t, client) + testUserAlert := createAlertServiceDefinition(t, client).ID + defer func() { + errDeleteUserAlert := client.DeleteMonitorAlertDefinition(context.Background(), testMonitorAlertDefinitionServiceType, testUserAlert) + require.NoError(t, errDeleteUserAlert) + }() + updateOpts := instToUpdate.GetUpdateOptions() + alertsUpdateData := linodego.InstanceAlert{ + UserAlerts: []int{testUserAlert}, + SystemAlerts: []int{sampleSystemAlert}, + } + updateOpts.Alerts = &alertsUpdateData + updateOpts.Backups = nil + updateResponse, errUpdate := client.UpdateInstance(context.Background(), instToUpdate.ID, updateOpts) + require.NoError(t, errUpdate) + assert.Equal(t, []int{sampleSystemAlert}, updateResponse.Alerts.SystemAlerts) + assert.Equal(t, []int{testUserAlert}, updateResponse.Alerts.UserAlerts) +} + func createInstance(t *testing.T, client *linodego.Client, enableCloudFirewall bool, modifiers ...instanceModifier) (*linodego.Instance, error) { if t != nil { t.Helper() @@ -1149,3 +1248,62 @@ func TestInstance_MaintenancePolicy(t *testing.T) { require.Error(t, err) require.Contains(t, err.Error(), "Unsupported maintenance policy slug format") } + +func getAlertChannelsList(t *testing.T, client *linodego.Client) []linodego.AlertChannel { + channels, err := client.ListAlertChannels(context.Background(), nil) + assert.NoError(t, err) + assert.NotEmpty(t, channels, "Expected at least one alert channel") + + return channels +} + +func createAlertServiceDefinition(t *testing.T, client *linodego.Client) *linodego.MonitorAlertDefinition { + ruleCriteria := linodego.AlertDefinitionCreateOptions{ + Label: fmt.Sprintf("test-%d-service-definition", time.Now().UnixNano()), + RuleCriteria: &linodego.RuleCriteriaOptions{ + Rules: []linodego.RuleOptions{ + { + AggregateFunction: "min", + Metric: "memory_usage", + Operator: "eq", + Threshold: 95, + DimensionFilters: []linodego.DimensionFilterOptions{ + { + DimensionLabel: "node_type", + Operator: "eq", + Value: "primary", + }, + }, + }, + }, + }, + TriggerConditions: &linodego.TriggerConditions{ + CriteriaCondition: "ALL", + EvaluationPeriodSeconds: 300, + PollingIntervalSeconds: 900, + TriggerOccurrences: 3, + }, + + Severity: 1, + ChannelIDs: []int{getAlertChannelsList(t, client)[0].ID}, + } + + alert, err := client.CreateMonitorAlertDefinition(context.Background(), testMonitorAlertDefinitionServiceType, ruleCriteria) + require.NoError(t, err) + return alert +} + +func getSampleSystemAlert(t *testing.T, client *linodego.Client) int { + alerts, listErr := client.ListMonitorAlertDefinitions(context.Background(), testMonitorAlertDefinitionServiceType, nil) + require.NoError(t, listErr) + sampleSystemAlertIR := 0 + for _, alert := range alerts { + if alert.Type == "system" { + sampleSystemAlertIR = alert.ID + break + } + } + require.Greater(t, sampleSystemAlertIR, 0, "No system alert definitions found. Cannot run tests dependent on system alert definitions.") + + return sampleSystemAlertIR +}