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.



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

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



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

def self.get_class
  GatewayDatasource
end

Instance Method Details

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

only MySQL type is currently supported



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

def create(name, encrypted_credentials, db_server, db_name)
  data = @tenant.post("/gateways/#{@gateway.id}/datasources", use_profile: false) 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



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

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