Class: Kennel::Models::SyntheticTest

Inherits:
Record
  • Object
show all
Includes:
TagsValidation
Defined in:
lib/kennel/models/synthetic_test.rb

Constant Summary collapse

TRACKING_FIELD =
:message
DEFAULTS =
{}.freeze
READONLY_ATTRIBUTES =
superclass::READONLY_ATTRIBUTES + [:status, :monitor_id]
LOCATIONS =
["aws:ca-central-1", "aws:eu-north-1", "aws:eu-west-1", "aws:eu-west-3", "aws:eu-west-2", "aws:ap-south-1", "aws:us-west-2", "aws:us-west-1", "aws:sa-east-1", "aws:us-east-2", "aws:ap-northeast-1", "aws:ap-northeast-2", "aws:eu-central-1", "aws:ap-southeast-2", "aws:ap-southeast-1"].freeze

Constants inherited from Record

Record::ALLOWED_KENNEL_ID_CHARS, Record::ALLOWED_KENNEL_ID_FULL, Record::ALLOWED_KENNEL_ID_REGEX, Record::ALLOWED_KENNEL_ID_SEGMENT, Record::LOCK, Record::MARKER_TEXT, Record::TRACKING_FIELDS, Record::UnvalidatedRecordError

Constants included from OptionalValidations

OptionalValidations::UNIGNORABLE

Constants inherited from Base

Base::SETTING_OVERRIDABLE_METHODS

Constants included from SettingsAsMethods

SettingsAsMethods::AS_PROCS, SettingsAsMethods::SETTING_OVERRIDABLE_METHODS

Instance Attribute Summary

Attributes inherited from Record

#filtered_validation_errors, #project, #unfiltered_validation_errors

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TagsValidation

#validate_json

Methods inherited from Record

#add_tracking_id, api_resource_map, #as_json, #build, #diff, #initialize, #invalid_update!, parse_any_url, parse_tracking_id, #remove_tracking_id, remove_tracking_id, #resolve_linked_tracking_ids!, #safe_tracking_id, #tracking_id, #validate_update!

Methods included from OptionalValidations

included, valid?

Methods inherited from Base

#kennel_id, #name, #to_json

Methods included from SubclassTracking

#recursive_subclasses, #subclasses

Methods included from SettingsAsMethods

included, #initialize, #raise_with_location

Constructor Details

This class inherits a constructor from Kennel::Models::Record

Class Method Details

.api_resourceObject



34
35
36
# File 'lib/kennel/models/synthetic_test.rb', line 34

def self.api_resource
  "synthetics/tests"
end

.normalize(expected, actual) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/kennel/models/synthetic_test.rb', line 46

def self.normalize(expected, actual)
  super

  # tags come in a semi-random order and order is never updated
  expected[:tags] = expected[:tags]&.sort
  actual[:tags] = actual[:tags]&.sort

  expected[:locations] = expected[:locations]&.sort
  actual[:locations] = actual[:locations]&.sort

  ignore_default(expected, actual, DEFAULTS)
end

.parse_url(url) ⇒ Object



42
43
44
# File 'lib/kennel/models/synthetic_test.rb', line 42

def self.parse_url(url)
  url[/\/synthetics\/details\/([a-z\d-]{11,})/, 1] # id format is 1ab-2ab-3ab
end

.url(id) ⇒ Object



38
39
40
# File 'lib/kennel/models/synthetic_test.rb', line 38

def self.url(id)
  Utils.path_to_url "/synthetics/details/#{id}"
end

Instance Method Details

#build_jsonObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kennel/models/synthetic_test.rb', line 19

def build_json
  locations = locations()

  super.merge(
    message: message,
    tags: tags,
    config: config,
    type: type,
    subtype: subtype,
    options: options,
    name: "#{name}#{LOCK}",
    locations: locations == :all ? LOCATIONS : locations
  )
end