Class: Databricks::Resources::Clusters

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

Overview

Instance Attribute Summary

Attributes inherited from Databricks::Resource

#properties

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

#create(**properties) ⇒ Object

Create a new cluster.

Parameters
  • properties (Hash<Symbol,Object>): Properties to create the cluster

Result
  • Cluster: The new cluster created



33
34
35
36
37
# File 'lib/databricks/resources/clusters.rb', line 33

def create(**properties)
  cluster = new_resource(:cluster, post_json('clusters/create', properties))
  cluster.add_properties(properties)
  cluster
end

#get(cluster_id) ⇒ Object

Get a cluster based on its cluster_id

Parameters
  • cluster_id (String): The cluster id to get

Result
  • Cluster: The cluster



23
24
25
# File 'lib/databricks/resources/clusters.rb', line 23

def get(cluster_id)
  new_resource(:cluster, get_json('clusters/get', { cluster_id: cluster_id }))
end

#listObject

List clusters

Result
  • Array<Cluster>: List of clusters



13
14
15
# File 'lib/databricks/resources/clusters.rb', line 13

def list
  (get_json('clusters/list')['clusters'] || []).map { |properties| new_resource(:cluster, properties) }
end