Class: PowerBI::Workspace
Defined Under Namespace
Classes: CapacityAssignmentError, UploadError
Instance Attribute Summary collapse
Attributes inherited from Object
#id
Instance Method Summary
collapse
Methods inherited from Object
instantiate_from_data, #reload, #set_attributes
Constructor Details
#initialize(tenant, parent, id = nil) ⇒ Workspace
Returns a new instance of Workspace.
8
9
10
11
12
13
|
# File 'lib/power-bi/workspace.rb', line 8
def initialize(tenant, parent, id = nil)
super(tenant, id)
@reports = ReportArray.new(@tenant, self)
@datasets = DatasetArray.new(@tenant, self)
@users = UserArray.new(@tenant, self)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class PowerBI::Object
Instance Attribute Details
Returns the value of attribute datasets.
3
4
5
|
# File 'lib/power-bi/workspace.rb', line 3
def datasets
@datasets
end
|
Returns the value of attribute reports.
3
4
5
|
# File 'lib/power-bi/workspace.rb', line 3
def reports
@reports
end
|
Returns the value of attribute users.
3
4
5
|
# File 'lib/power-bi/workspace.rb', line 3
def users
@users
end
|
Instance Method Details
#assign_to_capacity(capacity, timeout: 30) ⇒ Object
65
66
67
|
# File 'lib/power-bi/workspace.rb', line 65
def assign_to_capacity(capacity, timeout: 30)
_assign_to_capacity(capacity.id, timeout: timeout)
end
|
#data_to_attributes(data) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/power-bi/workspace.rb', line 19
def data_to_attributes(data)
{
id: data[:id],
is_read_only: data[:isReadOnly],
is_on_dedicated_capacity: data[:isOnDedicatedCapacity],
name: data[:name],
}
end
|
#dataset(id) ⇒ Object
61
62
63
|
# File 'lib/power-bi/workspace.rb', line 61
def dataset(id)
Dataset.new(@tenant, self, id)
end
|
51
52
53
54
55
|
# File 'lib/power-bi/workspace.rb', line 51
def delete
@tenant.delete("/groups/#{@id}")
@tenant.workspaces.reload
true
end
|
#get_data(id) ⇒ Object
15
16
17
|
# File 'lib/power-bi/workspace.rb', line 15
def get_data(id)
@tenant.get("/groups", {'$filter': "id eq #{id}"})[:value].first
end
|
#report(id) ⇒ Object
57
58
59
|
# File 'lib/power-bi/workspace.rb', line 57
def report(id)
Report.new(@tenant, self, id)
end
|
#unassign_from_capacity(timeout: 30) ⇒ Object
69
70
71
|
# File 'lib/power-bi/workspace.rb', line 69
def unassign_from_capacity(timeout: 30)
_assign_to_capacity('00000000-0000-0000-0000-000000000000', timeout: timeout)
end
|
#upload_pbix(file, dataset_name, timeout: 30) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/power-bi/workspace.rb', line 28
def upload_pbix(file, dataset_name, timeout: 30)
data = @tenant.post_file("/groups/#{@id}/imports", file, {datasetDisplayName: dataset_name})
import_id = data[:id]
success = false
iterations = 0
status_history = ''
old_status = ''
while !success
sleep 0.5
iterations += 1
raise UploadError.new("Upload did not succeed after #{timeout} seconds. Status history:#{status_history}") if iterations > (2 * timeout)
new_status = @tenant.get("/groups/#{@id}/imports/#{import_id}")[:importState].to_s
success = (new_status == "Succeeded")
if new_status != old_status
status_history += "\nStatus change after #{iterations/2}s: '#{old_status}' --> '#{new_status}'"
old_status = new_status
end
end
@reports.reload
@datasets.reload
true
end
|