0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby library for the GLPI API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
>= 0
~> 10.0
~> 3.0
>= 0

Runtime

 Project Readme

GLPI SDK for Ruby

Gem Gem

Ruby wrapper for GLPI REST API.

Installation

Add this line to your application's Gemfile:

gem 'glpi-sdk-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install glpi-sdk-ruby

Usage

A session object is mandatory to uses the others GLPI methods.

require 'glpi/sdk'
	
# Request a session token to uses other GLPI functions

url = 'http://path/to/glpi/apirest.php'
app_token = 'YOUR_APP_TOKEN'
username = 'YOUR_GLPI_USERNAME'
password = 'YOUR_GLPI_PASSWORD'
    
session = GLPI::SDK::Session.new(url, app_token, username, password)
session.token
# => "74e735e494e9613ee50d13135df6d27d"
session.kill
session.active_profile
session.active_entities
session.full_session
session.glpi_config
ticket = GLPI::SDK::Resource.find(session, 1, 'Ticket')
ticket.id
# => 1

ticket.name
# => "Hello World"
tickets = GLPI::SDK::Resource.all(session, item_type: 'Ticket')
ticket = GLPI::SDK::Resource.create(
  session,
  name: 'New ticket from SDK',
  content: 'Ticket created by GLPI SDK',
  item_type: 'Ticket'
)

ticket.id
# => 29

ticket.content
# => "Ticket created by GLPI SDK"
ticket = GLPI::SDK::Resource.update(
  session,
  29,
  content: 'Content updated by GLPI SDK',
  item_type: 'Ticket'
)

ticket.content
# => "Ticket updated by GLPI SDK"
GLPI::SDK::Resource.destroy(session, 29, 'Ticket')
# => true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/truly-systems/glpi-sdk-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the GLPI::SDK::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.