{-# 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.SNS.Types.PlatformApplication
-- 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.SNS.Types.PlatformApplication where

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

-- | Platform application object.
--
-- /See:/ 'newPlatformApplication' smart constructor.
data PlatformApplication = PlatformApplication'
  { -- | PlatformApplicationArn for platform application object.
    PlatformApplication -> Maybe Text
platformApplicationArn :: Prelude.Maybe Prelude.Text,
    -- | Attributes for platform application object.
    PlatformApplication -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (PlatformApplication -> PlatformApplication -> Bool
(PlatformApplication -> PlatformApplication -> Bool)
-> (PlatformApplication -> PlatformApplication -> Bool)
-> Eq PlatformApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlatformApplication -> PlatformApplication -> Bool
$c/= :: PlatformApplication -> PlatformApplication -> Bool
== :: PlatformApplication -> PlatformApplication -> Bool
$c== :: PlatformApplication -> PlatformApplication -> Bool
Prelude.Eq, ReadPrec [PlatformApplication]
ReadPrec PlatformApplication
Int -> ReadS PlatformApplication
ReadS [PlatformApplication]
(Int -> ReadS PlatformApplication)
-> ReadS [PlatformApplication]
-> ReadPrec PlatformApplication
-> ReadPrec [PlatformApplication]
-> Read PlatformApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlatformApplication]
$creadListPrec :: ReadPrec [PlatformApplication]
readPrec :: ReadPrec PlatformApplication
$creadPrec :: ReadPrec PlatformApplication
readList :: ReadS [PlatformApplication]
$creadList :: ReadS [PlatformApplication]
readsPrec :: Int -> ReadS PlatformApplication
$creadsPrec :: Int -> ReadS PlatformApplication
Prelude.Read, Int -> PlatformApplication -> ShowS
[PlatformApplication] -> ShowS
PlatformApplication -> String
(Int -> PlatformApplication -> ShowS)
-> (PlatformApplication -> String)
-> ([PlatformApplication] -> ShowS)
-> Show PlatformApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlatformApplication] -> ShowS
$cshowList :: [PlatformApplication] -> ShowS
show :: PlatformApplication -> String
$cshow :: PlatformApplication -> String
showsPrec :: Int -> PlatformApplication -> ShowS
$cshowsPrec :: Int -> PlatformApplication -> ShowS
Prelude.Show, (forall x. PlatformApplication -> Rep PlatformApplication x)
-> (forall x. Rep PlatformApplication x -> PlatformApplication)
-> Generic PlatformApplication
forall x. Rep PlatformApplication x -> PlatformApplication
forall x. PlatformApplication -> Rep PlatformApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlatformApplication x -> PlatformApplication
$cfrom :: forall x. PlatformApplication -> Rep PlatformApplication x
Prelude.Generic)

-- |
-- Create a value of 'PlatformApplication' 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:
--
-- 'platformApplicationArn', 'platformApplication_platformApplicationArn' - PlatformApplicationArn for platform application object.
--
-- 'attributes', 'platformApplication_attributes' - Attributes for platform application object.
newPlatformApplication ::
  PlatformApplication
newPlatformApplication :: PlatformApplication
newPlatformApplication =
  PlatformApplication' :: Maybe Text -> Maybe (HashMap Text Text) -> PlatformApplication
PlatformApplication'
    { $sel:platformApplicationArn:PlatformApplication' :: Maybe Text
platformApplicationArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:PlatformApplication' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | PlatformApplicationArn for platform application object.
platformApplication_platformApplicationArn :: Lens.Lens' PlatformApplication (Prelude.Maybe Prelude.Text)
platformApplication_platformApplicationArn :: (Maybe Text -> f (Maybe Text))
-> PlatformApplication -> f PlatformApplication
platformApplication_platformApplicationArn = (PlatformApplication -> Maybe Text)
-> (PlatformApplication -> Maybe Text -> PlatformApplication)
-> Lens
     PlatformApplication PlatformApplication (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlatformApplication' {Maybe Text
platformApplicationArn :: Maybe Text
$sel:platformApplicationArn:PlatformApplication' :: PlatformApplication -> Maybe Text
platformApplicationArn} -> Maybe Text
platformApplicationArn) (\s :: PlatformApplication
s@PlatformApplication' {} Maybe Text
a -> PlatformApplication
s {$sel:platformApplicationArn:PlatformApplication' :: Maybe Text
platformApplicationArn = Maybe Text
a} :: PlatformApplication)

-- | Attributes for platform application object.
platformApplication_attributes :: Lens.Lens' PlatformApplication (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
platformApplication_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PlatformApplication -> f PlatformApplication
platformApplication_attributes = (PlatformApplication -> Maybe (HashMap Text Text))
-> (PlatformApplication
    -> Maybe (HashMap Text Text) -> PlatformApplication)
-> Lens
     PlatformApplication
     PlatformApplication
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlatformApplication' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:PlatformApplication' :: PlatformApplication -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: PlatformApplication
s@PlatformApplication' {} Maybe (HashMap Text Text)
a -> PlatformApplication
s {$sel:attributes:PlatformApplication' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: PlatformApplication) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> PlatformApplication -> f PlatformApplication)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PlatformApplication
-> f PlatformApplication
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML PlatformApplication where
  parseXML :: [Node] -> Either String PlatformApplication
parseXML [Node]
x =
    Maybe Text -> Maybe (HashMap Text Text) -> PlatformApplication
PlatformApplication'
      (Maybe Text -> Maybe (HashMap Text Text) -> PlatformApplication)
-> Either String (Maybe Text)
-> Either String (Maybe (HashMap Text Text) -> PlatformApplication)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PlatformApplicationArn")
      Either String (Maybe (HashMap Text Text) -> PlatformApplication)
-> Either String (Maybe (HashMap Text Text))
-> Either String PlatformApplication
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Attributes" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe (HashMap Text Text)))
-> Either String (Maybe (HashMap Text Text))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String (HashMap Text Text))
-> [Node] -> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> Text -> Text -> [Node] -> Either String (HashMap Text Text)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"entry" Text
"key" Text
"value")
                  )

instance Prelude.Hashable PlatformApplication

instance Prelude.NFData PlatformApplication