Class: Grafana::Api::Orgs

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

Defined Under Namespace

Classes: Name, Quotas, Users

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Orgs

Returns a new instance of Orgs.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#address(org_id:, update_org_address_form:) ⇒ Object

Raises:

  • (ArgumentError)


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

def address(org_id:, update_org_address_form:)
  raise ArgumentError, 'org_id is required' if org_id.nil?
  raise ArgumentError, 'update_org_address_form is required' if update_org_address_form.nil?

  @connection.call(
    :PUT,
    '/orgs/{org_id}/address'
      .gsub('{org_id}', ERB::Util.url_encode(org_id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    body: update_org_address_form
  )
end

#create(create_org_command:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  @connection.call(
    :POST,
    '/orgs',
    type: Grafana::Api::Models::CreateOrg200Response,
    auth: ['api_key', 'basic'],
    body: create_org_command
  )
end

#delete(org_id:) ⇒ Object

Raises:

  • (ArgumentError)


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

def delete(org_id:)
  raise ArgumentError, 'org_id is required' if org_id.nil?

  @connection.call(
    :DELETE,
    '/orgs/{org_id}'
      .gsub('{org_id}', ERB::Util.url_encode(org_id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['basic']
  )
end

#get(org_id:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  @connection.call(
    :GET,
    '/orgs/{org_id}'
      .gsub('{org_id}', ERB::Util.url_encode(org_id.to_s)),
    type: Grafana::Api::Models::OrgDetailsDTO,
    auth: ['basic']
  )
end

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



59
60
61
62
63
64
65
66
67
# File 'lib/grafana-api/api/orgs.rb', line 59

def list(page: nil, perpage: nil, name: nil, query: nil)
  @connection.call(
    :GET,
    '/orgs',
    type: [Grafana::Api::Models::OrgDTO],
    auth: ['basic'],
    query: { 'page' => page, 'perpage' => perpage, 'name' => name, 'query' => query }
  )
end

#update(org_id:, update_org_form:) ⇒ Object

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/grafana-api/api/orgs.rb', line 69

def update(org_id:, update_org_form:)
  raise ArgumentError, 'org_id is required' if org_id.nil?
  raise ArgumentError, 'update_org_form is required' if update_org_form.nil?

  @connection.call(
    :PUT,
    '/orgs/{org_id}'
      .gsub('{org_id}', ERB::Util.url_encode(org_id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['basic'],
    body: update_org_form
  )
end