Class: PowerBI::GatewayDatasourceUserArray

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#reload

Constructor Details

#initialize(tenant, gateway_datasource) ⇒ GatewayDatasourceUserArray

Returns a new instance of GatewayDatasourceUserArray.



25
26
27
28
# File 'lib/power-bi/gateway_datasource_user.rb', line 25

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

Dynamic Method Handling

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

Class Method Details

.get_classObject



30
31
32
# File 'lib/power-bi/gateway_datasource_user.rb', line 30

def self.get_class
  GatewayDatasourceUser
end

Instance Method Details

#add_service_principal_profile_user(profile_id, principal_object_id, datasource_access_right: "Read") ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/power-bi/gateway_datasource_user.rb', line 35

def add_service_principal_profile_user(profile_id, principal_object_id, datasource_access_right: "Read")
  @tenant.post("/gateways/#{@gateway_datasource.gateway.id}/datasources/#{@gateway_datasource.id}/users", use_profile: false) do |req|
    req.body = {
      datasourceAccessRight: datasource_access_right,
      identifier: principal_object_id,
      principalType: "App",
      profile: {id: profile_id},
    }.to_json
  end
  self.reload
end

#get_dataObject



47
48
49
# File 'lib/power-bi/gateway_datasource_user.rb', line 47

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