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.



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

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



38
39
40
# File 'lib/power-bi/gateway_datasource_user.rb', line 38

def self.get_class
  GatewayDatasourceUser
end

Instance Method Details

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



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/power-bi/gateway_datasource_user.rb', line 43

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



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

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