Class: NitroIntelligence::Observability::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/nitro_intelligence/observability/project.rb

Defined Under Namespace

Classes: NotFoundError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slug:, id:, public_key:, secret_key:, **_kwargs) ⇒ Project

Returns a new instance of Project.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nitro_intelligence/observability/project.rb', line 11

def initialize(slug:, id:, public_key:, secret_key:, **_kwargs)
  @slug = slug
  @id = id
  @public_key = public_key
  @secret_key = secret_key
  @auth_token = Base64.strict_encode64("#{public_key}:#{secret_key}")
  @prompt_store = PromptStore.new(
    observability_project_slug: slug,
    observability_public_key: public_key,
    observability_secret_key: secret_key
  )
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



9
10
11
# File 'lib/nitro_intelligence/observability/project.rb', line 9

def auth_token
  @auth_token
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/nitro_intelligence/observability/project.rb', line 9

def id
  @id
end

#prompt_storeObject (readonly)

Returns the value of attribute prompt_store.



9
10
11
# File 'lib/nitro_intelligence/observability/project.rb', line 9

def prompt_store
  @prompt_store
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



9
10
11
# File 'lib/nitro_intelligence/observability/project.rb', line 9

def public_key
  @public_key
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



9
10
11
# File 'lib/nitro_intelligence/observability/project.rb', line 9

def secret_key
  @secret_key
end

#slugObject (readonly)

Returns the value of attribute slug.



9
10
11
# File 'lib/nitro_intelligence/observability/project.rb', line 9

def slug
  @slug
end

Class Method Details

.find_by_slug(slug:) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/nitro_intelligence/observability/project.rb', line 24

def self.find_by_slug(slug:)
  project_config = NitroIntelligence.config.observability_projects.find { |project| project["slug"] == slug }

  return new(**project_config.to_h.transform_keys(&:to_sym)) if project_config

  nil
end