First install Ruby 2.6 or higher. Then gem install samanage
Run from the command:
ruby script_name.rb API_TOKEN 2018-01-01 2018-12-31
or ruby script_name.rb API_TOKEN 2018-01-01 2018-12-31 eu
if on the EU datacenter.
# frozen_string_literal: true | |
################################################################# | |
## | |
## First install the api wrapper & xmlparser `gem install samanage nokogiri` | |
## To run `ruby import_whd_tickets.rb api-token export-file.csv` | |
## | |
## | |
## The CSV input columns were: | |
## |
## To run: 'gem install samanage' then 'ruby simple_site_export.rb API_TOKEN' or replace 12345 below with your token | |
require 'samanage' | |
token = ARGV[0] || '12345' | |
@samanage = Samanage::Api.new(token: token) | |
def log_to_csv(row: , filename: 'Sites Export.csv') | |
write_headers = !File.exists?(filename) | |
CSV.open(filename, 'a+', write_headers: write_headers, force_quotes: true, headers: row.keys) do |csv| | |
csv << row.values |
First install Ruby 2.6 or higher. Then gem install samanage
Run from the command:
ruby script_name.rb API_TOKEN 2018-01-01 2018-12-31
or ruby script_name.rb API_TOKEN 2018-01-01 2018-12-31 eu
if on the EU datacenter.
# Export incidents within date range | |
# | |
# First install the lastest Ruby version and our library via command `gem install samanage` | |
# | |
# Run with the command: `ruby script_name.rb API_TOKEN 2019-01-01 2019-12-31` | |
# or in the EU datacenter `ruby script_name.rb API_TOKEN 2019-01-01 2019-12-31 eu` | |
require 'samanage' | |
require 'csv' |