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
9
# File 'lib/power-bi/gateway_datasource.rb', line 5

def initialize(tenant, parent, id = nil)
  super(tenant, id)
  @gateway = parent
  @gateway_datasource_users = GatewayDatasourceUserArray.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

#gatewayObject (readonly)

Returns the value of attribute gateway.



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

def gateway
  @gateway
end

#gateway_datasource_usersObject (readonly)

Returns the value of attribute gateway_datasource_users.



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

def gateway_datasource_users
  @gateway_datasource_users
end

Instance Method Details

#data_to_attributes(data) ⇒ Object



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

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



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

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

#get_data(id) ⇒ Object



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

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

#update_credentials(encrypted_credentials) ⇒ Object



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

def update_credentials(encrypted_credentials)
  @tenant.patch("/gateways/#{gateway.id}/datasources/#{id}", use_profile: false) 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