Class: AdobeConnectAPI
- Inherits:
-
Object
- Object
- AdobeConnectAPI
- Includes:
- XMLParser
- Defined in:
- lib/adobe_connect_api.rb
Overview
NOTE KG: refactored so that all methods return the body of the query result, e.g. “<?xml version="1.0" encoding="utf-8"?>rn<results><status code="ok"/><sco account-id="7" disabled="" display-seq="0" folder-id="14152063" icon="meeting" lang="en" max-retries="" sco-id="14153596" source-sco-id="" type="meeting" version="0"><date-created>2013-03-27T17:55:36.403+01:00</date-created>< date-modified>2013-03-27T17:55:36.403+01:00</date-modified><name>Testmeeting from RSpec</name><url-path>/rspec_testmeeting/</url-path></sco></results>”
Instance Attribute Summary collapse
-
#pointconfig ⇒ Object
Returns the value of attribute pointconfig.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_meeting(name, folder_id, url_path) ⇒ Object
create a new meeting in Adobe Connect e.g.
-
#create_user(email = nil, login = nil, password = nil, first_name = nil, last_name = nil) ⇒ Object
creates a new user in Adobe Connect.
- #delete_meeting(sco_id) ⇒ Object
- #delete_user(principal_id) ⇒ Object
- #get_my_meetings_folder(email) ⇒ Object
-
#get_principal(filter = nil, sort = nil) ⇒ Object
searches the user with the given email address e.g.
-
#group_membership_update(group_id, principal_id, is_member) ⇒ Object
action=group-membership-update&group-id=integer&principal-id=integer&is-member=boolean.
-
#initialize(url = nil, environment, root_directory) ⇒ AdobeConnectAPI
constructor
The URL is the base URL of the Connect-Server, without the trailing slash.
-
#login(login = nil, password = nil, account_id = nil, external_auth = nil, domain = nil) ⇒ Object
makes the login to the server.
-
#logout ⇒ Object
makes a logout and removes the cookie.
-
#permissions_info(sco_id, filter = nil) ⇒ Object
TODO KG: refactor (return res.body) and test returns permission information of an sco-id.
-
#permissions_update(principal_id, acl_id, permission_id) ⇒ Object
e.g.
-
#query(action, hash = {}) ⇒ Object
sends a query to the server and returns the http response.
-
#report_bulk_consolidated_transactions(filter = nil, sort = nil) ⇒ Object
returns all transactions as a result object.
-
#report_bulk_objects(filter = nil, sort = nil) ⇒ Object
returns all SCOs as a result object.
-
#report_bulk_users(custom_fields = false, filter = nil, sort = nil) ⇒ Object
returns all users as a result object.
-
#report_groups(filter = nil, sort = nil) ⇒ Object
returns all groups.
-
#report_meeting_sessions(meeting_id, filter = nil, sort = nil) ⇒ Object
returns all the session of a meeting as a result object.
-
#report_memberships(group_id, filter = nil, sort = nil) ⇒ Object
returns all groups.
-
#report_quotas ⇒ Object
Returns all defined quotas (untested).
-
#sco_info(sco_id) ⇒ Object
returns SCO information of sco-id.
-
#search_meeting(name) ⇒ Object
sco-search-by-field&query=TB_ac_test&field=name.
-
#sessionid ⇒ Object
return BREEZESESSION id.
-
#set_passcode(acl_id, passcode) ⇒ Object
e.g.
- #update_meeting(sco_id, description, language) ⇒ Object
Methods included from XMLParser
#get_description, #get_folder_id, #get_invalid_subcode, #get_language, #get_principal_id, #get_sco_id, #get_sco_id_for_unique_name, #get_status_code
Constructor Details
#initialize(url = nil, environment, root_directory) ⇒ AdobeConnectAPI
The URL is the base URL of the Connect-Server, without the trailing slash
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/adobe_connect_api.rb', line 62 def initialize (url = nil, environment, root_directory) begin @pointconfig = YAML::load_file("#{root_directory}/config/config.breeze.yml")[environment] rescue # should not occur except when running tests end if (url == nil) @url = @pointconfig["url"] else @url = url end end |
Instance Attribute Details
#pointconfig ⇒ Object
Returns the value of attribute pointconfig.
42 43 44 |
# File 'lib/adobe_connect_api.rb', line 42 def pointconfig @pointconfig end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
41 42 43 |
# File 'lib/adobe_connect_api.rb', line 41 def url @url end |
Class Method Details
.version_string ⇒ Object
44 45 46 |
# File 'lib/adobe_connect_api.rb', line 44 def self.version_string "AdobeConnectAPI version #{AdobeConnectApi::VERSION}" end |
Instance Method Details
#create_meeting(name, folder_id, url_path) ⇒ Object
create a new meeting in Adobe Connect e.g. “collab-test.switch.ch/api/xml?action=sco-update&type=meeting&name=API-Test&folder-id=12578070&date-begin=2012-06-15T17:00&date-end=2012-06-15T23:00&url-path=apitest”
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/adobe_connect_api.rb', line 145 def create_meeting(name, folder_id, url_path) puts "ACS create meeting with name '#{name}', folder_id '#{folder_id.to_s}' and url_path '#{url_path}'" res = query("sco-update", "type" => "meeting", "name" => name, "folder-id" => folder_id, "url-path" => url_path) puts "ACS: meeting created" return res.body end |
#create_user(email = nil, login = nil, password = nil, first_name = nil, last_name = nil) ⇒ Object
creates a new user in Adobe Connect
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/adobe_connect_api.rb', line 115 def create_user(email = nil, login = nil, password = nil, first_name = nil, last_name = nil) if password == nil password = @pointconfig["generic_user_password"] end res = query("principal-update", "email" => email, "login" => login, "password" => password, "first-name" => first_name, "last-name" => last_name, "send-email" => false, "has-children" => 0, "type" => "user") puts "ACS: user created" return res.body end |
#delete_meeting(sco_id) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/adobe_connect_api.rb', line 158 def delete_meeting(sco_id) puts "ACS delete meeting with sco_id: " + sco_id res = query("sco-delete", "sco-id" => sco_id) puts "ACS: meeting deleted" return res.body end |
#delete_user(principal_id) ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/adobe_connect_api.rb', line 134 def delete_user(principal_id) puts "ACS delete user with id: " + principal_id res = query("principals-delete", "principal-id" => principal_id) puts "ACS: user deleted" return res.body end |
#get_my_meetings_folder(email) ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/adobe_connect_api.rb', line 179 def get_my_meetings_folder(email) # NOTE: this id does not change unless we set up AC new tree_id = 14 filter = AdobeConnectApi::FilterDefinition.new filter["name"] == email res = query("sco-contents", "sco-id" => tree_id, "filter" => filter) return res.body end |
#get_principal(filter = nil, sort = nil) ⇒ Object
searches the user with the given email address e.g. “collab-test.switch.ch/api/xml?action=principal-list&[email protected]”
170 171 172 173 174 175 176 177 |
# File 'lib/adobe_connect_api.rb', line 170 def get_principal(filter = nil, sort = nil) puts "ACS: get_principal" res = query("principal-list", "filter" => filter, "sort" => sort) return res.body end |
#group_membership_update(group_id, principal_id, is_member) ⇒ Object
action=group-membership-update&group-id=integer&principal-id=integer&is-member=boolean
224 225 226 227 228 229 230 231 |
# File 'lib/adobe_connect_api.rb', line 224 def group_membership_update(group_id, principal_id, is_member) res = query("group-membership-update", "group-id" => group_id, "principal-id" => principal_id, "is-member" => is_member) return res.body end |
#login(login = nil, password = nil, account_id = nil, external_auth = nil, domain = nil) ⇒ Object
makes the login to the server
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 |
# File 'lib/adobe_connect_api.rb', line 76 def login (login = nil, password = nil, account_id=nil, external_auth=nil, domain=nil) if (login != nil && password == nil) # user given --> use generic user password # TODO: generate password (see https://forge.switch.ch/redmine/issues/2355) password = @pointconfig["generic_user_password"] elsif (login == nil) && (password == nil) login = @pointconfig["username"] password = @pointconfig["password"] end res = query("login", "login" => login, "password" => password, "account-id" => account_id, "external-auth" => external_auth, "domain" => domain) = res.response["set-cookie"] puts .inspect .split(";").each{|s| array = s.split("=") if array[0] == "BREEZESESSION" @sessionid = array[1] end } puts "ACS: Logged in" return res.body end |
#logout ⇒ Object
makes a logout and removes the cookie
107 108 109 110 111 112 |
# File 'lib/adobe_connect_api.rb', line 107 def logout res = query("logout") @sessionid = nil puts "ACS: Logged out" return res.body end |
#permissions_info(sco_id, filter = nil) ⇒ Object
TODO KG: refactor (return res.body) and test returns permission information of an sco-id
317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/adobe_connect_api.rb', line 317 def (sco_id, filter = nil) res = query("permissions-info", "acl-id" => sco_id, "filter" => filter) return res.body data = XmlSimple.xml_in(res.body) if data['permissions'][0] return data['permissions'][0] end #puts YAML::dump(data) # if data["sco"][0] # return data["sco"][0] # end end |
#permissions_update(principal_id, acl_id, permission_id) ⇒ Object
191 192 193 194 195 196 197 198 |
# File 'lib/adobe_connect_api.rb', line 191 def (principal_id, acl_id, ) res = query("permissions-update", "principal-id" => principal_id, "acl-id" => acl_id, "permission-id" => ) return res.body end |
#query(action, hash = {}) ⇒ Object
sends a query to the server and returns the http response. Parameters, filter- and sort-definitions can be added. The filter as “filter” => … and the sort as “sort” => …
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/adobe_connect_api.rb', line 375 def query(action, hash = {}) # uri = URI.parse("https://130.59.10.31") # http = Net::HTTP.new(uri.host, uri.port) # http.use_ssl = true # http.verify_mode = OpenSSL::SSL::VERIFY_NONE # # request = Net::HTTP::Get.new(uri.request_uri) # # response = http.request(request) # response.body # response.status # response["header-here"] # All headers are lowercase uri = URI.parse(@url + "/api/xml?action=#{action}") hash.each_pair do |key, val| if val if key == "filter" or key == "sort" uri.query += val.query else uri.query += "&" + key + "=" + CGI::escape("#{val}") end end end http = Net::HTTP.new(uri.host, uri.port) if uri.scheme == "https" http.use_ssl=true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end request = Net::HTTP::Get.new(uri.request_uri) # logger = Logger.new('log/development.log') # logger.info(url.path + "?" + url.query) if @sessionid request.add_field("Cookie", "BREEZESESSION="+@sessionid) end puts "ACS query - request: " + request.path response = http.request(request) puts "ACS query - response: " + response.body.inspect return response end |
#report_bulk_consolidated_transactions(filter = nil, sort = nil) ⇒ Object
returns all transactions as a result object
359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/adobe_connect_api.rb', line 359 def report_bulk_consolidated_transactions(filter = nil, sort = nil) res = query("report-bulk-consolidated-transactions", "filter" => filter, "sort" => sort) data = XmlSimple.xml_in(res.body) rows = [] if data["report-bulk-consolidated-transactions"] data["report-bulk-consolidated-transactions"].each do |trans| rows = trans["row"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows) end |
#report_bulk_objects(filter = nil, sort = nil) ⇒ Object
returns all SCOs as a result object
333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/adobe_connect_api.rb', line 333 def report_bulk_objects(filter = nil, sort = nil) res = query("report-bulk-objects", "filter" => filter, "sort" => sort) data = XmlSimple.xml_in(res.body) rows = [] if data["report-bulk-objects"] data["report-bulk-objects"].each do |trans| rows = trans["row"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows) end |
#report_bulk_users(custom_fields = false, filter = nil, sort = nil) ⇒ Object
returns all users as a result object
346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/adobe_connect_api.rb', line 346 def report_bulk_users(custom_fields = false, filter = nil, sort = nil) res = query("report-bulk-users", "custom-fields" => custom_fields, "filter" => filter, "sort" => sort) data = XmlSimple.xml_in(res.body) rows = [] if data["report-bulk-users"] data["report-bulk-users"].each do |trans| rows = trans["row"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows) end |
#report_groups(filter = nil, sort = nil) ⇒ Object
returns all groups
286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/adobe_connect_api.rb', line 286 def report_groups(filter = nil, sort = nil) puts "ACS: Query: Groups" res = query("principal-list", "filter" => filter, "sort" => sort) data = XmlSimple.xml_in(res.body) groups = [] if data["principal-list"] data["principal-list"].each do |trans| groups = trans["principal"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], groups) end |
#report_meeting_sessions(meeting_id, filter = nil, sort = nil) ⇒ Object
returns all the session of a meeting as a result object
273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/adobe_connect_api.rb', line 273 def report_meeting_sessions(meeting_id, filter = nil, sort = nil) res = query("report-meeting-sessions", "sco-id" => meeting_id, "filter" => filter, "sort" => sort) data = XmlSimple.xml_in(res.body) rows = [] if data["report-meeting-sessions"] data["report-meeting-sessions"].each do |trans| rows = trans["row"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows) end |
#report_memberships(group_id, filter = nil, sort = nil) ⇒ Object
returns all groups
301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/adobe_connect_api.rb', line 301 def report_memberships(group_id, filter = nil, sort = nil) puts "ACS: Query: Group Memberships" res = query("principal-list", "group-id" => group_id, "filter" => filter, "sort" => sort) data = XmlSimple.xml_in(res.body) members = [] if data["principal-list"] data["principal-list"].each do |trans| members = trans["principal"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], members) end |
#report_quotas ⇒ Object
Returns all defined quotas (untested)
260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/adobe_connect_api.rb', line 260 def report_quotas res = query("report-quota") data = XmlSimple.xml_in(res.body) rows = [] if data["report-quotas"] data["report-quotas"].each do |trans| rows = trans["quota"] end end return AdobeConnectAPI::Result.new(data["status"][0]["code"], rows) end |
#sco_info(sco_id) ⇒ Object
returns SCO information of sco-id
201 202 203 204 |
# File 'lib/adobe_connect_api.rb', line 201 def sco_info(sco_id) res = query("sco-info", "sco-id" => sco_id) return res.body end |
#search_meeting(name) ⇒ Object
sco-search-by-field&query=TB_ac_test&field=name
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/adobe_connect_api.rb', line 207 def search_meeting(name) filter = AdobeConnectApi::FilterDefinition.new filter["type"] == "meeting" res = query("sco-search-by-field", "query" => name, "field" => "name", "filter" => filter) # data = XmlSimple.xml_in(res.body) # scos = [] # if data["sco-search-by-field-info"] # results = data["sco-search-by-field-info"][0] # scos = results["sco"] # end return res.body end |
#sessionid ⇒ Object
return BREEZESESSION id
49 50 51 |
# File 'lib/adobe_connect_api.rb', line 49 def sessionid @sessionid end |
#set_passcode(acl_id, passcode) ⇒ Object
e.g. acl-field-update&acl-id=13117741&field-id=meeting-passcode&value=12345
249 250 251 252 253 254 255 256 257 |
# File 'lib/adobe_connect_api.rb', line 249 def set_passcode(acl_id, passcode) res = query("acl-field-update", "acl-id" => acl_id, "field-id" => "meeting-passcode", "value" => passcode) data = XmlSimple.xml_in(res.body) return AdobeConnectAPI::Result.new(data["status"][0]["code"], nil) end |
#update_meeting(sco_id, description, language) ⇒ Object
233 234 235 236 237 238 239 240 241 |
# File 'lib/adobe_connect_api.rb', line 233 def update_meeting(sco_id, description, language) # "action = sco-update&sco-id=&description=&lang=" res = query("sco-update", "sco-id" => sco_id, "description" => description, "lang" => language) return res.body end |