Class: Samanage::Api
- Inherits:
-
Object
- Object
- Samanage::Api
- Includes:
- HTTParty
- Defined in:
- lib/samanage/api.rb,
lib/samanage/api/sites.rb,
lib/samanage/api/users.rb,
lib/samanage/api/utils.rb,
lib/samanage/api/groups.rb,
lib/samanage/api/changes.rb,
lib/samanage/api/mobiles.rb,
lib/samanage/api/category.rb,
lib/samanage/api/comments.rb,
lib/samanage/api/problems.rb,
lib/samanage/api/contracts.rb,
lib/samanage/api/hardwares.rb,
lib/samanage/api/incidents.rb,
lib/samanage/api/requester.rb,
lib/samanage/api/solutions.rb,
lib/samanage/api/attachments.rb,
lib/samanage/api/departments.rb,
lib/samanage/api/time_tracks.rb,
lib/samanage/api/custom_forms.rb,
lib/samanage/api/other_assets.rb,
lib/samanage/api/custom_fields.rb
Constant Summary collapse
- MAX_RETRIES =
3- PATHS =
{ category: 'categories.json', contract: 'contracts.json', change: 'changes.json', custom_fields: 'custom_fields.json', custom_forms: 'custom_forms.json', department: 'departments.json', group: 'groups.json', hardware: 'hardwares.json', problem: 'problems.json', incident: 'incidents.json', mobile: 'mobiles.json', other_asset: 'other_assets.json', site: 'sites.json', solution: 'solutions.json', user: 'users.json', }
Instance Attribute Summary collapse
-
#admins ⇒ Object
Returns the value of attribute admins.
-
#authorized ⇒ Object
Returns the value of attribute authorized.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#custom_forms ⇒ Object
Returns the value of attribute custom_forms.
-
#datacenter ⇒ Object
Returns the value of attribute datacenter.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #add_item_to_contract(id:, payload:) ⇒ Object
- #add_member_to_group(email:, group_id: nil, group_name: nil) ⇒ Object
-
#authorize ⇒ Object
Check “oken against api.json”.
- #authorized? ⇒ Boolean
-
#check_contract(options: {}) ⇒ Object
Check for contract using URL builder.
-
#check_hardware(options: {}) ⇒ Object
Check for hardware using URL builder.
-
#check_mobile(options: {}) ⇒ Object
Check for mobile using URL builder.
-
#check_user(field: 'email', value:, options: {}) ⇒ Object
Check for user by field (ex: users.json?field=value).
-
#collect_categories(options: {}) ⇒ Object
(also: #categories)
Samanage categories are not paginated - to break into subcategories, add.
-
#collect_changes(options: {}) ⇒ Object
(also: #changes)
Returns all changes.
-
#collect_contracts(options: {}) ⇒ Object
(also: #contracts)
Get all contracts.
-
#collect_custom_fields(options: {}) ⇒ Object
(also: #custom_fields)
Gets all custom fields.
-
#collect_custom_forms(options: {}) ⇒ Object
Get all custom forms.
- #collect_departments(options: {}) ⇒ Object (also: #departments)
- #collect_groups(options: {}) ⇒ Object (also: #groups)
-
#collect_hardwares(options: {}) ⇒ Object
(also: #hardwares)
Get all hardwares.
-
#collect_incidents(options: {}) ⇒ Object
(also: #incidents)
Returns all incidents.
-
#collect_mobiles(options: {}) ⇒ Object
(also: #mobiles)
Get all mobiles.
-
#collect_other_assets(options: {}) ⇒ Object
(also: #other_assets)
Returns all other assets.
-
#collect_problems(options: {}) ⇒ Object
(also: #problems)
Returns all problems.
- #collect_sites(options: {}) ⇒ Object (also: #sites)
- #collect_solutions(options: {}) ⇒ Object (also: #solutions)
-
#collect_users(options: {}) ⇒ Object
(also: #users)
Returns all users in the account.
- #create_category(payload: nil, options: {}) ⇒ Object
-
#create_change(payload: nil, options: {}) ⇒ Object
Create an change given json.
-
#create_comment(incident_id:, comment:, options: {}) ⇒ Object
Add a new comment.
-
#create_contract(payload:, options: {}) ⇒ Object
Create contract given json payload.
- #create_department(payload:, options: {}) ⇒ Object
- #create_group(payload:, options: {}) ⇒ Object
-
#create_hardware(payload:, options: {}) ⇒ Object
Create hardware given json payload.
-
#create_incident(payload: nil, options: {}) ⇒ Object
Create an incident given json.
-
#create_mobile(payload: nil, options: {}) ⇒ Object
Create mobile given json payload.
-
#create_other_asset(payload:, options: {}) ⇒ Object
Create an other_asset given json.
-
#create_problem(payload: nil, options: {}) ⇒ Object
Create an problem given json.
- #create_site(payload:, options: {}) ⇒ Object
- #create_solution(payload:, options: {}) ⇒ Object
- #create_time_track(incident_id:, payload:) ⇒ Object
-
#create_user(payload:, options: {}) ⇒ Object
Create user given JSON.
- #delete_category(id:) ⇒ Object
- #delete_change(id:) ⇒ Object
- #delete_contract(id:) ⇒ Object
- #delete_department(id:) ⇒ Object
- #delete_group(id:) ⇒ Object
- #delete_hardware(id:) ⇒ Object
- #delete_incident(id:) ⇒ Object
- #delete_mobile(id:) ⇒ Object
- #delete_other_asset(id:) ⇒ Object
- #delete_problem(id:) ⇒ Object
- #delete_site(id:) ⇒ Object
- #delete_solution(id:) ⇒ Object
- #delete_user(id:) ⇒ Object
- #download_attachment(attachment: {}, filename: nil, path: nil) ⇒ Object
-
#execute(http_method: 'get', path: nil, payload: nil, verbose: nil, headers: {}) ⇒ Object
Calling execute without a method defaults to GET.
-
#find_change(id:, options: {}) ⇒ Object
Find change by ID.
-
#find_contract(id:) ⇒ Object
Find contract given id.
- #find_group(id:) ⇒ Object
- #find_group_id_by_name(group: '', options: {}) ⇒ Object
-
#find_hardware(id:) ⇒ Object
Find hardware given id.
-
#find_hardwares_by_serial(serial_number:) ⇒ Object
Find hardware given a serial number.
-
#find_incident(id:, options: {}) ⇒ Object
Find incident by ID.
-
#find_mobile(id: nil) ⇒ Object
Find mobile given id.
-
#find_other_asset(id:) ⇒ Object
Find other_asset by id.
-
#find_problem(id:, options: {}) ⇒ Object
Find problem by ID.
-
#find_user(id:) ⇒ Object
Return user by ID.
-
#find_user_group_id_by_email(email:) ⇒ Object
Returns nil if no matching group_id.
-
#find_user_id_by_email(email:) ⇒ Object
Email is unique so compare first for exact match only.
-
#form_for(object_type: nil) ⇒ Object
Get form for a specific object type.
- #get_categories(path: PATHS[:category], options: {}) ⇒ Object
-
#get_changes(path: PATHS[:change], options: {}) ⇒ Object
Default get change path.
-
#get_comments(incident_id:) ⇒ Object
(also: #comments)
Find comments given incident_id.
-
#get_contracts(path: PATHS[:contract], options: {}) ⇒ Object
Get contract default path.
-
#get_custom_fields(path: PATHS[:custom_fields], options: {}) ⇒ Object
Get custom fields default url.
-
#get_custom_forms(path: PATHS[:custom_forms], options: {}) ⇒ Object
Get custom forms path.
- #get_departments(path: PATHS[:department], options: {}) ⇒ Object
- #get_groups(path: PATHS[:group], options: {}) ⇒ Object
-
#get_hardwares(path: PATHS[:hardware], options: {}) ⇒ Object
Get hardware default path.
-
#get_incidents(path: PATHS[:incident], options: {}) ⇒ Object
Default get incident path.
-
#get_mobiles(path: PATHS[:mobile], options: {}) ⇒ Object
Get mobile default path.
-
#get_other_assets(path: PATHS[:other_asset], options: {}) ⇒ Object
Default get other_assets path.
-
#get_problems(path: PATHS[:problem], options: {}) ⇒ Object
Default get problem path.
-
#get_requester_id(value:) ⇒ Object
Get requester from value (email).
- #get_sites(path: PATHS[:site], options: {}) ⇒ Object
- #get_solutions(path: PATHS[:solution], options: {}) ⇒ Object
-
#get_users(path: PATHS[:user], options: {}) ⇒ Object
Get users, using URL builder.
-
#initialize(token:, datacenter: nil, development_mode: false, max_retries: MAX_RETRIES, content_type: 'json') ⇒ Api
constructor
Development mode forces authorization & pre-populates admins and custom forms / fields datacenter should equal ‘eu’ or blank.
-
#list_admins ⇒ Object
Return all admins in the account.
-
#organize_forms ⇒ Object
Set forms by type and map fields.
- #send_activation_email(email:) ⇒ Object
- #set_params(options:) ⇒ Object
- #time_tracks(incident_id:) ⇒ Object
-
#update_change(payload:, id:, options: {}) ⇒ Object
Update an change given id and json.
-
#update_contract(payload:, id:, options: {}) ⇒ Object
Update contract given id.
-
#update_hardware(payload:, id:, options: {}) ⇒ Object
Update hardware given id.
-
#update_incident(payload:, id:, options: {}) ⇒ Object
Update an incident given id and json.
-
#update_mobile(payload:, id:, options: {}) ⇒ Object
Update mobile given id.
-
#update_other_asset(payload:, id:, options: {}) ⇒ Object
Update other_asset given json and id.
-
#update_problem(payload:, id:, options: {}) ⇒ Object
Update an problem given id and json.
- #update_solution(id:, payload:, options: {}) ⇒ Object
- #update_time_track(incident_id:, time_track_id:, payload:) ⇒ Object
-
#update_user(payload:, id:) ⇒ Object
Update user by id.
Constructor Details
#initialize(token:, datacenter: nil, development_mode: false, max_retries: MAX_RETRIES, content_type: 'json') ⇒ Api
Development mode forces authorization & pre-populates admins and custom forms / fields datacenter should equal ‘eu’ or blank
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/samanage/api.rb', line 27 def initialize(token: , datacenter: nil, development_mode: false, max_retries: MAX_RETRIES, content_type: 'json') self.token = token if !datacenter.nil? && datacenter.to_s.downcase != 'eu' datacenter = nil end self.datacenter ||= datacenter.to_s.downcase self.base_url = "https://api#{self.datacenter.to_s.downcase}.samanage.com/" self.content_type = 'json' self.admins = [] self.max_retries = max_retries if development_mode if self. != true self. end self.custom_forms = self.organize_forms self.admins = self.list_admins end end |
Instance Attribute Details
#admins ⇒ Object
Returns the value of attribute admins.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def admins @admins end |
#authorized ⇒ Object
Returns the value of attribute authorized.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def end |
#base_url ⇒ Object
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def base_url @base_url end |
#content_type ⇒ Object
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def content_type @content_type end |
#custom_forms ⇒ Object
Returns the value of attribute custom_forms.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def custom_forms @custom_forms end |
#datacenter ⇒ Object
Returns the value of attribute datacenter.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def datacenter @datacenter end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def max_retries @max_retries end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/samanage/api.rb', line 6 def token @token end |
Instance Method Details
#add_item_to_contract(id:, payload:) ⇒ Object
53 54 55 56 |
# File 'lib/samanage/api/contracts.rb', line 53 def add_item_to_contract(id: , payload: ) path = "contracts/#{id}/items.json" self.execute(path: path, http_method: 'post', payload: payload) end |
#add_member_to_group(email:, group_id: nil, group_name: nil) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/samanage/api/groups.rb', line 47 def add_member_to_group(email: , group_id: nil, group_name: nil) group_id = group_id ||= self.find_group_id_by_name(group: group_name) user_id = self.find_user_id_by_email(email: email) member_path = "memberships.json?group_id=#{group_id}.json&user_ids=#{user_id}" self.execute(path: member_path, http_method: 'post') end |
#authorize ⇒ Object
Check “oken against api.json”
51 52 53 54 |
# File 'lib/samanage/api.rb', line 51 def self.execute(path: "api.#{self.content_type}") self. = true end |
#authorized? ⇒ Boolean
46 47 48 |
# File 'lib/samanage/api.rb', line 46 def self. end |
#check_contract(options: {}) ⇒ Object
Check for contract using URL builder
42 43 44 45 |
# File 'lib/samanage/api/contracts.rb', line 42 def check_contract(options: {}) url = Samanage::UrlBuilder.new(path: PATHS[:contract], options: ).url self.execute(path: url) end |
#check_hardware(options: {}) ⇒ Object
Check for hardware using URL builder
49 50 51 52 |
# File 'lib/samanage/api/hardwares.rb', line 49 def check_hardware(options: {}) url = Samanage::UrlBuilder.new(path: PATHS[:hardware], options: ).url self.execute(path: url) end |
#check_mobile(options: {}) ⇒ Object
Check for mobile using URL builder
43 44 45 46 |
# File 'lib/samanage/api/mobiles.rb', line 43 def check_mobile(options: {}) url = Samanage::UrlBuilder.new(path: PATHS[:mobile], options: ).url self.execute(path: url) end |
#check_user(field: 'email', value:, options: {}) ⇒ Object
Check for user by field (ex: users.json?field=value)
64 65 66 67 68 69 70 |
# File 'lib/samanage/api/users.rb', line 64 def check_user(field: 'email', value: , options: {}) if field.to_s.downcase == 'email' value = value.to_s.gsub("+",'%2B') end url = "users.json?#{field}=#{value}" self.execute(path: url) end |
#collect_categories(options: {}) ⇒ Object Also known as: categories
Samanage categories are not paginated
-
to break into subcategories, add
12 13 14 15 |
# File 'lib/samanage/api/category.rb', line 12 def collect_categories(options: {}) request = self.execute(http_method: 'get', path: "categories.json") request[:data] end |
#collect_changes(options: {}) ⇒ Object Also known as: changes
Returns all changes. Options:
- audit_archives: true
- layout: 'long'
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/samanage/api/changes.rb', line 16 def collect_changes(options: {}) changes = Array.new total_pages = self.get_changes(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting changes page: #{page}/#{total_pages}" if [:verbose] path = "changes.json?" + params request = self.execute(http_method: 'get', path: path) request[:data].each do |change| if block_given? yield change end changes << change end end changes end |
#collect_contracts(options: {}) ⇒ Object Also known as: contracts
Get all contracts
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/samanage/api/contracts.rb', line 12 def collect_contracts(options: {}) contracts = Array.new total_pages = self.get_contracts(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting contracts page: #{page}/#{total_pages}" if [:verbose] path = "contracts.json?#{params}" self.execute(path: path)[:data].each do |contract| if block_given? yield contract end contracts << contract end end contracts end |
#collect_custom_fields(options: {}) ⇒ Object Also known as: custom_fields
Gets all custom fields
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/samanage/api/custom_fields.rb', line 12 def collect_custom_fields(options: {}) custom_fields = Array.new total_pages = self.get_custom_fields(options: )[:total_pages] ||= 2 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Custom Fields page: #{page}/#{total_pages}" if [:verbose] path = "custom_fields.json?#{params}" self.execute(path: path)[:data].each do |custom_field| if block_given? yield custom_field end custom_fields << custom_field end end custom_fields end |
#collect_custom_forms(options: {}) ⇒ Object
Get all custom forms
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/samanage/api/custom_forms.rb', line 10 def collect_custom_forms(options: {}) custom_forms = Array.new total_pages = self.get_custom_forms(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Custom Forms page: #{page}/#{total_pages}" if [:verbose] path = "custom_forms.json?#{params}" self.execute(path: path)[:data].each do |custom_form| if block_given? yield custom_form end custom_forms << custom_form end end custom_forms end |
#collect_departments(options: {}) ⇒ Object Also known as: departments
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/samanage/api/departments.rb', line 9 def collect_departments(options: {}) departments = Array.new total_pages = self.get_departments(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Departments page: #{page}/#{total_pages}" if [:verbose] path = "departments.json?#{params}" self.execute(path: path)[:data].each do |department| if block_given? yield department end departments << department end end departments end |
#collect_groups(options: {}) ⇒ Object Also known as: groups
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/samanage/api/groups.rb', line 9 def collect_groups(options: {}) groups = Array.new total_pages = self.get_groups(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Groups page: #{page}/#{total_pages}" if [:verbose] path = 'groups.json?' + params self.execute(path: path)[:data].each do |group| if block_given? yield group end groups << group end end groups end |
#collect_hardwares(options: {}) ⇒ Object Also known as: hardwares
Get all hardwares
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/samanage/api/hardwares.rb', line 12 def collect_hardwares(options: {}) hardwares = Array.new total_pages = self.get_hardwares(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Hardwares page: #{page}/#{total_pages}" if [:verbose] path = "hardwares.json?#{params}" self.execute(path: path)[:data].each do |hardware| if block_given? yield hardware end hardwares << hardware end end hardwares end |
#collect_incidents(options: {}) ⇒ Object Also known as: incidents
Returns all incidents. Options:
- audit_archives: true
- layout: 'long'
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/samanage/api/incidents.rb', line 16 def collect_incidents(options: {}) incidents = Array.new total_pages = self.get_incidents(options: )[:total_pages] puts "Pulling Incidents with Audit Archives (this may take a while)" if [:audit_archives] && [:verbose] 1.upto(total_pages) do |page| puts "Collecting Incidents page: #{page}/#{total_pages}" if [:verbose] if [:audit_archives] [:page] = page params = URI.encode_www_form(.except!(:layout,'layout')) # layout not needed as audit only on individual record paginated_path = "incidents.json?" + params paginated_incidents = self.execute(path: paginated_path)[:data] paginated_incidents.map do |incident| params = self.set_params(options: ) archive_uri = "incidents/#{incident['id']}.json?layout=long&audit_archive=true" incident_with_archive = self.execute(path: archive_uri)[:data] if block_given? yield incident_with_archive end incidents.push(incident_with_archive) end else [:page] = page params = self.set_params(options: ) path = "incidents.json?" + params self.execute(path: path)[:data].each do |incident| if block_given? yield incident end incidents.push(incident) end end end incidents end |
#collect_mobiles(options: {}) ⇒ Object Also known as: mobiles
Get all mobiles
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/samanage/api/mobiles.rb', line 13 def collect_mobiles(options: {}) mobiles = Array.new total_pages = self.get_mobiles(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Mobiles page: #{page}/#{total_pages}" if [:verbose] path = "mobiles.json?#{params}" self.execute(path: path)[:data].each do |mobile| if block_given? yield mobiles end mobiles << mobile end end mobiles end |
#collect_other_assets(options: {}) ⇒ Object Also known as: other_assets
Returns all other assets
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/samanage/api/other_assets.rb', line 12 def collect_other_assets(options: {}) other_assets = Array.new total_pages = self.get_other_assets(options: )[:total_pages] other_assets = [] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Other Assets page: #{page}/#{total_pages}" if [:verbose] path = "other_assets.json?#{params}" self.execute(path: path)[:data].each do |other_asset| if block_given? yield other_asset end other_assets << other_asset end end other_assets end |
#collect_problems(options: {}) ⇒ Object Also known as: problems
Returns all problems. Options:
- audit_archives: true
- layout: 'long'
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/samanage/api/problems.rb', line 16 def collect_problems(options: {}) problems = Array.new total_pages = self.get_problems(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting problems page: #{page}/#{total_pages}" if [:verbose] path = "problems.json?" + params request = self.execute(http_method: 'get', path: path) request[:data].each do |problem| if block_given? yield problem end problems << problem end end problems end |
#collect_sites(options: {}) ⇒ Object Also known as: sites
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/samanage/api/sites.rb', line 9 def collect_sites(options: {}) sites = Array.new total_pages = self.get_sites(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Sites page: #{page}/#{total_pages}" if [:verbose] path = "sites.json?" + params self.execute(path: path)[:data].each do |site| if block_given? yield site end sites << site end end sites end |
#collect_solutions(options: {}) ⇒ Object Also known as: solutions
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/samanage/api/solutions.rb', line 9 def collect_solutions(options: {}) solutions = Array.new total_pages = self.get_solutions(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) puts "Collecting Solutions page: #{page}/#{total_pages}" if [:verbose] path = "solutions.json?" + params self.execute(http_method: 'get', path: path)[:data].each do |solution| if block_given? yield solution end solutions << solution end end solutions end |
#collect_users(options: {}) ⇒ Object Also known as: users
Returns all users in the account
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/samanage/api/users.rb', line 12 def collect_users(options: {}) users = Array.new total_pages = self.get_users(options: )[:total_pages] 1.upto(total_pages) do |page| [:page] = page params = self.set_params(options: ) path = "users.json?" + params puts "Collecting Users page: #{page}/#{total_pages}" if [:verbose] path = "users.json?#{params}" self.execute(path: path)[:data].each do |user| if block_given? yield user end users << user end end users end |
#create_category(payload: nil, options: {}) ⇒ Object
17 18 19 |
# File 'lib/samanage/api/category.rb', line 17 def create_category(payload: nil, options: {}) self.execute(path: PATHS[:category], http_method: 'post', payload: payload) end |
#create_change(payload: nil, options: {}) ⇒ Object
Create an change given json
37 38 39 |
# File 'lib/samanage/api/changes.rb', line 37 def create_change(payload: nil, options: {}) self.execute(path: PATHS[:change], http_method: 'post', payload: payload) end |
#create_comment(incident_id:, comment:, options: {}) ⇒ Object
Add a new comment
12 13 14 15 16 |
# File 'lib/samanage/api/comments.rb', line 12 def create_comment(incident_id: , comment: , options: {}) params = self.set_params(options: ) path = "incidents/#{incident_id}/comments.json?" + params self.execute(http_method: 'post', path: path, payload: comment) end |
#create_contract(payload:, options: {}) ⇒ Object
Create contract given json payload
31 32 33 |
# File 'lib/samanage/api/contracts.rb', line 31 def create_contract(payload: , options: {}) self.execute(path: PATHS[:contract], http_method: 'post', payload: payload) end |
#create_department(payload:, options: {}) ⇒ Object
27 28 29 30 |
# File 'lib/samanage/api/departments.rb', line 27 def create_department(payload: , options: {}) self.execute(path: PATHS[:department], http_method: 'post', payload: payload) end |
#create_group(payload:, options: {}) ⇒ Object
27 28 29 |
# File 'lib/samanage/api/groups.rb', line 27 def create_group(payload: , options: {}) self.execute(path: PATHS[:group], http_method: 'post', payload: payload) end |
#create_hardware(payload:, options: {}) ⇒ Object
Create hardware given json payload
31 32 33 |
# File 'lib/samanage/api/hardwares.rb', line 31 def create_hardware(payload: , options: {}) self.execute(path: PATHS[:hardware], http_method: 'post', payload: payload) end |
#create_incident(payload: nil, options: {}) ⇒ Object
Create an incident given json
53 54 55 |
# File 'lib/samanage/api/incidents.rb', line 53 def create_incident(payload: nil, options: {}) self.execute(path: PATHS[:incident], http_method: 'post', payload: payload) end |
#create_mobile(payload: nil, options: {}) ⇒ Object
Create mobile given json payload
32 33 34 |
# File 'lib/samanage/api/mobiles.rb', line 32 def create_mobile(payload: nil, options: {}) self.execute(path: PATHS[:mobile], http_method: 'post', payload: payload) end |
#create_other_asset(payload:, options: {}) ⇒ Object
Create an other_asset given json
33 34 35 |
# File 'lib/samanage/api/other_assets.rb', line 33 def create_other_asset(payload: , options: {}) self.execute(path: PATHS[:other_asset], http_method: 'post', payload: payload) end |
#create_problem(payload: nil, options: {}) ⇒ Object
Create an problem given json
37 38 39 |
# File 'lib/samanage/api/problems.rb', line 37 def create_problem(payload: nil, options: {}) self.execute(path: PATHS[:problem], http_method: 'post', payload: payload) end |
#create_site(payload:, options: {}) ⇒ Object
27 28 29 |
# File 'lib/samanage/api/sites.rb', line 27 def create_site(payload: , options: {}) self.execute(path: PATHS[:site], http_method: 'post', payload: payload) end |
#create_solution(payload:, options: {}) ⇒ Object
27 28 29 |
# File 'lib/samanage/api/solutions.rb', line 27 def create_solution(payload: , options: {}) self.execute(path: PATHS[:solution], http_method: 'post', payload: payload) end |
#create_time_track(incident_id:, payload:) ⇒ Object
7 8 9 |
# File 'lib/samanage/api/time_tracks.rb', line 7 def create_time_track(incident_id: , payload: ) self.execute(path: "incidents/#{incident_id}/time_tracks.json", http_method: 'post', payload: payload) end |
#create_user(payload:, options: {}) ⇒ Object
Create user given JSON
32 33 34 |
# File 'lib/samanage/api/users.rb', line 32 def create_user(payload: , options: {}) self.execute(path: PATHS[:user], http_method: 'post', payload: payload) end |
#delete_category(id:) ⇒ Object
21 22 23 |
# File 'lib/samanage/api/category.rb', line 21 def delete_category(id: ) self.execute(path: "categories/#{id}", http_method: 'delete') end |
#delete_change(id:) ⇒ Object
56 57 58 |
# File 'lib/samanage/api/changes.rb', line 56 def delete_change(id: ) self.execute(path: "changes/#{id}.json", http_method: 'delete') end |
#delete_contract(id:) ⇒ Object
58 59 60 |
# File 'lib/samanage/api/contracts.rb', line 58 def delete_contract(id: ) self.execute(path: "contracts/#{id}.json", http_method: 'delete') end |
#delete_department(id:) ⇒ Object
31 32 33 |
# File 'lib/samanage/api/departments.rb', line 31 def delete_department(id: ) self.execute(path: "departments/#{id}.json", http_method: 'delete') end |
#delete_group(id:) ⇒ Object
54 55 56 |
# File 'lib/samanage/api/groups.rb', line 54 def delete_group(id: ) self.execute(path: "groups/#{id}.json", http_method: 'delete') end |
#delete_hardware(id:) ⇒ Object
60 61 62 |
# File 'lib/samanage/api/hardwares.rb', line 60 def delete_hardware(id: ) self.execute(path: "hardwares/#{id}.json", http_method: 'delete') end |
#delete_incident(id:) ⇒ Object
72 73 74 |
# File 'lib/samanage/api/incidents.rb', line 72 def delete_incident(id: ) self.execute(path: "incidents/#{id}.json", http_method: 'delete') end |
#delete_mobile(id:) ⇒ Object
54 55 56 |
# File 'lib/samanage/api/mobiles.rb', line 54 def delete_mobile(id: ) self.execute(path: "mobiles/#{id}.json", http_method: 'delete') end |
#delete_other_asset(id:) ⇒ Object
50 51 52 |
# File 'lib/samanage/api/other_assets.rb', line 50 def delete_other_asset(id: ) self.execute(path: "other_assets/#{id}.json", http_method: 'delete') end |
#delete_problem(id:) ⇒ Object
56 57 58 |
# File 'lib/samanage/api/problems.rb', line 56 def delete_problem(id: ) self.execute(path: "problems/#{id}.json", http_method: 'delete') end |
#delete_site(id:) ⇒ Object
31 32 33 |
# File 'lib/samanage/api/sites.rb', line 31 def delete_site(id: ) self.execute(path: "sites/#{id}.json", http_method: 'delete') end |
#delete_solution(id:) ⇒ Object
35 36 37 |
# File 'lib/samanage/api/solutions.rb', line 35 def delete_solution(id: ) self.execute(path: "solutions/#{id}.json", http_method: 'delete') end |
#delete_user(id:) ⇒ Object
78 79 80 |
# File 'lib/samanage/api/users.rb', line 78 def delete_user(id: ) self.execute(path: "users/#{id}.json", http_method: 'delete') end |
#download_attachment(attachment: {}, filename: nil, path: nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/samanage/api/attachments.rb', line 3 def (attachment: {}, filename: nil, path: nil) attachable_type = ['attachable_type'] attachable_id = ['attachable_id'].to_s filename = filename || ['filename'] url = ['url'] file_path = path ? path : File.join(Dir.pwd,attachable_type,attachable_id) unless File.directory?(file_path) FileUtils.mkpath(file_path) end exact_path = File.join(file_path,filename) = open(exact_path, "wb+") do |file| file << open(url).read end end |
#execute(http_method: 'get', path: nil, payload: nil, verbose: nil, headers: {}) ⇒ Object
Calling execute without a method defaults to GET
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/samanage/api.rb', line 57 def execute(http_method: 'get', path: nil, payload: nil, verbose: nil, headers: {}) if payload.class == String && self.content_type == 'json' begin payload = JSON.parse(payload) rescue => e puts "Invalid JSON: #{payload.inspect}" raise Samanage::Error.new(error: e, response: nil) end end token = token ||= self.token unless verbose.nil? verbose = '?layout=long' end headers = headers.merge({ 'Accept' => "application/vnd.samanage.v2.0+#{self.content_type}#{verbose}", 'Content-type' => "application/#{self.content_type}", 'X-Samanage-Authorization' => 'Bearer ' + self.token }) = { headers: headers, payload: payload } full_path = self.base_url + path retries = 0 begin case http_method.to_s.downcase when 'get' api_call = self.class.get(full_path, headers: headers) when 'post' api_call = self.class.post(full_path, query: payload, headers: headers) when 'put' api_call = self.class.put(full_path, query: payload, headers: headers) when 'delete' api_call = self.class.delete(full_path, query: payload, headers: headers) else raise Samanage::Error.new(response: {response: 'Unknown HTTP method'}) end rescue Errno::ECONNREFUSED, Net::OpenTimeout, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError, Errno::ENETDOWN, Errno::ECONNRESET, Errno::ENOENT, EOFError => e puts "[Warning] #{e.class}: #{e} - Retry: #{retries}/#{self.max_retries}" sleep 3 retries += 1 retry if retries < self.max_retries error = e response = e.class raise Samanage::InvalidRequest.new(error: error, response: response) end response = Hash.new response[:code] = api_call.code.to_i response[:json] = api_call.body response[:response] = api_call response[:headers] = api_call.headers response[:total_pages] = api_call.headers['X-Total-Pages'].to_i response[:total_pages] = 1 if response[:total_pages] == 0 response[:total_count] = api_call.headers['X-Total-Count'].to_i # Error cases case response[:code] when 200..201 begin response[:data] = JSON.parse(api_call.body) rescue JSON::ParserError => e response[:data] = api_call.body puts "[Warning] #{e.class}: #{e}" end response when 401 response[:data] = api_call.body error = response[:response] self. = false raise Samanage::AuthorizationError.new(error: error,response: response) when 404 response[:data] = api_call.body error = response[:response] raise Samanage::NotFound.new(error: error, response: response) when 422 response[:data] = api_call.body error = response[:response] raise Samanage::InvalidRequest.new(error: error, response: response) else response[:data] = api_call.body error = response[:response] raise Samanage::InvalidRequest.new(error: error, response: response) end end |
#find_change(id:, options: {}) ⇒ Object
Find change by ID
42 43 44 45 46 47 48 |
# File 'lib/samanage/api/changes.rb', line 42 def find_change(id: , options: {}) path = "changes/#{id}.json" if [:layout] == 'long' path += '?layout=long' end self.execute(path: path) end |
#find_contract(id:) ⇒ Object
Find contract given id
36 37 38 39 |
# File 'lib/samanage/api/contracts.rb', line 36 def find_contract(id: ) path = "contracts/#{id}.json" self.execute(path: path) end |
#find_group(id:) ⇒ Object
42 43 44 45 |
# File 'lib/samanage/api/groups.rb', line 42 def find_group(id: ) path = "groups/#{id}.json" self.execute(path: path) end |
#find_group_id_by_name(group: '', options: {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/samanage/api/groups.rb', line 31 def find_group_id_by_name(group: '', options: {}) .merge!({name: group}) if group && !.keys.include?(:name) params = self.set_params(options: ) path = "groups.json?" + params group_api = self.execute(path: path ) # Group names are case sensitive if !group_api[:data].empty? && group == group_api[:data].first['name'] return group_api[:data].first['id'] end end |
#find_hardware(id:) ⇒ Object
Find hardware given id
36 37 38 39 |
# File 'lib/samanage/api/hardwares.rb', line 36 def find_hardware(id: ) path = "hardwares/#{id}.json" self.execute(path: path) end |
#find_hardwares_by_serial(serial_number:) ⇒ Object
Find hardware given a serial number
42 43 44 45 |
# File 'lib/samanage/api/hardwares.rb', line 42 def find_hardwares_by_serial(serial_number: ) path = "hardwares.json?serial_number[]=#{serial_number}" self.execute(path: path) end |
#find_incident(id:, options: {}) ⇒ Object
Find incident by ID
58 59 60 61 62 63 |
# File 'lib/samanage/api/incidents.rb', line 58 def find_incident(id: , options: {}) params = self.set_params(options: ) path = "incidents/#{id}.json?" + params self.execute(path: path) end |
#find_mobile(id: nil) ⇒ Object
Find mobile given id
37 38 39 40 |
# File 'lib/samanage/api/mobiles.rb', line 37 def find_mobile(id: nil) path = "mobiles/#{id}.json" self.execute(path: path) end |
#find_other_asset(id:) ⇒ Object
Find other_asset by id
39 40 41 42 |
# File 'lib/samanage/api/other_assets.rb', line 39 def find_other_asset(id: ) path = "other_assets/#{id}.json" self.execute(path: path) end |
#find_problem(id:, options: {}) ⇒ Object
Find problem by ID
42 43 44 45 46 47 48 |
# File 'lib/samanage/api/problems.rb', line 42 def find_problem(id: , options: {}) path = "problems/#{id}.json" if [:layout] == 'long' path += '?layout=long' end self.execute(path: path) end |
#find_user(id:) ⇒ Object
Return user by ID
37 38 39 40 |
# File 'lib/samanage/api/users.rb', line 37 def find_user(id: ) path = "users/#{id}.json" self.execute(path: path) end |
#find_user_group_id_by_email(email:) ⇒ Object
Returns nil if no matching group_id
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/samanage/api/users.rb', line 51 def find_user_group_id_by_email(email: ) user = self.check_user(value: email) group_ids = user[:data].select{|u| u['email'].to_s.downcase == email.to_s.downcase}.first.to_h['group_ids'].to_a group_ids.each do |group_id| group = self.find_group(id: group_id) if group[:data]['is_user'] && email.to_s.downcase == group[:data]['email'].to_s.downcase return group_id end end return nil end |
#find_user_id_by_email(email:) ⇒ Object
Email is unique so compare first for exact match only. Returns nil or the id
43 44 45 46 47 48 |
# File 'lib/samanage/api/users.rb', line 43 def find_user_id_by_email(email: ) api_call = self.get_users(options: {email: email}) api_call[:data] .select{|u| u['email'].to_s.downcase == email.to_s.downcase} .first.to_h['id'] end |
#form_for(object_type: nil) ⇒ Object
Get form for a specific object type
43 44 45 46 47 48 |
# File 'lib/samanage/api/custom_forms.rb', line 43 def form_for(object_type: nil) if self.custom_forms == nil self.custom_forms = self.organize_forms end self.custom_forms[object_type] end |
#get_categories(path: PATHS[:category], options: {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/samanage/api/category.rb', line 3 def get_categories(path: PATHS[:category], options: {}) params = self.set_params(options: ) path = 'categories.json?' + params self.execute(path: path) end |
#get_changes(path: PATHS[:change], options: {}) ⇒ Object
Default get change path
5 6 7 8 9 |
# File 'lib/samanage/api/changes.rb', line 5 def get_changes(path: PATHS[:change], options: {}) params = self.set_params(options: ) path = 'changes.json?' + params self.execute(path: path) end |
#get_comments(incident_id:) ⇒ Object Also known as: comments
Find comments given incident_id
6 7 8 9 |
# File 'lib/samanage/api/comments.rb', line 6 def get_comments(incident_id: ) path = "incidents/#{incident_id}/comments.json" self.execute(path: path) end |
#get_contracts(path: PATHS[:contract], options: {}) ⇒ Object
Get contract default path
5 6 7 8 9 |
# File 'lib/samanage/api/contracts.rb', line 5 def get_contracts(path: PATHS[:contract], options: {}) params = self.set_params(options: ) path = 'contracts.json?' + params self.execute(path: path) end |
#get_custom_fields(path: PATHS[:custom_fields], options: {}) ⇒ Object
Get custom fields default url
5 6 7 8 9 |
# File 'lib/samanage/api/custom_fields.rb', line 5 def get_custom_fields(path: PATHS[:custom_fields], options:{}) params = self.set_params(options: ) path = 'custom_fields.json?' + params self.execute(path: path) end |
#get_custom_forms(path: PATHS[:custom_forms], options: {}) ⇒ Object
Get custom forms path
4 5 6 7 |
# File 'lib/samanage/api/custom_forms.rb', line 4 def get_custom_forms(path: PATHS[:custom_forms], options: {}) params = self.set_params(options: ) self.execute(path: path) end |
#get_departments(path: PATHS[:department], options: {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/samanage/api/departments.rb', line 3 def get_departments(path: PATHS[:department], options: {}) params = self.set_params(options: ) path = 'departments.json?' + params self.execute(path: path) end |
#get_groups(path: PATHS[:group], options: {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/samanage/api/groups.rb', line 3 def get_groups(path: PATHS[:group], options: {}) params = self.set_params(options: ) path = 'groups.json?' + params self.execute(path: path) end |
#get_hardwares(path: PATHS[:hardware], options: {}) ⇒ Object
Get hardware default path
5 6 7 8 9 |
# File 'lib/samanage/api/hardwares.rb', line 5 def get_hardwares(path: PATHS[:hardware], options: {}) params = self.set_params(options: ) path = 'hardwares.json?' + params self.execute(path: path) end |
#get_incidents(path: PATHS[:incident], options: {}) ⇒ Object
Default get incident path
5 6 7 8 9 |
# File 'lib/samanage/api/incidents.rb', line 5 def get_incidents(path: PATHS[:incident], options: {}) params = self.set_params(options: ) path = 'incidents.json?' + params self.execute(path: path) end |
#get_mobiles(path: PATHS[:mobile], options: {}) ⇒ Object
Get mobile default path
5 6 7 8 9 10 |
# File 'lib/samanage/api/mobiles.rb', line 5 def get_mobiles(path: PATHS[:mobile], options: {}) params = self.set_params(options: ) path = 'mobiles.json?' + params self.execute(path: path) end |
#get_other_assets(path: PATHS[:other_asset], options: {}) ⇒ Object
Default get other_assets path
5 6 7 8 9 |
# File 'lib/samanage/api/other_assets.rb', line 5 def get_other_assets(path: PATHS[:other_asset], options: {}) params = self.set_params(options: ) path = 'other_assets.json?' + params self.execute(path: path) end |
#get_problems(path: PATHS[:problem], options: {}) ⇒ Object
Default get problem path
5 6 7 8 9 |
# File 'lib/samanage/api/problems.rb', line 5 def get_problems(path: PATHS[:problem], options: {}) params = self.set_params(options: ) path = 'problems.json?' + params self.execute(path: path) end |
#get_requester_id(value:) ⇒ Object
Get requester from value (email)
4 5 6 7 |
# File 'lib/samanage/api/requester.rb', line 4 def get_requester_id(value: ) api_call = self.execute(path: "requesters.json?name=#{value}") api_call[:data].size == 1 ? api_call[:data][0] : nil end |
#get_sites(path: PATHS[:site], options: {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/samanage/api/sites.rb', line 3 def get_sites(path: PATHS[:site], options: {}) params = self.set_params(options: ) path = 'sites.json?' + params self.execute(path: path) end |
#get_solutions(path: PATHS[:solution], options: {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/samanage/api/solutions.rb', line 3 def get_solutions(path: PATHS[:solution], options: {}) params = self.set_params(options: ) path = 'solutions.json?' + params self.execute(path: path) end |
#get_users(path: PATHS[:user], options: {}) ⇒ Object
Get users, using URL builder
5 6 7 8 9 |
# File 'lib/samanage/api/users.rb', line 5 def get_users(path: PATHS[:user], options: {}) params = self.set_params(options: ) path = 'users.json?' + params self.execute(path: path) end |
#list_admins ⇒ Object
Return all admins in the account
152 153 154 155 156 157 |
# File 'lib/samanage/api.rb', line 152 def list_admins admin_role_id = self.execute(path: "roles.json")[:data].select{|role| role['name'] == 'Administrator'}.first['id'] self.admins.push( self.execute(path: "users.json?role=#{admin_role_id}")[:data].map{|u| u['email']} ).flatten end |
#organize_forms ⇒ Object
Set forms by type and map fields
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/samanage/api/custom_forms.rb', line 29 def organize_forms custom_forms = self.collect_custom_forms custom_forms.map{|form| form.delete_if{|k, v| v.nil?}} custom_forms.map{|form| form['custom_form_fields'].map{|fields| fields.delete_if{|k, v| v == false}}} custom_forms.map{|form| form['custom_form_fields'].map{|fields| fields['custom_field'].delete_if{|k, v| !v}}} custom_forms.group_by{|k| k['module']}.each_pair{|forms_name, forms| forms.each{|form| form['custom_form_fields'].group_by{|f| f['name'] } } } end |
#send_activation_email(email:) ⇒ Object
5 6 7 8 9 |
# File 'lib/samanage/api/utils.rb', line 5 def send_activation_email(email: ) user_id = self.find_user_id_by_email(email: email) raise Samanage::Error.new(error: 'Invalid Email', response: {}) unless user_id self.execute(http_method: 'put', path: "users/#{user_id}.json?send_activation_email=1&add_callbacks=1") end |
#set_params(options:) ⇒ Object
145 146 147 148 |
# File 'lib/samanage/api.rb', line 145 def set_params(options:) [:audit_archive] = [:audit_archive] || [:audit_archives] if [:audit_archives] URI.encode_www_form(.except(:verbose)) end |
#time_tracks(incident_id:) ⇒ Object
3 4 5 |
# File 'lib/samanage/api/time_tracks.rb', line 3 def time_tracks(incident_id: ) self.execute(path: "incidents/#{incident_id}/time_tracks.json")[:data] end |
#update_change(payload:, id:, options: {}) ⇒ Object
Update an change given id and json
51 52 53 54 |
# File 'lib/samanage/api/changes.rb', line 51 def update_change(payload: , id: , options: {}) path = "changes/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |
#update_contract(payload:, id:, options: {}) ⇒ Object
Update contract given id
48 49 50 51 |
# File 'lib/samanage/api/contracts.rb', line 48 def update_contract(payload: , id: , options: {}) path = "contracts/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |
#update_hardware(payload:, id:, options: {}) ⇒ Object
Update hardware given id
55 56 57 58 |
# File 'lib/samanage/api/hardwares.rb', line 55 def update_hardware(payload: , id: , options: {}) path = "hardwares/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |
#update_incident(payload:, id:, options: {}) ⇒ Object
Update an incident given id and json
66 67 68 69 70 |
# File 'lib/samanage/api/incidents.rb', line 66 def update_incident(payload: , id: , options: {}) params = self.set_params(options: ) path = "incidents/#{id}.json?" + params self.execute(path: path, http_method: 'put', payload: payload) end |
#update_mobile(payload:, id:, options: {}) ⇒ Object
Update mobile given id
49 50 51 52 |
# File 'lib/samanage/api/mobiles.rb', line 49 def update_mobile(payload: , id: , options: {}) path = "mobiles/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |
#update_other_asset(payload:, id:, options: {}) ⇒ Object
Update other_asset given json and id
45 46 47 48 |
# File 'lib/samanage/api/other_assets.rb', line 45 def update_other_asset(payload: , id: , options: {}) path = "other_assets/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |
#update_problem(payload:, id:, options: {}) ⇒ Object
Update an problem given id and json
51 52 53 54 |
# File 'lib/samanage/api/problems.rb', line 51 def update_problem(payload: , id: , options: {}) path = "problems/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |
#update_solution(id:, payload:, options: {}) ⇒ Object
31 32 33 |
# File 'lib/samanage/api/solutions.rb', line 31 def update_solution(id: ,payload: , options: {}) self.execute(path: "solutions/#{id}.json", http_method: 'put', payload: payload) end |
#update_time_track(incident_id:, time_track_id:, payload:) ⇒ Object
11 12 13 |
# File 'lib/samanage/api/time_tracks.rb', line 11 def update_time_track(incident_id: ,time_track_id: ,payload: ) self.execute(path: "incidents/#{incident_id}/time_tracks.json") end |
#update_user(payload:, id:) ⇒ Object
Update user by id
73 74 75 76 |
# File 'lib/samanage/api/users.rb', line 73 def update_user(payload: , id: ) path = "users/#{id}.json" self.execute(path: path, http_method: 'put', payload: payload) end |