{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutAppsList
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an Firewall Manager applications list.
module Amazonka.FMS.PutAppsList
  ( -- * Creating a Request
    PutAppsList (..),
    newPutAppsList,

    -- * Request Lenses
    putAppsList_tagList,
    putAppsList_appsList,

    -- * Destructuring the Response
    PutAppsListResponse (..),
    newPutAppsListResponse,

    -- * Response Lenses
    putAppsListResponse_appsList,
    putAppsListResponse_appsListArn,
    putAppsListResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutAppsList' smart constructor.
data PutAppsList = PutAppsList'
  { -- | The tags associated with the resource.
    PutAppsList -> Maybe [Tag]
tagList :: Prelude.Maybe [Tag],
    -- | The details of the Firewall Manager applications list to be created.
    PutAppsList -> AppsListData
appsList :: AppsListData
  }
  deriving (PutAppsList -> PutAppsList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAppsList -> PutAppsList -> Bool
$c/= :: PutAppsList -> PutAppsList -> Bool
== :: PutAppsList -> PutAppsList -> Bool
$c== :: PutAppsList -> PutAppsList -> Bool
Prelude.Eq, ReadPrec [PutAppsList]
ReadPrec PutAppsList
Int -> ReadS PutAppsList
ReadS [PutAppsList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAppsList]
$creadListPrec :: ReadPrec [PutAppsList]
readPrec :: ReadPrec PutAppsList
$creadPrec :: ReadPrec PutAppsList
readList :: ReadS [PutAppsList]
$creadList :: ReadS [PutAppsList]
readsPrec :: Int -> ReadS PutAppsList
$creadsPrec :: Int -> ReadS PutAppsList
Prelude.Read, Int -> PutAppsList -> ShowS
[PutAppsList] -> ShowS
PutAppsList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAppsList] -> ShowS
$cshowList :: [PutAppsList] -> ShowS
show :: PutAppsList -> String
$cshow :: PutAppsList -> String
showsPrec :: Int -> PutAppsList -> ShowS
$cshowsPrec :: Int -> PutAppsList -> ShowS
Prelude.Show, forall x. Rep PutAppsList x -> PutAppsList
forall x. PutAppsList -> Rep PutAppsList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutAppsList x -> PutAppsList
$cfrom :: forall x. PutAppsList -> Rep PutAppsList x
Prelude.Generic)

-- |
-- Create a value of 'PutAppsList' 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:
--
-- 'tagList', 'putAppsList_tagList' - The tags associated with the resource.
--
-- 'appsList', 'putAppsList_appsList' - The details of the Firewall Manager applications list to be created.
newPutAppsList ::
  -- | 'appsList'
  AppsListData ->
  PutAppsList
newPutAppsList :: AppsListData -> PutAppsList
newPutAppsList AppsListData
pAppsList_ =
  PutAppsList'
    { $sel:tagList:PutAppsList' :: Maybe [Tag]
tagList = forall a. Maybe a
Prelude.Nothing,
      $sel:appsList:PutAppsList' :: AppsListData
appsList = AppsListData
pAppsList_
    }

-- | The tags associated with the resource.
putAppsList_tagList :: Lens.Lens' PutAppsList (Prelude.Maybe [Tag])
putAppsList_tagList :: Lens' PutAppsList (Maybe [Tag])
putAppsList_tagList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAppsList' {Maybe [Tag]
tagList :: Maybe [Tag]
$sel:tagList:PutAppsList' :: PutAppsList -> Maybe [Tag]
tagList} -> Maybe [Tag]
tagList) (\s :: PutAppsList
s@PutAppsList' {} Maybe [Tag]
a -> PutAppsList
s {$sel:tagList:PutAppsList' :: Maybe [Tag]
tagList = Maybe [Tag]
a} :: PutAppsList) 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 details of the Firewall Manager applications list to be created.
putAppsList_appsList :: Lens.Lens' PutAppsList AppsListData
putAppsList_appsList :: Lens' PutAppsList AppsListData
putAppsList_appsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAppsList' {AppsListData
appsList :: AppsListData
$sel:appsList:PutAppsList' :: PutAppsList -> AppsListData
appsList} -> AppsListData
appsList) (\s :: PutAppsList
s@PutAppsList' {} AppsListData
a -> PutAppsList
s {$sel:appsList:PutAppsList' :: AppsListData
appsList = AppsListData
a} :: PutAppsList)

instance Core.AWSRequest PutAppsList where
  type AWSResponse PutAppsList = PutAppsListResponse
  request :: (Service -> Service) -> PutAppsList -> Request PutAppsList
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutAppsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutAppsList)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe AppsListData -> Maybe Text -> Int -> PutAppsListResponse
PutAppsListResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"AppsList")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"AppsListArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutAppsList where
  hashWithSalt :: Int -> PutAppsList -> Int
hashWithSalt Int
_salt PutAppsList' {Maybe [Tag]
AppsListData
appsList :: AppsListData
tagList :: Maybe [Tag]
$sel:appsList:PutAppsList' :: PutAppsList -> AppsListData
$sel:tagList:PutAppsList' :: PutAppsList -> Maybe [Tag]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tagList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AppsListData
appsList

instance Prelude.NFData PutAppsList where
  rnf :: PutAppsList -> ()
rnf PutAppsList' {Maybe [Tag]
AppsListData
appsList :: AppsListData
tagList :: Maybe [Tag]
$sel:appsList:PutAppsList' :: PutAppsList -> AppsListData
$sel:tagList:PutAppsList' :: PutAppsList -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tagList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AppsListData
appsList

