{-# 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.FMS.Types.AppsListData
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.FMS.Types.AppsListData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types.App
import qualified Amazonka.Prelude as Prelude

-- | An Firewall Manager applications list.
--
-- /See:/ 'newAppsListData' smart constructor.
data AppsListData = AppsListData'
  { -- | The time that the Firewall Manager applications list was created.
    AppsListData -> Maybe POSIX
createTime :: Prelude.Maybe Data.POSIX,
    -- | The time that the Firewall Manager applications list was last updated.
    AppsListData -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Data.POSIX,
    -- | The ID of the Firewall Manager applications list.
    AppsListData -> Maybe Text
listId :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for each update to the list. When you update the
    -- list, the update token must match the token of the current version of
    -- the application list. You can retrieve the update token by getting the
    -- list.
    AppsListData -> Maybe Text
listUpdateToken :: Prelude.Maybe Prelude.Text,
    -- | A map of previous version numbers to their corresponding @App@ object
    -- arrays.
    AppsListData -> Maybe (HashMap Text [App])
previousAppsList :: Prelude.Maybe (Prelude.HashMap Prelude.Text [App]),
    -- | The name of the Firewall Manager applications list.
    AppsListData -> Text
listName :: Prelude.Text,
    -- | An array of applications in the Firewall Manager applications list.
    AppsListData -> [App]
appsList :: [App]
  }
  deriving (AppsListData -> AppsListData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppsListData -> AppsListData -> Bool
$c/= :: AppsListData -> AppsListData -> Bool
== :: AppsListData -> AppsListData -> Bool
$c== :: AppsListData -> AppsListData -> Bool
Prelude.Eq, ReadPrec [AppsListData]
ReadPrec AppsListData
Int -> ReadS AppsListData
ReadS [AppsListData]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppsListData]
$creadListPrec :: ReadPrec [AppsListData]
readPrec :: ReadPrec AppsListData
$creadPrec :: ReadPrec AppsListData
readList :: ReadS [AppsListData]
$creadList :: ReadS [AppsListData]
readsPrec :: Int -> ReadS AppsListData
$creadsPrec :: Int -> ReadS AppsListData
Prelude.Read, Int -> AppsListData -> ShowS
[AppsListData] -> ShowS
AppsListData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppsListData] -> ShowS
$cshowList :: [AppsListData] -> ShowS
show :: AppsListData -> String
$cshow :: AppsListData -> String
showsPrec :: Int -> AppsListData -> ShowS
$cshowsPrec :: Int -> AppsListData -> ShowS
Prelude.Show, forall x. Rep AppsListData x -> AppsListData
forall x. AppsListData -> Rep AppsListData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AppsListData x -> AppsListData
$cfrom :: forall x. AppsListData -> Rep AppsListData x
Prelude.Generic)

-- |
-- Create a value of 'AppsListData' 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:
--
-- 'createTime', 'appsListData_createTime' - The time that the Firewall Manager applications list was created.
--
-- 'lastUpdateTime', 'appsListData_lastUpdateTime' - The time that the Firewall Manager applications list was last updated.
--
-- 'listId', 'appsListData_listId' - The ID of the Firewall Manager applications list.
--
-- 'listUpdateToken', 'appsListData_listUpdateToken' - A unique identifier for each update to the list. When you update the
-- list, the update token must match the token of the current version of
-- the application list. You can retrieve the update token by getting the
-- list.
--
-- 'previousAppsList', 'appsListData_previousAppsList' - A map of previous version numbers to their corresponding @App@ object
-- arrays.
--
-- 'listName', 'appsListData_listName' - The name of the Firewall Manager applications list.
--
-- 'appsList', 'appsListData_appsList' - An array of applications in the Firewall Manager applications list.
newAppsListData ::
  -- | 'listName'
  Prelude.Text ->
  AppsListData
newAppsListData :: Text -> AppsListData
newAppsListData Text
pListName_ =
  AppsListData'
    { $sel:createTime:AppsListData' :: Maybe POSIX
createTime = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:AppsListData' :: Maybe POSIX
lastUpdateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:listId:AppsListData' :: Maybe Text
listId = forall a. Maybe a
Prelude.Nothing,
      $sel:listUpdateToken:AppsListData' :: Maybe Text
listUpdateToken = forall a. Maybe a
Prelude.Nothing,
      $sel:previousAppsList:AppsListData' :: Maybe (HashMap Text [App])
previousAppsList = forall a. Maybe a
Prelude.Nothing,
      $sel:listName:AppsListData' :: Text
listName = Text
pListName_,
      $sel:appsList:AppsListData' :: [App]
appsList = forall a. Monoid a => a
Prelude.mempty
    }

