w3c_api 0.1.0 → 0.1.1
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 +4 -4
- data/LICENSE.md +1 -1
- data/README.adoc +845 -436
- data/lib/w3c_api/cli.rb +20 -20
- data/lib/w3c_api/client.rb +66 -195
- data/lib/w3c_api/commands/affiliation.rb +33 -33
- data/lib/w3c_api/commands/ecosystem.rb +47 -47
- data/lib/w3c_api/commands/group.rb +68 -68
- data/lib/w3c_api/commands/output_formatter.rb +11 -11
- data/lib/w3c_api/commands/participation.rb +20 -22
- data/lib/w3c_api/commands/series.rb +26 -26
- data/lib/w3c_api/commands/specification.rb +77 -52
- data/lib/w3c_api/commands/translation.rb +18 -18
- data/lib/w3c_api/commands/user.rb +60 -60
- data/lib/w3c_api/hal.rb +164 -0
- data/lib/w3c_api/models/account.rb +44 -0
- data/lib/w3c_api/models/affiliation.rb +54 -65
- data/lib/w3c_api/models/affiliation_index.rb +11 -0
- data/lib/w3c_api/models/call_for_translation.rb +15 -39
- data/lib/w3c_api/models/chair_index.rb +11 -0
- data/lib/w3c_api/models/charter.rb +48 -89
- data/lib/w3c_api/models/charter_index.rb +11 -0
- data/lib/w3c_api/models/connected_account.rb +21 -30
- data/lib/w3c_api/models/ecosystem.rb +20 -42
- data/lib/w3c_api/models/{ecosystems.rb → ecosystem_index.rb} +4 -10
- data/lib/w3c_api/models/evangelist_index.rb +11 -0
- data/lib/w3c_api/models/extension.rb +5 -7
- data/lib/w3c_api/models/group.rb +63 -142
- data/lib/w3c_api/models/group_index.rb +12 -0
- data/lib/w3c_api/models/join_emails.rb +5 -7
- data/lib/w3c_api/models/participant_index.rb +11 -0
- data/lib/w3c_api/models/participation.rb +31 -90
- data/lib/w3c_api/models/participation_index.rb +11 -0
- data/lib/w3c_api/models/photo.rb +26 -0
- data/lib/w3c_api/models/serie.rb +21 -51
- data/lib/w3c_api/models/{series.rb → serie_index.rb} +22 -13
- data/lib/w3c_api/models/spec_version.rb +69 -83
- data/lib/w3c_api/models/spec_version_index.rb +13 -0
- data/lib/w3c_api/models/spec_version_ref.rb +11 -13
- data/lib/w3c_api/models/specification.rb +54 -66
- data/lib/w3c_api/models/specification_index.rb +10 -0
- data/lib/w3c_api/models/team_contact_index.rb +11 -0
- data/lib/w3c_api/models/testimonial.rb +17 -0
- data/lib/w3c_api/models/translation.rb +33 -72
- data/lib/w3c_api/models/{translations.rb → translation_index.rb} +4 -12
- data/lib/w3c_api/models/user.rb +95 -165
- data/lib/w3c_api/models/user_index.rb +11 -0
- data/lib/w3c_api/models.rb +35 -12
- data/lib/w3c_api/version.rb +1 -1
- data/lib/w3c_api.rb +3 -2
- metadata +35 -19
- data/lib/w3c_api/models/affiliations.rb +0 -33
- data/lib/w3c_api/models/base.rb +0 -39
- data/lib/w3c_api/models/call_for_translation_ref.rb +0 -15
- data/lib/w3c_api/models/charters.rb +0 -17
- data/lib/w3c_api/models/collection_base.rb +0 -79
- data/lib/w3c_api/models/delegate_enumerable.rb +0 -54
- data/lib/w3c_api/models/groups.rb +0 -38
- data/lib/w3c_api/models/link.rb +0 -17
- data/lib/w3c_api/models/participations.rb +0 -17
- data/lib/w3c_api/models/series_collection.rb +0 -17
- data/lib/w3c_api/models/spec_versions.rb +0 -17
- data/lib/w3c_api/models/specifications.rb +0 -17
- data/lib/w3c_api/models/users.rb +0 -44
data/lib/w3c_api/cli.rb
CHANGED
@@ -11,31 +11,31 @@ require_relative 'commands/affiliation'
|
|
11
11
|
require_relative 'commands/participation'
|
12
12
|
|
13
13
|
module W3cApi
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
# Main CLI class that registers all subcommands
|
15
|
+
class Cli < Thor
|
16
|
+
# Register subcommands
|
17
|
+
desc 'specification SUBCOMMAND ...ARGS', 'Work with W3C specifications'
|
18
|
+
subcommand 'specification', Commands::Specification
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
desc 'group SUBCOMMAND ...ARGS', 'Work with W3C groups'
|
21
|
+
subcommand 'group', Commands::Group
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
desc 'user SUBCOMMAND ...ARGS', 'Work with W3C users'
|
24
|
+
subcommand 'user', Commands::User
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
desc 'translation SUBCOMMAND ...ARGS', 'Work with W3C translations'
|
27
|
+
subcommand 'translation', Commands::Translation
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
desc 'ecosystem SUBCOMMAND ...ARGS', 'Work with W3C ecosystems'
|
30
|
+
subcommand 'ecosystem', Commands::Ecosystem
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
desc 'series SUBCOMMAND ...ARGS', 'Work with W3C specification series'
|
33
|
+
subcommand 'series', Commands::Series
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
desc 'affiliation SUBCOMMAND ...ARGS', 'Work with W3C affiliations'
|
36
|
+
subcommand 'affiliation', Commands::Affiliation
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
desc 'participation SUBCOMMAND ...ARGS', 'Work with W3C participations'
|
39
|
+
subcommand 'participation', Commands::Participation
|
40
|
+
end
|
41
41
|
end
|
data/lib/w3c_api/client.rb
CHANGED
@@ -1,320 +1,191 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'faraday'
|
4
|
-
require 'faraday/follow_redirects'
|
5
3
|
require 'json'
|
4
|
+
require 'rainbow'
|
5
|
+
require 'pp'
|
6
|
+
require_relative 'hal'
|
6
7
|
|
7
8
|
module W3cApi
|
8
|
-
class Error < StandardError; end
|
9
|
-
class NotFoundError < Error; end
|
10
|
-
class UnauthorizedError < Error; end
|
11
|
-
class BadRequestError < Error; end
|
12
|
-
class ServerError < Error; end
|
13
|
-
|
14
9
|
class Client
|
15
|
-
API_ENDPOINT = 'https://api.w3.org'
|
16
|
-
|
17
|
-
attr_reader :last_response
|
18
|
-
|
19
|
-
def initialize(options = {})
|
20
|
-
@api_endpoint = options[:api_endpoint] || API_ENDPOINT
|
21
|
-
@connection = create_connection
|
22
|
-
@params_default = { page: 1, items: 3000 }
|
23
|
-
@debug = !ENV['DEBUG_API'].nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
# Specification methods
|
27
|
-
|
28
10
|
def specifications(options = {})
|
29
|
-
|
30
|
-
Models::Specifications.from_response(response['_links']['specifications'])
|
11
|
+
Hal.instance.register.fetch(:specification_index)
|
31
12
|
end
|
32
13
|
|
33
14
|
def specification(shortname, options = {})
|
34
|
-
|
35
|
-
Models::Specification.from_response(response)
|
15
|
+
Hal.instance.register.fetch(:specification_resource, shortname: shortname)
|
36
16
|
end
|
37
17
|
|
38
18
|
def specification_versions(shortname, options = {})
|
39
|
-
|
40
|
-
Models::SpecVersions.from_response(response['_links']['version-history'])
|
19
|
+
Hal.instance.register.fetch(:specification_resource_version_index, shortname: shortname)
|
41
20
|
end
|
42
21
|
|
43
22
|
def specification_version(shortname, version, options = {})
|
44
|
-
|
45
|
-
Models::SpecVersion.from_response(response)
|
23
|
+
Hal.instance.register.fetch(:specification_resource_version_resource, shortname: shortname, version: version)
|
46
24
|
end
|
47
25
|
|
48
26
|
def specifications_by_status(status, options = {})
|
49
|
-
|
50
|
-
Models::Specifications.from_response(response['_links']['specifications'])
|
27
|
+
Hal.instance.register.fetch(:specification_by_status_index, status: status)
|
51
28
|
end
|
52
29
|
|
53
30
|
def specification_supersedes(shortname, options = {})
|
54
|
-
|
55
|
-
Models::Specifications.from_response(response['_links']['specifications'])
|
31
|
+
Hal.instance.register.fetch(:specification_supersedes_index, shortname: shortname)
|
56
32
|
end
|
57
33
|
|
58
34
|
def specification_superseded_by(shortname, options = {})
|
59
|
-
|
60
|
-
|
35
|
+
Hal.instance.register.fetch(:specification_superseded_by_index, shortname: shortname)
|
36
|
+
end
|
37
|
+
|
38
|
+
# New methods for editors and deliverers
|
39
|
+
|
40
|
+
def specification_editors(shortname, options = {})
|
41
|
+
Hal.instance.register.fetch(:specification_editors_index, shortname: shortname)
|
42
|
+
end
|
43
|
+
|
44
|
+
def specification_deliverers(shortname, options = {})
|
45
|
+
Hal.instance.register.fetch(:specification_deliverers_index, shortname: shortname)
|
61
46
|
end
|
62
47
|
|
63
48
|
# Series methods
|
64
49
|
|
65
50
|
def series(options = {})
|
66
|
-
|
67
|
-
Models::Series.from_response(response['_links']['specification-series'])
|
51
|
+
Hal.instance.register.fetch(:serie_index)
|
68
52
|
end
|
69
53
|
|
70
54
|
def series_by_shortname(shortname, options = {})
|
71
|
-
|
72
|
-
Models::Serie.from_response(response)
|
55
|
+
Hal.instance.register.fetch(:serie_resource, shortname: shortname)
|
73
56
|
end
|
74
57
|
|
75
58
|
def series_specifications(shortname, options = {})
|
76
|
-
|
77
|
-
Models::Specifications.from_response(response['_links']['specifications'])
|
59
|
+
Hal.instance.register.fetch(:serie_specification_resource, shortname: shortname)
|
78
60
|
end
|
79
61
|
|
80
62
|
# Group methods
|
81
63
|
|
82
64
|
def groups(options = {})
|
83
|
-
|
84
|
-
Models::Groups.from_response(response['_links']['groups'])
|
65
|
+
Hal.instance.register.fetch(:group_index)
|
85
66
|
end
|
86
67
|
|
87
68
|
def group(id, options = {})
|
88
|
-
|
89
|
-
Models::Group.from_response(response)
|
69
|
+
Hal.instance.register.fetch(:group_resource, id: id)
|
90
70
|
end
|
91
71
|
|
92
72
|
def group_specifications(id, options = {})
|
93
|
-
|
94
|
-
Models::Specifications.from_response(response['_links']['specifications'])
|
73
|
+
Hal.instance.register.fetch(:group_specifications_index, id: id)
|
95
74
|
end
|
96
75
|
|
97
76
|
def group_users(id, options = {})
|
98
|
-
|
99
|
-
Models::Users.from_response(response['_links']['users'])
|
77
|
+
Hal.instance.register.fetch(:group_users_index, id: id)
|
100
78
|
end
|
101
79
|
|
102
80
|
def group_charters(id, options = {})
|
103
|
-
|
104
|
-
Models::Charters.from_response(response['_links']['charters'])
|
81
|
+
Hal.instance.register.fetch(:group_charters_index, id: id)
|
105
82
|
end
|
106
83
|
|
107
84
|
def group_chairs(id, options = {})
|
108
|
-
|
109
|
-
Models::Users.from_response(response['_links']['chairs'])
|
110
|
-
rescue NotFoundError
|
111
|
-
# Return empty users collection when endpoint not found
|
112
|
-
Models::Users.from_response([])
|
85
|
+
Hal.instance.register.fetch(:group_chairs_index, id: id)
|
113
86
|
end
|
114
87
|
|
115
88
|
def group_team_contacts(id, options = {})
|
116
|
-
|
117
|
-
Models::Users.from_response(response['_links']['team-contacts'])
|
118
|
-
rescue NotFoundError
|
119
|
-
# Return empty users collection when endpoint not found
|
120
|
-
Models::Users.from_response([])
|
89
|
+
Hal.instance.register.fetch(:group_team_contacts_index, id: id)
|
121
90
|
end
|
122
91
|
|
123
92
|
def group_participations(id, options = {})
|
124
|
-
|
125
|
-
Models::Participations.from_response(response['_links']['participations'])
|
93
|
+
Hal.instance.register.fetch(:group_participations_index, id: id)
|
126
94
|
end
|
127
95
|
|
128
96
|
# User methods
|
129
97
|
|
130
|
-
def users(options = {})
|
131
|
-
|
132
|
-
|
133
|
-
end
|
98
|
+
# def users(options = {})
|
99
|
+
# raise ArgumentError,
|
100
|
+
# 'The W3C API does not support fetching all users. You must provide a specific user ID with the user method.'
|
101
|
+
# end
|
134
102
|
|
135
|
-
def user(
|
136
|
-
|
137
|
-
Models::User.from_response(response)
|
103
|
+
def user(hash, options = {})
|
104
|
+
Hal.instance.register.fetch(:user_resource, hash: hash)
|
138
105
|
end
|
139
106
|
|
140
|
-
def
|
141
|
-
|
142
|
-
Models::Specifications.from_response(response['_links']['specifications'])
|
143
|
-
rescue NotFoundError
|
144
|
-
# Return empty specifications collection when endpoint not found
|
145
|
-
Models::Specifications.from_response([])
|
107
|
+
def user_groups(hash, options = {})
|
108
|
+
Hal.instance.register.fetch(:user_groups_index, hash: hash)
|
146
109
|
end
|
147
110
|
|
148
|
-
def
|
149
|
-
|
150
|
-
Models::Groups.from_response(response['_links']['groups'])
|
111
|
+
def user_affiliations(hash, options = {})
|
112
|
+
Hal.instance.register.fetch(:user_affiliations_index, hash: hash)
|
151
113
|
end
|
152
114
|
|
153
|
-
def
|
154
|
-
|
155
|
-
Models::Affiliations.from_response(response['_links']['affiliations'])
|
156
|
-
rescue NotFoundError
|
157
|
-
# Return empty affiliations collection when endpoint not found
|
158
|
-
Models::Affiliations.from_response([])
|
115
|
+
def user_participations(hash, options = {})
|
116
|
+
Hal.instance.register.fetch(:user_participations_index, hash: hash)
|
159
117
|
end
|
160
118
|
|
161
|
-
def
|
162
|
-
|
163
|
-
Models::Participations.from_response(response['_links']['participations'])
|
164
|
-
rescue NotFoundError
|
165
|
-
# Return empty participations collection when endpoint not found
|
166
|
-
Models::Participations.from_response([])
|
119
|
+
def user_chair_of_groups(hash, options = {})
|
120
|
+
Hal.instance.register.fetch(:user_chair_of_groups_index, hash: hash)
|
167
121
|
end
|
168
122
|
|
169
|
-
def
|
170
|
-
|
171
|
-
Models::Groups.from_response(response['_links']['groups'])
|
172
|
-
rescue NotFoundError
|
173
|
-
# Return empty groups collection when endpoint not found
|
174
|
-
Models::Groups.from_response([])
|
123
|
+
def user_team_contact_of_groups(hash, options = {})
|
124
|
+
Hal.instance.register.fetch(:user_team_contact_of_groups_index, hash: hash)
|
175
125
|
end
|
176
126
|
|
177
|
-
def
|
178
|
-
|
179
|
-
Models::Groups.from_response(response['_links']['groups'])
|
180
|
-
rescue NotFoundError
|
181
|
-
# Return empty groups collection when endpoint not found
|
182
|
-
Models::Groups.from_response([])
|
127
|
+
def user_specifications(hash, options = {})
|
128
|
+
Hal.instance.register.fetch(:user_specifications_index, hash: hash)
|
183
129
|
end
|
184
130
|
|
185
131
|
# Translation methods
|
186
132
|
|
187
133
|
def translations(options = {})
|
188
|
-
|
189
|
-
Models::Translations.from_response(response['_links']['translations'])
|
134
|
+
Hal.instance.register.fetch(:translation_index)
|
190
135
|
end
|
191
136
|
|
192
137
|
def translation(id, options = {})
|
193
|
-
|
194
|
-
Models::Translation.from_response(response)
|
138
|
+
Hal.instance.register.fetch(:translation_resource, id: id)
|
195
139
|
end
|
196
140
|
|
197
141
|
# Affiliation methods
|
198
142
|
|
199
143
|
def affiliations(options = {})
|
200
|
-
|
201
|
-
Models::Affiliations.from_response(response['_links']['affiliations'])
|
144
|
+
Hal.instance.register.fetch(:affiliation_index)
|
202
145
|
end
|
203
146
|
|
204
147
|
def affiliation(id, options = {})
|
205
|
-
|
206
|
-
Models::Affiliation.from_response(response)
|
148
|
+
Hal.instance.register.fetch(:affiliation_resource, id: id)
|
207
149
|
end
|
208
150
|
|
209
151
|
def affiliation_participants(id, options = {})
|
210
|
-
|
211
|
-
Models::Users.from_response(response['_links']['participants'])
|
152
|
+
Hal.instance.register.fetch(:affiliation_participants_index, id: id)
|
212
153
|
end
|
213
154
|
|
214
155
|
def affiliation_participations(id, options = {})
|
215
|
-
|
216
|
-
Models::Participations.from_response(response['_links']['participations'])
|
156
|
+
Hal.instance.register.fetch(:affiliation_participations_index, id: id)
|
217
157
|
end
|
218
158
|
|
219
159
|
# Ecosystem methods
|
220
160
|
|
221
161
|
def ecosystems(options = {})
|
222
|
-
|
223
|
-
Models::Ecosystems.from_response(response['_links']['ecosystems'])
|
162
|
+
Hal.instance.register.fetch(:ecosystem_index)
|
224
163
|
end
|
225
164
|
|
226
|
-
def ecosystem(
|
227
|
-
|
228
|
-
Models::Ecosystem.from_response(response)
|
165
|
+
def ecosystem(id, options = {})
|
166
|
+
Hal.instance.register.fetch(:ecosystem_resource, id: id)
|
229
167
|
end
|
230
168
|
|
231
169
|
def ecosystem_groups(shortname, options = {})
|
232
|
-
|
233
|
-
Models::Groups.from_response(response['_links']['groups'])
|
170
|
+
Hal.instance.register.fetch(:ecosystem_groups_index, shortname: shortname)
|
234
171
|
end
|
235
172
|
|
236
173
|
def ecosystem_evangelists(shortname, options = {})
|
237
|
-
|
238
|
-
Models::Users.from_response(response['_links']['users'])
|
174
|
+
Hal.instance.register.fetch(:ecosystem_evangelists_index, shortname: shortname)
|
239
175
|
end
|
240
176
|
|
241
177
|
def ecosystem_member_organizations(shortname, options = {})
|
242
|
-
|
243
|
-
Models::Affiliations.from_response(response['_links']['affiliations'])
|
178
|
+
Hal.instance.register.fetch(:ecosystem_member_organizations_index, shortname: shortname)
|
244
179
|
end
|
245
180
|
|
246
181
|
# Participation methods
|
247
182
|
|
248
183
|
def participation(id, options = {})
|
249
|
-
|
250
|
-
Models::Participation.from_response(response)
|
184
|
+
Hal.instance.register.fetch(:participation_resource, id: id)
|
251
185
|
end
|
252
186
|
|
253
187
|
def participation_participants(id, options = {})
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
# Make the get method public for testing
|
259
|
-
def get(url, params = {})
|
260
|
-
@last_response = @connection.get(url, params)
|
261
|
-
handle_response(@last_response, url)
|
262
|
-
end
|
263
|
-
|
264
|
-
private
|
265
|
-
|
266
|
-
def create_connection
|
267
|
-
Faraday.new(url: @api_endpoint) do |conn|
|
268
|
-
conn.use Faraday::FollowRedirects::Middleware
|
269
|
-
conn.request :json
|
270
|
-
conn.response :json, content_type: /\bjson$/
|
271
|
-
conn.adapter Faraday.default_adapter
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
def handle_response(response, url)
|
276
|
-
debug_log(response, url) if @debug
|
277
|
-
|
278
|
-
case response.status
|
279
|
-
when 200..299
|
280
|
-
response.body
|
281
|
-
when 400
|
282
|
-
raise W3cApi::BadRequestError, response_message(response)
|
283
|
-
when 401
|
284
|
-
raise W3cApi::UnauthorizedError, response_message(response)
|
285
|
-
when 404
|
286
|
-
raise W3cApi::NotFoundError, response_message(response)
|
287
|
-
when 500..599
|
288
|
-
raise W3cApi::ServerError, response_message(response)
|
289
|
-
else
|
290
|
-
raise W3cApi::Error, response_message(response)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
def debug_log(response, url)
|
295
|
-
puts "\n===== DEBUG: W3C API REQUEST =====".blue if defined?(Rainbow)
|
296
|
-
puts "\n===== DEBUG: W3C API REQUEST =====" unless defined?(Rainbow)
|
297
|
-
puts "URL: #{url}"
|
298
|
-
puts "Status: #{response.status}"
|
299
|
-
|
300
|
-
# Format headers as JSON
|
301
|
-
puts "\nHeaders:"
|
302
|
-
headers_hash = response.headers.to_h
|
303
|
-
puts JSON.pretty_generate(headers_hash)
|
304
|
-
|
305
|
-
puts "\nResponse body:"
|
306
|
-
if response.body.is_a?(Hash) || response.body.is_a?(Array)
|
307
|
-
puts JSON.pretty_generate(response.body)
|
308
|
-
else
|
309
|
-
puts response.body.inspect
|
310
|
-
end
|
311
|
-
puts "===== END DEBUG OUTPUT =====\n"
|
312
|
-
end
|
313
|
-
|
314
|
-
def response_message(response)
|
315
|
-
message = "Status: #{response.status}"
|
316
|
-
message += ", Error: #{response.body['error']}" if response.body.is_a?(Hash) && response.body['error']
|
317
|
-
message
|
318
|
-
end
|
319
|
-
end # End of Client class
|
320
|
-
end # End of W3c module
|
188
|
+
Hal.instance.register.fetch(:participation_participants_index, id: id)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -5,44 +5,44 @@ require_relative 'output_formatter'
|
|
5
5
|
require_relative '../client'
|
6
6
|
|
7
7
|
module W3cApi
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
module Commands
|
9
|
+
# Thor CLI command for affiliation operations
|
10
|
+
class Affiliation < Thor
|
11
|
+
include OutputFormatter
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
desc 'fetch [OPTIONS]', 'Fetch affiliations'
|
14
|
+
option :id, type: :numeric, desc: 'Affiliation ID'
|
15
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
16
|
+
def fetch
|
17
|
+
client = W3cApi::Client.new
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
affiliations = if options[:id]
|
20
|
+
# Single affiliation
|
21
|
+
client.affiliation(options[:id])
|
22
|
+
else
|
23
|
+
client.affiliations
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
output_results(affiliations, options[:format])
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
desc 'participants', 'Fetch participants of an affiliation'
|
30
|
+
option :id, type: :numeric, required: true, desc: 'Affiliation ID'
|
31
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
32
|
+
def participants
|
33
|
+
client = W3cApi::Client.new
|
34
|
+
participants = client.affiliation_participants(options[:id])
|
35
|
+
output_results(participants, options[:format])
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
38
|
+
desc 'participations', 'Fetch participations of an affiliation'
|
39
|
+
option :id, type: :numeric, required: true, desc: 'Affiliation ID'
|
40
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
41
|
+
def participations
|
42
|
+
client = W3cApi::Client.new
|
43
|
+
participations = client.affiliation_participations(options[:id])
|
44
|
+
output_results(participations, options[:format])
|
46
45
|
end
|
47
46
|
end
|
47
|
+
end
|
48
48
|
end
|
@@ -5,53 +5,53 @@ require_relative 'output_formatter'
|
|
5
5
|
require_relative '../client'
|
6
6
|
|
7
7
|
module W3cApi
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
8
|
+
module Commands
|
9
|
+
# Thor CLI command for ecosystem operations
|
10
|
+
class Ecosystem < Thor
|
11
|
+
include OutputFormatter
|
12
|
+
|
13
|
+
desc 'fetch [OPTIONS]', 'Fetch ecosystems'
|
14
|
+
option :shortname, type: :string, desc: 'Ecosystem shortname'
|
15
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
16
|
+
def fetch
|
17
|
+
client = W3cApi::Client.new
|
18
|
+
|
19
|
+
ecosystems = if options[:shortname]
|
20
|
+
# Single ecosystem
|
21
|
+
client.ecosystem(options[:shortname])
|
22
|
+
else
|
23
|
+
client.ecosystems
|
24
|
+
end
|
25
|
+
|
26
|
+
output_results(ecosystems, options[:format])
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'groups', 'Fetch groups in an ecosystem'
|
30
|
+
option :shortname, type: :string, required: true, desc: 'Ecosystem shortname'
|
31
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
32
|
+
def groups
|
33
|
+
client = W3cApi::Client.new
|
34
|
+
groups = client.ecosystem_groups(options[:shortname])
|
35
|
+
output_results(groups, options[:format])
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'evangelists', 'Fetch evangelists of an ecosystem'
|
39
|
+
option :shortname, type: :string, required: true, desc: 'Ecosystem shortname'
|
40
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
41
|
+
def evangelists
|
42
|
+
client = W3cApi::Client.new
|
43
|
+
evangelists = client.ecosystem_evangelists(options[:shortname])
|
44
|
+
output_results(evangelists, options[:format])
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'member-organizations', 'Fetch member organizations of an ecosystem'
|
48
|
+
option :shortname, type: :string, required: true, desc: 'Ecosystem shortname'
|
49
|
+
option :format, type: :string, default: 'yaml', enum: %w[json yaml], desc: 'Output format'
|
50
|
+
def member_organizations
|
51
|
+
client = W3cApi::Client.new
|
52
|
+
organizations = client.ecosystem_member_organizations(options[:shortname])
|
53
|
+
output_results(organizations, options[:format])
|
55
54
|
end
|
56
55
|
end
|
56
|
+
end
|
57
57
|
end
|