Class: Grafana::Api::AccessControl::Roles

Inherits:
Object
  • Object
show all
Defined in:
lib/grafana-api/api/access_control/roles.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Roles

Returns a new instance of Roles.



5
6
7
# File 'lib/grafana-api/api/access_control/roles.rb', line 5

def initialize(connection)
  @connection = connection
end

Instance Method Details

#assignments(role_uid:) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/grafana-api/api/access_control/roles.rb', line 9

def assignments(role_uid:)
  raise ArgumentError, 'role_uid is required' if role_uid.nil?

  @connection.call(
    :GET,
    '/access-control/roles/{roleUID}/assignments'
      .gsub('{roleUID}', ERB::Util.url_encode(role_uid.to_s)),
    type: Grafana::Api::Models::RoleAssignmentsDTO,
    auth: ['api_key', 'basic']
  )
end

#assignments_put(role_uid:, set_role_assignments_command:) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/grafana-api/api/access_control/roles.rb', line 21

def assignments_put(role_uid:, set_role_assignments_command:)
  raise ArgumentError, 'role_uid is required' if role_uid.nil?
  raise ArgumentError, 'set_role_assignments_command is required' if set_role_assignments_command.nil?

  @connection.call(
    :PUT,
    '/access-control/roles/{roleUID}/assignments'
      .gsub('{roleUID}', ERB::Util.url_encode(role_uid.to_s)),
    type: Grafana::Api::Models::RoleAssignmentsDTO,
    auth: ['api_key', 'basic'],
    body: set_role_assignments_command
  )
end

#create(create_role_form:) ⇒ Object

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/grafana-api/api/access_control/roles.rb', line 35

def create(create_role_form:)
  raise ArgumentError, 'create_role_form is required' if create_role_form.nil?

  @connection.call(
    :POST,
    '/access-control/roles',
    type: Grafana::Api::Models::RoleDTO,
    auth: ['api_key', 'basic'],
    body: create_role_form
  )
end

#delete(role_uid:, force: nil, global: nil) ⇒ Object

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/grafana-api/api/access_control/roles.rb', line 47

def delete(role_uid:, force: nil, global: nil)
  raise ArgumentError, 'role_uid is required' if role_uid.nil?

  @connection.call(
    :DELETE,
    '/access-control/roles/{roleUID}'
      .gsub('{roleUID}', ERB::Util.url_encode(role_uid.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    query: { 'force' => force, 'global' => global }
  )
end

#get(role_uid:) ⇒ Object

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
67
68
69
70
# File 'lib/grafana-api/api/access_control/roles.rb', line 60

def get(role_uid:)
  raise ArgumentError, 'role_uid is required' if role_uid.nil?

  @connection.call(
    :GET,
    '/access-control/roles/{roleUID}'
      .gsub('{roleUID}', ERB::Util.url_encode(role_uid.to_s)),
    type: Grafana::Api::Models::RoleDTO,
    auth: ['api_key', 'basic']
  )
end

#list(delegatable: nil, include_hidden: nil, target_org_id: nil) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/grafana-api/api/access_control/roles.rb', line 72

def list(delegatable: nil, include_hidden: nil, target_org_id: nil)
  @connection.call(
    :GET,
    '/access-control/roles',
    type: [Grafana::Api::Models::RoleDTO],
    auth: ['api_key', 'basic'],
    query: { 'delegatable' => delegatable, 'includeHidden' => include_hidden, 'targetOrgId' => target_org_id }
  )
end

#update(role_uid:, update_role_command:) ⇒ Object

Raises:

  • (ArgumentError)


82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/grafana-api/api/access_control/roles.rb', line 82

def update(role_uid:, update_role_command:)
  raise ArgumentError, 'role_uid is required' if role_uid.nil?
  raise ArgumentError, 'update_role_command is required' if update_role_command.nil?

  @connection.call(
    :PUT,
    '/access-control/roles/{roleUID}'
      .gsub('{roleUID}', ERB::Util.url_encode(role_uid.to_s)),
    type: Grafana::Api::Models::RoleDTO,
    auth: ['api_key', 'basic'],
    body: update_role_command
  )
end