-- | The time that the Firewall Manager applications list was created.
appsListData_createTime :: Lens.Lens' AppsListData (Prelude.Maybe Prelude.UTCTime)
appsListData_createTime :: Lens' AppsListData (Maybe UTCTime)
appsListData_createTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {Maybe POSIX
createTime :: Maybe POSIX
$sel:createTime:AppsListData' :: AppsListData -> Maybe POSIX
createTime} -> Maybe POSIX
createTime) (\s :: AppsListData
s@AppsListData' {} Maybe POSIX
a -> AppsListData
s {$sel:createTime:AppsListData' :: Maybe POSIX
createTime = Maybe POSIX
a} :: AppsListData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time that the Firewall Manager applications list was last updated.
appsListData_lastUpdateTime :: Lens.Lens' AppsListData (Prelude.Maybe Prelude.UTCTime)
appsListData_lastUpdateTime :: Lens' AppsListData (Maybe UTCTime)
appsListData_lastUpdateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:AppsListData' :: AppsListData -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: AppsListData
s@AppsListData' {} Maybe POSIX
a -> AppsListData
s {$sel:lastUpdateTime:AppsListData' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: AppsListData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ID of the Firewall Manager applications list.
appsListData_listId :: Lens.Lens' AppsListData (Prelude.Maybe Prelude.Text)
appsListData_listId :: Lens' AppsListData (Maybe Text)
appsListData_listId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {Maybe Text
listId :: Maybe Text
$sel:listId:AppsListData' :: AppsListData -> Maybe Text
listId} -> Maybe Text
listId) (\s :: AppsListData
s@AppsListData' {} Maybe Text
a -> AppsListData
s {$sel:listId:AppsListData' :: Maybe Text
listId = Maybe Text
a} :: AppsListData)

-- | A unique identifier for each update to the list. When you update the
-- list, the update token must match the token of the current version of
-- the application list. You can retrieve the update token by getting the
-- list.
appsListData_listUpdateToken :: Lens.Lens' AppsListData (Prelude.Maybe Prelude.Text)
appsListData_listUpdateToken :: Lens' AppsListData (Maybe Text)
appsListData_listUpdateToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {Maybe Text
listUpdateToken :: Maybe Text
$sel:listUpdateToken:AppsListData' :: AppsListData -> Maybe Text
listUpdateToken} -> Maybe Text
listUpdateToken) (\s :: AppsListData
s@AppsListData' {} Maybe Text
a -> AppsListData
s {$sel:listUpdateToken:AppsListData' :: Maybe Text
listUpdateToken = Maybe Text
a} :: AppsListData)

-- | A map of previous version numbers to their corresponding @App@ object
-- arrays.
appsListData_previousAppsList :: Lens.Lens' AppsListData (Prelude.Maybe (Prelude.HashMap Prelude.Text [App]))
appsListData_previousAppsList :: Lens' AppsListData (Maybe (HashMap Text [App]))
appsListData_previousAppsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {Maybe (HashMap Text [App])
previousAppsList :: Maybe (HashMap Text [App])
$sel:previousAppsList:AppsListData' :: AppsListData -> Maybe (HashMap Text [App])
previousAppsList} -> Maybe (HashMap Text [App])
previousAppsList) (\s :: AppsListData
s@AppsListData' {} Maybe (HashMap Text [App])
a -> AppsListData
s {$sel:previousAppsList:AppsListData' :: Maybe (HashMap Text [App])
previousAppsList = Maybe (HashMap Text [App])
a} :: AppsListData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the Firewall Manager applications list.
appsListData_listName :: Lens.Lens' AppsListData Prelude.Text
appsListData_listName :: Lens' AppsListData Text
appsListData_listName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {Text
listName :: Text
$sel:listName:AppsListData' :: AppsListData -> Text
listName} -> Text
listName) (\s :: AppsListData
s@AppsListData' {} Text
a -> AppsListData
s {$sel:listName:AppsListData' :: Text
listName = Text
a} :: AppsListData)

