{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CognitoIdentityProvider.Types.AnalyticsConfigurationType
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentityProvider.Types.AnalyticsConfigurationType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The Amazon Pinpoint analytics configuration for collecting metrics for a
-- user pool.
--
-- In regions where Pinpoint is not available, Cognito User Pools only
-- supports sending events to Amazon Pinpoint projects in us-east-1. In
-- regions where Pinpoint is available, Cognito User Pools will support
-- sending events to Amazon Pinpoint projects within that same region.
--
-- /See:/ 'newAnalyticsConfigurationType' smart constructor.
data AnalyticsConfigurationType = AnalyticsConfigurationType'
  { -- | The Amazon Resource Name (ARN) of an Amazon Pinpoint project. You can
    -- use the Amazon Pinpoint project for Pinpoint integration with the chosen
    -- User Pool Client. Amazon Cognito publishes events to the pinpoint
    -- project declared by the app ARN.
    AnalyticsConfigurationType -> Maybe Text
applicationArn :: Prelude.Maybe Prelude.Text,
    -- | If @UserDataShared@ is @true@, Amazon Cognito will include user data in
    -- the events it publishes to Amazon Pinpoint analytics.
    AnalyticsConfigurationType -> Maybe Bool
userDataShared :: Prelude.Maybe Prelude.Bool,
    -- | The application ID for an Amazon Pinpoint application.
    AnalyticsConfigurationType -> Maybe Text
applicationId :: Prelude.Maybe Prelude.Text,
    -- | The external ID.
    AnalyticsConfigurationType -> Maybe Text
externalId :: Prelude.Maybe Prelude.Text,
    -- | The ARN of an IAM role that authorizes Amazon Cognito to publish events
    -- to Amazon Pinpoint analytics.
    AnalyticsConfigurationType -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AnalyticsConfigurationType -> AnalyticsConfigurationType -> Bool
(AnalyticsConfigurationType -> AnalyticsConfigurationType -> Bool)
-> (AnalyticsConfigurationType
    -> AnalyticsConfigurationType -> Bool)
-> Eq AnalyticsConfigurationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalyticsConfigurationType -> AnalyticsConfigurationType -> Bool
$c/= :: AnalyticsConfigurationType -> AnalyticsConfigurationType -> Bool
== :: AnalyticsConfigurationType -> AnalyticsConfigurationType -> Bool
$c== :: AnalyticsConfigurationType -> AnalyticsConfigurationType -> Bool
Prelude.Eq, ReadPrec [AnalyticsConfigurationType]
ReadPrec AnalyticsConfigurationType
Int -> ReadS AnalyticsConfigurationType
ReadS [AnalyticsConfigurationType]
(Int -> ReadS AnalyticsConfigurationType)
-> ReadS [AnalyticsConfigurationType]
-> ReadPrec AnalyticsConfigurationType
-> ReadPrec [AnalyticsConfigurationType]
-> Read AnalyticsConfigurationType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalyticsConfigurationType]
$creadListPrec :: ReadPrec [AnalyticsConfigurationType]
readPrec :: ReadPrec AnalyticsConfigurationType
$creadPrec :: ReadPrec AnalyticsConfigurationType
readList :: ReadS [AnalyticsConfigurationType]
$creadList :: ReadS [AnalyticsConfigurationType]
readsPrec :: Int -> ReadS AnalyticsConfigurationType
$creadsPrec :: Int -> ReadS AnalyticsConfigurationType
Prelude.Read, Int -> AnalyticsConfigurationType -> ShowS
[AnalyticsConfigurationType] -> ShowS
AnalyticsConfigurationType -> String
(Int -> AnalyticsConfigurationType -> ShowS)
-> (AnalyticsConfigurationType -> String)
-> ([AnalyticsConfigurationType] -> ShowS)
-> Show AnalyticsConfigurationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalyticsConfigurationType] -> ShowS
$cshowList :: [AnalyticsConfigurationType] -> ShowS
show :: AnalyticsConfigurationType -> String
$cshow :: AnalyticsConfigurationType -> String
showsPrec :: Int -> AnalyticsConfigurationType -> ShowS
$cshowsPrec :: Int -> AnalyticsConfigurationType -> ShowS
Prelude.Show, (forall x.
 AnalyticsConfigurationType -> Rep AnalyticsConfigurationType x)
-> (forall x.
    Rep AnalyticsConfigurationType x -> AnalyticsConfigurationType)
-> Generic AnalyticsConfigurationType
forall x.
Rep AnalyticsConfigurationType x -> AnalyticsConfigurationType
forall x.
AnalyticsConfigurationType -> Rep AnalyticsConfigurationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AnalyticsConfigurationType x -> AnalyticsConfigurationType
$cfrom :: forall x.
AnalyticsConfigurationType -> Rep AnalyticsConfigurationType x
Prelude.Generic)

