Class: Databricks::Resources::Dbfs

Inherits:
Databricks::Resource show all
Defined in:
lib/databricks/resources/dbfs.rb

Overview

Instance Method Summary collapse

Methods inherited from Databricks::Resource

#add_properties, #initialize, #inspect, #new_resource, #sub_resource, sub_resources

Constructor Details

This class inherits a constructor from Databricks::Resource

Instance Method Details

#delete(path, recursive: false) ⇒ Object

Delete a path

Parameters
  • path (String): Path to delete

  • recursive (Boolean): Do we delete recursively? [default: false]



40
41
42
43
44
45
46
47
48
# File 'lib/databricks/resources/dbfs.rb', line 40

def delete(path, recursive: false)
  post_json(
    'dbfs/delete',
    {
      path: path,
      recursive: recursive
    }
  )
end

#list(path) ⇒ Object

List a path

Parameters
  • path (String): Path to be listed

Result
  • Array<String>: List of DBFS paths



15
16
17
# File 'lib/databricks/resources/dbfs.rb', line 15

def list(path)
  (get_json('dbfs/list', { path: path })['files'] || []).map { |properties| new_resource(:file, properties) }
end

#put(path, local_file) ⇒ Object

Put a new file

Parameters
  • path (String): Path to the file to create

  • local_file (String): Path to the local file to put



24
25
26
27
28
29
30
31
32
33
# File 'lib/databricks/resources/dbfs.rb', line 24

def put(path, local_file)
  post(
    'dbfs/put',
    {
      path: path,
      contents: ::File.new(local_file, 'rb'),
      overwrite: true
    }
  )
end