Class: PowerBI::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/power-bi/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tenant, data) ⇒ Report

Returns a new instance of Report.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/power-bi/report.rb', line 5

def initialize(tenant, data)
  @id = data[:id]
  @report_type = data[:reportType]
  @name = data[:name]
  @web_url = data[:webUrl]
  @embed_url = data[:embedUrl]
  @is_from_pbix = data[:isFromPbix]
  @is_owned_by_me = data[:isOwnedByMe]
  @dataset_id = data[:datasetId]
  @workspace = data[:workspace]
  @tenant = tenant
end

Instance Attribute Details

#dataset_idObject (readonly)

Returns the value of attribute dataset_id.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def dataset_id
  @dataset_id
end

#embed_urlObject (readonly)

Returns the value of attribute embed_url.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def embed_url
  @embed_url
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def id
  @id
end

#is_from_pbixObject (readonly)

Returns the value of attribute is_from_pbix.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def is_from_pbix
  @is_from_pbix
end

#is_owned_by_meObject (readonly)

Returns the value of attribute is_owned_by_me.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def is_owned_by_me
  @is_owned_by_me
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def name
  @name
end

#report_typeObject (readonly)

Returns the value of attribute report_type.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def report_type
  @report_type
end

#web_urlObject (readonly)

Returns the value of attribute web_url.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def web_url
  @web_url
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



3
4
5
# File 'lib/power-bi/report.rb', line 3

def workspace
  @workspace
end

Instance Method Details

#clone(target_workspace, new_report_name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/power-bi/report.rb', line 18

def clone(target_workspace, new_report_name)
  data = @tenant.post("/reports/#{@id}/Clone") do |req|
    req.body = {
      name: new_report_name,
      targetWorkspaceId: target_workspace.id
    }.to_json
  end
  target_workspace.reports.reload
  data[:workspace] = target_workspace
  Report.new(@tenant, data)
end

#rebind(target_dataset) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/power-bi/report.rb', line 30

def rebind(target_dataset)
  @tenant.post("/groups/#{workspace.id}/reports/#{id}/Rebind") do |req|
    req.body = {
      datasetId: target_dataset.id
    }.to_json
  end
  true
end