-- |
-- Create a value of 'AnalyticsConfigurationType' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'applicationArn', 'analyticsConfigurationType_applicationArn' - The Amazon Resource Name (ARN) of an Amazon Pinpoint project. You can
-- use the Amazon Pinpoint project for Pinpoint integration with the chosen
-- User Pool Client. Amazon Cognito publishes events to the pinpoint
-- project declared by the app ARN.
--
-- 'userDataShared', 'analyticsConfigurationType_userDataShared' - If @UserDataShared@ is @true@, Amazon Cognito will include user data in
-- the events it publishes to Amazon Pinpoint analytics.
--
-- 'applicationId', 'analyticsConfigurationType_applicationId' - The application ID for an Amazon Pinpoint application.
--
-- 'externalId', 'analyticsConfigurationType_externalId' - The external ID.
--
-- 'roleArn', 'analyticsConfigurationType_roleArn' - The ARN of an IAM role that authorizes Amazon Cognito to publish events
-- to Amazon Pinpoint analytics.
newAnalyticsConfigurationType ::
  AnalyticsConfigurationType
newAnalyticsConfigurationType :: AnalyticsConfigurationType
newAnalyticsConfigurationType =
  AnalyticsConfigurationType' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AnalyticsConfigurationType
AnalyticsConfigurationType'
    { $sel:applicationArn:AnalyticsConfigurationType' :: Maybe Text
applicationArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userDataShared:AnalyticsConfigurationType' :: Maybe Bool
userDataShared = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:AnalyticsConfigurationType' :: Maybe Text
applicationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:externalId:AnalyticsConfigurationType' :: Maybe Text
externalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:AnalyticsConfigurationType' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of an Amazon Pinpoint project. You can
-- use the Amazon Pinpoint project for Pinpoint integration with the chosen
-- User Pool Client. Amazon Cognito publishes events to the pinpoint
-- project declared by the app ARN.
analyticsConfigurationType_applicationArn :: Lens.Lens' AnalyticsConfigurationType (Prelude.Maybe Prelude.Text)
analyticsConfigurationType_applicationArn :: (Maybe Text -> f (Maybe Text))
-> AnalyticsConfigurationType -> f AnalyticsConfigurationType
analyticsConfigurationType_applicationArn = (AnalyticsConfigurationType -> Maybe Text)
-> (AnalyticsConfigurationType
    -> Maybe Text -> AnalyticsConfigurationType)
-> Lens
     AnalyticsConfigurationType
     AnalyticsConfigurationType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyticsConfigurationType' {Maybe Text
applicationArn :: Maybe Text
$sel:applicationArn:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
applicationArn} -> Maybe Text
applicationArn) (\s :: AnalyticsConfigurationType
s@AnalyticsConfigurationType' {} Maybe Text
a -> AnalyticsConfigurationType
s {$sel:applicationArn:AnalyticsConfigurationType' :: Maybe Text
applicationArn = Maybe Text
a} :: AnalyticsConfigurationType)

-- | If @UserDataShared@ is @true@, Amazon Cognito will include user data in
-- the events it publishes to Amazon Pinpoint analytics.
analyticsConfigurationType_userDataShared :: Lens.Lens' AnalyticsConfigurationType (Prelude.Maybe Prelude.Bool)
analyticsConfigurationType_userDataShared :: (Maybe Bool -> f (Maybe Bool))
-> AnalyticsConfigurationType -> f AnalyticsConfigurationType
analyticsConfigurationType_userDataShared = (AnalyticsConfigurationType -> Maybe Bool)
-> (AnalyticsConfigurationType
    -> Maybe Bool -> AnalyticsConfigurationType)
-> Lens
     AnalyticsConfigurationType
     AnalyticsConfigurationType
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyticsConfigurationType' {Maybe Bool
userDataShared :: Maybe Bool
$sel:userDataShared:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Bool
userDataShared} -> Maybe Bool
userDataShared) (\s :: AnalyticsConfigurationType
s@AnalyticsConfigurationType' {} Maybe Bool
a -> AnalyticsConfigurationType
s {$sel:userDataShared:AnalyticsConfigurationType' :: Maybe Bool
userDataShared = Maybe Bool
a} :: AnalyticsConfigurationType)

-- | The application ID for an Amazon Pinpoint application.
analyticsConfigurationType_applicationId :: Lens.Lens' AnalyticsConfigurationType (Prelude.Maybe Prelude.Text)
analyticsConfigurationType_applicationId :: (Maybe Text -> f (Maybe Text))
-> AnalyticsConfigurationType -> f AnalyticsConfigurationType
analyticsConfigurationType_applicationId = (AnalyticsConfigurationType -> Maybe Text)
-> (AnalyticsConfigurationType
    -> Maybe Text -> AnalyticsConfigurationType)
