Class: DogapiDemo::V1::EmbedService
- Inherits:
-
APIService
- Object
- APIService
- DogapiDemo::V1::EmbedService
- Defined in:
- lib/dogapi-demo/v1/embed.rb
Overview
EMBED API
Constant Summary collapse
- API_VERSION =
"v1"
Instance Method Summary collapse
-
#create_embed(graph_json, description = {}) ⇒ Object
Create an embeddable graph.
-
#enable_embed(embed_id) ⇒ Object
Enable a specific embed.
-
#get_all_embeds ⇒ Object
Get all embeds for the API user’s org.
-
#get_embed(embed_id, description = {}) ⇒ Object
Get a specific embed.
-
#revoke_embed(embed_id) ⇒ Object
Revoke a specific embed.
Methods inherited from APIService
#connect, #initialize, #request, #suppress_error_if_silent
Constructor Details
This class inherits a constructor from DogapiDemo::APIService
Instance Method Details
#create_embed(graph_json, description = {}) ⇒ Object
Create an embeddable graph
:graph_json => JSON: graph definition :timeframe => String: representing the interval of the graph. Default is “1_hour” :size => String: representing the size of the graph. Default is “medium”. :legend => String: flag representing whether a legend is displayed. Default is “no”. :title => String: represents title of the graph. Default is “Embed created through API.”
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/dogapi-demo/v1/embed.rb', line 54 def (graph_json, description= {}) begin params = { :api_key => @api_key, :application_key => @application_key } body = { :graph_json => graph_json, }.merge(description) request(Net::HTTP::Post, "/api/#{API_VERSION}/graph/embed", params, body, true) rescue Exception => e suppress_error_if_silent e end end |
#enable_embed(embed_id) ⇒ Object
Enable a specific embed
:embed_id => String: embed token for a specific embed
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/dogapi-demo/v1/embed.rb', line 74 def () begin params = { :api_key => @api_key, :application_key => @application_key } request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed/#{}/enable", params, nil, false) rescue Exception => e suppress_error_if_silent e end end |
#get_all_embeds ⇒ Object
Get all embeds for the API user’s org
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dogapi-demo/v1/embed.rb', line 14 def () begin params = { :api_key => @api_key, :application_key => @application_key } request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed", params, nil, false) rescue Exception => e suppress_error_if_silent e end end |
#get_embed(embed_id, description = {}) ⇒ Object
Get a specific embed
:embed_id => String: embed token for a specific embed :size => String: “small”, “medium”(defualt), “large”, or “xlarge”. :legend => String: “yes” or “no”(default) :template_vars => String: variable name => variable value (any number of template vars)
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dogapi-demo/v1/embed.rb', line 33 def (, description= {}) begin # Initialize parameters and merge with description params = { :api_key => @api_key, :application_key => @application_key, }.merge(description) request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed/#{}", params, nil, false) rescue Exception => e suppress_error_if_silent e end end |
#revoke_embed(embed_id) ⇒ Object
Revoke a specific embed
:embed_id => String: embed token for a specific embed
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/dogapi-demo/v1/embed.rb', line 90 def () begin params = { :api_key => @api_key, :application_key => @application_key } request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed/#{}/revoke", params, nil, false) rescue Exception => e suppress_error_if_silent e end end |