instance Data.ToHeaders PutAppsList where
  toHeaders :: PutAppsList -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSFMS_20180101.PutAppsList" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutAppsList where
  toJSON :: PutAppsList -> Value
toJSON PutAppsList' {Maybe [Tag]
AppsListData
appsList :: AppsListData
tagList :: Maybe [Tag]
$sel:appsList:PutAppsList' :: PutAppsList -> AppsListData
$sel:tagList:PutAppsList' :: PutAppsList -> Maybe [Tag]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TagList" 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 [Tag]
tagList,
            forall a. a -> Maybe a
Prelude.Just (Key
"AppsList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AppsListData
appsList)
          ]
      )

instance Data.ToPath PutAppsList where
  toPath :: PutAppsList -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery PutAppsList where
  toQuery :: PutAppsList -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutAppsListResponse' smart constructor.
data PutAppsListResponse = PutAppsListResponse'
  { -- | The details of the Firewall Manager applications list.
    PutAppsListResponse -> Maybe AppsListData
appsList :: Prelude.Maybe AppsListData,
    -- | The Amazon Resource Name (ARN) of the applications list.
    PutAppsListResponse -> Maybe Text
appsListArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    PutAppsListResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutAppsListResponse -> PutAppsListResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAppsListResponse -> PutAppsListResponse -> Bool
$c/= :: PutAppsListResponse -> PutAppsListResponse -> Bool
== :: PutAppsListResponse -> PutAppsListResponse -> Bool
$c== :: PutAppsListResponse -> PutAppsListResponse -> Bool
Prelude.Eq, ReadPrec [PutAppsListResponse]
ReadPrec PutAppsListResponse
Int -> ReadS PutAppsListResponse
ReadS [PutAppsListResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAppsListResponse]
$creadListPrec :: ReadPrec [PutAppsListResponse]
readPrec :: ReadPrec PutAppsListResponse
$creadPrec :: ReadPrec PutAppsListResponse
readList :: ReadS [PutAppsListResponse]
$creadList :: ReadS [PutAppsListResponse]
readsPrec :: Int -> ReadS PutAppsListResponse
$creadsPrec :: Int -> ReadS PutAppsListResponse
Prelude.Read, Int -> PutAppsListResponse -> ShowS
[PutAppsListResponse] -> ShowS
PutAppsListResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAppsListResponse] -> ShowS
$cshowList :: [PutAppsListResponse] -> ShowS
show :: PutAppsListResponse -> String
$cshow :: PutAppsListResponse -> String
showsPrec :: Int -> PutAppsListResponse -> ShowS
$cshowsPrec :: Int -> PutAppsListResponse -> ShowS
Prelude.Show, forall x. Rep PutAppsListResponse x -> PutAppsListResponse
forall x. PutAppsListResponse -> Rep PutAppsListResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutAppsListResponse x -> PutAppsListResponse
$cfrom :: forall x. PutAppsListResponse -> Rep PutAppsListResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutAppsListResponse' 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:
--
-- 'appsList', 'putAppsListResponse_appsList' - The details of the Firewall Manager applications list.
--
-- 'appsListArn', 'putAppsListResponse_appsListArn' - The Amazon Resource Name (ARN) of the applications list.
--
-- 'httpStatus', 'putAppsListResponse_httpStatus' - The response's http status code.
newPutAppsListResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutAppsListResponse
newPutAppsListResponse :: Int -> PutAppsListResponse
newPutAppsListResponse Int
pHttpStatus_ =
  PutAppsListResponse'
    { $sel:appsList:PutAppsListResponse' :: Maybe AppsListData
appsList = forall a. Maybe a
Prelude.Nothing,
      $sel:appsListArn:PutAppsListResponse' :: Maybe Text
appsListArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutAppsListResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The Amazon Resource Name (ARN) of the applications list.
putAppsListResponse_appsListArn :: Lens.Lens' PutAppsListResponse (Prelude.Maybe Prelude.Text)
putAppsListResponse_appsListArn :: Lens' PutAppsListResponse (Maybe Text)
putAppsListResponse_appsListArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAppsListResponse' {Maybe Text
appsListArn :: Maybe Text
$sel:appsListArn:PutAppsListResponse' :: PutAppsListResponse -> Maybe Text
appsListArn} -> Maybe Text
appsListArn) (\s :: PutAppsListResponse
s@PutAppsListResponse' {} Maybe Text
a -> PutAppsListResponse
s {$sel:appsListArn:PutAppsListResponse' :: Maybe Text
appsListArn = Maybe Text
a} :: PutAppsListResponse)

-- | The response's http status code.
putAppsListResponse_httpStatus :: Lens.Lens' PutAppsListResponse Prelude.Int
putAppsListResponse_httpStatus :: Lens' PutAppsListResponse Int
putAppsListResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAppsListResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutAppsListResponse' :: PutAppsListResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutAppsListResponse
s@PutAppsListResponse' {} Int
a -> PutAppsListResponse
s {$sel:httpStatus:PutAppsListResponse' :: Int
httpStatus = Int
a} :: PutAppsListResponse)

instance Prelude.NFData PutAppsListResponse where
  rnf :: PutAppsListResponse -> ()
rnf PutAppsListResponse' {Int
Maybe Text
Maybe AppsListData
httpStatus :: Int
appsListArn :: Maybe Text
appsList :: Maybe AppsListData
$sel:httpStatus:PutAppsListResponse' :: PutAppsListResponse -> Int
$sel:appsListArn:PutAppsListResponse' :: PutAppsListResponse -> Maybe Text
$sel:appsList:PutAppsListResponse' :: PutAppsListResponse -> Maybe AppsListData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AppsListData
appsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
appsListArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus