{-# 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.CognitoSync.Types.PushSync
-- 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.CognitoSync.Types.PushSync where

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

-- | Configuration options to be applied to the identity pool.
--
-- /See:/ 'newPushSync' smart constructor.
data PushSync = PushSync'
  { -- | List of SNS platform application ARNs that could be used by clients.
    PushSync -> Maybe [Text]
applicationArns :: Prelude.Maybe [Prelude.Text],
    -- | A role configured to allow Cognito to call SNS on behalf of the
    -- developer.
    PushSync -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (PushSync -> PushSync -> Bool
(PushSync -> PushSync -> Bool)
-> (PushSync -> PushSync -> Bool) -> Eq PushSync
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PushSync -> PushSync -> Bool
$c/= :: PushSync -> PushSync -> Bool
== :: PushSync -> PushSync -> Bool
$c== :: PushSync -> PushSync -> Bool
Prelude.Eq, ReadPrec [PushSync]
ReadPrec PushSync
Int -> ReadS PushSync
ReadS [PushSync]
(Int -> ReadS PushSync)
-> ReadS [PushSync]
-> ReadPrec PushSync
-> ReadPrec [PushSync]
-> Read PushSync
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PushSync]
$creadListPrec :: ReadPrec [PushSync]
readPrec :: ReadPrec PushSync
$creadPrec :: ReadPrec PushSync
readList :: ReadS [PushSync]
$creadList :: ReadS [PushSync]
readsPrec :: Int -> ReadS PushSync
$creadsPrec :: Int -> ReadS PushSync
Prelude.Read, Int -> PushSync -> ShowS
[PushSync] -> ShowS
PushSync -> String
(Int -> PushSync -> ShowS)
-> (PushSync -> String) -> ([PushSync] -> ShowS) -> Show PushSync
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PushSync] -> ShowS
$cshowList :: [PushSync] -> ShowS
show :: PushSync -> String
$cshow :: PushSync -> String
showsPrec :: Int -> PushSync -> ShowS
$cshowsPrec :: Int -> PushSync -> ShowS
Prelude.Show, (forall x. PushSync -> Rep PushSync x)
-> (forall x. Rep PushSync x -> PushSync) -> Generic PushSync
forall x. Rep PushSync x -> PushSync
forall x. PushSync -> Rep PushSync x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PushSync x -> PushSync
$cfrom :: forall x. PushSync -> Rep PushSync x
Prelude.Generic)

-- |
-- Create a value of 'PushSync' 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:
--
-- 'applicationArns', 'pushSync_applicationArns' - List of SNS platform application ARNs that could be used by clients.
--
-- 'roleArn', 'pushSync_roleArn' - A role configured to allow Cognito to call SNS on behalf of the
-- developer.
newPushSync ::
  PushSync
newPushSync :: PushSync
newPushSync =
  PushSync' :: Maybe [Text] -> Maybe Text -> PushSync
PushSync'
    { $sel:applicationArns:PushSync' :: Maybe [Text]
applicationArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:PushSync' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | List of SNS platform application ARNs that could be used by clients.
pushSync_applicationArns :: Lens.Lens' PushSync (Prelude.Maybe [Prelude.Text])
pushSync_applicationArns :: (Maybe [Text] -> f (Maybe [Text])) -> PushSync -> f PushSync
pushSync_applicationArns = (PushSync -> Maybe [Text])
-> (PushSync -> Maybe [Text] -> PushSync)
-> Lens PushSync PushSync (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PushSync' {Maybe [Text]
applicationArns :: Maybe [Text]
$sel:applicationArns:PushSync' :: PushSync -> Maybe [Text]
applicationArns} -> Maybe [Text]
applicationArns) (\s :: PushSync
s@PushSync' {} Maybe [Text]
a -> PushSync
s {$sel:applicationArns:PushSync' :: Maybe [Text]
applicationArns = Maybe [Text]
a} :: PushSync) ((Maybe [Text] -> f (Maybe [Text])) -> PushSync -> f PushSync)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PushSync
-> f PushSync
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A role configured to allow Cognito to call SNS on behalf of the
-- developer.
pushSync_roleArn :: Lens.Lens' PushSync (Prelude.Maybe Prelude.Text)
pushSync_roleArn :: (Maybe Text -> f (Maybe Text)) -> PushSync -> f PushSync
pushSync_roleArn = (PushSync -> Maybe Text)
-> (PushSync -> Maybe Text -> PushSync)
-> Lens PushSync PushSync (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PushSync' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:PushSync' :: PushSync -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: PushSync
s@PushSync' {} Maybe Text
a -> PushSync
s {$sel:roleArn:PushSync' :: Maybe Text
roleArn = Maybe Text
a} :: PushSync)

instance Core.FromJSON PushSync where
  parseJSON :: Value -> Parser PushSync
parseJSON =
    String -> (Object -> Parser PushSync) -> Value -> Parser PushSync
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PushSync"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> PushSync
PushSync'
            (Maybe [Text] -> Maybe Text -> PushSync)
-> Parser (Maybe [Text]) -> Parser (Maybe Text -> PushSync)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ApplicationArns"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> PushSync)
-> Parser (Maybe Text) -> Parser PushSync
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 PushSync

instance Prelude.NFData PushSync

instance Core.ToJSON PushSync where
  toJSON :: PushSync -> Value
toJSON PushSync' {Maybe [Text]
Maybe Text
roleArn :: Maybe Text
applicationArns :: Maybe [Text]
$sel:roleArn:PushSync' :: PushSync -> Maybe Text
$sel:applicationArns:PushSync' :: PushSync -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ApplicationArns" 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]
applicationArns,
            (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
          ]
      )