From 954b82601407c6c2709eedb7b0cd66a30309f061 Mon Sep 17 00:00:00 2001 From: simukappu Date: Mon, 26 Feb 2024 09:05:14 +0900 Subject: [PATCH] [WIP] Update API namespace from Chime to ChimeSDKMeetings --- amazon-chime-sdk-rails.gemspec | 2 +- lib/amazon-chime-sdk-rails.rb | 5 +- lib/chime_sdk/config.rb | 10 - lib/chime_sdk/controller/common.rb | 23 +-- lib/chime_sdk/controller/meetings.rb | 5 +- lib/chime_sdk/meeting_coordinator.rb | 182 +++++++++++------- lib/generators/templates/chime_sdk.rb | 3 - .../templates/views/meetings/index.html.erb | 25 +-- .../templates/views/meetings/show.html.erb | 2 +- .../app/views/meetings/index.html.erb | 25 +-- .../app/views/meetings/show.html.erb | 2 +- .../config/initializers/chime_sdk.rb | 3 - spec/requests/atendees_spec.rb | 16 +- spec/requests/meetings_spec.rb | 51 +++-- 14 files changed, 175 insertions(+), 179 deletions(-) diff --git a/amazon-chime-sdk-rails.gemspec b/amazon-chime-sdk-rails.gemspec index 420fa82..c60b2dc 100644 --- a/amazon-chime-sdk-rails.gemspec +++ b/amazon-chime-sdk-rails.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.2.2' s.add_dependency 'railties', '>= 5.0.0' - s.add_dependency 'aws-sdk-chime', '>= 1.0.0' + s.add_dependency 'aws-sdk-chimesdkmeetings', '>= 1.0.0' s.add_development_dependency 'rspec-rails', '>= 4.0.1' s.add_development_dependency 'factory_bot_rails', '>= 6.1.0' diff --git a/lib/amazon-chime-sdk-rails.rb b/lib/amazon-chime-sdk-rails.rb index 99e814d..216520b 100644 --- a/lib/amazon-chime-sdk-rails.rb +++ b/lib/amazon-chime-sdk-rails.rb @@ -17,7 +17,6 @@ def self.config # config.appication_name = 'chime-sdk-rails' # config.media_region = 'us-east-1' # config.prefix = "#{config.application_name}-#{Rails.env}-" - # config.max_meeting_results = 10 # config.max_attendee_results = 10 # config.create_meeting_with_attendee = true # config.create_attendee_from_meeting = true @@ -27,8 +26,8 @@ def self.configure yield(config) if block_given? end - # Load AWS SDK for Amazon Chime - require 'aws-sdk-chime' + # Load AWS SDK for Amazon Chime SDK meetings + require 'aws-sdk-chimesdkmeetings' # Load ChimeSdk helpers require 'chime_sdk/controller/common' diff --git a/lib/chime_sdk/config.rb b/lib/chime_sdk/config.rb index 38bd145..f5f1a6d 100644 --- a/lib/chime_sdk/config.rb +++ b/lib/chime_sdk/config.rb @@ -28,15 +28,6 @@ class Config # @return [Boolean] Prefix to make unique key of Chime SDK meetings and attendees attr_accessor :prefix - # @overload max_meeting_results - # Return default max_results value used in list_meetings API. - # @return [Boolean] Default max_results value used in list_meetings API - # @overload max_meeting_results=(value) - # Set default max_results value used in list_meetings API. - # @param [Boolean] max_meeting_results The new max_meeting_results - # @return [Boolean] Default max_results value used in list_meetings API - attr_accessor :max_meeting_results - # @overload max_attendee_results # Return default max_results value used in list_attendees API. # @return [Boolean] Default max_results value used in list_attendees API @@ -80,7 +71,6 @@ def initialize @application_name = 'chime-sdk-rails' @media_region = 'us-east-1' @prefix = "#{@application_name}-#{Rails.env}-" - @max_meeting_results = 10 @max_attendee_results = 10 @create_meeting_with_attendee = true @create_attendee_from_meeting = true diff --git a/lib/chime_sdk/controller/common.rb b/lib/chime_sdk/controller/common.rb index e3d030d..425c794 100644 --- a/lib/chime_sdk/controller/common.rb +++ b/lib/chime_sdk/controller/common.rb @@ -6,9 +6,9 @@ module Common extend ActiveSupport::Concern included do - rescue_from Aws::Chime::Errors::ForbiddenException, with: :render_forbidden - rescue_from Aws::Chime::Errors::NotFoundException, with: :render_resource_not_found - rescue_from Aws::Chime::Errors::ValidationException, with: :render_resource_not_found + rescue_from Aws::ChimeSDKMeetings::Errors::ForbiddenException, with: :render_forbidden + rescue_from Aws::ChimeSDKMeetings::Errors::NotFoundException, with: :render_resource_not_found + rescue_from Aws::ChimeSDKMeetings::Errors::ValidationException, with: :render_resource_not_found class ::String # Convets to boolean. @@ -39,14 +39,6 @@ def attendee_id @attendee ? @attendee[:Attendee][:AttendeeId] : attendee_id_param end - # List meetings by MeetingCoordinator. - # @api protected - # @return [Array] Meeting list - def list_meetings - @meetings = ChimeSdk::MeetingCoordinator.list_meetings(prefix_filter: meeting_request_id) - @meetings = @meetings.map { |meeting| merge_application_meeting_metadata(meeting) } - end - # Create meeting by MeetingCoordinator. # @api protected # @return [Hash] Created meeting @@ -82,7 +74,7 @@ def list_attendees # @api protected # @return [Hash] Created attendee def create_attendee - @attendee = ChimeSdk::MeetingCoordinator.create_attendee(meeting_id, attendee_request_id, tags: attendee_tags) + @attendee = ChimeSdk::MeetingCoordinator.create_attendee(meeting_id, attendee_request_id) @attendee = merge_application_attendee_metadata(@attendee) end @@ -144,13 +136,6 @@ def meeting_tags tags + optional_meeting_tags end - # Return tags for attendees from defined optional_attendee_tags. - # @api protected - # @return [Array] Tags for attendees - def attendee_tags - tags + optional_attendee_tags - end - # Merge application metadata into meeting instance and return. # @api protected # @param [Hash] meeting Meeting JSON object as hash diff --git a/lib/chime_sdk/controller/meetings.rb b/lib/chime_sdk/controller/meetings.rb index e86d968..627a8f9 100644 --- a/lib/chime_sdk/controller/meetings.rb +++ b/lib/chime_sdk/controller/meetings.rb @@ -21,10 +21,11 @@ def index if params[:create_meeting].to_s.to_boolean(false) || ChimeSdk.config.create_meeting_by_get_request && params[:create_meeting].to_s.to_boolean(true) create else - list_meetings + @meeting_request_id = ChimeSdk.config.prefix + meeting_request_id + @attendee_request_id = ChimeSdk.config.prefix + attendee_request_id respond_to do |format| format.html - format.json { render json: { meetings: @meetings } } + format.json { render json: { meeting_request_id: @meeting_request_id, attendee_request_id: @attendee_request_id } } end end end diff --git a/lib/chime_sdk/meeting_coordinator.rb b/lib/chime_sdk/meeting_coordinator.rb index c51d671..79f0857 100644 --- a/lib/chime_sdk/meeting_coordinator.rb +++ b/lib/chime_sdk/meeting_coordinator.rb @@ -1,74 +1,64 @@ module ChimeSdk # Meeting coordinator as a wrapper module of AWS SDK for Ruby, which simulates AWS SDK for JavaScript. - # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Chime/Client.html Aws::Chime::Client of AWS SDK for Ruby - # @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Chime.html AWS.Chime of AWS SDK for JavaScript + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html Aws::ChimeSDKMeetings::Client of AWS SDK for Ruby + # @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ChimeSDKMeetings.html AWS.ChimeSDKMeetings of AWS SDK for JavaScript module MeetingCoordinator - require 'aws-sdk-chime' + require 'aws-sdk-chimesdkmeetings' - # Return initialized Aws::Chime::Client. + # Return initialized Aws::ChimeSDKMeetings::Client. # You must use "us-east-1" as the region for Chime API and set the endpoint. - # @return [Aws::Chime::Client] Initialized Aws::Chime::Client instance + # @return [Aws::ChimeSDKMeetings::Client] Initialized Aws::ChimeSDKMeetings::Client instance # @see https://aws.github.io/amazon-chime-sdk-js/modules/gettingstarted.html def self.client - @@client ||= Aws::Chime::Client.new(region: 'us-east-1') + @@client ||= Aws::ChimeSDKMeetings::Client.new(region: 'us-east-1') end - # Reset client with initialized Aws::Chime::Client instance. - # @param [Aws::Chime::Client] client Initialized Aws::Chime::Client instance - # @return [Aws::Chime::Client] Initialized Aws::Chime::Client instance + # Reset client with initialized Aws::ChimeSDKMeetings::Client instance. + # @param [Aws::ChimeSDKMeetings::Client] client Initialized Aws::ChimeSDKMeetings::Client instance + # @return [Aws::ChimeSDKMeetings::Client] Initialized Aws::ChimeSDKMeetings::Client instance def self.reset_client(client) @@client = client end - # Wrapper of Aws::Chime::Client#list_meetings method. - # This function also provides prefix match filter of external_meeting_id. - # This method filters the result with ChimeSdk.config.prefix to return only meetings in your application. - # @param [Integer] max_results (ChimeSdk.config.max_meeting_results) The maximum number of results to return in a single call - # @param [String] prefix_filter (nil) Additional string for prefix match filter of external_meeting_id - # @return [Array] Array of filtered meeting JSON object as hash - # @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 - def self.list_meetings( - max_results: ChimeSdk.config.max_meeting_results, - prefix_filter: nil - ) - resp = client.list_meetings({ - max_results: max_results - }) - meetings = resp.meetings - meetings = meetings.select { |meeting| meeting.external_meeting_id.start_with?(ChimeSdk.config.prefix + prefix_filter) } if prefix_filter - meetings.map { |meeting| meeting_as_json(meeting) } - end - - # Wrapper of Aws::Chime::Client#create_meeting method. + # Wrapper of Aws::ChimeSDKMeetings::Client#create_meeting method. # This method uses 'ChimeSdk.config.prefix + meeting_request_id' for client_request_token and external_meeting_id. # @param [required, String] meeting_request_id The unique identifier for the client request. Use a different token for different meetings. - # @param [String] meeting_host_id (nil) Reserved # @param [String] media_region (ChimeSdk.config.media_region) The Region in which to create the meeting - # @param [Array] tags (nil) The tag key-value pairs - # @param [Aws::Chime::Types::MeetingNotificationConfiguration] notifications_configuration (nil) The configuration for resource targets to receive notifications when meeting and attendee events occur + # @param [String] meeting_host_id (nil) Reserved + # @param [Aws::ChimeSDKMeetings::Types::MeetingNotificationConfiguration] notifications_configuration (nil) The configuration for resource targets to receive notifications when meeting and attendee events occur + # @param [Aws::ChimeSDKMeetings::Types::MeetingFeaturesConfiguration] meeting_features (nil) Lists the audio and video features enabled for a meeting, such as echo reduction + # @param [String] primary_meeting_id (nil) When specified, replicates the media from the primary meeting to the new meeting + # @param [Array] tenant_ids (nil) A consistent and opaque identifier, created and maintained by the builder to represent a segment of their users + # @param [Array] tags (nil) Applies one or more tags to an Amazon Chime SDK meeting # @return [Hash] Created meeting JSON object as hash - # @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 + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#create_meeting-instance_method Aws::ChimeSDKMeetings::Client#create_meeting of AWS SDK for Ruby def self.create_meeting(meeting_request_id, - meeting_host_id: nil, media_region: ChimeSdk.config.media_region, - tags: [], - notifications_configuration: {} + meeting_host_id: nil, + notifications_configuration: {}, + meeting_features: {}, + primary_meeting_id: nil, + tenant_ids: nil, + tags: [] ) resp = client.create_meeting({ client_request_token: ChimeSdk.config.prefix + meeting_request_id, - external_meeting_id: ChimeSdk.config.prefix + meeting_request_id, - meeting_host_id: meeting_host_id, media_region: media_region, - tags: tags, - notifications_configuration: notifications_configuration + meeting_host_id: meeting_host_id, + external_meeting_id: ChimeSdk.config.prefix + meeting_request_id, + notifications_configuration: notifications_configuration, + meeting_features: meeting_features, + primary_meeting_id: primary_meeting_id, + tenant_ids: tenant_ids, + tags: tags }) meeting_as_json(resp.meeting) end - # Wrapper of Aws::Chime::Client#get_meeting method. + # Wrapper of Aws::ChimeSDKMeetings::Client#get_meeting method. # @param [required, String] meeting_id The Amazon Chime SDK meeting ID # @return [Hash] Meeting JSON object as hash - # @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 + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#get_meeting-instance_method Aws::ChimeSDKMeetings::Client#get_meeting of AWS SDK for Ruby def self.get_meeting(meeting_id) resp = client.get_meeting({ meeting_id: meeting_id @@ -76,51 +66,60 @@ def self.get_meeting(meeting_id) meeting_as_json(resp.meeting) end - # Wrapper of Aws::Chime::Client#delete_meeting method. + # Wrapper of Aws::ChimeSDKMeetings::Client#delete_meeting method. # @param [required, String] meeting_id The Amazon Chime SDK meeting ID # @return [void] - # @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 + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#delete_meeting-instance_method Aws::ChimeSDKMeetings::Client#delete_meeting of AWS SDK for Ruby def self.delete_meeting(meeting_id) client.delete_meeting({ meeting_id: meeting_id }) end - # Wrapper of Aws::Chime::Client#list_attendees method. + # Wrapper of Aws::ChimeSDKMeetings::Client#list_attendees method. # @param [required, String] meeting_id The Amazon Chime SDK meeting ID # @param [Integer] max_results (ChimeSdk.config.max_attendee_results) The maximum number of results to return in a single call # @return [Array] Array of attendee JSON object as hash - # @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 + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#list_attendees-instance_method Aws::ChimeSDKMeetings::Client#list_attendees of AWS SDK for Ruby def self.list_attendees(meeting_id, max_results: ChimeSdk.config.max_attendee_results ) - resp = client.list_attendees({ - meeting_id: meeting_id, - max_results: max_results - }) + # attendees = [], next_token = nil + # loop do + resp = client.list_attendees({ + meeting_id: meeting_id, + # next_token: next_token, + max_results: max_results + }) + # next_token = resp.next_token + # attendees += resp.attendees + # break if next_token.nil? + # end + # attendees.map { |attendee| attendee_as_json(attendee) } resp.attendees.map { |attendee| attendee_as_json(attendee) } end - # Wrapper of Aws::Chime::Client#create_attendee method. + # Wrapper of Aws::ChimeSDKMeetings::Client#create_attendee method. # This method uses 'ChimeSdk.config.prefix + attendee_request_id' for external_user_id. # @param [required, String] meeting_id The Amazon Chime SDK meeting ID # @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. + # @param [Aws::ChimeSDKMeetings::Types::AttendeeCapabilities] capabilities The capabilities (audio, video, or content) that you want to grant an attendee # @return [Hash] Created attendee JSON object as hash - # @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 - def self.create_attendee(meeting_id, attendee_request_id, tags: []) + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#create_attendee-instance_method Aws::ChimeSDKMeetings::Client#create_attendee of AWS SDK for Ruby + def self.create_attendee(meeting_id, attendee_request_id, capabilities: nil) resp = client.create_attendee({ meeting_id: meeting_id, external_user_id: ChimeSdk.config.prefix + attendee_request_id, - tags: tags + capabilities: capabilities }) attendee_as_json(resp.attendee) end - # Wrapper of Aws::Chime::Client#get_attendee method. + # Wrapper of Aws::ChimeSDKMeetings::Client#get_attendee method. # @param [required, String] meeting_id The Amazon Chime SDK meeting ID # @param [required, String] attendee_id The Amazon Chime SDK attendee ID # @return [Hash] Attendee JSON object as hash - # @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 + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#get_attendee-instance_method Aws::ChimeSDKMeetings::Client#get_attendee of AWS SDK for Ruby def self.get_attendee(meeting_id, attendee_id) resp = client.get_attendee({ meeting_id: meeting_id, @@ -129,10 +128,11 @@ def self.get_attendee(meeting_id, attendee_id) attendee_as_json(resp.attendee) end - # Wrapper of Aws::Chime::Client#delete_attendee method. + # Wrapper of Aws::ChimeSDKMeetings::Client#delete_attendee method. + # @param [required, String] meeting_id The Amazon Chime SDK meeting ID # @param [required, String] attendee_id The Amazon Chime SDK attendee ID # @return [void] - # @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 + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#delete_attendee-instance_method Aws::ChimeSDKMeetings::Client#delete_attendee of AWS SDK for Ruby def self.delete_attendee(meeting_id, attendee_id) client.delete_attendee({ meeting_id: meeting_id, @@ -140,45 +140,79 @@ def self.delete_attendee(meeting_id, attendee_id) }) end - # Build meeting JSON object as hash from Aws::Chime::Types::Meeting object - # @param [required, Aws::Chime::Types::Meeting] meeting Meeting response as Aws::Chime::Types::Meeting object + # Build meeting JSON object as hash from Aws::ChimeSDKMeetings::Types::Meeting object + # @param [required, Aws::ChimeSDKMeetings::Types::Meeting] meeting Meeting response as Aws::ChimeSDKMeetings::Types::Meeting object # @return [Hash] Meeting JSON object as hash - # @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 - # @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Chime.html#getMeeting-property AWS.Chime#getMeeting of AWS SDK for JavaScript + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#get_meeting-instance_method Aws::ChimeSDKMeetings::Client#get_meeting of AWS SDK for Ruby + # @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ChimeSDKMeetings.html#getMeeting-property AWS.Chime#getMeeting of AWS SDK for JavaScript def self.meeting_as_json(meeting) - return {} unless meeting.is_a?(Aws::Chime::Types::Meeting) - { + return {} unless meeting.is_a?(Aws::ChimeSDKMeetings::Types::Meeting) + meeting_json = { "Meeting": { "MeetingId": meeting.meeting_id, + "MeetingHostId": meeting.meeting_host_id, "ExternalMeetingId": meeting.external_meeting_id, + "MediaRegion": meeting.media_region, "MediaPlacement": { "AudioHostUrl": meeting.media_placement.audio_host_url, "AudioFallbackUrl": meeting.media_placement.audio_fallback_url, + "SignalingUrl": meeting.media_placement.signaling_url, + "TurnControlUrl": meeting.media_placement.turn_control_url, + # This parameter is deprecated and no longer used by the Amazon Chime SDK "ScreenDataUrl": meeting.media_placement.screen_data_url, - "ScreenSharingUrl": meeting.media_placement.screen_sharing_url, + # This parameter is deprecated and no longer used by the Amazon Chime SDK "ScreenViewingUrl": meeting.media_placement.screen_viewing_url, - "SignalingUrl": meeting.media_placement.signaling_url, - "TurnControlUrl": meeting.media_placement.turn_control_url + # This parameter is deprecated and no longer used by the Amazon Chime SDK + "ScreenSharingUrl": meeting.media_placement.screen_sharing_url, + # This parameter is deprecated and no longer used by the Amazon Chime SDK + "EventIngestionUrl": meeting.media_placement.event_ingestion_url }, - "MediaRegion": meeting.media_region + "PrimaryMeetingId": meeting.primary_meeting_id, + "TenantIds": meeting.tenant_ids, + "MeetingArn": meeting.meeting_arn } } + unless meeting.meeting_features.nil? + meeting_json[:Meeting]["MeetingFeatures"] = { + "Audio": { + "EchoReduction": meeting.meeting_features.audio.echo_reduction + }, + "Video": { + "MaxResolution": meeting.meeting_features.video.max_resolution + }, + "Content": { + "MaxResolution": meeting.meeting_features.content.max_resolution + }, + "Attendee": { + "MaxCount": meeting.meeting_features.attendee.max_count + } + } + end + meeting_json end - # Build attendee JSON object as hash from Aws::Chime::Types::Attendee object - # @param [required, Aws::Chime::Types::Attendee] attendee Attendee response as Aws::Chime::Types::Attendee object + # Build attendee JSON object as hash from Aws::ChimeSDKMeetings::Types::Attendee object + # @param [required, Aws::ChimeSDKMeetings::Types::Attendee] attendee Attendee response as Aws::ChimeSDKMeetings::Types::Attendee object # @return [Hash] Attendee JSON object as hash - # @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 - # @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Chime.html#getAttendee-property AWS.Chime#getAttendee of AWS SDK for JavaScript + # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ChimeSDKMeetings/Client.html#get_attendee-instance_method Aws::ChimeSDKMeetings::Client#get_attendee of AWS SDK for Ruby + # @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ChimeSDKMeetings.html#getAttendee-property AWS.Chime#getAttendee of AWS SDK for JavaScript def self.attendee_as_json(attendee) - return {} unless attendee.is_a?(Aws::Chime::Types::Attendee) - { + return {} unless attendee.is_a?(Aws::ChimeSDKMeetings::Types::Attendee) + attendee_json = { "Attendee": { "ExternalUserId": attendee.external_user_id, "AttendeeId": attendee.attendee_id, "JoinToken": attendee.join_token } } + unless attendee.capabilities.nil? + attendee_json[:Attendee]["Capabilities"] = { + "Audio": attendee.capabilities.audio, + "Video": attendee.capabilities.video, + "Content": attendee.capabilities.content + } + end + attendee_json end end end \ No newline at end of file diff --git a/lib/generators/templates/chime_sdk.rb b/lib/generators/templates/chime_sdk.rb index 73ff6d3..a981923 100644 --- a/lib/generators/templates/chime_sdk.rb +++ b/lib/generators/templates/chime_sdk.rb @@ -11,9 +11,6 @@ # Default value is "#{config.application_name}-#{Rails.env}-". config.prefix = "#{config.application_name}-#{Rails.env}-" - # Configure default max_results value used in list_meetings API. - config.max_meeting_results = 10 - # Configure default max_results value used in list_attendees API. config.max_attendee_results = 10 diff --git a/lib/generators/templates/views/meetings/index.html.erb b/lib/generators/templates/views/meetings/index.html.erb index e8d5acf..769d940 100644 --- a/lib/generators/templates/views/meetings/index.html.erb +++ b/lib/generators/templates/views/meetings/index.html.erb @@ -2,26 +2,9 @@

