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.



53
54
55
56
# File 'lib/power-bi/gateway_datasource.rb', line 53

def initialize(tenant, gateway)
  super(tenant, gateway)
  @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



58
59
60
# File 'lib/power-bi/gateway_datasource.rb', line 58

def self.get_class
  GatewayDatasource
end

Instance Method Details

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

only MySQL type is currently supported



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/power-bi/gateway_datasource.rb', line 63

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.instantiate_from_data(@tenant, @gateway, data)
end

#get_dataObject



84
85
86
# File 'lib/power-bi/gateway_datasource.rb', line 84

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