Class: PowerBI::GatewayDatasourceArray

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#reload

Constructor Details

#initialize(tenant, gateway) ⇒ GatewayDatasourceArray

Returns a new instance of GatewayDatasourceArray.



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

def initialize(tenant, gateway)
  super(tenant)
  @gateway = gateway
end

Dynamic Method Handling

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

Class Method Details

.get_classObject



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

def self.get_class
  GatewayDatasource
end

Instance Method Details

#create(name, encrypted_credentials, db_server, db_name) ⇒ Object

only MySQL type is currently supported



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/power-bi/gateway_datasource.rb', line 53

def create(name, encrypted_credentials, db_server, db_name)
  data = @tenant.post("/gateways/#{@gateway.id}/datasources",) do |req|
    req.body = {
      connectionDetails: {server: db_server, database: db_name}.to_json,
      credentialDetails: {
        credentialType: "Basic",
        credentials: encrypted_credentials,
        encryptedConnection: "Encrypted",
        encryptionAlgorithm: "RSA-OAEP",
        privacyLevel: "Organizational",
        useCallerAADIdentity: false,
        useEndUserOAuth2Credentials: false,
      },
      datasourceName: name,
      datasourceType: 'MySql',
    }.to_json
  end
  self.reload
  GatewayDatasource.new(@tenant, data)
end

#get_dataObject



74
75
76
77
# File 'lib/power-bi/gateway_datasource.rb', line 74

def get_data
  data = @tenant.get("/gateways/#{@gateway.id}/datasources")[:value]
  data.each { |d| d[:gateway] = @gateway }
end