Class: Exa::Instrumentation::Endpoint

Inherits:
T::Enum
  • Object
show all
Defined in:
lib/exa/instrumentation/events.rb

Overview

Enum representing API endpoints for instrumentation

Class Method Summary collapse

Class Method Details

.from_path(path) ⇒ Object

Map a path string to an Endpoint enum value



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/exa/instrumentation/events.rb', line 31

def self.from_path(path)
  normalized = Array(path).join("/").downcase

  case normalized
  when "search" then Search
  when "contents" then Contents
  when "findsimilar" then FindSimilar
  when "answer" then Answer
  when /^research$/ then Research
  when /^research\/[^\/]+$/ then Research
  when /^research\/[^\/]+\/cancel$/ then ResearchCancel
  when /^websets$/ then WebsetCreate
  when /^websets\/[^\/]+$/ then WebsetGet
  when /^websets\/[^\/]+\/items/ then WebsetItems
  when /^websets\/[^\/]+\/enrichments/ then WebsetEnrichments
  when /^websets\/[^\/]+\/search$/ then WebsetSearch
  when /^websets\/[^\/]+\/cancel$/ then WebsetCancel
  when /^events/ then Events
  when /^webhooks/ then Webhooks
  when /^imports/ then Imports
  else Unknown
  end
end