Meetings by Amazon Chime SDK

- - - - - - - - - - - - <% @meetings.each do |meeting| %> - - - - - - - <% end %> - -
Meeting IDExternal Meeting IDMedia Region
<%= link_to(meeting[:Meeting][:MeetingId], meeting_resource_path(meeting[:Meeting][:MeetingId])) %><%= meeting[:Meeting][:ExternalMeetingId] %><%= meeting[:Meeting][:MediaRegion] %><%= link_to 'Destroy', meeting_resource_path(meeting[:Meeting][:MeetingId]), method: :delete, data: { confirm: 'Are you sure?' } %>
+

+Meeting Request ID : <%= @meeting_request_id %>
+Attendee Request ID : <%= @attendee_request_id %>
+

<%= link_to 'Create Meeting', meeting_resources_path, method: :post %>

\ No newline at end of file diff --git a/lib/generators/templates/views/meetings/show.html.erb b/lib/generators/templates/views/meetings/show.html.erb index a031a50..4560a2f 100644 --- a/lib/generators/templates/views/meetings/show.html.erb +++ b/lib/generators/templates/views/meetings/show.html.erb @@ -2,7 +2,7 @@

Meeting by Amazon Chime SDK

-

<%= link_to("Show Meetings", meeting_resources_path) %>

