Class: VoiceML::AssistantsV1ToolsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/resources/assistants_v1.rb

Overview

============================================================================

/v1/Tools — 5 CRUD ops on the top-level Tool resource. list accepts an optional assistant_id: filter (wire name AssistantId). Fetch returns the ToolWithPolicies shape (policies inline).

Constant Summary collapse

CREATE_FIELDS =
%i[name type enabled assistant_id description meta].freeze
UPDATE_FIELDS =
%i[name type enabled description meta].freeze

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ AssistantsV1ToolsResource

Returns a new instance of AssistantsV1ToolsResource.



287
288
289
# File 'lib/voiceml/resources/assistants_v1.rb', line 287

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(name:, type:, enabled:, **kwargs) ⇒ Object



298
299
300
301
302
303
304
305
# File 'lib/voiceml/resources/assistants_v1.rb', line 298

def create(name:, type:, enabled:, **kwargs)
  kwargs[:name]    = name
  kwargs[:type]    = type
  kwargs[:enabled] = enabled
  AssistantsV1Tool.from_hash(
    @transport.request(:post, '/v1/Tools', json: build_json(CREATE_FIELDS, kwargs))
  )
end

#delete(id) ⇒ Object



317
318
319
320
# File 'lib/voiceml/resources/assistants_v1.rb', line 317

def delete(id)
  @transport.request(:delete, "/v1/Tools/#{id}")
  nil
end

#fetch(id) ⇒ Object



307
308
309
# File 'lib/voiceml/resources/assistants_v1.rb', line 307

def fetch(id)
  AssistantsV1ToolWithPolicies.from_hash(@transport.request(:get, "/v1/Tools/#{id}"))
end

#list(assistant_id: nil, page_size: nil) ⇒ Object



291
292
293
294
295
296
# File 'lib/voiceml/resources/assistants_v1.rb', line 291

def list(assistant_id: nil, page_size: nil)
  params = {}
  params['AssistantId'] = assistant_id unless assistant_id.nil?
  params['PageSize']    = page_size    unless page_size.nil?
  AssistantsV1ToolList.new(@transport.request(:get, '/v1/Tools', params: params))
end

#update(id, **kwargs) ⇒ Object



311
312
313
314
315
# File 'lib/voiceml/resources/assistants_v1.rb', line 311

def update(id, **kwargs)
  AssistantsV1Tool.from_hash(
    @transport.request(:put, "/v1/Tools/#{id}", json: build_json(UPDATE_FIELDS, kwargs))
  )
end