extensis_portfolio 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +116 -0
- data/Guardfile +8 -0
- data/README.md +100 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/extensis_portfolio.gemspec +31 -0
- data/lib/extensis_portfolio.rb +14 -0
- data/lib/extensis_portfolio/asset_downloader.rb +64 -0
- data/lib/extensis_portfolio/asset_query.rb +17 -0
- data/lib/extensis_portfolio/asset_query_term.rb +25 -0
- data/lib/extensis_portfolio/connection.rb +150 -0
- data/lib/extensis_portfolio/job.rb +22 -0
- data/lib/extensis_portfolio/rsa_encryption.rb +12 -0
- data/lib/extensis_portfolio/task.rb +28 -0
- data/lib/extensis_portfolio/version.rb +3 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 072fa1e9c2d66f4e150ab038dc4f6e36430fec97
|
4
|
+
data.tar.gz: e65c94bd2307934bb11644f62fcd00de163210a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8b82ebea9e44b41126ec0b406e6998f2123473bcf8bb01f75ebf14fae80719d9d61f82aa0f59db61843f1d44519b6b91a525547fbf11d907f3d71bcf4371700
|
7
|
+
data.tar.gz: 44b79bbd466c2688ef3175c6994ef1bcc86bb29ba8efcebe5450eac6464bc896aa72f7556e187d8ff690530db58a66231e1d570561aac43251521d31e90bc4d7
|
data/.gitignore
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all logfiles and tempfiles.
|
11
|
+
/log/*
|
12
|
+
!/log/.keep
|
13
|
+
/tmp
|
14
|
+
/test/log
|
15
|
+
*.log
|
16
|
+
*.gem
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
extensis_portfolio (0.1.2)
|
5
|
+
faraday (~> 0.9)
|
6
|
+
savon (~> 2.11)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.4.0)
|
12
|
+
akami (1.3.1)
|
13
|
+
gyoku (>= 0.4.0)
|
14
|
+
nokogiri
|
15
|
+
builder (3.2.2)
|
16
|
+
celluloid (0.16.0)
|
17
|
+
timers (~> 4.0.0)
|
18
|
+
coderay (1.1.0)
|
19
|
+
crack (0.4.3)
|
20
|
+
safe_yaml (~> 1.0.0)
|
21
|
+
faraday (0.9.2)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
|
+
ffi (1.9.8)
|
24
|
+
formatador (0.2.5)
|
25
|
+
guard (2.12.5)
|
26
|
+
formatador (>= 0.2.4)
|
27
|
+
listen (~> 2.7)
|
28
|
+
lumberjack (~> 1.0)
|
29
|
+
nenv (~> 0.1)
|
30
|
+
notiffany (~> 0.0)
|
31
|
+
pry (>= 0.9.12)
|
32
|
+
shellany (~> 0.0)
|
33
|
+
thor (>= 0.18.1)
|
34
|
+
guard-compat (1.2.1)
|
35
|
+
guard-minitest (2.4.4)
|
36
|
+
guard-compat (~> 1.2)
|
37
|
+
minitest (>= 3.0)
|
38
|
+
gyoku (1.3.1)
|
39
|
+
builder (>= 2.1.2)
|
40
|
+
hashdiff (0.3.0)
|
41
|
+
hitimes (1.2.2)
|
42
|
+
httpi (2.4.2)
|
43
|
+
rack
|
44
|
+
socksify
|
45
|
+
listen (2.10.0)
|
46
|
+
celluloid (~> 0.16.0)
|
47
|
+
rb-fsevent (>= 0.9.3)
|
48
|
+
rb-inotify (>= 0.9)
|
49
|
+
lumberjack (1.0.9)
|
50
|
+
method_source (0.8.2)
|
51
|
+
mini_portile2 (2.1.0)
|
52
|
+
minispec-metadata (2.0.0)
|
53
|
+
minitest
|
54
|
+
minitest (5.6.1)
|
55
|
+
minitest-vcr (1.4.0)
|
56
|
+
minispec-metadata (~> 2.0)
|
57
|
+
minitest (>= 4.7.5)
|
58
|
+
vcr (>= 2.9)
|
59
|
+
multipart-post (2.0.0)
|
60
|
+
nenv (0.2.0)
|
61
|
+
nokogiri (1.6.8)
|
62
|
+
mini_portile2 (~> 2.1.0)
|
63
|
+
pkg-config (~> 1.1.7)
|
64
|
+
nori (2.6.0)
|
65
|
+
notiffany (0.0.6)
|
66
|
+
nenv (~> 0.1)
|
67
|
+
shellany (~> 0.0)
|
68
|
+
pkg-config (1.1.7)
|
69
|
+
pry (0.10.1)
|
70
|
+
coderay (~> 1.1.0)
|
71
|
+
method_source (~> 0.8.1)
|
72
|
+
slop (~> 3.4)
|
73
|
+
rack (2.0.1)
|
74
|
+
rake (10.4.2)
|
75
|
+
rb-fsevent (0.9.4)
|
76
|
+
rb-inotify (0.9.5)
|
77
|
+
ffi (>= 0.5.0)
|
78
|
+
safe_yaml (1.0.4)
|
79
|
+
savon (2.11.1)
|
80
|
+
akami (~> 1.2)
|
81
|
+
builder (>= 2.1.2)
|
82
|
+
gyoku (~> 1.2)
|
83
|
+
httpi (~> 2.3)
|
84
|
+
nokogiri (>= 1.4.0)
|
85
|
+
nori (~> 2.4)
|
86
|
+
wasabi (~> 3.4)
|
87
|
+
shellany (0.0.1)
|
88
|
+
slop (3.6.0)
|
89
|
+
socksify (1.7.0)
|
90
|
+
thor (0.19.1)
|
91
|
+
timers (4.0.1)
|
92
|
+
hitimes
|
93
|
+
vcr (3.0.3)
|
94
|
+
wasabi (3.5.0)
|
95
|
+
httpi (~> 2.0)
|
96
|
+
nokogiri (>= 1.4.2)
|
97
|
+
webmock (2.1.0)
|
98
|
+
addressable (>= 2.3.6)
|
99
|
+
crack (>= 0.3.2)
|
100
|
+
hashdiff
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
bundler (~> 1.9)
|
107
|
+
extensis_portfolio!
|
108
|
+
guard
|
109
|
+
guard-minitest
|
110
|
+
minitest
|
111
|
+
minitest-vcr
|
112
|
+
rake (~> 10.0)
|
113
|
+
webmock
|
114
|
+
|
115
|
+
BUNDLED WITH
|
116
|
+
1.12.5
|
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# Extensis Portfolio
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/tomasc/extensis_portfolio.svg)](https://travis-ci.org/tomasc/extensis_portfolio) [![Gem Version](https://badge.fury.io/rb/extensis_portfolio.svg)](http://badge.fury.io/rb/extensis_portfolio)
|
4
|
+
|
5
|
+
A simple wrapper for the Extensis Portfolio API, which uses both SOAP and HTTP.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'extensis_portfolio'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then run:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install extensis_portfolio
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Create a connection to the Extensis Portfolio API:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
connection = ExtensisPortfolio::Connection.new(server, username, password)
|
29
|
+
```
|
30
|
+
|
31
|
+
Where server is the url including port, without any suffixes e.g. `http://demo.extensis.com:8090`
|
32
|
+
|
33
|
+
Get a list of available SOAP operations:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
connection.get_soap_operations
|
37
|
+
```
|
38
|
+
|
39
|
+
### Downloading an asset
|
40
|
+
|
41
|
+
Download an asset:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
ExtensisPortfolio::AssetDownloader.new(connection, asset_id, catalog_id).download_file
|
45
|
+
```
|
46
|
+
|
47
|
+
### Querying
|
48
|
+
|
49
|
+
You can query for assets on a connection with the `get_assets` method. The query is built in two steps.
|
50
|
+
|
51
|
+
First you create an `ExtensisPortfolio::AssetQueryTerm`:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# AssetQueryTerm takes three parameters: "field_name", "operator" and "values"
|
55
|
+
# this query is for an asset where the "asset_id" field is equal to 1234
|
56
|
+
query_term = ExtensisPortfolio::AssetQueryTerm.new("asset_id", "equalValue", 1234)
|
57
|
+
```
|
58
|
+
|
59
|
+
[Available value operators](http://doc.extensis.com/api/portfolio/assets_queryOperator.html)
|
60
|
+
|
61
|
+
The `asset_query_term` is then used to build a new instance of `ExtensisPortfolio::AssetQuery`:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
query = ExtensisPortfolio::AssetQuery.new(query_term)
|
65
|
+
```
|
66
|
+
|
67
|
+
Which is finally used in the `get_assets` call:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
# get_assets takes three parameters: catalog_id, query and an optional options hash
|
71
|
+
connection.get_assets(catalog_id, query)
|
72
|
+
```
|
73
|
+
|
74
|
+
## Testing
|
75
|
+
|
76
|
+
The gem comes with a MiniTest / Guard test suite, simply run:
|
77
|
+
|
78
|
+
$ bundle install
|
79
|
+
|
80
|
+
Followed by:
|
81
|
+
|
82
|
+
$ bundle exec guard
|
83
|
+
|
84
|
+
## Development
|
85
|
+
|
86
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
87
|
+
|
88
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
89
|
+
|
90
|
+
## Notes
|
91
|
+
API fails:
|
92
|
+
* `getJobIDs` should be `getJobIds`, this is the only place where `id` is with capital D... Means that `Savon` call has to be `get_job_i_ds`
|
93
|
+
|
94
|
+
## Contributing
|
95
|
+
|
96
|
+
1. Fork it ( https://github.com/tomasc/extensis_portfolio/fork )
|
97
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
98
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
99
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
100
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "extensis_portfolio"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'extensis_portfolio/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'extensis_portfolio'
|
8
|
+
spec.version = ExtensisPortfolio::VERSION
|
9
|
+
spec.authors = ['Tomáš Celizna', 'Asger Behncke Jacobsen']
|
10
|
+
spec.email = ['mail@tomascelizna.com', 'asger@8kilo.com']
|
11
|
+
|
12
|
+
spec.summary = 'A simple wrapper for the Extensis Portfolio API.'
|
13
|
+
spec.description = 'A simple wrapper for the Extensis Portfolio API using the SOAP client Savon and the HTTP client Faraday.'
|
14
|
+
spec.homepage = 'https://github.com/tomasc/extensis_portfolio'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'savon', '~> 2.11'
|
22
|
+
spec.add_dependency 'faraday', '~> 0.9'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'guard'
|
27
|
+
spec.add_development_dependency 'guard-minitest'
|
28
|
+
spec.add_development_dependency 'minitest'
|
29
|
+
spec.add_development_dependency 'minitest-vcr'
|
30
|
+
spec.add_development_dependency 'webmock'
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "savon"
|
2
|
+
require "faraday"
|
3
|
+
require "base64"
|
4
|
+
require "openssl"
|
5
|
+
|
6
|
+
require "extensis_portfolio/asset_downloader"
|
7
|
+
require "extensis_portfolio/asset_query"
|
8
|
+
require "extensis_portfolio/asset_query_term"
|
9
|
+
require "extensis_portfolio/connection"
|
10
|
+
require "extensis_portfolio/job"
|
11
|
+
require "extensis_portfolio/task"
|
12
|
+
require "extensis_portfolio/rsa_encryption"
|
13
|
+
|
14
|
+
require "extensis_portfolio/version"
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module ExtensisPortfolio
|
2
|
+
class AssetDownloader
|
3
|
+
# Creates a new instance of ExtensisPortfolio::AssetDownloader
|
4
|
+
#
|
5
|
+
# @param connection [ExtensisPortfolio::Connection]
|
6
|
+
# @param catalog_id [String]
|
7
|
+
def initialize(connection, catalog_id)
|
8
|
+
@connection = connection
|
9
|
+
@session_id = connection.session_id
|
10
|
+
@soap_client = connection.soap_client
|
11
|
+
@http_client = connection.http_client
|
12
|
+
@catalog_id = catalog_id
|
13
|
+
end
|
14
|
+
|
15
|
+
# Runs the HTTP request on the connection and returns a file
|
16
|
+
#
|
17
|
+
# @param asset_id [String]
|
18
|
+
# @return [Hash] response of the request
|
19
|
+
def download_asset(asset_id)
|
20
|
+
http_download_file_request(asset_id).body
|
21
|
+
end
|
22
|
+
|
23
|
+
private # =============================================================
|
24
|
+
|
25
|
+
def task
|
26
|
+
ExtensisPortfolio::Task.new('Download asset', 'download', @catalog_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def job
|
30
|
+
ExtensisPortfolio::Job.new('original', [task.to_hash])
|
31
|
+
end
|
32
|
+
|
33
|
+
def asset_query_term(asset_id)
|
34
|
+
ExtensisPortfolio::AssetQueryTerm.new('asset_id', 'equalValue', asset_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
def asset_query(asset_id)
|
38
|
+
ExtensisPortfolio::AssetQuery.new(asset_query_term(asset_id).to_hash)
|
39
|
+
end
|
40
|
+
|
41
|
+
def run_job_message(asset_id)
|
42
|
+
{
|
43
|
+
session_id: @session_id,
|
44
|
+
catalog_id: @catalog_id,
|
45
|
+
assets: asset_query(asset_id).to_hash,
|
46
|
+
job: job.to_hash
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def run_job_request(asset_id)
|
51
|
+
@soap_client.call(:run_job, message: run_job_message(asset_id))
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_job_id(asset_id)
|
55
|
+
run_job_request(asset_id).body.fetch(:run_job_response).fetch(:return)
|
56
|
+
end
|
57
|
+
|
58
|
+
def http_download_file_request(asset_id)
|
59
|
+
job_id = get_job_id(asset_id)
|
60
|
+
|
61
|
+
@http_client.get('/FileTransfer/download', sessionId: @session_id, jobId: job_id)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ExtensisPortfolio
|
2
|
+
class AssetQuery
|
3
|
+
# Creates a new instance of ExtensisPortfolio::AssetQuery
|
4
|
+
#
|
5
|
+
# @param query_term [ExtensisPortfolio::AssetQueryTerm]
|
6
|
+
def initialize(query_term)
|
7
|
+
@query_term = query_term
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns a Hash for use in a soap request
|
11
|
+
#
|
12
|
+
# @return [Hash]
|
13
|
+
def to_hash
|
14
|
+
{ query_term: @query_term.to_hash }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ExtensisPortfolio
|
2
|
+
class AssetQueryTerm
|
3
|
+
# Creates a new instance of ExtensisPortfolio::AssetQueryTerm
|
4
|
+
#
|
5
|
+
# @param field_name [String] the field used for the query, e.g. `asset_id`
|
6
|
+
# @param operator [String] query operator, e.g. `equalValue`
|
7
|
+
# @param values [String] the value to query for, e.g. id of the asset
|
8
|
+
def initialize(field_name, operator, values)
|
9
|
+
@field_name = field_name
|
10
|
+
@operator = operator
|
11
|
+
@values = values
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns a Hash for use in a soap request
|
15
|
+
#
|
16
|
+
# @return [Hash]
|
17
|
+
def to_hash
|
18
|
+
{
|
19
|
+
field_name: @field_name,
|
20
|
+
operator: @operator,
|
21
|
+
values: @values
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module ExtensisPortfolio
|
4
|
+
class Connection
|
5
|
+
# Returns the session_id used to make calls to the Extensis Portfolio API
|
6
|
+
#
|
7
|
+
# @return [String]
|
8
|
+
attr_reader :session_id
|
9
|
+
|
10
|
+
# Returns a Faraday::Connection object for making http requests to the
|
11
|
+
# Extensis Portfolio API
|
12
|
+
#
|
13
|
+
# @return [Faraday::Connection]
|
14
|
+
attr_reader :http_client
|
15
|
+
|
16
|
+
# Returns a Savon::Client for making calls soap requests to the
|
17
|
+
# Extensis Portfolio API
|
18
|
+
#
|
19
|
+
# @return [Savon::Client]
|
20
|
+
attr_reader :soap_client
|
21
|
+
|
22
|
+
# Creates a new instance of ExtensisPortfolio::Connection
|
23
|
+
#
|
24
|
+
# @param server [String]
|
25
|
+
# @param username [String]
|
26
|
+
# @param password [String]
|
27
|
+
def initialize(server, username, password, options = {})
|
28
|
+
@username = username
|
29
|
+
@password = password
|
30
|
+
savon_options = options.merge(wsdl: "#{server}/ws/1.0/AssetService?wsdl")
|
31
|
+
@soap_client = Savon.client(savon_options)
|
32
|
+
@http_client = Faraday.new(url: server)
|
33
|
+
@session_id = get_session_id
|
34
|
+
end
|
35
|
+
|
36
|
+
# Logs in the soap client
|
37
|
+
#
|
38
|
+
# @param username [String]
|
39
|
+
# @param password [String]
|
40
|
+
# @return [Savon::Response]
|
41
|
+
def login(_username, _password)
|
42
|
+
message = { user_name: @username, encrypted_password: get_encrypted_password }
|
43
|
+
|
44
|
+
@soap_client.call(:login, message: message)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Logs out the soap client, making the session id invalid
|
48
|
+
#
|
49
|
+
def logout
|
50
|
+
message = { session_id: @session_id }
|
51
|
+
|
52
|
+
@soap_client.call(:logout, message: message)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns a list of available soap operations
|
56
|
+
#
|
57
|
+
# @return [Array]
|
58
|
+
def get_soap_operations
|
59
|
+
@soap_client.operations
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns a list of assets based on a query
|
63
|
+
# TODO: Simple method to get asset by id
|
64
|
+
#
|
65
|
+
# @param catalog_id [String]
|
66
|
+
# @param query [AssetQuery]
|
67
|
+
# @param result_options [Hash] optional hash with options how to display the results
|
68
|
+
# @return [Array]
|
69
|
+
def get_assets(catalog_id, query, result_options = {})
|
70
|
+
message = { session_id: @session_id, catalog_id: catalog_id, assets: query.to_hash, result_options: result_options }
|
71
|
+
|
72
|
+
@soap_client.call(:get_assets, message: message).body[:get_assets_response][:return][:assets]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns the asset that has the provided id
|
76
|
+
#
|
77
|
+
# @param catalog_id [String]
|
78
|
+
# @param asset_id [String]
|
79
|
+
# @param result_options [Hash] optional hash with options how to display the results
|
80
|
+
# @return [Hash]
|
81
|
+
def get_asset_by_id(catalog_id, asset_id, result_options = {})
|
82
|
+
query_term = ExtensisPortfolio::AssetQueryTerm.new('asset_id', 'equalValue', asset_id)
|
83
|
+
query = ExtensisPortfolio::AssetQuery.new(query_term.to_hash)
|
84
|
+
|
85
|
+
get_assets(catalog_id, query, result_options)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns a list of catalogs
|
89
|
+
#
|
90
|
+
# @return [Array]
|
91
|
+
def get_catalogs
|
92
|
+
message = { session_id: @session_id }
|
93
|
+
|
94
|
+
@soap_client.call(:get_catalogs, message: message).body[:get_catalogs_response][:return]
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns a list of job ids
|
98
|
+
#
|
99
|
+
# @return [Array]
|
100
|
+
def get_job_ids
|
101
|
+
message = { session_id: @session_id }
|
102
|
+
|
103
|
+
@soap_client.call(:get_job_i_ds, message: message).body[:get_job_i_ds_response][:return]
|
104
|
+
end
|
105
|
+
|
106
|
+
# Get the status of jobs
|
107
|
+
#
|
108
|
+
# @param job_ids [Array] array of job ids
|
109
|
+
# @return [Array]
|
110
|
+
def get_status_for_jobs(job_ids)
|
111
|
+
message = { session_id: @session_id, job_ids: job_ids }
|
112
|
+
|
113
|
+
@soap_client.call(:get_status_for_jobs, message: message).body[:get_status_for_jobs_response][:return]
|
114
|
+
end
|
115
|
+
|
116
|
+
# Get the error details of a job
|
117
|
+
#
|
118
|
+
# @param job_id [String] job id
|
119
|
+
# @return [Hash]
|
120
|
+
def get_error_details_for_job(job_id)
|
121
|
+
message = { session_id: @session_id, job_id: job_id }
|
122
|
+
@soap_client.call(:get_error_details_for_job, message: message).body[:get_error_details_for_job_response][:return]
|
123
|
+
end
|
124
|
+
|
125
|
+
private # =============================================================
|
126
|
+
|
127
|
+
def get_session_id
|
128
|
+
login_response = login(@username, @password).body.fetch(:login_response)
|
129
|
+
|
130
|
+
login_response.fetch(:return)
|
131
|
+
end
|
132
|
+
|
133
|
+
def get_rsa_public_encryption_key
|
134
|
+
response = @soap_client.call(:get_rsa_public_encryption_key).body
|
135
|
+
encryption_key = response.fetch(:get_rsa_public_encryption_key_response).fetch(:return)
|
136
|
+
|
137
|
+
{
|
138
|
+
modulus: encryption_key.fetch(:modulus_base16).to_i(16),
|
139
|
+
exponent: encryption_key.fetch(:exponent).to_i
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_encrypted_password
|
144
|
+
modulus = get_rsa_public_encryption_key.fetch(:modulus)
|
145
|
+
exponent = get_rsa_public_encryption_key.fetch(:exponent)
|
146
|
+
|
147
|
+
ExtensisPortfolio::RSAEncryption.new(modulus, exponent).encrypt(@password)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ExtensisPortfolio
|
2
|
+
class Job
|
3
|
+
# Creates a new instance of ExtensisPortfolio::Job
|
4
|
+
#
|
5
|
+
# @param source_image [String] source image, either `original` or `preview`
|
6
|
+
# @param tasks [Array] array of tasks
|
7
|
+
def initialize(source_image, tasks)
|
8
|
+
@source_image = source_image
|
9
|
+
@tasks = tasks.map(&:to_hash)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns a Hash for use in a soap request
|
13
|
+
#
|
14
|
+
# @return [Hash]
|
15
|
+
def to_hash
|
16
|
+
{
|
17
|
+
source_image: @source_image,
|
18
|
+
tasks: @tasks
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ExtensisPortfolio
|
2
|
+
class RSAEncryption
|
3
|
+
def initialize(modulus, exponent)
|
4
|
+
seq = OpenSSL::ASN1::Sequence.new([OpenSSL::ASN1::Integer.new(modulus), OpenSSL::ASN1::Integer.new(exponent)])
|
5
|
+
@public_key = OpenSSL::PKey::RSA.new(seq.to_der)
|
6
|
+
end
|
7
|
+
|
8
|
+
def encrypt(string)
|
9
|
+
Base64.encode64(@public_key.public_encrypt(string))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ExtensisPortfolio
|
2
|
+
class Task
|
3
|
+
# Creates a new ExtensisPortfolio::Task
|
4
|
+
#
|
5
|
+
# @param name [String] the name of the task
|
6
|
+
# @param type [String] the type of task, [list of options](http://doc.extensis.com/api/portfolio/assets_taskType.html)
|
7
|
+
# @param catalog_id [String] the catalog id
|
8
|
+
# @param settings [Array] optional settings
|
9
|
+
def initialize(name, type, catalog_id, settings = [])
|
10
|
+
@name = name
|
11
|
+
@type = type
|
12
|
+
@catalog_id = catalog_id
|
13
|
+
@settings = settings
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns a Hash for use in a soap request
|
17
|
+
#
|
18
|
+
# @return [Hash]
|
19
|
+
def to_hash
|
20
|
+
{
|
21
|
+
name: @name,
|
22
|
+
type: @type,
|
23
|
+
catalog_id: @catalog_id,
|
24
|
+
settings: @settings
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: extensis_portfolio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomáš Celizna
|
8
|
+
- Asger Behncke Jacobsen
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.11'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.11'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.9'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.9'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.9'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.9'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: guard
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: guard-minitest
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: minitest
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: minitest-vcr
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: webmock
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
description: A simple wrapper for the Extensis Portfolio API using the SOAP client
|
141
|
+
Savon and the HTTP client Faraday.
|
142
|
+
email:
|
143
|
+
- mail@tomascelizna.com
|
144
|
+
- asger@8kilo.com
|
145
|
+
executables: []
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- ".gitignore"
|
150
|
+
- ".travis.yml"
|
151
|
+
- Gemfile
|
152
|
+
- Gemfile.lock
|
153
|
+
- Guardfile
|
154
|
+
- README.md
|
155
|
+
- Rakefile
|
156
|
+
- bin/console
|
157
|
+
- bin/setup
|
158
|
+
- extensis_portfolio.gemspec
|
159
|
+
- lib/extensis_portfolio.rb
|
160
|
+
- lib/extensis_portfolio/asset_downloader.rb
|
161
|
+
- lib/extensis_portfolio/asset_query.rb
|
162
|
+
- lib/extensis_portfolio/asset_query_term.rb
|
163
|
+
- lib/extensis_portfolio/connection.rb
|
164
|
+
- lib/extensis_portfolio/job.rb
|
165
|
+
- lib/extensis_portfolio/rsa_encryption.rb
|
166
|
+
- lib/extensis_portfolio/task.rb
|
167
|
+
- lib/extensis_portfolio/version.rb
|
168
|
+
- test_logfile.log
|
169
|
+
homepage: https://github.com/tomasc/extensis_portfolio
|
170
|
+
licenses: []
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.4.5.1
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: A simple wrapper for the Extensis Portfolio API.
|
192
|
+
test_files: []
|