-> Lens
     AnalyticsConfigurationType
     AnalyticsConfigurationType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyticsConfigurationType' {Maybe Text
applicationId :: Maybe Text
$sel:applicationId:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
applicationId} -> Maybe Text
applicationId) (\s :: AnalyticsConfigurationType
s@AnalyticsConfigurationType' {} Maybe Text
a -> AnalyticsConfigurationType
s {$sel:applicationId:AnalyticsConfigurationType' :: Maybe Text
applicationId = Maybe Text
a} :: AnalyticsConfigurationType)

-- | The external ID.
analyticsConfigurationType_externalId :: Lens.Lens' AnalyticsConfigurationType (Prelude.Maybe Prelude.Text)
analyticsConfigurationType_externalId :: (Maybe Text -> f (Maybe Text))
-> AnalyticsConfigurationType -> f AnalyticsConfigurationType
analyticsConfigurationType_externalId = (AnalyticsConfigurationType -> Maybe Text)
-> (AnalyticsConfigurationType
    -> Maybe Text -> AnalyticsConfigurationType)
-> Lens
     AnalyticsConfigurationType
     AnalyticsConfigurationType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyticsConfigurationType' {Maybe Text
externalId :: Maybe Text
$sel:externalId:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
externalId} -> Maybe Text
externalId) (\s :: AnalyticsConfigurationType
s@AnalyticsConfigurationType' {} Maybe Text
a -> AnalyticsConfigurationType
s {$sel:externalId:AnalyticsConfigurationType' :: Maybe Text
externalId = Maybe Text
a} :: AnalyticsConfigurationType)

-- | The ARN of an IAM role that authorizes Amazon Cognito to publish events
-- to Amazon Pinpoint analytics.
analyticsConfigurationType_roleArn :: Lens.Lens' AnalyticsConfigurationType (Prelude.Maybe Prelude.Text)
analyticsConfigurationType_roleArn :: (Maybe Text -> f (Maybe Text))
-> AnalyticsConfigurationType -> f AnalyticsConfigurationType
analyticsConfigurationType_roleArn = (AnalyticsConfigurationType -> Maybe Text)
-> (AnalyticsConfigurationType
    -> Maybe Text -> AnalyticsConfigurationType)
-> Lens
     AnalyticsConfigurationType
     AnalyticsConfigurationType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyticsConfigurationType' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: AnalyticsConfigurationType
s@AnalyticsConfigurationType' {} Maybe Text
a -> AnalyticsConfigurationType
s {$sel:roleArn:AnalyticsConfigurationType' :: Maybe Text
roleArn = Maybe Text
a} :: AnalyticsConfigurationType)

instance Core.FromJSON AnalyticsConfigurationType where
  parseJSON :: Value -> Parser AnalyticsConfigurationType
parseJSON =
    String
-> (Object -> Parser AnalyticsConfigurationType)
-> Value
-> Parser AnalyticsConfigurationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnalyticsConfigurationType"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AnalyticsConfigurationType
AnalyticsConfigurationType'
            (Maybe Text
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> AnalyticsConfigurationType)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> AnalyticsConfigurationType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ApplicationArn")
            Parser
  (Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> AnalyticsConfigurationType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> AnalyticsConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UserDataShared")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> AnalyticsConfigurationType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> AnalyticsConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ApplicationId")
            Parser (Maybe Text -> Maybe Text -> AnalyticsConfigurationType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AnalyticsConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExternalId")
            Parser (Maybe Text -> AnalyticsConfigurationType)
-> Parser (Maybe Text) -> Parser AnalyticsConfigurationType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RoleArn")
      )

instance Prelude.Hashable AnalyticsConfigurationType

instance Prelude.NFData AnalyticsConfigurationType

instance Core.ToJSON AnalyticsConfigurationType where
  toJSON :: AnalyticsConfigurationType -> Value
toJSON AnalyticsConfigurationType' {Maybe Bool
Maybe Text
roleArn :: Maybe Text
externalId :: Maybe Text
applicationId :: Maybe Text
userDataShared :: Maybe Bool
applicationArn :: Maybe Text
$sel:roleArn:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
$sel:externalId:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
$sel:applicationId:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
$sel:userDataShared:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Bool
$sel:applicationArn:AnalyticsConfigurationType' :: AnalyticsConfigurationType -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ApplicationArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
applicationArn,
            (Text
"UserDataShared" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
userDataShared,
            (Text
"ApplicationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
applicationId,
            (Text
"ExternalId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
externalId,
            (Text
"RoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn
          ]
      )