Class: Grafana::Api::Teams::Groups

Inherits:
Object
  • Object
show all
Defined in:
lib/grafana-api/api/teams/groups.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Groups

Returns a new instance of Groups.



5
6
7
# File 'lib/grafana-api/api/teams/groups.rb', line 5

def initialize(connection)
  @connection = connection
end

Instance Method Details

#bulk_destroy(team_id:, group_id: nil) ⇒ Object

Raises:

  • (ArgumentError)


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

def bulk_destroy(team_id:, group_id: nil)
  raise ArgumentError, 'team_id is required' if team_id.nil?

  @connection.call(
    :DELETE,
    '/teams/{teamId}/groups'
      .gsub('{teamId}', ERB::Util.url_encode(team_id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    query: { 'groupId' => group_id }
  )
end

#create(team_id:, team_group_mapping:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  @connection.call(
    :POST,
    '/teams/{teamId}/groups'
      .gsub('{teamId}', ERB::Util.url_encode(team_id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    body: team_group_mapping
  )
end

#list(team_id:) ⇒ Object

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/grafana-api/api/teams/groups.rb', line 36

def list(team_id:)
  raise ArgumentError, 'team_id is required' if team_id.nil?

  @connection.call(
    :GET,
    '/teams/{teamId}/groups'
      .gsub('{teamId}', ERB::Util.url_encode(team_id.to_s)),
    type: [Grafana::Api::Models::TeamGroupDTO],
    auth: ['api_key', 'basic']
  )
end

#search(team_id:, page: nil, perpage: nil, query: nil, name: nil) ⇒ Object

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/grafana-api/api/teams/groups.rb', line 48

def search(team_id:, page: nil, perpage: nil, query: nil, name: nil)
  raise ArgumentError, 'team_id is required' if team_id.nil?

  @connection.call(
    :GET,
    '/teams/{teamId}/groups/search'
      .gsub('{teamId}', ERB::Util.url_encode(team_id.to_s)),
    type: [Grafana::Api::Models::SearchTeamGroupsQueryResult],
    auth: ['api_key', 'basic'],
    query: { 'page' => page, 'perpage' => perpage, 'query' => query, 'name' => name }
  )
end