Class: ZohoSdk::Analytics::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/zoho-sdk/analytics/workspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace_name, client) ⇒ Workspace

Returns a new instance of Workspace.



7
8
9
10
11
# File 'lib/zoho-sdk/analytics/workspace.rb', line 7

def initialize(workspace_name, client)
  @workspace_name = workspace_name
  @client = client
   = nil
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/zoho-sdk/analytics/workspace.rb', line 5

def client
  @client
end

Instance Method Details

#create_table(table_name, folder = nil, **opts) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/zoho-sdk/analytics/workspace.rb', line 36

def create_table(table_name, folder = nil, **opts)
  table_design = {
    "TABLENAME" => table_name,
    "TABLEDESCRIPTION" => opts[:description] || "",
    "COLUMNS" => []
  }
  table_design["FOLDERNAME"] = folder if !folder.nil?
  res = client.get path: name, params: {
    "ZOHO_ACTION" => "CREATETABLE",
    "ZOHO_TABLE_DESIGN" => table_design.to_json
  }
  if res.success?
    data = JSON.parse(res.body)
    Table.new(name, self, client)
  else
    nil
  end
end

#metadataObject



17
18
19
20
# File 'lib/zoho-sdk/analytics/workspace.rb', line 17

def 
  return  if !.nil?
  metadata!
end

#metadata!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/zoho-sdk/analytics/workspace.rb', line 22

def metadata!
  res = client.get path: name, params: {
    "ZOHO_ACTION" => "DATABASEMETADATA",
    "ZOHO_METADATA" => "ZOHO_CATALOG_INFO"
  }
  if res.success?
    data = JSON.parse(res.body)
     = data.dig("response", "result")
    
  else
    nil
  end
end

#nameObject



13
14
15
# File 'lib/zoho-sdk/analytics/workspace.rb', line 13

def name
  @workspace_name
end

#table(table_name) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/zoho-sdk/analytics/workspace.rb', line 55

def table(table_name)
  res = client.get path: name, params: {
    "ZOHO_ACTION" => "ISVIEWEXIST",
    "ZOHO_VIEW_NAME" => table_name
  }
  if res.success?
    data = JSON.parse(res.body)
    if data.dig("response", "result", "isviewexist") == "true"
      Table.new(table_name, self, client)
    else
      nil
    end
  else
    nil
  end
end