Class: Uc3DmpCognito::Client
- Inherits:
-
Object
- Object
- Uc3DmpCognito::Client
- Defined in:
- lib/uc3-dmp-cognito/client.rb
Overview
Helper functions for working with Dynamo JSON
Constant Summary collapse
- MSG_MISSING_POOL =
'No Cognito Pool defined. Expecting `ENV[\'COGNITO_USER_POOL_ID\']'
- MSG_COGNITO_ERROR =
'Cognito User Pool Error - %{msg} - %{trace}'
Class Method Summary collapse
-
.get_client_name(client_id:, debug: false) ⇒ Object
Fetch the name of the client from the client id provided.
Class Method Details
.get_client_name(client_id:, debug: false) ⇒ Object
Fetch the name of the client from the client id provided. DMP Provenance names match the Cognito client names
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/uc3-dmp-cognito/client.rb', line 14 def get_client_name(client_id:, debug: false) puts '----------------------------------' puts "GEM ENV:" puts ENV.inspect puts ENV['COGNITO_USER_POOL_ID'] puts '----------------------------------' user_pool_id = ENV.fetch('COGNITO_USER_POOL_ID', nil) raise ClientError, MSG_MISSING_POOL if user_pool_id.nil? client = Aws::CognitoIdentityProvider::Client.new(region: ENV.fetch('AWS_REGION', nil)) resp = client.describe_user_pool_client({ user_pool_id: user_pool_id, client_id: client_id }) resp&.user_pool_client&.client_name&.downcase rescue Aws::Errors::ServiceError => e raise ClientError, format(MSG_COGNITO_ERROR, msg: e., trace: e.backtrace) end |