Class: Igniter::Lang::DiagnosticPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/lang/diagnostic_payload.rb

Constant Summary collapse

SEMANTICS =
{
  report_only: true,
  runtime_enforced: false,
  package_adapter_authorized: false,
  real_data_export_authorized: false,
  readiness_enforced: false,
  ledger_core: false
}.freeze
DEFAULT_REDACTION_POLICY =
{
  raw_ref_export: false,
  hash_source_refs: true,
  redacted_ref_kinds: []
}.freeze
STATUSES =
%i[ok warning blocked unknown].freeze
DECISIONS =
%i[trusted provisional blocked unknown].freeze
RAW_REF_KEYS =
%i[raw_ref raw_refs raw_source_ref raw_source_refs].freeze
RAW_REF_PREFIX =
"raw:"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diagnostic_id:, profile:, status:, decision:, payload: {}, evidence_links: {}, redaction_policy: {}, metadata: {}) ⇒ DiagnosticPayload

Returns a new instance of DiagnosticPayload.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/igniter/lang/diagnostic_payload.rb', line 35

def initialize(
  diagnostic_id:,
  profile:,
  status:,
  decision:,
  payload: {},
  evidence_links: {},
  redaction_policy: {},
  metadata: {}
)
  @diagnostic_id = require_value(:diagnostic_id, diagnostic_id)
  @profile = require_value(:profile, profile)
  @status = normalize_status(status)
  @decision = normalize_decision(decision)
  @payload = deep_freeze(normalize_hash(payload, :payload))
  @evidence_links = deep_freeze(normalize_hash(evidence_links, :evidence_links))
  @redaction_policy = deep_freeze(normalize_redaction_policy(redaction_policy))
  @metadata = deep_freeze(normalize_hash(, :metadata))
  reject_raw_refs!
  freeze
end

Instance Attribute Details

#decisionObject (readonly)

Returns the value of attribute decision.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def decision
  @decision
end

#diagnostic_idObject (readonly)

Returns the value of attribute diagnostic_id.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def diagnostic_id
  @diagnostic_id
end

Returns the value of attribute evidence_links.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def evidence_links
  @evidence_links
end

#metadataObject (readonly)

Returns the value of attribute metadata.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def 
  @metadata
end

#payloadObject (readonly)

Returns the value of attribute payload.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def payload
  @payload
end

#profileObject (readonly)

Returns the value of attribute profile.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def profile
  @profile
end

#redaction_policyObject (readonly)

Returns the value of attribute redaction_policy.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def redaction_policy
  @redaction_policy
end

#statusObject (readonly)

Returns the value of attribute status.



26
27
28
# File 'lib/igniter/lang/diagnostic_payload.rb', line 26

def status
  @status
end

Instance Method Details

#report_only?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/igniter/lang/diagnostic_payload.rb', line 57

def report_only?
  true
end

#runtime_enforced?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/igniter/lang/diagnostic_payload.rb', line 61

def runtime_enforced?
  false
end

#to_hObject



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/igniter/lang/diagnostic_payload.rb', line 65

def to_h
  {
    diagnostic_id: diagnostic_id,
    profile: profile,
    status: status,
    decision: decision,
    payload: payload,
    evidence_links: evidence_links,
    redaction_policy: redaction_policy,
    semantics: SEMANTICS,
    metadata: 
  }
end