strawberry_api 0.1.0
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/.gitignore +9 -0
- data/.rubocop.yml +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +135 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/HTTParty/Response.html +148 -0
- data/doc/StrawberryAPI/AccessRight.html +431 -0
- data/doc/StrawberryAPI/ApiKey.html +637 -0
- data/doc/StrawberryAPI/ArchiveStrategy.html +365 -0
- data/doc/StrawberryAPI/ArchiveStrategyState.html +1057 -0
- data/doc/StrawberryAPI/Asset.html +1791 -0
- data/doc/StrawberryAPI/AssetCopyToStrategy.html +145 -0
- data/doc/StrawberryAPI/AssetFeedback.html +370 -0
- data/doc/StrawberryAPI/Client/ApiKeys.html +904 -0
- data/doc/StrawberryAPI/Client/ArchiveStrategies.html +784 -0
- data/doc/StrawberryAPI/Client/AssetCopyToStrategies.html +805 -0
- data/doc/StrawberryAPI/Client/AssetFeedbacks.html +232 -0
- data/doc/StrawberryAPI/Client/Assets.html +888 -0
- data/doc/StrawberryAPI/Client/Collections.html +319 -0
- data/doc/StrawberryAPI/Client/CopyToFeedbacks.html +232 -0
- data/doc/StrawberryAPI/Client/CustomMetadata.html +210 -0
- data/doc/StrawberryAPI/Client/CustomMetadataFields.html +214 -0
- data/doc/StrawberryAPI/Client/CustomMetadataOptions.html +214 -0
- data/doc/StrawberryAPI/Client/CustomMetadataSets.html +214 -0
- data/doc/StrawberryAPI/Client/Edits.html +485 -0
- data/doc/StrawberryAPI/Client/Features.html +319 -0
- data/doc/StrawberryAPI/Client/Libraries.html +321 -0
- data/doc/StrawberryAPI/Client/Markers.html +234 -0
- data/doc/StrawberryAPI/Client/ProjectCopyToStrategies.html +857 -0
- data/doc/StrawberryAPI/Client/ProjectFeedbacks.html +232 -0
- data/doc/StrawberryAPI/Client/Projects.html +2764 -0
- data/doc/StrawberryAPI/Client/Roles.html +214 -0
- data/doc/StrawberryAPI/Client/Schedules.html +319 -0
- data/doc/StrawberryAPI/Client/Searches.html +293 -0
- data/doc/StrawberryAPI/Client/Sessions.html +376 -0
- data/doc/StrawberryAPI/Client/Settings.html +210 -0
- data/doc/StrawberryAPI/Client/StatusFlags.html +315 -0
- data/doc/StrawberryAPI/Client/Teams.html +1067 -0
- data/doc/StrawberryAPI/Client/Templates.html +319 -0
- data/doc/StrawberryAPI/Client/Users.html +1255 -0
- data/doc/StrawberryAPI/Client.html +487 -0
- data/doc/StrawberryAPI/Collection.html +427 -0
- data/doc/StrawberryAPI/Configuration.html +481 -0
- data/doc/StrawberryAPI/CopyToFeedback.html +220 -0
- data/doc/StrawberryAPI/CustomMetadataField.html +999 -0
- data/doc/StrawberryAPI/CustomMetadataOption.html +567 -0
- data/doc/StrawberryAPI/CustomMetadataSet.html +649 -0
- data/doc/StrawberryAPI/CustomMetadatum.html +718 -0
- data/doc/StrawberryAPI/Edit.html +637 -0
- data/doc/StrawberryAPI/Feature.html +567 -0
- data/doc/StrawberryAPI/Feedback.html +641 -0
- data/doc/StrawberryAPI/HttpClient.html +971 -0
- data/doc/StrawberryAPI/Library.html +637 -0
- data/doc/StrawberryAPI/Marker.html +847 -0
- data/doc/StrawberryAPI/Project.html +2395 -0
- data/doc/StrawberryAPI/ProjectCopyToStrategy.html +365 -0
- data/doc/StrawberryAPI/ProjectFeedback.html +370 -0
- data/doc/StrawberryAPI/Proxy.html +1267 -0
- data/doc/StrawberryAPI/Role.html +567 -0
- data/doc/StrawberryAPI/Schedule.html +2387 -0
- data/doc/StrawberryAPI/Session.html +121 -0
- data/doc/StrawberryAPI/Setting.html +207 -0
- data/doc/StrawberryAPI/StatusFlag.html +207 -0
- data/doc/StrawberryAPI/Strategy.html +641 -0
- data/doc/StrawberryAPI/Team.html +789 -0
- data/doc/StrawberryAPI/Template.html +707 -0
- data/doc/StrawberryAPI/User.html +999 -0
- data/doc/StrawberryAPI.html +483 -0
- data/doc/_index.html +632 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +222 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +222 -0
- data/doc/js/app.js +292 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +3059 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/strawberry_api/access_right.rb +18 -0
- data/lib/strawberry_api/api_key.rb +19 -0
- data/lib/strawberry_api/asset.rb +51 -0
- data/lib/strawberry_api/client/api_keys.rb +49 -0
- data/lib/strawberry_api/client/archive_strategies.rb +87 -0
- data/lib/strawberry_api/client/asset_copy_to_strategies.rb +83 -0
- data/lib/strawberry_api/client/asset_feedbacks.rb +18 -0
- data/lib/strawberry_api/client/assets.rb +92 -0
- data/lib/strawberry_api/client/collections.rb +29 -0
- data/lib/strawberry_api/client/copy_to_feedbacks.rb +18 -0
- data/lib/strawberry_api/client/custom_metadata.rb +16 -0
- data/lib/strawberry_api/client/custom_metadata_fields.rb +18 -0
- data/lib/strawberry_api/client/custom_metadata_options.rb +18 -0
- data/lib/strawberry_api/client/custom_metadata_sets.rb +18 -0
- data/lib/strawberry_api/client/edits.rb +47 -0
- data/lib/strawberry_api/client/features.rb +29 -0
- data/lib/strawberry_api/client/libraries.rb +30 -0
- data/lib/strawberry_api/client/markers.rb +19 -0
- data/lib/strawberry_api/client/project_copy_to_strategies.rb +88 -0
- data/lib/strawberry_api/client/project_feedbacks.rb +18 -0
- data/lib/strawberry_api/client/projects.rb +305 -0
- data/lib/strawberry_api/client/roles.rb +18 -0
- data/lib/strawberry_api/client/schedules.rb +29 -0
- data/lib/strawberry_api/client/searches.rb +25 -0
- data/lib/strawberry_api/client/sessions.rb +33 -0
- data/lib/strawberry_api/client/settings.rb +16 -0
- data/lib/strawberry_api/client/status_flags.rb +27 -0
- data/lib/strawberry_api/client/teams.rb +107 -0
- data/lib/strawberry_api/client/templates.rb +29 -0
- data/lib/strawberry_api/client/users.rb +125 -0
- data/lib/strawberry_api/client.rb +95 -0
- data/lib/strawberry_api/collection.rb +16 -0
- data/lib/strawberry_api/configuration.rb +19 -0
- data/lib/strawberry_api/custom_metadata/custom_metadata_field.rb +30 -0
- data/lib/strawberry_api/custom_metadata/custom_metadata_option.rb +18 -0
- data/lib/strawberry_api/custom_metadata/custom_metadata_set.rb +25 -0
- data/lib/strawberry_api/custom_metadatum.rb +30 -0
- data/lib/strawberry_api/edit.rb +19 -0
- data/lib/strawberry_api/feature.rb +18 -0
- data/lib/strawberry_api/feedback/asset_feedback.rb +15 -0
- data/lib/strawberry_api/feedback/copy_to_feedback.rb +12 -0
- data/lib/strawberry_api/feedback/project_feedback.rb +15 -0
- data/lib/strawberry_api/feedback.rb +19 -0
- data/lib/strawberry_api/http_client.rb +135 -0
- data/lib/strawberry_api/library.rb +19 -0
- data/lib/strawberry_api/marker.rb +22 -0
- data/lib/strawberry_api/project.rb +48 -0
- data/lib/strawberry_api/proxy.rb +28 -0
- data/lib/strawberry_api/role.rb +18 -0
- data/lib/strawberry_api/schedule.rb +44 -0
- data/lib/strawberry_api/session.rb +7 -0
- data/lib/strawberry_api/setting.rb +12 -0
- data/lib/strawberry_api/status_flag.rb +12 -0
- data/lib/strawberry_api/strategy/archive_strategy.rb +10 -0
- data/lib/strawberry_api/strategy/archive_strategy_state.rb +25 -0
- data/lib/strawberry_api/strategy/asset_copy_to_strategy.rb +6 -0
- data/lib/strawberry_api/strategy/project_copy_to_strategy.rb +9 -0
- data/lib/strawberry_api/strategy.rb +19 -0
- data/lib/strawberry_api/team.rb +27 -0
- data/lib/strawberry_api/template.rb +20 -0
- data/lib/strawberry_api/user.rb +30 -0
- data/lib/strawberry_api/version.rb +3 -0
- data/lib/strawberry_api.rb +36 -0
- data/samples/README.md +14 -0
- data/samples/list_assets_links.rb +15 -0
- data/samples/list_projects.rb +14 -0
- data/samples/login.rb +18 -0
- data/samples/test.rb +12 -0
- data/strawberry_api.gemspec +40 -0
- metadata +242 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module StrawberryAPI
|
4
|
+
# Class HttpClient provides a way to query a remote HTTP server
|
5
|
+
# It shamelessly uses the HTTParty gem for all the dirty job
|
6
|
+
#
|
7
|
+
# @author Pierre Lebrun <pierreyves.lebrun@gmail.com>
|
8
|
+
#
|
9
|
+
class HttpClient
|
10
|
+
|
11
|
+
include HTTParty
|
12
|
+
headers 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-FLAVOURSYS-CLIENT': 'API client 1.0'
|
13
|
+
|
14
|
+
# Class HTTParty::Response provides methods to handle HTTP reponses
|
15
|
+
#
|
16
|
+
# @author John Nunemaker <nunemaker@gmail.com>
|
17
|
+
#
|
18
|
+
class HTTParty::Response
|
19
|
+
# Alias for HTTParty parsed_reponse method
|
20
|
+
alias_method :parse, :parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
# Logs in and stores authentication session
|
24
|
+
#
|
25
|
+
# @option [String] host Hostname or IP address of Strawberry server
|
26
|
+
# @option [String] username Username of Strawberry's user
|
27
|
+
# @option [String] password Password of Strawberry's user
|
28
|
+
# @option [String] api_key API key of Strawberry's user
|
29
|
+
#
|
30
|
+
# @return [StrawberryAPI::API:User] logged in user
|
31
|
+
#
|
32
|
+
def initialize(**options)
|
33
|
+
if options.empty?
|
34
|
+
username = StrawberryAPI.config.username
|
35
|
+
password = StrawberryAPI.config.password
|
36
|
+
api_key = StrawberryAPI.config.api_key
|
37
|
+
else
|
38
|
+
username = options[:username]
|
39
|
+
password = options[:password]
|
40
|
+
api_key = options[:api_key]
|
41
|
+
end
|
42
|
+
|
43
|
+
self.class.base_uri("http://#{StrawberryAPI.config.host}/api/v1")
|
44
|
+
|
45
|
+
if api_key
|
46
|
+
self.class.get("/session", headers: {Authorization: "Bearer #{api_key}"}).success?
|
47
|
+
|
48
|
+
@headers = self.class.headers.dup
|
49
|
+
@headers[:Authorization] = "Bearer #{api_key}"
|
50
|
+
elsif username && password
|
51
|
+
session = self.class.post('/session', query: {login: username, password: password})
|
52
|
+
authentication_token = session.parse['authentication_token']
|
53
|
+
|
54
|
+
@cookies = self.class.cookies.dup
|
55
|
+
@cookies[:_auth_token] = authentication_token
|
56
|
+
else
|
57
|
+
raise 'Invalid credentials provided'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def request(method, path, mute_failure: false, **options)
|
62
|
+
options[:headers] = @headers
|
63
|
+
options[:cookies] = @cookies
|
64
|
+
|
65
|
+
response = self.class.send(method, path, options)
|
66
|
+
|
67
|
+
if mute_failure
|
68
|
+
response
|
69
|
+
else
|
70
|
+
handle_response(response)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Handles HTTParty reponse
|
75
|
+
#
|
76
|
+
# @param [HTTParty::Response] response
|
77
|
+
#
|
78
|
+
# @return [HTTParty::Response] HTTP reponse
|
79
|
+
#
|
80
|
+
# @raise [String] Indicates the reponse error code and information
|
81
|
+
#
|
82
|
+
def handle_response(response)
|
83
|
+
if response.success?
|
84
|
+
response
|
85
|
+
else
|
86
|
+
raise "#{response.code} #{response['error']}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Overrides HTTPary reponse handling
|
91
|
+
#
|
92
|
+
# @param [String] path
|
93
|
+
# @param [String] mute_failure Prevents error raise if request fails
|
94
|
+
#
|
95
|
+
# @return [HTTParty::Response] API response
|
96
|
+
#
|
97
|
+
def get(path, mute_failure: false, **options)
|
98
|
+
request(:get, path, mute_failure: false, **options)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Overrides HTTPary reponse handling
|
102
|
+
#
|
103
|
+
# @param [String] path
|
104
|
+
# @param [String] mute_failure Prevents error raise if request fails
|
105
|
+
#
|
106
|
+
# @return [HTTParty::Response] API response
|
107
|
+
#
|
108
|
+
def post(path, mute_failure: false, **options)
|
109
|
+
request(:post, path, mute_failure: false, **options)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Overrides HTTPary reponse handling
|
113
|
+
#
|
114
|
+
# @param [String] path
|
115
|
+
# @param [String] mute_failure Prevents error raise if request fails
|
116
|
+
#
|
117
|
+
# @return [HTTParty::Response] API response
|
118
|
+
#
|
119
|
+
def put(path, mute_failure: false, **options)
|
120
|
+
request(:put, path, mute_failure: false, **options)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Overrides HTTPary reponse handling
|
124
|
+
#
|
125
|
+
# @param [String] path
|
126
|
+
# @param [String] mute_failure Prevents error raise if request fails
|
127
|
+
#
|
128
|
+
# @return [HTTParty::Response] API response
|
129
|
+
#
|
130
|
+
def delete(path, mute_failure: false, **options)
|
131
|
+
request(:delete, path, mute_failure: false, **options)
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Library
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :project_id
|
7
|
+
attr_accessor :ingest_path
|
8
|
+
attr_accessor :ingest_storage
|
9
|
+
attr_accessor :options
|
10
|
+
attr_accessor :ingest_path_exists
|
11
|
+
|
12
|
+
def initialize(params = {})
|
13
|
+
params.each do |k, v|
|
14
|
+
instance_variable_set("@#{k.gsub(/[!@#$%^&*?']/, '')}", v) unless v.nil?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Marker
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :asset_id
|
7
|
+
attr_accessor :text
|
8
|
+
attr_accessor :created_by
|
9
|
+
attr_accessor :in
|
10
|
+
attr_accessor :out
|
11
|
+
attr_accessor :created_at
|
12
|
+
attr_accessor :updated_at
|
13
|
+
attr_accessor :guid
|
14
|
+
|
15
|
+
def initialize(params = {})
|
16
|
+
params.each do |k, v|
|
17
|
+
instance_variable_set("@#{k.gsub(/[!@#$%^&*?']/, '')}", v) unless v.nil?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Project
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :size
|
8
|
+
attr_accessor :created_at
|
9
|
+
attr_accessor :updated_at
|
10
|
+
attr_accessor :locked_by
|
11
|
+
attr_accessor :templatename
|
12
|
+
attr_accessor :template_type
|
13
|
+
attr_accessor :last_opened_by
|
14
|
+
attr_accessor :created_by
|
15
|
+
attr_accessor :last_used_at
|
16
|
+
attr_accessor :delta
|
17
|
+
attr_accessor :user_id
|
18
|
+
attr_accessor :archive_strategy_id
|
19
|
+
attr_accessor :archive_strategy_state
|
20
|
+
attr_accessor :frozen_by_id
|
21
|
+
attr_accessor :is_library_project
|
22
|
+
attr_accessor :last_opened_by_edit
|
23
|
+
attr_accessor :created_by_edit
|
24
|
+
attr_accessor :deleted
|
25
|
+
attr_accessor :owner_id
|
26
|
+
attr_accessor :quota
|
27
|
+
attr_accessor :prefix
|
28
|
+
attr_accessor :encoding_priority
|
29
|
+
attr_accessor :fsp_cache
|
30
|
+
attr_accessor :alternative_name
|
31
|
+
attr_accessor :tiering_storage
|
32
|
+
attr_accessor :tiered_at
|
33
|
+
attr_accessor :mounted_by
|
34
|
+
attr_accessor :subprojects
|
35
|
+
attr_accessor :parentprojects
|
36
|
+
|
37
|
+
def initialize(params = {})
|
38
|
+
params.each do |k, v|
|
39
|
+
if k == 'archive_strategy_state'
|
40
|
+
ArchiveStrategyState.new(v)
|
41
|
+
end
|
42
|
+
|
43
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Proxy
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :asset_id
|
7
|
+
attr_accessor :path
|
8
|
+
attr_accessor :created_at
|
9
|
+
attr_accessor :updated_at
|
10
|
+
attr_accessor :in_progress
|
11
|
+
attr_accessor :preview_ext
|
12
|
+
attr_accessor :thumbnail_ext
|
13
|
+
attr_accessor :animation_ext
|
14
|
+
attr_accessor :structure_version
|
15
|
+
attr_accessor :video
|
16
|
+
attr_accessor :thumbnail
|
17
|
+
attr_accessor :animation
|
18
|
+
attr_accessor :preview
|
19
|
+
attr_accessor :stream
|
20
|
+
|
21
|
+
def initialize(params = {})
|
22
|
+
params.each do |k, v|
|
23
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Role
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :size
|
8
|
+
attr_accessor :created_at
|
9
|
+
attr_accessor :updated_at
|
10
|
+
|
11
|
+
def initialize(params = {})
|
12
|
+
params.each do |k, v|
|
13
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Schedule
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :size
|
8
|
+
attr_accessor :created_at
|
9
|
+
attr_accessor :updated_at
|
10
|
+
attr_accessor :locked_by
|
11
|
+
attr_accessor :templatename
|
12
|
+
attr_accessor :template_type
|
13
|
+
attr_accessor :last_opened_by
|
14
|
+
attr_accessor :created_by
|
15
|
+
attr_accessor :last_used_at
|
16
|
+
attr_accessor :delta
|
17
|
+
attr_accessor :user_id
|
18
|
+
attr_accessor :archive_strategy_id
|
19
|
+
attr_accessor :archive_strategy_state_id
|
20
|
+
attr_accessor :frozen_by_id
|
21
|
+
attr_accessor :is_library_project
|
22
|
+
attr_accessor :last_opened_by_edit
|
23
|
+
attr_accessor :created_by_edit
|
24
|
+
attr_accessor :deleted
|
25
|
+
attr_accessor :owner_id
|
26
|
+
attr_accessor :quota
|
27
|
+
attr_accessor :prefix
|
28
|
+
attr_accessor :encoding_priority
|
29
|
+
attr_accessor :fsp_cache
|
30
|
+
attr_accessor :alternative_name
|
31
|
+
attr_accessor :tiering_storage
|
32
|
+
attr_accessor :tiered_at
|
33
|
+
attr_accessor :mounted_by
|
34
|
+
attr_accessor :subprojects
|
35
|
+
attr_accessor :parentprojects
|
36
|
+
|
37
|
+
def initialize(params = {})
|
38
|
+
params.each do |k, v|
|
39
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class ArchiveStrategyState
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :archive_strategy_id
|
7
|
+
attr_accessor :user_id
|
8
|
+
attr_accessor :project_id
|
9
|
+
attr_accessor :direction
|
10
|
+
attr_accessor :state
|
11
|
+
attr_accessor :error
|
12
|
+
attr_accessor :stage
|
13
|
+
attr_accessor :progress
|
14
|
+
attr_accessor :started_at
|
15
|
+
attr_accessor :cancelled
|
16
|
+
attr_accessor :exclude_linked_files
|
17
|
+
|
18
|
+
def initialize(params = {})
|
19
|
+
params.each do |k, v|
|
20
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Strategy
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :destination
|
8
|
+
attr_accessor :format
|
9
|
+
attr_accessor :admin_only
|
10
|
+
attr_accessor :enabled
|
11
|
+
|
12
|
+
def initialize(params = {})
|
13
|
+
params.each do |k, v|
|
14
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Team
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :created_at
|
8
|
+
attr_accessor :updated_at
|
9
|
+
attr_accessor :quota_mail_sent
|
10
|
+
attr_accessor :quota
|
11
|
+
attr_accessor :space_used
|
12
|
+
attr_accessor :users
|
13
|
+
|
14
|
+
def initialize(params = {})
|
15
|
+
params.each do |k, v|
|
16
|
+
if k == 'users'
|
17
|
+
v.map! do |user|
|
18
|
+
User.new(user)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class Template
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :created_at
|
8
|
+
attr_accessor :updated_at
|
9
|
+
attr_accessor :template_type
|
10
|
+
attr_accessor :position
|
11
|
+
attr_accessor :substitution_patterns
|
12
|
+
|
13
|
+
def initialize(params = {})
|
14
|
+
params.each do |k, v|
|
15
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module StrawberryAPI
|
2
|
+
|
3
|
+
class User
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :username
|
7
|
+
attr_accessor :authentication_token
|
8
|
+
attr_accessor :created_at
|
9
|
+
attr_accessor :updated_at
|
10
|
+
attr_accessor :firstname
|
11
|
+
attr_accessor :lastname
|
12
|
+
attr_accessor :own_team_id
|
13
|
+
attr_accessor :role_id
|
14
|
+
attr_accessor :role
|
15
|
+
attr_accessor :teams
|
16
|
+
|
17
|
+
def initialize(params = {})
|
18
|
+
params.each do |k, v|
|
19
|
+
if k == 'teams'
|
20
|
+
v.map! do |team|
|
21
|
+
Team.new(team)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
instance_variable_set("@#{k.gsub(/[!@#$%^&*?']/, '')}", v) unless v.nil?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'strawberry_api/configuration'
|
2
|
+
require 'strawberry_api/http_client'
|
3
|
+
require 'strawberry_api/client'
|
4
|
+
require 'strawberry_api/version'
|
5
|
+
|
6
|
+
# module StrawberryAPI provides access to Strawberry REST API
|
7
|
+
#
|
8
|
+
# @author Pierre Lebrun <pierreyves.lebrun@gmail.com>
|
9
|
+
#
|
10
|
+
module StrawberryAPI
|
11
|
+
|
12
|
+
# Return configuration
|
13
|
+
# If it has not been configured yet, initialize configuration
|
14
|
+
# @return [StrawberryAPI::Configuration] configuration object
|
15
|
+
def self.config
|
16
|
+
@config ||= StrawberryAPI::Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# Set configuration
|
20
|
+
#
|
21
|
+
# @param config [StrawberryAPI::Configuration] configuration object
|
22
|
+
# @return [StrawberryAPI::Configuration] configuration object
|
23
|
+
def self.config=(config)
|
24
|
+
raise TypeError unless config.is_a?(StrawberryAPI::Configuration)
|
25
|
+
@config = config
|
26
|
+
end
|
27
|
+
|
28
|
+
# Configure some settings
|
29
|
+
#
|
30
|
+
# @yield [config] Given configuration object
|
31
|
+
# @yieldparam config [StrawberryAPI::Configuration] configuration object
|
32
|
+
#
|
33
|
+
def self.configure
|
34
|
+
yield(config)
|
35
|
+
end
|
36
|
+
end
|
data/samples/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
## Samples
|
2
|
+
|
3
|
+
* [Login](login.rb)
|
4
|
+
* Client authenticating via both credentials and authentication tokens
|
5
|
+
* Uses the `logged_in?` method to confirm authentication successed
|
6
|
+
|
7
|
+
* [Projects listing](list_projects.rb)
|
8
|
+
* Client authenticating via credentials
|
9
|
+
* Uses `projects` method to fetch all projects
|
10
|
+
|
11
|
+
* [Assets links listing](list_assets_links.rb)
|
12
|
+
* Client authenticating via credentials
|
13
|
+
* Uses `methods` method to fetch all projects
|
14
|
+
* Uses `links` method on each asset to fetch the its links to other projects
|
@@ -0,0 +1,15 @@
|
|
1
|
+
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require File.join(dir, 'strawberry_api')
|
3
|
+
|
4
|
+
# Logs in to Strawberry server
|
5
|
+
strawberry = StrawberryAPI::Client.new(host: 'server_IP_or_hostname', username: 'username', password: 'password')
|
6
|
+
|
7
|
+
# Gets all Strawberry assets
|
8
|
+
StrawberryAPI.assets.each do |asset|
|
9
|
+
# Makes sure the asset is a video
|
10
|
+
# We don't care about other media types, they are muggles
|
11
|
+
if asset.video?
|
12
|
+
puts "The asset #{asset.name} is linked to the following projects:"
|
13
|
+
p asset.links
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require File.join(dir, 'strawberry_api')
|
3
|
+
|
4
|
+
# Configures API client
|
5
|
+
StrawberryAPI.configure do |c|
|
6
|
+
c.host = 'server_IP_or_hostname'
|
7
|
+
c.api_key = 'api_key'
|
8
|
+
end
|
9
|
+
|
10
|
+
# Instanciates a new client using the above config
|
11
|
+
strawberry = StrawberryAPI::Client.new
|
12
|
+
|
13
|
+
# Lists all projects
|
14
|
+
p StrawberryAPI.projects
|
data/samples/login.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require File.join(dir, 'strawberry_api')
|
3
|
+
|
4
|
+
# Configures API client
|
5
|
+
StrawberryAPI.configure do |c|
|
6
|
+
c.host = 'server_IP_or_hostname'
|
7
|
+
c.api_key = 'api_key'
|
8
|
+
end
|
9
|
+
|
10
|
+
# Instanciates a new client using the above config
|
11
|
+
strawberry = StrawberryAPI::Client.new
|
12
|
+
|
13
|
+
# Shows whether login was successful or not
|
14
|
+
if StrawberryAPI.logged_in?
|
15
|
+
p 'Successfully logged in!'
|
16
|
+
else
|
17
|
+
p 'Failed logging in...'
|
18
|
+
end
|
data/samples/test.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'pp'
|
2
|
+
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require File.join(dir, 'strawberry_api')
|
4
|
+
|
5
|
+
StrawberryAPI.configure do |c|
|
6
|
+
c.host = '10.240.51.151'
|
7
|
+
c.api_key = '7a8d4f46550e875a57a955c3897f75a4'
|
8
|
+
end
|
9
|
+
|
10
|
+
sb1 = StrawberryAPI::Client.new
|
11
|
+
p sb1.library(project_id: 24)
|
12
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "strawberry_api/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "strawberry_api"
|
8
|
+
spec.version = StrawberryAPI::VERSION
|
9
|
+
spec.authors = ["Pierre Lebrun"]
|
10
|
+
spec.email = ["pierreyves.lebrun@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Strawberry API client"
|
13
|
+
spec.description = "This gem is a client for Flavousys Strawberry REST API"
|
14
|
+
#spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
|
39
|
+
spec.add_runtime_dependency "httparty", "~> 0.16"
|
40
|
+
end
|