Created
February 8, 2019 01:52
-
-
Save snehitgajjar/d4f7b8306fc67cac2327a0dc90350883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZabbixApi::Basic | |
.get | |
calls get_full_data | |
.add | |
calls create | |
.destroy | |
calls delete | |
ZabbixApi::Basic | |
.log | |
when debug is set to true | |
prints the message | |
when debug is set to false | |
does not print the message | |
.symbolize_keys | |
when hash with string keys is passed | |
converts all the string keys to symbol | |
when string object is passed | |
returns the same object back | |
when nil object is passed | |
returns nil back | |
.normalize_hash | |
when hash is passed | |
normalizes the hash | |
duplicates the hash before modifying | |
when passed hash contains key hostid | |
deletes hostid from hash during normalization | |
.normalize_array | |
when array is passed | |
normalizes the array | |
.parse_keys | |
when hash is passed | |
returns the object id | |
when passed hash is empty | |
should be nil | |
when TrueClass is passed | |
should be truthy | |
when FalseClass is passed | |
should be falsy | |
.merge_params | |
should eq {:test1=>1, :test2=>2} | |
merged two hashes in new hash object | |
ZabbixApi::Basic | |
.initialize | |
sets passed client object as class variable | |
.method_name | |
raises an ApiError with message | |
.default_options | |
should be empty | |
.keys | |
should eq "test-keys" | |
.key | |
should eq "test-keyid" | |
.indentify | |
raises an ApiError with message | |
ZabbixApi::Basic | |
.create | |
logs the debug message | |
prints the result | |
when default_options is not empty | |
merges data with default options | |
.delete | |
logs the debug message | |
prints the result | |
.create_or_update | |
logs the debug message | |
when ID already exists | |
calls update | |
when ID does not exist | |
calls create | |
.update | |
logs the debug message | |
when dump and data are equal and force set to false | |
logs message | |
returns the integer data value based on key | |
when dump and data are equal and force set to true | |
parses the result from the api request | |
when dump and data are not equal and force set to false | |
parses the result from the api request | |
.get_full_data | |
logs the debug message | |
when api request is successful | |
returns an array of hash return by an API | |
.get_raw | |
logs the debug message | |
when api request is successful | |
returns an array of hash return by an API | |
.dump_by_id | |
logs the debug message | |
when api request is successful | |
returns an array of hash return by an API | |
.all | |
when api request is successful | |
returns an array of hash return by an API | |
.get_id | |
logs the debug message | |
when data has `indentify` as a key | |
symbolizes the data | |
returns the id from the response | |
when data does not have `indentify` as a key | |
symbolizes the data | |
.get_or_create | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
ZabbixApi::Actions | |
.method_name | |
should eq "action" | |
.indentify | |
should eq "name" | |
ZabbixApi::Applications | |
.method_name | |
should eq "application" | |
.indentify | |
should eq "name" | |
.get_or_create | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update | |
when Application ID already exist | |
updates an object returns the object ID | |
when Application ID does not exist | |
creates an object returns the newly created object ID | |
when an API request raise ApiError | |
propogates the ApiError raise by an API | |
when an API request raise HttpError | |
propogates the HttpError raise by an API | |
ZabbixApi::Configurations | |
.array_flag | |
should be truthy | |
.method_name | |
should eq "configuration" | |
.indentify | |
should eq "host" | |
.export | |
should eq {:test=>1} | |
.import | |
should eq {:test=>1} | |
ZabbixApi::BaseError | |
.initialize | |
/Users/sg045734/.rvm/gems/ruby-2.3.0/gems/rspec-mocks-3.8.0/lib/rspec/mocks/any_instance/recorder.rb:195: warning: removing `initialize' may cause serious problems | |
/Users/sg045734/.rvm/gems/ruby-2.3.0/gems/rspec-mocks-3.8.0/lib/rspec/mocks/method_double.rb:265: warning: removing `initialize' may cause serious problems | |
/Users/sg045734/.rvm/gems/ruby-2.3.0/gems/rspec-mocks-3.8.0/lib/rspec/mocks/any_instance/recorder.rb:195: warning: removing `initialize' may cause serious problems | |
calls super with error message | |
when response is passed in | |
response class variable should be set | |
error class variable should be set | |
error message class variable should be set | |
when response is not passed in | |
should not set response class variable | |
should not set error class variable | |
should not set error message class variable | |
ZabbixApi::Graphs | |
.method_name | |
should eq "graph" | |
.indentify | |
should eq "name" | |
.get_full_data | |
logs debug message | |
should eq {:test=>1} | |
.get_ids_by_host | |
when filter is not nil or filter contains name | |
returns ids of filter matching graph | |
when filter is nil | |
returns all the ids | |
when filter is not nil or filter does not contain name | |
returns an empty array | |
.get_items | |
should eq {:test=>1} | |
.get_or_create | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update | |
when Graph ID already exist | |
updates an object returns the Graph ID | |
when Graph ID does not exist | |
creates an object returns the newly created object ID | |
._update | |
updates an object returns the Graph ID | |
ZabbixApi::HostGroups | |
.method_name | |
should eq "hostgroup" | |
.indentify | |
should eq "name" | |
.key | |
should eq "groupid" | |
ZabbixApi::Hosts | |
.method_name | |
should eq "host" | |
.indentify | |
should eq "host" | |
.dump_by_id | |
logs debug message | |
should eq {:test=>1} | |
.default_options | |
should eq {:available=>1, :groups=>[], :host=>nil, :interfaces=>[], :proxy_hostid=>nil, :status=>0} | |
.unlink_templates | |
when result is an empty hash | |
should be falsy | |
when result is not an empty hash | |
should be truthy | |
.create_or_update | |
when Host ID already exist | |
updates an object returns the Host ID | |
when Host ID does not exist | |
creates an object returns the newly created object ID | |
ZabbixApi::HttpTests | |
.method_name | |
should eq "httptest" | |
.indentify | |
should eq "name" | |
.default_options | |
should eq {:hostid=>nil, :name=>nil, :steps=>[]} | |
.get_or_create | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update | |
when Host ID already exist | |
updates an object returns the Host ID | |
when Host ID does not exist | |
creates an object returns the newly created object ID | |
ZabbixApi::Items | |
.method_name | |
should eq "item" | |
.indentify | |
should eq "name" | |
.default_options | |
should eq {:authtype=>0, :data_type=>0, :delay=>60, :delay_flex=>"", :delta=>0, :formula=>0, :history=>60, :hos...sts=>"localhost", :trends=>365, :type=>7, :units=>"", :username=>"", :value_type=>3, :valuemapid=>0} | |
.get_or_create | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update | |
when Item ID already exist | |
updates an object returns the Item ID | |
when Item ID does not exist | |
creates an object returns the newly created object ID | |
ZabbixApi::Maintenance | |
.method_name | |
should eq "maintenance" | |
.indentify | |
should eq "name" | |
ZabbixApi::Mediatypes | |
.method_name | |
should eq "mediatype" | |
.indentify | |
should eq "description" | |
.default_options | |
should eq {:description=>"", :exec_path=>"", :gsm_modem=>"", :passwd=>"", :smtp_email=>"", :smtp_helo=>"", :smtp_server=>"", :type=>0, :username=>""} | |
ZabbixApi::Mediatypes | |
.method_name | |
should eq "mediatype" | |
.indentify | |
should eq "description" | |
.default_options | |
should eq {:description=>"", :exec_path=>"", :gsm_modem=>"", :passwd=>"", :smtp_email=>"", :smtp_helo=>"", :smtp_server=>"", :type=>0, :username=>""} | |
ZabbixApi::Proxies | |
.method_name | |
should eq "proxy" | |
.indentify | |
should eq "host" | |
.delete | |
when result is not empty | |
returns the id of first proxy | |
when result is empty | |
should be nil | |
.isreadable | |
should equal true or equal false | |
.iswritable | |
should equal true or equal false | |
ZabbixApi::Screens | |
.method_name | |
should eq "screen" | |
.indentify | |
should eq "name" | |
.delete | |
when result is not empty | |
returns the id of first screen | |
when result is empty | |
should be nil | |
.get_or_create_for_host | |
when screen already exist | |
returns the id of first screen | |
when screen doesn't exist | |
when data do not have all value for request | |
creates screen with default and rest of provided values | |
when data do not have all value for request | |
creates screen with values provided in data | |
ZabbixApi::Scripts | |
.method_name | |
should eq "script" | |
.indentify | |
should eq "name" | |
.execute | |
should eq "testresult" | |
.getscriptsbyhost | |
should eq "testresult" | |
ZabbixApi::Server | |
.initialize | |
sets client class variable | |
sets api_version class variable | |
ZabbixApi::Templates | |
.method_name | |
should eq "template" | |
.indentify | |
should eq "host" | |
.delete | |
when result is not empty | |
returns the id of first template | |
when result is empty | |
should be nil | |
.get_ids_by_host | |
should eq [1, 2] | |
.get_or_create | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.mass_update | |
when api_request returns empty result | |
should be falsy | |
when api_request doesn not return empty result | |
should be truthy | |
.mass_add | |
when api_request returns empty result | |
should be falsy | |
when api_request doesn not return empty result | |
should be truthy | |
.mass_remove | |
when api_request returns empty result | |
should be falsy | |
when api_request doesn not return empty result | |
should be truthy | |
ZabbixApi::Triggers | |
.method_name | |
should eq "trigger" | |
.indentify | |
should eq "description" | |
.dump_by_id | |
logs debug message | |
should eq {:test=>1} | |
.safe_update | |
logs debug message | |
when dump and data hash are equal | |
logs debug message | |
returns item_id | |
when dump and data hash are not equal | |
logs debug message | |
returns newly created item_id | |
.get_or_create | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update | |
logs debug message | |
calls get_or_create function | |
ZabbixApi::Triggers | |
.create_or_update | |
logs debug message | |
calls get_or_create | |
ZabbixApi::Usergroups | |
.method_name | |
should eq "usergroup" | |
.indentify | |
should eq "name" | |
.key | |
should eq "usrgrpid" | |
.permissions | |
when permission is provided in data | |
uses permission provided in data | |
returns first usrgrpid | |
when permission is not provided in data | |
uses permission provided in data | |
returns first usrgrpid | |
when api returns nil result | |
returns nil | |
.add_user | |
when returns result with usergroups | |
returns first usrgrpid | |
when api returns nil result | |
returns nil | |
.update_users | |
when returns result with usergroups | |
returns first usrgrpid | |
when api returns nil result | |
returns nil | |
ZabbixApi::Usermacros | |
.indentify | |
should eq "macro" | |
.method_name | |
should eq "usermacro" | |
.get_id | |
logs the debug message | |
when data has `indentify` as a key | |
symbolizes the data | |
returns the id from the response | |
when request response is empty | |
should be nil | |
when data does not have `indentify` as a key | |
symbolizes the data | |
.get_id_global | |
logs the debug message | |
when data has `indentify` as a key | |
symbolizes the data | |
returns the id from the response | |
when request response is empty | |
should be nil | |
when data does not have `indentify` as a key | |
symbolizes the data | |
.get_full_data | |
logs the debug message | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.get_full_data_global | |
logs the debug message | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.create | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.create_global | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.delete | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.delete_global | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.update | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.update_global | |
should eq [{"globalmacroid"=>"111", "testindentify"=>1}] | |
.get_or_create_global | |
logs the debug message | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update | |
when ID already exist | |
returns the existing ID | |
when id does not exist | |
returns the newly created ID | |
.create_or_update_global | |
when ID already exist | |
returns the existing ID | |
.request | |
when api response is not empty and contains result key | |
returns the first hostmacroid ID | |
when api response is empty | |
should be nil | |
when method contains `.get` | |
when result_key contains `global` | |
should eq {"globalmacroids"=>["111"]} | |
ZabbixApi::Users | |
.method_name | |
should eq "user" | |
.indentify | |
should eq "alias" | |
.key | |
should eq "userid" | |
.keys | |
should eq "userids" | |
.add_medias | |
when api_request returns nil result | |
should be nil | |
when api_request doesn not return empty result | |
returns first mediaid | |
.update_medias | |
when api_request returns nil result | |
should be nil | |
when api_request doesn not return empty result | |
returns first userid | |
ZabbixApi::ValueMaps | |
.method_name | |
should eq "valuemap" | |
.indentify | |
should eq "name" | |
.key | |
should eq "valuemapid" | |
.get_or_create | |
logs debug message | |
when id is found | |
returns the id | |
when id is not found | |
creates a new id | |
.create_or_update | |
when id is found | |
updates the data valueid item | |
when id is not found | |
creates a new valueid item | |
ZabbixApi::Client | |
.id | |
should be a kind of Integer | |
be in between 0 to 100_000 | |
.api_version | |
gets version using api_request | |
when api_version is already set | |
does not request an api for version | |
.auth | |
gets auth using api request | |
.initialize | |
when proxy is provided and no_proxy flag is false | |
sets proxy class variables | |
sets auth_hash | |
when proxy is provided and no_proxy flag is true | |
does not proxy class variables | |
sets auth_hash | |
when proxy is not provided and no_proxy flag is false | |
does not proxy class variables | |
sets auth_hash | |
when major api_version is not supported | |
sets auth_hash | |
.message_json | |
when method is apiinfo.version | |
adds auth information before generating json | |
when method is user.login | |
adds auth information before generating json | |
when method is not `apiinfo.version` or `user.login` | |
adds auth information before generating json | |
.http_request | |
when response code is 200 | |
returns the response body | |
when response code is not 200 | |
raises HttpError | |
when timeout is given as an option | |
sets provided timeout | |
when proxy_uri is not provided | |
create http object without proxy | |
when debug is set to true | |
logs messages | |
._request | |
logs DEBUG message | |
returns result from the response | |
when result contains error | |
raises ApiError | |
.pretty_body | |
when body doesn not contain password as param | |
returns unparsed body | |
when body contains password as param | |
changes password to `***` | |
.api_request | |
should eq {"result"=>"testresult"} | |
Finished in 0.17314 seconds (files took 0.256 seconds to load) | |
257 examples, 0 failures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment