Class: PowerBI::GatewayDatasource

Inherits:
Object
  • Object
show all
Defined in:
lib/power-bi/gateway_datasource.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) ⇒ GatewayDatasource

Returns a new instance of GatewayDatasource.



5
6
7
8
# File 'lib/power-bi/gateway_datasource.rb', line 5

def initialize(tenant, parent, id = nil)
  super(tenant, id)
  @gateway = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PowerBI::Object

Instance Attribute Details

#gatewayObject (readonly)

Returns the value of attribute gateway.



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

def gateway
  @gateway
end

Instance Method Details

#data_to_attributes(data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/power-bi/gateway_datasource.rb', line 14

def data_to_attributes(data)
  {
    gateway_id: data[:gatewayId],
    datasource_type: data[:datasourceType],
    datasource_name: data[:datasourceName],
    connection_details: data[:connectionDetails],
    id: data[:id],
    credential_type: data[:credentialType],
    gateway: data[:gateway],
  }
end

#deleteObject



43
44
45
46
47
# File 'lib/power-bi/gateway_datasource.rb', line 43

def delete
  @tenant.delete("/gateways/#{gateway.id}/datasources/#{id}")
  @gateway.gateway_datasources.reload
  true
end

#get_data(id) ⇒ Object



10
11
12
# File 'lib/power-bi/gateway_datasource.rb', line 10

def get_data(id)
  @tenant.get("/gateways/#{@gateway.id}/datasources/#{id}")
end

#update_credentials(encrypted_credentials) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/power-bi/gateway_datasource.rb', line 26

def update_credentials(encrypted_credentials)
  @tenant.patch("/gateways/#{gateway.id}/datasources/#{id}") do |req|
    req.body = {
      credentialDetails: {
        credentialType: "Basic",
        credentials: encrypted_credentials,
        encryptedConnection: "Encrypted",
        encryptionAlgorithm: "RSA-OAEP",
        privacyLevel: "Organizational",
        useCallerAADIdentity: false,
        useEndUserOAuth2Credentials: false,
      },
    }.to_json
  end
  true
end