Class: PowerBI::Dataset

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

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) ⇒ Dataset

Returns a new instance of Dataset.



5
6
7
8
9
10
11
# File 'lib/power-bi/dataset.rb', line 5

def initialize(tenant, parent, id = nil)
  super(tenant, id)
  @workspace = parent
  @datasources = DatasourceArray.new(@tenant, self)
  @parameters = ParameterArray.new(@tenant, self)
  @refresh_history = RefreshArray.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

#datasourcesObject (readonly)

Returns the value of attribute datasources.



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

def datasources
  @datasources
end

#parametersObject (readonly)

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



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

def workspace
  @workspace
end

Instance Method Details

#bind_to_gateway(gateway, gateway_datasource) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/power-bi/dataset.rb', line 66

def bind_to_gateway(gateway, gateway_datasource)
  @tenant.post("/groups/#{workspace.id}/datasets/#{id}/Default.BindToGateway") do |req|
    req.body = {
      gatewayObjectId: gateway.id,
      datasourceObjectIds: [gateway_datasource.id]
    }.to_json
  end
  true
end

#data_to_attributes(data) ⇒ Object



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

def data_to_attributes(data)
  {
    id: data[:id],
    name: data[:name],
    add_rows_API_enabled: data[:addRowsAPIEnabled],
    configured_by: data[:configuredBy],
    is_refreshable: data[:isRefreshable],
    is_effective_identity_required: data[:isEffectiveIdentityRequired],
    is_effective_identity_roles_required: data[:isEffectiveIdentityRolesRequired],
    is_on_prem_gateway_required: data[:isOnPremGatewayRequired],
    target_storage_mode: data[:targetStorageMode],
  }
end

#deleteObject



60
61
62
63
64
# File 'lib/power-bi/dataset.rb', line 60

def delete
  @tenant.delete("/groups/#{workspace.id}/datasets/#{id}")
  @workspace.datasets.reload
  true
end

#get_data(id) ⇒ Object



13
14
15
# File 'lib/power-bi/dataset.rb', line 13

def get_data(id)
  @tenant.get("/groups/#{@workspace.id}/datasets/#{id}")
end

#last_refreshObject



46
47
48
# File 'lib/power-bi/dataset.rb', line 46

def last_refresh
  @refresh_history.first
end

#refreshObject



50
51
52
53
54
55
56
57
58
# File 'lib/power-bi/dataset.rb', line 50

def refresh
  @tenant.post("/groups/#{workspace.id}/datasets/#{id}/refreshes") do |req|
    req.body = {
      notifyOption: "NoNotification"
    }.to_json
  end
  @refresh_history.reload
  true
end

#refresh_history(entries_to_load = 1) ⇒ Object



41
42
43
44
# File 'lib/power-bi/dataset.rb', line 41

def refresh_history(entries_to_load = 1)
  @refresh_history.entries_to_load = entries_to_load
  @refresh_history
end

#update_parameter(name, value) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/power-bi/dataset.rb', line 31

def update_parameter(name, value)
  @tenant.post("/groups/#{workspace.id}/datasets/#{id}/Default.UpdateParameters") do |req|
    req.body = {
      updateDetails: [{name: name, newValue: value.to_s}]
    }.to_json
  end
  @parameters.reload
  true
end