+

<%= link_to("Back to index", meeting_resources_path) %>

<% if @meeting %> Meeting diff --git a/spec/rails_app/app/views/meetings/index.html.erb b/spec/rails_app/app/views/meetings/index.html.erb index e623f13..4f49b06 100644 --- a/spec/rails_app/app/views/meetings/index.html.erb +++ b/spec/rails_app/app/views/meetings/index.html.erb @@ -2,27 +2,10 @@

Meetings by Amazon Chime SDK

- - - - - - - - - - - - <% @meetings.each do |meeting| %> - - - - - - - <% end %> - -
Meeting IDExternal Meeting IDMedia Region
<%= link_to(meeting[:Meeting][:MeetingId], meeting_resource_path(meeting[:Meeting][:MeetingId])) %><%= meeting[:Meeting][:ExternalMeetingId] %><%= meeting[:Meeting][:MediaRegion] %><%= link_to 'Destroy', meeting_resource_path(meeting[:Meeting][:MeetingId]), method: :delete, data: { confirm: 'Are you sure?' } %>
+

+Meeting Request ID : <%= @meeting_request_id %>
+Attendee Request ID : <%= @attendee_request_id %>
+

<%= link_to 'Create Meeting', meeting_resources_path, method: :post %>

<%= link_to("Back to Room", room_path(@room)) %>

