Class: AlertManagement::HttpIntegration

Inherits:
ApplicationRecord show all
Includes:
Gitlab::EncryptedAttribute, Gitlab::Routing
Defined in:
app/models/alert_management/http_integration.rb

Constant Summary collapse

LEGACY_IDENTIFIERS =
%w[legacy legacy-prometheus].freeze

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Routing

includes_helpers, redirect_legacy_paths, url_helpers

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.generate_tokenObject



61
62
63
# File 'app/models/alert_management/http_integration.rb', line 61

def self.generate_token
  SecureRandom.hex
end

Instance Method Details

#legacy?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/alert_management/http_integration.rb', line 55

def legacy?
  LEGACY_IDENTIFIERS.include?(endpoint_identifier)
end

#urlObject



44
45
46
47
48
49
50
51
52
53
# File 'app/models/alert_management/http_integration.rb', line 44

def url
  case endpoint_identifier
  when 'legacy'
    project_alerts_notify_url(project, format: :json)
  when 'legacy-prometheus'
    notify_project_prometheus_alerts_url(project, format: :json)
  else
    project_alert_http_integration_url(project, name_slug, endpoint_identifier, format: :json)
  end
end