class Dogapi::V1::TagService
Constants
- API_VERSION
Public Instance Methods
add(host_id, tags, source=nil)
click to toggle source
Adds a list of tags to a host
# File lib/dogapi/v1/tag.rb, line 59 def add(host_id, tags, source=nil) begin params = { :api_key => @api_key, :application_key => @application_key } if source params['source'] = source end body = { :tags => tags } request(Net::HTTP::Post, '/api/' + API_VERSION + '/tags/hosts/' + host_id.to_s, params, body, true) rescue Exception => e if @silent warn e return -1, {} else raise e end end end
detach(host_id, source=nil)
click to toggle source
Remove all tags from a host
# File lib/dogapi/v1/tag.rb, line 117 def detach(host_id, source=nil) begin params = { :api_key => @api_key, :application_key => @application_key } if source params['source'] = source end request(Net::HTTP::Delete, '/api/' + API_VERSION + '/tags/hosts/' + host_id.to_s, params, nil, false) rescue Exception => e if @silent warn e return -1, {} else raise e end end end
detatch(host_id)
click to toggle source
DEPRECATED: Spelling mistake temporarily preserved as an alias.
# File lib/dogapi/v1/tag.rb, line 111 def detatch(host_id) warn "[DEPRECATION] Dogapi::V1::TagService.detatch() is deprecated. Use `detach` instead." detach(host_id) end
get(host_id, source=nil, by_source=false)
click to toggle source
Gets all tags for a given host
# File lib/dogapi/v1/tag.rb, line 34 def get(host_id, source=nil, by_source=false) begin params = { :api_key => @api_key, :application_key => @application_key } if source params['source'] = source end if by_source params['by_source'] = 'true' end request(Net::HTTP::Get, '/api/' + API_VERSION + '/tags/hosts/' + host_id.to_s, params, nil, false) rescue Exception => e if @silent warn e return -1, {} else raise e end end end
get_all(source=nil)
click to toggle source
Gets all tags in your org and the hosts tagged with them
# File lib/dogapi/v1/tag.rb, line 12 def get_all(source=nil) begin params = { :api_key => @api_key, :application_key => @application_key } if source params['source'] = source end request(Net::HTTP::Get, '/api/' + API_VERSION + '/tags/hosts', params, nil, false) rescue Exception => e if @silent warn e return -1, {} else raise e end end end
update(host_id, tags, source=nil)
click to toggle source
Remove all tags from a host and replace them with a new list
# File lib/dogapi/v1/tag.rb, line 85 def update(host_id, tags, source=nil) begin params = { :api_key => @api_key, :application_key => @application_key } if source params['source'] = source end body = { :tags => tags } request(Net::HTTP::Put, '/api/' + API_VERSION + '/tags/hosts/' + host_id.to_s, params, body, true) rescue Exception => e if @silent warn e return -1, {} else raise e end end end