pa_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4791135237e2c5bbd0d5ee9fc7f8dc652b9801c
4
+ data.tar.gz: f7fc2fea684450c81c2791a2d18ad1114af9dec0
5
+ SHA512:
6
+ metadata.gz: baf414e8f30f16d591184a9fafcf8306892f1dcb3fcbf4aab3e2ee229c4f0285280e029b7f10ef95ca86187359d2be259b0c8868411762271c4fc09f22bc5d8f
7
+ data.tar.gz: 5230b939a3f38d1daf5c4b805f54e103d42059a368987d155159413939fc152f360f576a8337a2b381ddae1e9a85989a3a6ff459a24e2e4fc83c7182f3ed00c6
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .ruby-vars
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pa_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kryptyk Fysh
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # PaApi
2
+
3
+ A simple wrapper for the Parallels Automation APIs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pa_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pa_api
20
+
21
+ ## Usage
22
+
23
+ Just use the damn thing already.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/pa_api/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ module PaApi
2
+ VERSION = "0.0.1"
3
+ end
data/lib/pa_api.rb ADDED
@@ -0,0 +1,67 @@
1
+ require "pa_api/version"
2
+
3
+ # Provides functionality to make POA and PBA API calls.
4
+ module PaApi
5
+ require 'xmlrpc/client'
6
+ require 'base64'
7
+
8
+ # Provides a connection to the defualt POA API, as set in ENV['POA_API']
9
+ class POA
10
+ def initialize(host: ENV['POA_API'], path: '/RPC2', port: 8440)
11
+ @conn = XMLRPC::Client.new3(host: host, path: path, port: port)
12
+ end
13
+
14
+ # Makes a call to the POA API, with the method param being the full POA
15
+ # method name, as a string, and an optional params Hash.
16
+ # Returns a Hash result.
17
+ def call(method, params = {})
18
+ begin
19
+ @conn.call(method, params)
20
+ rescue => e
21
+ return e
22
+ end
23
+ end
24
+ end
25
+
26
+ # Provides a connection to the default PBA API as configued in ENV['PBA_API']
27
+ class PBA
28
+ def initialize(host: ENV['PBA_API'], path: '/RPC2', port: 5224)
29
+ @conn = XMLRPC::Client.new3(host: host, path: path, port: port)
30
+ end
31
+
32
+ # Makes a call to the PBA API, with the method param being the full method
33
+ # name, as a string, and an optional params Array. The server param can
34
+ # also be supplied for API calls that do not use 'BM'.
35
+ # Returns a Hash result.
36
+ def call(method, params = [], server = 'BM')
37
+ begin
38
+ {
39
+ status: 0,
40
+ result: @conn.call(
41
+ :Execute,
42
+ Method: method,
43
+ Server: server,
44
+ Params: params
45
+ )['Result'][0]
46
+ }
47
+ rescue XMLRPC::FaultException => e
48
+ {
49
+ error_message: Base64.decode64(e.faultString).strip,
50
+ status: -1,
51
+ method: method,
52
+ params: params,
53
+ result: nil
54
+ }
55
+ rescue => e
56
+ {
57
+ status: -1,
58
+ result: nil,
59
+ method: method,
60
+ params: params,
61
+ error_message: e
62
+ }
63
+ end
64
+ end
65
+ end
66
+ end
67
+
data/pa_api.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pa_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pa_api"
8
+ spec.version = PaApi::VERSION
9
+ spec.authors = ["Kryptyk Fysh"]
10
+ spec.email = ["kryptykfysh@kryptykfysh.co.uk"]
11
+ spec.summary = %q{A simple wrapper for the Parallels Automation APIs.}
12
+ spec.description = File.read('README.md')
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pa_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kryptyk Fysh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: |
42
+ # PaApi
43
+
44
+ A simple wrapper for the Parallels Automation APIs.
45
+
46
+ ## Installation
47
+
48
+ Add this line to your application's Gemfile:
49
+
50
+ ```ruby
51
+ gem 'pa_api'
52
+ ```
53
+
54
+ And then execute:
55
+
56
+ $ bundle
57
+
58
+ Or install it yourself as:
59
+
60
+ $ gem install pa_api
61
+
62
+ ## Usage
63
+
64
+ Just use the damn thing already.
65
+
66
+ ## Contributing
67
+
68
+ 1. Fork it ( https://github.com/[my-github-username]/pa_api/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create a new Pull Request
73
+ email:
74
+ - kryptykfysh@kryptykfysh.co.uk
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - lib/pa_api.rb
85
+ - lib/pa_api/version.rb
86
+ - pa_api.gemspec
87
+ homepage: ''
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.8
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: A simple wrapper for the Parallels Automation APIs.
111
+ test_files: []
112
+ has_rdoc: