amazon-chime-sdk-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +87 -0
- data/.rspec +2 -0
- data/.travis.yml +47 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +25 -0
- data/LICENSE +21 -0
- data/README.md +1109 -0
- data/Rakefile +20 -0
- data/amazon-chime-sdk-rails.gemspec +29 -0
- data/gemfiles/Gemfile.rails-5.0 +25 -0
- data/gemfiles/Gemfile.rails-5.1 +25 -0
- data/gemfiles/Gemfile.rails-5.2 +25 -0
- data/gemfiles/Gemfile.rails-6.0 +25 -0
- data/lib/amazon-chime-sdk-rails.rb +37 -0
- data/lib/chime_sdk/config.rb +90 -0
- data/lib/chime_sdk/controller/attendees.rb +128 -0
- data/lib/chime_sdk/controller/common.rb +202 -0
- data/lib/chime_sdk/controller/meetings.rb +192 -0
- data/lib/chime_sdk/meeting_coordinator.rb +184 -0
- data/lib/chime_sdk/version.rb +4 -0
- data/lib/generators/chime_sdk/controllers_generator.rb +104 -0
- data/lib/generators/chime_sdk/install_generator.rb +27 -0
- data/lib/generators/chime_sdk/js_generator.rb +67 -0
- data/lib/generators/chime_sdk/views_generator.rb +43 -0
- data/lib/generators/templates/chime_sdk.rb +28 -0
- data/lib/generators/templates/controllers/README +35 -0
- data/lib/generators/templates/controllers/meeting_attendees_controller.rb +106 -0
- data/lib/generators/templates/controllers/meetings_controller.rb +146 -0
- data/lib/generators/templates/views/meetings/index.html.erb +27 -0
- data/lib/generators/templates/views/meetings/show.html.erb +136 -0
- data/spec/factories/rooms.rb +5 -0
- data/spec/factories/users.rb +8 -0
- data/spec/generators/controllers_generator_spec.rb +113 -0
- data/spec/generators/install_generator_spec.rb +24 -0
- data/spec/generators/js_generator_spec.rb +26 -0
- data/spec/generators/views_generator_spec.rb +46 -0
- data/spec/rails_app/Rakefile +15 -0
- data/spec/rails_app/app/assets/config/manifest.js +2 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/assets/javascripts/.keep +0 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_app/app/assets/stylesheets/scaffolds.scss +65 -0
- data/spec/rails_app/app/controllers/api/meeting_attendees_controller.rb +3 -0
- data/spec/rails_app/app/controllers/api/meetings_controller.rb +3 -0
- data/spec/rails_app/app/controllers/api/rooms_controller.rb +3 -0
- data/spec/rails_app/app/controllers/application_controller.rb +11 -0
- data/spec/rails_app/app/controllers/entries_controller.rb +47 -0
- data/spec/rails_app/app/controllers/meeting_attendees_controller.rb +121 -0
- data/spec/rails_app/app/controllers/meetings_controller.rb +162 -0
- data/spec/rails_app/app/controllers/rooms_controller.rb +76 -0
- data/spec/rails_app/app/controllers/spa_controller.rb +6 -0
- data/spec/rails_app/app/javascript/App.vue +50 -0
- data/spec/rails_app/app/javascript/channels/consumer.js +6 -0
- data/spec/rails_app/app/javascript/channels/index.js +5 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +84 -0
- data/spec/rails_app/app/javascript/components/meetings/Index.vue +100 -0
- data/spec/rails_app/app/javascript/components/meetings/Meeting.vue +178 -0
- data/spec/rails_app/app/javascript/components/rooms/Index.vue +53 -0
- data/spec/rails_app/app/javascript/components/rooms/Show.vue +91 -0
- data/spec/rails_app/app/javascript/packs/application.js +17 -0
- data/spec/rails_app/app/javascript/packs/spa.js +14 -0
- data/spec/rails_app/app/javascript/router/index.js +74 -0
- data/spec/rails_app/app/javascript/store/index.js +37 -0
- data/spec/rails_app/app/models/application_record.rb +3 -0
- data/spec/rails_app/app/models/entry.rb +5 -0
- data/spec/rails_app/app/models/room.rb +12 -0
- data/spec/rails_app/app/models/user.rb +6 -0
- data/spec/rails_app/app/views/devise/registrations/new.html.erb +34 -0
- data/spec/rails_app/app/views/layouts/_header.html.erb +20 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +18 -0
- data/spec/rails_app/app/views/meetings/index.html.erb +28 -0
- data/spec/rails_app/app/views/meetings/show.html.erb +136 -0
- data/spec/rails_app/app/views/rooms/_form.html.erb +22 -0
- data/spec/rails_app/app/views/rooms/_room.json.jbuilder +7 -0
- data/spec/rails_app/app/views/rooms/edit.html.erb +6 -0
- data/spec/rails_app/app/views/rooms/index.html.erb +27 -0
- data/spec/rails_app/app/views/rooms/index.json.jbuilder +1 -0
- data/spec/rails_app/app/views/rooms/new.html.erb +5 -0
- data/spec/rails_app/app/views/rooms/show.html.erb +42 -0
- data/spec/rails_app/app/views/rooms/show.json.jbuilder +1 -0
- data/spec/rails_app/app/views/spa/index.html.erb +1 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/bundle +114 -0
- data/spec/rails_app/bin/rails +9 -0
- data/spec/rails_app/bin/rake +9 -0
- data/spec/rails_app/bin/setup +36 -0
- data/spec/rails_app/bin/spring +17 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/bin/yarn +11 -0
- data/spec/rails_app/config.ru +5 -0
- data/spec/rails_app/config/application.rb +21 -0
- data/spec/rails_app/config/boot.rb +4 -0
- data/spec/rails_app/config/cable.yml +10 -0
- data/spec/rails_app/config/credentials.yml.enc +1 -0
- data/spec/rails_app/config/database.yml +25 -0
- data/spec/rails_app/config/environment.rb +14 -0
- data/spec/rails_app/config/environments/development.rb +62 -0
- data/spec/rails_app/config/environments/production.rb +112 -0
- data/spec/rails_app/config/environments/test.rb +49 -0
- data/spec/rails_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/rails_app/config/initializers/assets.rb +15 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/chime_sdk.rb +28 -0
- data/spec/rails_app/config/initializers/content_security_policy.rb +30 -0
- data/spec/rails_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/rails_app/config/initializers/devise.rb +311 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +60 -0
- data/spec/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails_app/config/initializers/inflections.rb +16 -0
- data/spec/rails_app/config/initializers/mime_types.rb +4 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/devise.en.yml +65 -0
- data/spec/rails_app/config/locales/en.yml +33 -0
- data/spec/rails_app/config/puma.rb +38 -0
- data/spec/rails_app/config/routes.rb +24 -0
- data/spec/rails_app/config/secrets.yml +8 -0
- data/spec/rails_app/config/spring.rb +6 -0
- data/spec/rails_app/config/storage.yml +34 -0
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/20200912140231_devise_create_users.rb +45 -0
- data/spec/rails_app/db/migrate/20200912140352_add_tokens_to_users.rb +12 -0
- data/spec/rails_app/db/migrate/20200912140657_create_rooms.rb +9 -0
- data/spec/rails_app/db/migrate/20200912140749_create_entries.rb +10 -0
- data/spec/rails_app/db/schema.rb +49 -0
- data/spec/rails_app/db/seeds.rb +41 -0
- data/spec/rails_app/log/.keep +0 -0
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/rails_app/public/404.html +67 -0
- data/spec/rails_app/public/422.html +67 -0
- data/spec/rails_app/public/500.html +66 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/robots.txt +1 -0
- data/spec/rails_app/tmp/.keep +0 -0
- data/spec/requests/atendees_spec.rb +182 -0
- data/spec/requests/meetings_spec.rb +433 -0
- data/spec/spec_helper.rb +35 -0
- metadata +400 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
module ChimeSdk
|
2
|
+
module Controller
|
3
|
+
# Meetings controller implementation by amazon-chime-sdk-rails.
|
4
|
+
module Meetings
|
5
|
+
# Controller implementation to be included in custom meetings controllers.
|
6
|
+
module Mixin
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
include ChimeSdk::Controller::Common
|
11
|
+
include ActionController::MimeResponds
|
12
|
+
helper_method :meeting_resources_path, :meeting_resource_path, :attendee_resources_path, :attendee_resource_path, :application_attendee_name
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /meetings
|
16
|
+
# GET /meetings.json
|
17
|
+
# @overload index(params)
|
18
|
+
# @param [Hash] params Request parameter options
|
19
|
+
# @option params [String] :create_meeting (ChimeSdk.config.create_meeting_by_get_request) Whether the application creates meeting in this meetings#index action by HTTP GET request
|
20
|
+
def index
|
21
|
+
if params[:create_meeting].to_s.to_boolean(false) || ChimeSdk.config.create_meeting_by_get_request
|
22
|
+
create
|
23
|
+
else
|
24
|
+
list_meetings
|
25
|
+
respond_to do |format|
|
26
|
+
format.html
|
27
|
+
format.json { render json: { meetings: @meetings } }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# GET /meetings/:meeting_id
|
33
|
+
# GET /meetings/:meeting_id.json
|
34
|
+
# @overload show(params)
|
35
|
+
# @param [Hash] params Request parameter options
|
36
|
+
# @option params [String] :create_attendee_from_meeting (ChimeSdk.config.create_attendee_from_meeting) Whether the application creates attendee from meeting in meetings#show action
|
37
|
+
def show
|
38
|
+
get_meeting
|
39
|
+
if params[:create_attendee_from_meeting].to_s.to_boolean(false) || ChimeSdk.config.create_attendee_from_meeting
|
40
|
+
create_attendee_from_meeting
|
41
|
+
end
|
42
|
+
respond_to do |format|
|
43
|
+
format.html
|
44
|
+
format.json { render json: @meeting }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# POST /meetings
|
49
|
+
# POST /meetings.json
|
50
|
+
# @overload create(params)
|
51
|
+
# @param [Hash] params Request parameter options
|
52
|
+
# @option params [String] :create_meeting_with_attendee (ChimeSdk.config.create_meeting_with_attendee) Whether the application creates meeting with attendee in this meetings#create action
|
53
|
+
def create
|
54
|
+
if params[:create_meeting_with_attendee].to_s.to_boolean(false) || ChimeSdk.config.create_meeting_with_attendee
|
55
|
+
create_meeting_with_attendee
|
56
|
+
else
|
57
|
+
create_meeting
|
58
|
+
end
|
59
|
+
respond_to do |format|
|
60
|
+
format.html { redirect_to meeting_resource_path(meeting_id), notice: "Meeting <#{meeting_id}> was successfully created." }
|
61
|
+
format.json { render status: 201, json: @meeting.merge(@attendee || {}) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# DELETE /meetings/:meeting_id
|
66
|
+
# DELETE /meetings/:meeting_id.json
|
67
|
+
def destroy
|
68
|
+
delete_meeting
|
69
|
+
respond_to do |format|
|
70
|
+
format.html { redirect_to meeting_resources_path, notice: "Meeting <#{meeting_id}> was successfully destroyed." }
|
71
|
+
format.json { head 204 }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
# Override the following functions in your controllers
|
77
|
+
# :nocov:
|
78
|
+
|
79
|
+
# Request parameter representing meeting id such as params[:id].
|
80
|
+
# Configure it depending on your application routes.
|
81
|
+
# @api protected
|
82
|
+
# @return [String, Integer] Meeting id from request parameter
|
83
|
+
def meeting_id_param
|
84
|
+
params[:id]
|
85
|
+
end
|
86
|
+
|
87
|
+
# Unique meeting request id to identify meeting by Amazon Chime.
|
88
|
+
# Configure it depending on your application resources to identify meeting.
|
89
|
+
# For example, set "PrivateRoom-#{@room.id}" by Room model.
|
90
|
+
# @api protected
|
91
|
+
# @return [String] Unique meeting request id to identify meeting by Amazon Chime
|
92
|
+
def meeting_request_id
|
93
|
+
"default"
|
94
|
+
end
|
95
|
+
|
96
|
+
# Unique attendee request id to identify attendee by Amazon Chime.
|
97
|
+
# Configure it depending on your application resources to identify attendee.
|
98
|
+
# For example, set "User-#{current_user.id}" by User model.
|
99
|
+
# @api protected
|
100
|
+
# @return [String] Unique attendee request id to identify attendee by Amazon Chime
|
101
|
+
def attendee_request_id
|
102
|
+
"default"
|
103
|
+
end
|
104
|
+
|
105
|
+
# Path for meetings#index action such as meetings_path.
|
106
|
+
# Configure it depending on your application routes.
|
107
|
+
# @api protected
|
108
|
+
# @param [Hash] params Request parameters for path method
|
109
|
+
# @return [String] Path for meetings#index action such as meetings_path
|
110
|
+
def meeting_resources_path(params = {})
|
111
|
+
meetings_path(params)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Path for meetings#show action such as meeting_path(meeting_id).
|
115
|
+
# Configure it depending on your application routes.
|
116
|
+
# @api protected
|
117
|
+
# @param [String] meeting_id Meeting id
|
118
|
+
# @param [Hash] params Request parameters for path method
|
119
|
+
# @return [String] Path for meetings#show action such as meeting_path(meeting_id)
|
120
|
+
def meeting_resource_path(meeting_id, params = {})
|
121
|
+
meeting_path(meeting_id, params)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Path for attendees#index action such as attendees_path(meeting_id).
|
125
|
+
# Configure it depending on your application routes.
|
126
|
+
# @api protected
|
127
|
+
# @param [String] meeting_id Meeting id
|
128
|
+
# @param [Hash] params Request parameters for path method
|
129
|
+
# @return [String] Path for attendees#index action such as attendees_path(meeting_id)
|
130
|
+
def attendee_resources_path(meeting_id, params = {})
|
131
|
+
attendees_path(meeting_id, params)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Path for attendees#show action such as attendee_path(meeting_id, attendee_id).
|
135
|
+
# Configure it depending on your application routes.
|
136
|
+
# @api protected
|
137
|
+
# @param [String] meeting_id Meeting id
|
138
|
+
# @param [String] attendee_id Attendee id
|
139
|
+
# @param [Hash] params Request parameters for path method
|
140
|
+
# @return [String] Path for attendees#index action such as attendees_path(meeting_id)
|
141
|
+
def attendee_resource_path(meeting_id, attendee_id, params = {})
|
142
|
+
attendee_path(meeting_id, attendee_id, params)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Optional meeting tags to pass to Amazon Chime.
|
146
|
+
# This is an optional parameter and configure it depending on your application.
|
147
|
+
# @api protected
|
148
|
+
# @return [Array<Hash>] Optional tags for meetings
|
149
|
+
def optional_meeting_tags
|
150
|
+
[]
|
151
|
+
end
|
152
|
+
|
153
|
+
# Optional attendee tags to pass to Amazon Chime.
|
154
|
+
# This is an optional parameter and configure it depending on your application.
|
155
|
+
# @api protected
|
156
|
+
# @return [Array<Hash>] Optional tags for attendees
|
157
|
+
def optional_attendee_tags
|
158
|
+
[]
|
159
|
+
end
|
160
|
+
|
161
|
+
# Appication metadata that meetings API returns as JSON response included in meeting resource.
|
162
|
+
# This is an optional parameter and configure it depending on your application.
|
163
|
+
# @api protected
|
164
|
+
# @param [Hash] meeting Meeting JSON object as hash
|
165
|
+
# @return [Hash] Appication metadata for meetings
|
166
|
+
def application_meeting_metadata(meeting)
|
167
|
+
{}
|
168
|
+
end
|
169
|
+
|
170
|
+
# Appication metadata that attendees API returns as JSON response included in attendee resource.
|
171
|
+
# This is an optional parameter and configure it depending on your application.
|
172
|
+
# @api protected
|
173
|
+
# @param [Hash] attendee Attendee JSON object as hash
|
174
|
+
# @return [Hash] Appication metadata for attendees
|
175
|
+
def application_attendee_metadata(attendee)
|
176
|
+
{}
|
177
|
+
end
|
178
|
+
|
179
|
+
# Application attendee name to resolve from attendee object in your view.
|
180
|
+
# This is an optional parameter and configure it depending on your application.
|
181
|
+
# @api protected
|
182
|
+
# @param [Hash] attendee Attendee JSON object as hash
|
183
|
+
# @return [String] Appication attendee name to resolve from attendee object in your view
|
184
|
+
def application_attendee_name(attendee)
|
185
|
+
attendee[:Attendee][:AttendeeId]
|
186
|
+
end
|
187
|
+
|
188
|
+
# :nocov:
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
module ChimeSdk
|
2
|
+
# Meeting coordinator as a wrapper module of AWS SDK for Ruby, which simulates AWS SDK for JavaScript.
|
3
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html Aws::Chime::Client of AWS SDK for Ruby
|
4
|
+
# @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Chime.html AWS.Chime of AWS SDK for JavaScript
|
5
|
+
module MeetingCoordinator
|
6
|
+
require 'aws-sdk-chime'
|
7
|
+
|
8
|
+
# Return initialized Aws::Chime::Client.
|
9
|
+
# You must use "us-east-1" as the region for Chime API and set the endpoint.
|
10
|
+
# @return [Aws::Chime::Client] Initialized Aws::Chime::Client instance
|
11
|
+
# @see https://aws.github.io/amazon-chime-sdk-js/modules/gettingstarted.html
|
12
|
+
def self.client
|
13
|
+
@@client ||= Aws::Chime::Client.new(region: 'us-east-1')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Reset client with initialized Aws::Chime::Client instance.
|
17
|
+
# @param [Aws::Chime::Client] client Initialized Aws::Chime::Client instance
|
18
|
+
# @return [Aws::Chime::Client] Initialized Aws::Chime::Client instance
|
19
|
+
def self.reset_client(client)
|
20
|
+
@@client = client
|
21
|
+
end
|
22
|
+
|
23
|
+
# Wrapper of Aws::Chime::Client#list_meetings method.
|
24
|
+
# This function also provides prefix match filter of external_meeting_id.
|
25
|
+
# This method filters the result with ChimeSdk.config.prefix to return only meetings in your application.
|
26
|
+
# @param [Integer] max_results (ChimeSdk.config.max_meeting_results) The maximum number of results to return in a single call
|
27
|
+
# @param [String] prefix_filter (nil) Additional string for prefix match filter of external_meeting_id
|
28
|
+
# @return [Array<Hash>] Array of filtered meeting JSON object as hash
|
29
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#list_meetings-instance_method Aws::Chime::Client#list_meetings of AWS SDK for Ruby
|
30
|
+
def self.list_meetings(
|
31
|
+
max_results: ChimeSdk.config.max_meeting_results,
|
32
|
+
prefix_filter: nil
|
33
|
+
)
|
34
|
+
resp = client.list_meetings({
|
35
|
+
max_results: max_results
|
36
|
+
})
|
37
|
+
meetings = resp.meetings
|
38
|
+
meetings = meetings.select { |meeting| meeting.external_meeting_id.start_with?(ChimeSdk.config.prefix + prefix_filter) } if prefix_filter
|
39
|
+
meetings.map { |meeting| meeting_as_json(meeting) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Wrapper of Aws::Chime::Client#create_meeting method.
|
43
|
+
# This method uses 'ChimeSdk.config.prefix + meeting_request_id' for client_request_token and external_meeting_id.
|
44
|
+
# @param [required, String] meeting_request_id The unique identifier for the client request. Use a different token for different meetings.
|
45
|
+
# @param [String] meeting_host_id (nil) Reserved
|
46
|
+
# @param [String] media_region (ChimeSdk.config.media_region) The Region in which to create the meeting
|
47
|
+
# @param [Array<Aws::Chime::Types::Tag>] tags (nil) The tag key-value pairs
|
48
|
+
# @param [Aws::Chime::Types::MeetingNotificationConfiguration] notifications_configuration (nil) The configuration for resource targets to receive notifications when meeting and attendee events occur
|
49
|
+
# @return [Hash] Created meeting JSON object as hash
|
50
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#create_meeting-instance_method Aws::Chime::Client#create_meeting of AWS SDK for Ruby
|
51
|
+
def self.create_meeting(meeting_request_id,
|
52
|
+
meeting_host_id: nil,
|
53
|
+
media_region: ChimeSdk.config.media_region,
|
54
|
+
tags: [],
|
55
|
+
notifications_configuration: {}
|
56
|
+
)
|
57
|
+
resp = client.create_meeting({
|
58
|
+
client_request_token: ChimeSdk.config.prefix + meeting_request_id,
|
59
|
+
external_meeting_id: ChimeSdk.config.prefix + meeting_request_id,
|
60
|
+
meeting_host_id: meeting_host_id,
|
61
|
+
media_region: media_region,
|
62
|
+
tags: tags,
|
63
|
+
notifications_configuration: notifications_configuration
|
64
|
+
})
|
65
|
+
meeting_as_json(resp.meeting)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Wrapper of Aws::Chime::Client#get_meeting method.
|
69
|
+
# @param [required, String] meeting_id The Amazon Chime SDK meeting ID
|
70
|
+
# @return [Hash] Meeting JSON object as hash
|
71
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#get_meeting-instance_method Aws::Chime::Client#get_meeting of AWS SDK for Ruby
|
72
|
+
def self.get_meeting(meeting_id)
|
73
|
+
resp = client.get_meeting({
|
74
|
+
meeting_id: meeting_id
|
75
|
+
})
|
76
|
+
meeting_as_json(resp.meeting)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Wrapper of Aws::Chime::Client#delete_meeting method.
|
80
|
+
# @param [required, String] meeting_id The Amazon Chime SDK meeting ID
|
81
|
+
# @return [void]
|
82
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#delete_meeting-instance_method Aws::Chime::Client#delete_meeting of AWS SDK for Ruby
|
83
|
+
def self.delete_meeting(meeting_id)
|
84
|
+
client.delete_meeting({
|
85
|
+
meeting_id: meeting_id
|
86
|
+
})
|
87
|
+
end
|
88
|
+
|
89
|
+
# Wrapper of Aws::Chime::Client#list_attendees method.
|
90
|
+
# @param [required, String] meeting_id The Amazon Chime SDK meeting ID
|
91
|
+
# @param [Integer] max_results (ChimeSdk.config.max_attendee_results) The maximum number of results to return in a single call
|
92
|
+
# @return [Array<Hash>] Array of attendee JSON object as hash
|
93
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#list_attendees-instance_method Aws::Chime::Client#list_attendees of AWS SDK for Ruby
|
94
|
+
def self.list_attendees(meeting_id,
|
95
|
+
max_results: ChimeSdk.config.max_attendee_results
|
96
|
+
)
|
97
|
+
resp = client.list_attendees({
|
98
|
+
meeting_id: meeting_id,
|
99
|
+
max_results: max_results
|
100
|
+
})
|
101
|
+
resp.attendees.map { |attendee| attendee_as_json(attendee) }
|
102
|
+
end
|
103
|
+
|
104
|
+
# Wrapper of Aws::Chime::Client#create_attendee method.
|
105
|
+
# This method uses 'ChimeSdk.config.prefix + attendee_request_id' for external_user_id.
|
106
|
+
# @param [required, String] meeting_id The Amazon Chime SDK meeting ID
|
107
|
+
# @param [required, String] attendee_request_id Part of the Amazon Chime SDK external user ID. Links the attendee to an identity managed by a builder application.
|
108
|
+
# @return [Hash] Created attendee JSON object as hash
|
109
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#create_attendee-instance_method Aws::Chime::Client#create_attendee of AWS SDK for Ruby
|
110
|
+
def self.create_attendee(meeting_id, attendee_request_id, tags: [])
|
111
|
+
resp = client.create_attendee({
|
112
|
+
meeting_id: meeting_id,
|
113
|
+
external_user_id: ChimeSdk.config.prefix + attendee_request_id,
|
114
|
+
tags: tags
|
115
|
+
})
|
116
|
+
attendee_as_json(resp.attendee)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Wrapper of Aws::Chime::Client#get_attendee method.
|
120
|
+
# @param [required, String] meeting_id The Amazon Chime SDK meeting ID
|
121
|
+
# @param [required, String] attendee_id The Amazon Chime SDK attendee ID
|
122
|
+
# @return [Hash] Attendee JSON object as hash
|
123
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#get_attendee-instance_method Aws::Chime::Client#get_attendee of AWS SDK for Ruby
|
124
|
+
def self.get_attendee(meeting_id, attendee_id)
|
125
|
+
resp = client.get_attendee({
|
126
|
+
meeting_id: meeting_id,
|
127
|
+
attendee_id: attendee_id
|
128
|
+
})
|
129
|
+
attendee_as_json(resp.attendee)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Wrapper of Aws::Chime::Client#delete_attendee method.
|
133
|
+
# @param [required, String] attendee_id The Amazon Chime SDK attendee ID
|
134
|
+
# @return [void]
|
135
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#delete_attendee-instance_method Aws::Chime::Client#delete_attendee of AWS SDK for Ruby
|
136
|
+
def self.delete_attendee(meeting_id, attendee_id)
|
137
|
+
client.delete_attendee({
|
138
|
+
meeting_id: meeting_id,
|
139
|
+
attendee_id: attendee_id
|
140
|
+
})
|
141
|
+
end
|
142
|
+
|
143
|
+
# Build meeting JSON object as hash from Aws::Chime::Types::Meeting object
|
144
|
+
# @param [required, Aws::Chime::Types::Meeting] meeting Meeting response as Aws::Chime::Types::Meeting object
|
145
|
+
# @return [Hash] Meeting JSON object as hash
|
146
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#get_meeting-instance_method Aws::Chime::Client#get_meeting of AWS SDK for Ruby
|
147
|
+
# @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Chime.html#getMeeting-property AWS.Chime#getMeeting of AWS SDK for JavaScript
|
148
|
+
def self.meeting_as_json(meeting)
|
149
|
+
return {} unless meeting.is_a?(Aws::Chime::Types::Meeting)
|
150
|
+
{
|
151
|
+
"Meeting": {
|
152
|
+
"MeetingId": meeting.meeting_id,
|
153
|
+
"ExternalMeetingId": meeting.external_meeting_id,
|
154
|
+
"MediaPlacement": {
|
155
|
+
"AudioHostUrl": meeting.media_placement.audio_host_url,
|
156
|
+
"AudioFallbackUrl": meeting.media_placement.audio_fallback_url,
|
157
|
+
"ScreenDataUrl": meeting.media_placement.screen_data_url,
|
158
|
+
"ScreenSharingUrl": meeting.media_placement.screen_sharing_url,
|
159
|
+
"ScreenViewingUrl": meeting.media_placement.screen_viewing_url,
|
160
|
+
"SignalingUrl": meeting.media_placement.signaling_url,
|
161
|
+
"TurnControlUrl": meeting.media_placement.turn_control_url
|
162
|
+
},
|
163
|
+
"MediaRegion": meeting.media_region
|
164
|
+
}
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
# Build attendee JSON object as hash from Aws::Chime::Types::Attendee object
|
169
|
+
# @param [required, Aws::Chime::Types::Attendee] attendee Attendee response as Aws::Chime::Types::Attendee object
|
170
|
+
# @return [Hash] Attendee JSON object as hash
|
171
|
+
# @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html#get_attendee-instance_method Aws::Chime::Client#get_attendee of AWS SDK for Ruby
|
172
|
+
# @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Chime.html#getAttendee-property AWS.Chime#getAttendee of AWS SDK for JavaScript
|
173
|
+
def self.attendee_as_json(attendee)
|
174
|
+
return {} unless attendee.is_a?(Aws::Chime::Types::Attendee)
|
175
|
+
{
|
176
|
+
"Attendee": {
|
177
|
+
"ExternalUserId": attendee.external_user_id,
|
178
|
+
"AttendeeId": attendee.attendee_id,
|
179
|
+
"JoinToken": attendee.join_token
|
180
|
+
}
|
181
|
+
}
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module ChimeSdk
|
4
|
+
module Generators
|
5
|
+
# Controller generator to copy customizable meetings and attendees controller files from templates.
|
6
|
+
# @example Run controller generator as default name
|
7
|
+
# rails generate chime_sdk:controllers
|
8
|
+
# @example Run controller generator with prefix as 'room'
|
9
|
+
# rails generate chime_sdk:controllers room
|
10
|
+
# @example Run controller generator with parent option as 'room'
|
11
|
+
# rails generate chime_sdk:controllers -r room
|
12
|
+
# @example Run controller generator with namespace option as 'api'
|
13
|
+
# rails generate chime_sdk:controllers -n api
|
14
|
+
class ControllersGenerator < Rails::Generators::Base
|
15
|
+
desc <<-DESC.strip_heredoc
|
16
|
+
Create meetings and attendees controllers for Amazon Chime SDK in your app/controllers folder.
|
17
|
+
|
18
|
+
Example:
|
19
|
+
|
20
|
+
rails generate chime_sdk:controllers
|
21
|
+
|
22
|
+
You can specify prefix of controllers name like this:
|
23
|
+
|
24
|
+
rails generate chime_sdk:controllers room
|
25
|
+
|
26
|
+
Then, meeting controller class will be generated as app/controllers/room_meetings_controller.rb like this:
|
27
|
+
|
28
|
+
class RoomMeetingsController < ApplicationController
|
29
|
+
include ChimeSdk::Controller::Meetings::Mixin
|
30
|
+
def meeting_resources_path(params = {})
|
31
|
+
room_meetings_path(@room, params)
|
32
|
+
end
|
33
|
+
...
|
34
|
+
end
|
35
|
+
|
36
|
+
Use --parent option to specify parent resource of meetings. If you specify prefix of controllers name, parent option will be ignored.
|
37
|
+
|
38
|
+
rails generate chime_sdk:controllers --parent room
|
39
|
+
|
40
|
+
Then, meeting controller class will be generated as app/controllers/meetings_controller.rb like this:
|
41
|
+
|
42
|
+
class MeetingsController < ApplicationController
|
43
|
+
include ChimeSdk::Controller::Meetings::Mixin
|
44
|
+
def meeting_resources_path(params = {})
|
45
|
+
room_meetings_path(@room, params)
|
46
|
+
end
|
47
|
+
...
|
48
|
+
end
|
49
|
+
|
50
|
+
Use --namespace option to specify namespace of generated controllers.
|
51
|
+
|
52
|
+
rails generate chime_sdk:controllers --namespace api
|
53
|
+
|
54
|
+
Then, meeting controller class will be generated as app/controllers/api/meetings_controller.rb like this:
|
55
|
+
|
56
|
+
class Api::MeetingsController < ApplicationController
|
57
|
+
include ChimeSdk::Controller::Meetings::Mixin
|
58
|
+
def meeting_resources_path(params = {})
|
59
|
+
api_meetings_path(params)
|
60
|
+
end
|
61
|
+
...
|
62
|
+
end
|
63
|
+
|
64
|
+
Use --controllers option to specify which controller you want to generate. If you do no specify a controller, all controllers will be created.
|
65
|
+
|
66
|
+
rails generate chime_sdk:controllers --controllers meetings
|
67
|
+
DESC
|
68
|
+
|
69
|
+
# Controllers to be generated
|
70
|
+
CONTROLLERS = ['meetings', 'meeting_attendees'].freeze
|
71
|
+
|
72
|
+
source_root File.expand_path("../../templates/controllers", __FILE__)
|
73
|
+
argument :prefix, required: false,
|
74
|
+
desc: "Prefix of controllers name, e.g. room"
|
75
|
+
class_option :parent, aliases: "-r", type: :string,
|
76
|
+
desc: "Parent resource of generated controllers, e.g. room"
|
77
|
+
class_option :namespace, aliases: "-n", type: :string,
|
78
|
+
desc: "Namespace of generated controllers, e.g. api"
|
79
|
+
class_option :controllers, aliases: "-c", type: :array,
|
80
|
+
desc: "Select specific controllers to generate (#{CONTROLLERS.join(', ')})"
|
81
|
+
|
82
|
+
# Generate controller files in application directory
|
83
|
+
def generate_controllers
|
84
|
+
@namespace = options[:namespace].blank? ? '' : "#{options[:namespace].camelize}::"
|
85
|
+
@class_name_prefix = prefix.blank? ? '' : prefix.singularize.camelize
|
86
|
+
@param_name_prefix = prefix.blank? ? '' : "#{prefix.singularize.underscore}_"
|
87
|
+
parent_resource = prefix.present? ? prefix.singularize.underscore : (options[:parent].blank? ? '' : options[:parent].singularize.underscore)
|
88
|
+
@path_name_prefix = (options[:namespace].blank? ? '' : "#{options[:namespace].singularize.underscore}_") + (parent_resource.blank? ? '' : "#{parent_resource}_")
|
89
|
+
@path_args_prefix = parent_resource.blank? ? '' : "@#{parent_resource}, "
|
90
|
+
@default_meeting_request_id = parent_resource.blank? ? 'default' : "#{parent_resource.camelize}-#{'#'}{@#{parent_resource}.id}"
|
91
|
+
file_name_prefix = (options[:namespace].blank? ? '' : "#{options[:namespace].underscore}/") + @param_name_prefix
|
92
|
+
controllers = options[:controllers] || CONTROLLERS
|
93
|
+
controllers.each do |name|
|
94
|
+
template "#{name}_controller.rb", "app/controllers/#{file_name_prefix}#{name}_controller.rb"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Show readme after generated controllers
|
99
|
+
def show_readme
|
100
|
+
readme "README" if behavior == :invoke
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|