Class: ZohoSdk::Analytics::Workspace
- Inherits:
-
Object
- Object
- ZohoSdk::Analytics::Workspace
- Defined in:
- lib/zoho-sdk/analytics/workspace.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create_table(table_name, folder = nil, **opts) ⇒ Table
Create a new table in the workspace.
-
#initialize(workspace_name, client) ⇒ Workspace
constructor
A new instance of Workspace.
- #metadata ⇒ Object
- #metadata! ⇒ Object
- #name ⇒ Object
-
#table(table_name) ⇒ Table
Retrieve a table by name from the workspace.
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 @metadata = nil end |
Instance Attribute Details
#client ⇒ Object (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) ⇒ Table
Create a new table in the workspace.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/zoho-sdk/analytics/workspace.rb', line 42 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 |
#metadata ⇒ Object
17 18 19 20 |
# File 'lib/zoho-sdk/analytics/workspace.rb', line 17 def return @metadata if !@metadata.nil? 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 res = client.get path: name, params: { "ZOHO_ACTION" => "DATABASEMETADATA", "ZOHO_METADATA" => "ZOHO_CATALOG_INFO" } if res.success? data = JSON.parse(res.body) @metadata = data.dig("response", "result") @metadata else nil end end |
#name ⇒ Object
13 14 15 |
# File 'lib/zoho-sdk/analytics/workspace.rb', line 13 def name @workspace_name end |
#table(table_name) ⇒ Table
Retrieve a table by name from the workspace
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/zoho-sdk/analytics/workspace.rb', line 64 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 |