userspace:webservice_corner:ruby-rpc
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| userspace:webservice_corner:ruby-rpc [2014/06/20 11:04] – dkoch | userspace:webservice_corner:ruby-rpc [2021/08/23 10:37] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Ruby JSON-RPC ====== | ====== Ruby JSON-RPC ====== | ||
| - | This is an example for a json-rpc in Ruby | + | 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. | ||
| + | Change **test: | ||
| <code ruby> | <code ruby> | ||
| require ' | require ' | ||
| require ' | require ' | ||
| - | require ' | + | require 'json' |
| + | require ' | ||
| class OpsiRPC | class OpsiRPC | ||
| Line 33: | 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 | ||
| </ | </ | ||
userspace/webservice_corner/ruby-rpc.1403255080.txt.gz · Last modified: (external edit)
