Class: OmniAI::Google::Upload::File

Inherits:
Object
  • Object
show all
Defined in:
lib/omniai/google/upload/file.rb

Overview

A file that can be used for generating chat completions.

Defined Under Namespace

Classes: DeleteError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, name:, uri:, state:, mime_type:) ⇒ File

Returns a new instance of File.

Parameters:

  • client (Client)
  • name (String)
  • uri (String)
  • state (String)
  • mime_type (String)


45
46
47
48
49
50
51
# File 'lib/omniai/google/upload/file.rb', line 45

def initialize(client:, name:, uri:, state:, mime_type:)
  @client = client
  @name = name
  @uri = uri
  @state = state
  @mime_type = mime_type
end

Instance Attribute Details

#mime_typeString

Returns:

  • (String)


24
25
26
# File 'lib/omniai/google/upload/file.rb', line 24

def mime_type
  @mime_type
end

#nameString

Returns:

  • (String)


12
13
14
# File 'lib/omniai/google/upload/file.rb', line 12

def name
  @name
end

#stateString

Returns:

  • (String)


20
21
22
# File 'lib/omniai/google/upload/file.rb', line 20

def state
  @state
end

#uriString

Returns:

  • (String)


16
17
18
# File 'lib/omniai/google/upload/file.rb', line 16

def uri
  @uri
end

Class Method Details

.parse(client:, data:) ⇒ File

Parameters:

Returns:



30
31
32
33
34
35
36
37
38
# File 'lib/omniai/google/upload/file.rb', line 30

def self.parse(client:, data:)
  new(
    client: client,
    name: data['name'],
    uri: data['uri'],
    state: data['state'],
    mime_type: data['mimeType']
  )
end

Instance Method Details

#delete!Object

Raises:



54
55
56
57
58
59
# File 'lib/omniai/google/upload/file.rb', line 54

def delete!
  response = @client.connection
    .delete("/#{@client.version}/#{@name}", params: { key: @client.api_key })

  raise DeleteError, response unless response.status.success?
end