Class: Outhad::Integrations::Source::WatsonxAi::Client

Inherits:
SourceConnector
  • Object
show all
Defined in:
lib/outhad/integrations/source/watsonx_ai/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/outhad/integrations/source/watsonx_ai/client.rb', line 8

def check_connection(connection_config)
  get_access_token(connection_config[:api_key])
  url = format(
    WATSONX_HEALTH_DEPLOYMENT_URL,
    region: connection_config[:region],
    version: API_VERSION
  )
  response = send_request(
    url: url,
    http_method: HTTP_GET,
    payload: {},
    headers: auth_headers(@access_token),
    config: connection_config[:config]
  )
  evaluate_deployment_status(response, connection_config[:deployment_id])
rescue StandardError => e
  handle_exception(e, { context: "WATSONX AI:CHECK_CONNECTION:EXCEPTION", type: "error" })
  failure_status(e)
end

#discover(_connection_config) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/outhad/integrations/source/watsonx_ai/client.rb', line 28

def discover(_connection_config)
  catalog_json = read_json(CATALOG_SPEC_PATH)
  catalog = build_catalog(catalog_json)
  catalog.to_outhad_message
rescue StandardError => e
  handle_exception(e, { context: "WATSONX AI:DISCOVER:EXCEPTION", type: "error" })
end

#read(sync_config) ⇒ Object



36
37
38
39
40
41
# File 'lib/outhad/integrations/source/watsonx_ai/client.rb', line 36

def read(sync_config)
  connection_config, payload = prepare_config_and_payload(sync_config)
  process_model_request(connection_config, payload) { |message| yield message if block_given? }
rescue StandardError => e
  handle_exception(e, { context: "WATSONX AI:READ:EXCEPTION", type: "error" })
end