DSX::Dml
Provides tools to ease working with the DSX DML command syntax, an archaic and obnoxious format used by DSX Access systems' SFTP APIs for making changes to records in their access control system's database(s).
Installation
Add this line to your application's Gemfile:
gem 'dsx-dml'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dsx-dml
Usage
Zones (Locations) and Changesets (Batches of commands)
require 'dsx/dml'
zone = Dsx::Dml::Zone.new(1111, 2, {address: '127.0.0.1', user: 'dsx_user', password: 'dsx_password'})
changeset_0 = zone.use('123456789100')
changeset_0.table('Names').write({
FName: 'Harry',
LName: 'Bird',
Company: 'Harry Bird Co',
Visitor: '',
Trace: '',
Notes: 'Often wears bowties'
}).table('UDF').write({
UdfNum: 2,
UdfText: '123456789100'
}).table('Cards').write({
Code: '123456789100',
PIN: 1234,
StartDate: '01/01/2001',
StopDate: '11/11/2111',
NumUses: 9999
})
changeset_1 = zone.use('123456789101')
changeset_1.table('Cards').add_acl('Parking Garage').write()
changeset_0.net_sftp()
changeset_1.curl()
Operations
Dsx::Dml::Operation
is a wraper intended to make it easier to set up and use certain DML operations.
require 'dsx/operation'
op = Dsx::Dml::Operation.new({ location_num: 1111,
udf_num: 2,
first_name: 'Harry',
last_name: 'Bird',
company: 'Harry Bird Co',
identifier: '123456789100' },
{ address: '127.0.0.1',
user: 'dsx_user',
password: 'dsx_password' })
op.access_levels += ['Top Secret Lab 1', 'Top Secret Lab 2']
op.access_levels -= ['Super Secret Lab 0']
op.linking_level = 3
op.net_sftp()
Writer
Dsx::Dml::Writer
is used to push commands to DSX SFTP endpoints. Supports Net::SFTP
and curl
.
While writer credentials can be passed through to Dsx::Dml::Operation
and Dsx::Dml::Zone
, writers
can also be instantiated separately and passed at write time.
require 'dsx/operation'
require 'dsx/writer'
writer = Dsx::Dml::Writer.new({ address: '127.0.0.1',
user: 'dsx_user',
password: 'dsx_password' })
op = Dsx::Dml::Operation.new({ location_num: 1111,
udf_num: 2,
first_name: 'Harry',
last_name: 'Bird',
company: 'Harry Bird Co',
identifier: '123456789100' })
op.access_levels += ['Top Secret Lab 3']
op.net_sftp(writer)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request