-- | An array of applications in the Firewall Manager applications list.
appsListData_appsList :: Lens.Lens' AppsListData [App]
appsListData_appsList :: Lens' AppsListData [App]
appsListData_appsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppsListData' {[App]
appsList :: [App]
$sel:appsList:AppsListData' :: AppsListData -> [App]
appsList} -> [App]
appsList) (\s :: AppsListData
s@AppsListData' {} [App]
a -> AppsListData
s {$sel:appsList:AppsListData' :: [App]
appsList = [App]
a} :: AppsListData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AppsListData where
  parseJSON :: Value -> Parser AppsListData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AppsListData"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text [App])
-> Text
-> [App]
-> AppsListData
AppsListData'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastUpdateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ListId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ListUpdateToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"PreviousAppsList"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ListName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AppsList" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AppsListData where
  hashWithSalt :: Int -> AppsListData -> Int
hashWithSalt Int
_salt AppsListData' {[App]
Maybe Text
Maybe (HashMap Text [App])
Maybe POSIX
Text
appsList :: [App]
listName :: Text
previousAppsList :: Maybe (HashMap Text [App])
listUpdateToken :: Maybe Text
listId :: Maybe Text
lastUpdateTime :: Maybe POSIX
createTime :: Maybe POSIX
$sel:appsList:AppsListData' :: AppsListData -> [App]
$sel:listName:AppsListData' :: AppsListData -> Text
$sel:previousAppsList:AppsListData' :: AppsListData -> Maybe (HashMap Text [App])
$sel:listUpdateToken:AppsListData' :: AppsListData -> Maybe Text
$sel:listId:AppsListData' :: AppsListData -> Maybe Text
$sel:lastUpdateTime:AppsListData' :: AppsListData -> Maybe POSIX
$sel:createTime:AppsListData' :: AppsListData -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
listId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
listUpdateToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text [App])
previousAppsList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
listName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [App]
appsList

instance Prelude.NFData AppsListData where
  rnf :: AppsListData -> ()
rnf AppsListData' {[App]
Maybe Text
Maybe (HashMap Text [App])
Maybe POSIX
Text
appsList :: [App]
listName :: Text
previousAppsList :: Maybe (HashMap Text [App])
listUpdateToken :: Maybe Text
listId :: Maybe Text
lastUpdateTime :: Maybe POSIX
createTime :: Maybe POSIX
$sel:appsList:AppsListData' :: AppsListData -> [App]
$sel:listName:AppsListData' :: AppsListData -> Text
$sel:previousAppsList:AppsListData' :: AppsListData -> Maybe (HashMap Text [App])
$sel:listUpdateToken:AppsListData' :: AppsListData -> Maybe Text
$sel:listId:AppsListData' :: AppsListData -> Maybe Text
$sel:lastUpdateTime:AppsListData' :: AppsListData -> Maybe POSIX
$sel:createTime:AppsListData' :: AppsListData -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
listId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
listUpdateToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text [App])
previousAppsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
listName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [App]
appsList

instance Data.ToJSON AppsListData where
  toJSON :: AppsListData -> Value
toJSON AppsListData' {[App]
Maybe Text
Maybe (HashMap Text [App])
Maybe POSIX
Text
appsList :: [App]
listName :: Text
previousAppsList :: Maybe (HashMap Text [App])
listUpdateToken :: Maybe Text
listId :: Maybe Text
lastUpdateTime :: Maybe POSIX
createTime :: Maybe POSIX
$sel:appsList:AppsListData' :: AppsListData -> [App]
$sel:listName:AppsListData' :: AppsListData -> Text
$sel:previousAppsList:AppsListData' :: AppsListData -> Maybe (HashMap Text [App])
$sel:listUpdateToken:AppsListData' :: AppsListData -> Maybe Text
$sel:listId:AppsListData' :: AppsListData -> Maybe Text
$sel:lastUpdateTime:AppsListData' :: AppsListData -> Maybe POSIX
$sel:createTime:AppsListData' :: AppsListData -> Maybe POSIX
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CreateTime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
createTime,
            (Key
"LastUpdateTime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
lastUpdateTime,
            (Key
"ListId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
listId,
            (Key
"ListUpdateToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
listUpdateToken,
            (Key
"PreviousAppsList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text [App])
previousAppsList,
            forall a. a -> Maybe a
Prelude.Just (Key
"ListName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
listName),
            forall a. a -> Maybe a
Prelude.Just (Key
"AppsList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [App]
appsList)
          ]
      )