class DogapiDemo::V1::EmbedService
¶ ↑
EMBED API
¶ ↑
Constants
- API_VERSION
Public Instance Methods
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.”
# File lib/dogapi-demo/v1/embed.rb 54 def create_embed(graph_json, description= {}) 55 begin 56 params = { 57 :api_key => @api_key, 58 :application_key => @application_key 59 } 60 61 body = { 62 :graph_json => graph_json, 63 }.merge(description) 64 65 request(Net::HTTP::Post, "/api/#{API_VERSION}/graph/embed", params, body, true) 66 rescue Exception => e 67 suppress_error_if_silent e 68 end 69 end
Enable a specific embed
:embed_id => String: embed token for a specific embed
# File lib/dogapi-demo/v1/embed.rb 74 def enable_embed(embed_id) 75 begin 76 params = { 77 :api_key => @api_key, 78 :application_key => @application_key 79 } 80 81 request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed/#{embed_id}/enable", params, nil, false) 82 rescue Exception => e 83 suppress_error_if_silent e 84 end 85 end
Get all embeds for the API user's org
# File lib/dogapi-demo/v1/embed.rb 14 def get_all_embeds() 15 begin 16 params = { 17 :api_key => @api_key, 18 :application_key => @application_key 19 } 20 21 request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed", params, nil, false) 22 rescue Exception => e 23 suppress_error_if_silent e 24 end 25 end
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)
# File lib/dogapi-demo/v1/embed.rb 33 def get_embed(embed_id, description= {}) 34 begin 35 # Initialize parameters and merge with description 36 params = { 37 :api_key => @api_key, 38 :application_key => @application_key, 39 }.merge(description) 40 41 request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed/#{embed_id}", params, nil, false) 42 rescue Exception => e 43 suppress_error_if_silent e 44 end 45 end
Revoke a specific embed
:embed_id => String: embed token for a specific embed
# File lib/dogapi-demo/v1/embed.rb 90 def revoke_embed(embed_id) 91 begin 92 params = { 93 :api_key => @api_key, 94 :application_key => @application_key 95 } 96 97 request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/embed/#{embed_id}/revoke", params, nil, false) 98 rescue Exception => e 99 suppress_error_if_silent e 100 end 101 end