PasswordManagerProRestClient 0.0.1pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/PasswordManagerProRestClient.rb +64 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9bbddcd2680a1be0ae307816589d19e5585bd4e4
|
|
4
|
+
data.tar.gz: 035a8d4a80d97411174ec947f0d08f2712f2abfb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 51abc95277cf48a4750697e8a20a65982d06fe68cec1065362fdca306e0af6edb5e4ecf7283cb5306064017307fb66835294bde9a2eaea90658711a047bc6c60
|
|
7
|
+
data.tar.gz: fdad96214f9a4beea2984f812ecbf7d1be00d8863a5200d34c3d985e84192c5ce4d9765f127c49b764fa61a0780a4aa0ee375f0508954d2ebfb86ed4c7ccf4b8
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
class PasswordManagerProRestClient
|
|
4
|
+
|
|
5
|
+
def initialize(server, api_key, port = 7272, enable_insecure_ssl = false)
|
|
6
|
+
@server = server
|
|
7
|
+
@api_key = api_key
|
|
8
|
+
@port = port
|
|
9
|
+
@base_server_uri = "https://" + server + ":" + port + "/restapi/json/v1/"
|
|
10
|
+
@enable_insecure_ssl = enable_insecure_ssl
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.get(uri_string)
|
|
14
|
+
full_uri = "https://#{@baseserveruri}:#{@port}/restapi/json/v1/#{uri_string}&AUTHTOKEN=#{@api_key}"
|
|
15
|
+
uri = URI.parse(full_uri)
|
|
16
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
17
|
+
http.use_ssl = true
|
|
18
|
+
if(@enable_insecure_ssl)
|
|
19
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # read into this
|
|
20
|
+
end
|
|
21
|
+
return_val = http.get(uri.request_uri).body
|
|
22
|
+
json_val = JSON.parse(return_val)
|
|
23
|
+
if(json_val["operation"]["result"]["status"] == "Success")
|
|
24
|
+
return json_val["operation"]["Details"]
|
|
25
|
+
end
|
|
26
|
+
throw :failure
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.get_resource(resource_id)
|
|
30
|
+
if(resource_id.nil?)
|
|
31
|
+
#Get All Resouces
|
|
32
|
+
methodUri = "resources?"
|
|
33
|
+
else
|
|
34
|
+
#Get the specific Resource
|
|
35
|
+
methodUri = "resources/#{resource_id}?"
|
|
36
|
+
end
|
|
37
|
+
return self.get(methodUri)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.get_resource_account(resource_id, account_id)
|
|
41
|
+
if(accountid.nil?)
|
|
42
|
+
#Get All Resouces
|
|
43
|
+
methodUri = "resources/#{resource_id}/accounts?"
|
|
44
|
+
else
|
|
45
|
+
#Get the specific Resource
|
|
46
|
+
methodUri = "resources/#{resource_id}/accounts/#{account_id}?"
|
|
47
|
+
end
|
|
48
|
+
return self.get(methodUri)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.get_resource_account_password(resource_id, account_id)
|
|
52
|
+
if(resourceid.is_a? String and accountid.is_a? String)
|
|
53
|
+
#Fetch Based on Resource Names. Resolve IDs.
|
|
54
|
+
resource_id, account_id = self.get_resource_account_id(resource_id,account_id)
|
|
55
|
+
end
|
|
56
|
+
methodUri = "resources/#{resource_id}/accounts/#{account_id}/password?"
|
|
57
|
+
return self.get(methodUri)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.get_resource_account_id(resource_name, account_name)
|
|
61
|
+
id_fetch = self.get("resources/resourcename/#{resource_name}/accounts/accountname/#{account_name}?")
|
|
62
|
+
return id_fetch["RESOURCEID"].to_i, id_fetch["ACCOUNTID"].to_i
|
|
63
|
+
end
|
|
64
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: PasswordManagerProRestClient
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1pre
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Patrick McMorran
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple gem for fetching passwords over the rest api of Password Manager
|
|
14
|
+
Pro
|
|
15
|
+
email: kingrolloinc@sbcglobal.net
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/PasswordManagerProRestClient.rb
|
|
21
|
+
homepage: https://github.com/wildbillcat/PasswordManagerProRestClient
|
|
22
|
+
licenses:
|
|
23
|
+
- The Unlicense
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">"
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: 1.3.1
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.4.4
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Pssword Manager Pro Rest Client
|
|
45
|
+
test_files: []
|
|
46
|
+
has_rdoc:
|