Class: PowerBI::GatewayDatasource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tenant, data) ⇒ GatewayDatasource

Returns a new instance of GatewayDatasource.



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

def initialize(tenant, 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]
  @tenant = tenant
end

Instance Attribute Details

#connection_detailsObject (readonly)

Returns the value of attribute connection_details.



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

def connection_details
  @connection_details
end

#credential_typeObject (readonly)

Returns the value of attribute credential_type.



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

def credential_type
  @credential_type
end

#datasource_nameObject (readonly)

Returns the value of attribute datasource_name.



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

def datasource_name
  @datasource_name
end

#datasource_typeObject (readonly)

Returns the value of attribute datasource_type.



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

def datasource_type
  @datasource_type
end

#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_idObject (readonly)

Returns the value of attribute gateway_id.



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

def gateway_id
  @gateway_id
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#deleteObject



33
34
35
36
37
# File 'lib/power-bi/gateway_datasource.rb', line 33

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

#update_credentials(encrypted_credentials) ⇒ Object



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

def update_credentials(encrypted_credentials)
  response = @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