Class: Dogapi::V1::DashboardListService

Inherits:
APIService
  • Object
show all
Defined in:
lib/dogapi/v1/dashboard_list.rb

Overview

Dashboard List API

Constant Summary collapse

API_VERSION =
'v1'
RESOURCE_NAME =
'dashboard/lists/manual'
SUB_RESOURCE_NAME =
'dashboards'

Instance Attribute Summary

Attributes inherited from APIService

#api_key, #application_key

Instance Method Summary collapse

Methods inherited from APIService

#connect, #handle_redirect, #handle_response, #initialize, #prepare_params, #prepare_request, #request, #should_set_api_and_app_keys_in_params?, #suppress_error_if_silent

Constructor Details

This class inherits a constructor from Dogapi::APIService

Instance Method Details

#add_items(resource_id, dashboards) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/dogapi/v1/dashboard_list.rb', line 53

def add_items(resource_id, dashboards)
  body = {
    dashboards: dashboards
  }

  request(
    Net::HTTP::Post,
    "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}/#{SUB_RESOURCE_NAME}",
    nil,
    body,
    true
  )
end

#allObject



35
36
37
# File 'lib/dogapi/v1/dashboard_list.rb', line 35

def all
  request(Net::HTTP::Get, "/api/#{API_VERSION}/#{RESOURCE_NAME}", nil, nil, false)
end

#create(name) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/dogapi/v1/dashboard_list.rb', line 15

def create(name)
  body = {
    name: name
  }

  request(Net::HTTP::Post, "/api/#{API_VERSION}/#{RESOURCE_NAME}", nil, body, true)
end

#delete(resource_id) ⇒ Object



39
40
41
# File 'lib/dogapi/v1/dashboard_list.rb', line 39

def delete(resource_id)
  request(Net::HTTP::Delete, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}", nil, nil, false)
end

#delete_items(resource_id, dashboards) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/dogapi/v1/dashboard_list.rb', line 81

def delete_items(resource_id, dashboards)
  body = {
    dashboards: dashboards
  }

  request(
    Net::HTTP::Delete,
    "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}/#{SUB_RESOURCE_NAME}",
    nil,
    body,
    true
  )
end

#get(resource_id) ⇒ Object



31
32
33
# File 'lib/dogapi/v1/dashboard_list.rb', line 31

def get(resource_id)
  request(Net::HTTP::Get, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}", nil, nil, false)
end

#get_items(resource_id) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/dogapi/v1/dashboard_list.rb', line 43

def get_items(resource_id)
  request(
    Net::HTTP::Get,
    "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}/#{SUB_RESOURCE_NAME}",
    nil,
    nil,
    false
  )
end

#update(resource_id, name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/dogapi/v1/dashboard_list.rb', line 23

def update(resource_id, name)
  body = {
    name: name
  }

  request(Net::HTTP::Put, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}", nil, body, true)
end

#update_items(resource_id, dashboards) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/dogapi/v1/dashboard_list.rb', line 67

def update_items(resource_id, dashboards)
  body = {
    dashboards: dashboards
  }

  request(
    Net::HTTP::Put,
    "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{resource_id}/#{SUB_RESOURCE_NAME}",
    nil,
    body,
    true
  )
end