\ No newline at end of file diff --git a/spec/rails_app/app/views/meetings/show.html.erb b/spec/rails_app/app/views/meetings/show.html.erb index 57b6052..a4cec8a 100644 --- a/spec/rails_app/app/views/meetings/show.html.erb +++ b/spec/rails_app/app/views/meetings/show.html.erb @@ -2,7 +2,7 @@

Meeting by Amazon Chime SDK

-

<%= link_to("Show Meetings", meeting_resources_path) %>

+

<%= link_to("Back to index", meeting_resources_path) %>

<% if ENV['REACT_MEETING_DEMO_URL'] %>

diff --git a/spec/rails_app/config/initializers/chime_sdk.rb b/spec/rails_app/config/initializers/chime_sdk.rb index 73ff6d3..a981923 100644 --- a/spec/rails_app/config/initializers/chime_sdk.rb +++ b/spec/rails_app/config/initializers/chime_sdk.rb @@ -11,9 +11,6 @@ # Default value is "#{config.application_name}-#{Rails.env}-". config.prefix = "#{config.application_name}-#{Rails.env}-" - # Configure default max_results value used in list_meetings API. - config.max_meeting_results = 10 - # Configure default max_results value used in list_attendees API. config.max_attendee_results = 10 diff --git a/spec/requests/atendees_spec.rb b/spec/requests/atendees_spec.rb index 3c71ea0..403f0cb 100644 --- a/spec/requests/atendees_spec.rb +++ b/spec/requests/atendees_spec.rb @@ -11,16 +11,26 @@ test_attendee = { external_user_id: "ChimeSdkRailsApp-test-User-#{@attendee_user.id}", attendee_id: @attendee_id, - join_token: "dummy" + join_token: "dummy", + capabilities: { + audio: "SendReceive", + video: "SendReceive", + content: "SendReceive" + } } dummy_attendee = { external_user_id: "ChimeSdkRailsApp-test-User-0", attendee_id: @dummy_attendee_id, - join_token: "dummy" + join_token: "dummy", + capabilities: { + audio: "SendReceive", + video: "SendReceive", + content: "SendReceive" + } } # Use stubs for the AWS SDK for Ruby - client = Aws::Chime::Client.new(stub_responses: true) + client = Aws::ChimeSDKMeetings::Client.new(stub_responses: true) client.stub_responses(:list_attendees, { attendees: [ test_attendee, dummy_attendee ] }) diff --git a/spec/requests/meetings_spec.rb b/spec/requests/meetings_spec.rb index a0c8734..32e1e18 100644 --- a/spec/requests/meetings_spec.rb +++ b/spec/requests/meetings_spec.rb @@ -8,30 +8,51 @@ dummy_media_placement = { audio_host_url: "dummy", audio_fallback_url: "dummy", + signaling_url: "dummy", + turn_control_url: "dummy", screen_data_url: "dummy", - screen_sharing_url: "dummy", screen_viewing_url: "dummy", - signaling_url: "dummy", - turn_control_url: "dummy" + screen_sharing_url: "dummy", + event_ingestion_url: "dummy" + } + meeting_features = { + audio: { + echo_reduction: "AVAILABLE" + }, + video: { + max_resolution: "HD" + }, + content: { + max_resolution: "FHD" + }, + attendee: { + max_count: 100 + } } test_meeting = { meeting_id: @meeting_id, + meeting_host_id: nil, external_meeting_id: "ChimeSdkRailsApp-test-PrivateRoom-#{@room.id}", + media_region: "us-east-1", media_placement: dummy_media_placement, - media_region: "us-east-1" + meeting_features: meeting_features, + primary_meeting_id: nil, + tenant_ids: [], + meeting_arn: "arn:aws:chime:us-east-1:000000000000:meeting/#{@meeting_id}" } dummy_meeting = { meeting_id: @dummy_meeting_id, external_meeting_id: "ChimeSdkRailsApp-test-PrivateRoom-0", + media_region: "us-east-1", media_placement: dummy_media_placement, - media_region: "us-east-1" + meeting_features: meeting_features, + primary_meeting_id: nil, + tenant_ids: [], + meeting_arn: "arn:aws:chime:us-east-1:000000000000:meeting/#{@meeting_id}" } # Use stubs for the AWS SDK for Ruby - client = Aws::Chime::Client.new(stub_responses: true) - client.stub_responses(:list_meetings, { - meetings: [ test_meeting, dummy_meeting ] - }) + client = Aws::ChimeSDKMeetings::Client.new(stub_responses: true) client.stub_responses(:get_meeting, -> (context) { context.params[:meeting_id] == @meeting_id ? { meeting: test_meeting } : 'NotFoundException' }) @@ -101,12 +122,12 @@ expect(response).to have_http_status(200) end - it "returns meetings list filtered by prefix" do - expect(JSON.parse(response.body)["meetings"].length).to eq(1) + it "returns meeting_request_id" do + expect(JSON.parse(response.body)["meeting_request_id"]).not_to be_nil end - it "returns valid meeting in the list" do - expect(JSON.parse(response.body)["meetings"][0]["Meeting"]["MeetingId"]).to eq(@meeting_id) + it "returns attendee_request_id" do + expect(JSON.parse(response.body)["attendee_request_id"]).not_to be_nil end end @@ -287,10 +308,6 @@ expect(response).to have_http_status(200) expect(response.body).to include("Meetings by Amazon Chime SDK") end - - it "returns valid meeting in the list" do - expect(response.body).to include(@meeting_id) - end end context "with true as create_meeting parameter" do