Class: PowerBI::Dataset

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tenant, data) ⇒ Dataset

Returns a new instance of Dataset.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/power-bi/dataset.rb', line 7

def initialize(tenant, 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]
  @workspace = data[:workspace]
  @tenant = tenant
  @datasources = DatasourceArray.new(@tenant, self)
  @parameters = ParameterArray.new(@tenant, self)
  @refresh_history = RefreshArray.new(@tenant, self)
end

Instance Attribute Details

#add_rows_API_enabledObject (readonly)

Returns the value of attribute add_rows_API_enabled.



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

def add_rows_API_enabled
  @add_rows_API_enabled
end

#configured_byObject (readonly)

Returns the value of attribute configured_by.



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

def configured_by
  @configured_by
end

#datasourcesObject (readonly)

Returns the value of attribute datasources.



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

def datasources
  @datasources
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#is_effective_identity_requiredObject (readonly)

Returns the value of attribute is_effective_identity_required.



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

def is_effective_identity_required
  @is_effective_identity_required
end

#is_effective_identity_roles_requiredObject (readonly)

Returns the value of attribute is_effective_identity_roles_required.



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

def is_effective_identity_roles_required
  @is_effective_identity_roles_required
end

#is_on_prem_gateway_requiredObject (readonly)

Returns the value of attribute is_on_prem_gateway_required.



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

def is_on_prem_gateway_required
  @is_on_prem_gateway_required
end

#is_refreshableObject (readonly)

Returns the value of attribute is_refreshable.



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

def is_refreshable
  @is_refreshable
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

#refresh_historyObject (readonly)

Returns the value of attribute refresh_history.



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

def refresh_history
  @refresh_history
end

#target_storage_modeObject (readonly)

Returns the value of attribute target_storage_mode.



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

def target_storage_mode
  @target_storage_mode
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



53
54
55
56
57
58
59
60
61
# File 'lib/power-bi/dataset.rb', line 53

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

#deleteObject



48
49
50
51
# File 'lib/power-bi/dataset.rb', line 48

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

#last_refreshObject



34
35
36
# File 'lib/power-bi/dataset.rb', line 34

def last_refresh
  @refresh_history.first
end

#refreshObject



38
39
40
41
42
43
44
45
46
# File 'lib/power-bi/dataset.rb', line 38

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

#update_parameter(name, value) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/power-bi/dataset.rb', line 24

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