This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
userspace:webservice_corner:ruby-rpc [2014/06/20 09:28] dkoch |
userspace:webservice_corner:ruby-rpc [2021/08/23 08:37] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ruby JSON-RPC ====== | ====== Ruby JSON-RPC ====== | ||
+ | This is an example of a JSON-RPC send from [[https:// | ||
+ | |||
+ | ===== Dependencies | ||
+ | Use gem to install json first. | ||
+ | < | ||
+ | |||
+ | ===== Example ===== | ||
This is an example for a json-rpc in Ruby. | This is an example for a json-rpc in Ruby. | ||
Change **test: | Change **test: | ||
Line 6: | Line 13: | ||
require ' | require ' | ||
require ' | require ' | ||
- | require ' | + | require 'json' |
+ | require ' | ||
class OpsiRPC | class OpsiRPC | ||
Line 34: | Line 42: | ||
end | end | ||
- | | + | |
- | + | # Examples: | |
- | prodcuts=h.product_getObjects | + | |
- | prodcuts.each do |product| | + | # Show all product ids |
+ | opsirpc.product_getObjects.each do |product| | ||
puts product[' | puts product[' | ||
- | end | + | end |
+ | |||
+ | # Query only particular fields ( " | ||
+ | # ( attributes: ) | ||
+ | opsirpc.product_getObjects(" | ||
+ | puts result | ||
+ | end | ||
+ | |||
+ | # Get products where packageVersion=2.1 | ||
+ | # ( filter: ) | ||
+ | opsirpc.product_getObjects([], | ||
+ | puts result | ||
+ | end | ||
+ | |||
+ | # Install Y where X is installed | ||
+ | opsirpc.productOnClient_getHashes([' | ||
+ | opsirpc.setProductActionRequestWithDependencies(' | ||
+ | end | ||
</ | </ |