{-# 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-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)
--
-- 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_appsListArn,
    putAppsListResponse_appsList,
    putAppsListResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FMS.Types
import qualified Amazonka.Lens as Lens
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
(PutAppsList -> PutAppsList -> Bool)
-> (PutAppsList -> PutAppsList -> Bool) -> Eq PutAppsList
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]
(Int -> ReadS PutAppsList)
-> ReadS [PutAppsList]
-> ReadPrec PutAppsList
-> ReadPrec [PutAppsList]
-> Read 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
(Int -> PutAppsList -> ShowS)
-> (PutAppsList -> String)
-> ([PutAppsList] -> ShowS)
-> Show PutAppsList
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. PutAppsList -> Rep PutAppsList x)
-> (forall x. Rep PutAppsList x -> PutAppsList)
-> Generic PutAppsList
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' :: Maybe [Tag] -> AppsListData -> PutAppsList
PutAppsList'
    { $sel:tagList:PutAppsList' :: Maybe [Tag]
tagList = Maybe [Tag]
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 :: (Maybe [Tag] -> f (Maybe [Tag])) -> PutAppsList -> f PutAppsList
putAppsList_tagList = (PutAppsList -> Maybe [Tag])
-> (PutAppsList -> Maybe [Tag] -> PutAppsList)
-> Lens PutAppsList PutAppsList (Maybe [Tag]) (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag])) -> PutAppsList -> f PutAppsList)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutAppsList
-> f PutAppsList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
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 :: (AppsListData -> f AppsListData) -> PutAppsList -> f PutAppsList
putAppsList_appsList = (PutAppsList -> AppsListData)
-> (PutAppsList -> AppsListData -> PutAppsList)
-> Lens PutAppsList PutAppsList AppsListData AppsListData
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 :: PutAppsList -> Request PutAppsList
request = Service -> PutAppsList -> Request PutAppsList
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutAppsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutAppsList)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutAppsList))
-> Logger
-> Service
-> Proxy PutAppsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutAppsList)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe AppsListData -> Int -> PutAppsListResponse
PutAppsListResponse'
            (Maybe Text -> Maybe AppsListData -> Int -> PutAppsListResponse)
-> Either String (Maybe Text)
-> Either String (Maybe AppsListData -> Int -> PutAppsListResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AppsListArn")
            Either String (Maybe AppsListData -> Int -> PutAppsListResponse)
-> Either String (Maybe AppsListData)
-> Either String (Int -> PutAppsListResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe AppsListData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AppsList")
            Either String (Int -> PutAppsListResponse)
-> Either String Int -> Either String PutAppsListResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutAppsList

instance Prelude.NFData PutAppsList

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TagList" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tagList,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AppsList" Text -> AppsListData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AppsListData
appsList)
          ]
      )

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

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

-- | /See:/ 'newPutAppsListResponse' smart constructor.
data PutAppsListResponse = PutAppsListResponse'
  { -- | The Amazon Resource Name (ARN) of the applications list.
    PutAppsListResponse -> Maybe Text
appsListArn :: Prelude.Maybe Prelude.Text,
    -- | The details of the Firewall Manager applications list.
    PutAppsListResponse -> Maybe AppsListData
appsList :: Prelude.Maybe AppsListData,
    -- | The response's http status code.
    PutAppsListResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutAppsListResponse -> PutAppsListResponse -> Bool
(PutAppsListResponse -> PutAppsListResponse -> Bool)
-> (PutAppsListResponse -> PutAppsListResponse -> Bool)
-> Eq PutAppsListResponse
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]
(Int -> ReadS PutAppsListResponse)
-> ReadS [PutAppsListResponse]
-> ReadPrec PutAppsListResponse
-> ReadPrec [PutAppsListResponse]
-> Read 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
(Int -> PutAppsListResponse -> ShowS)
-> (PutAppsListResponse -> String)
-> ([PutAppsListResponse] -> ShowS)
-> Show PutAppsListResponse
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. PutAppsListResponse -> Rep PutAppsListResponse x)
-> (forall x. Rep PutAppsListResponse x -> PutAppsListResponse)
-> Generic PutAppsListResponse
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:
--
-- 'appsListArn', 'putAppsListResponse_appsListArn' - The Amazon Resource Name (ARN) of the applications list.
--
-- 'appsList', 'putAppsListResponse_appsList' - The details of the Firewall Manager applications list.
--
-- 'httpStatus', 'putAppsListResponse_httpStatus' - The response's http status code.
newPutAppsListResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutAppsListResponse
newPutAppsListResponse :: Int -> PutAppsListResponse
newPutAppsListResponse Int
pHttpStatus_ =
  PutAppsListResponse' :: Maybe Text -> Maybe AppsListData -> Int -> PutAppsListResponse
PutAppsListResponse'
    { $sel:appsListArn:PutAppsListResponse' :: Maybe Text
appsListArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:appsList:PutAppsListResponse' :: Maybe AppsListData
appsList = Maybe AppsListData
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutAppsListResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the applications list.
putAppsListResponse_appsListArn :: Lens.Lens' PutAppsListResponse (Prelude.Maybe Prelude.Text)
putAppsListResponse_appsListArn :: (Maybe Text -> f (Maybe Text))
-> PutAppsListResponse -> f PutAppsListResponse
putAppsListResponse_appsListArn = (PutAppsListResponse -> Maybe Text)
-> (PutAppsListResponse -> Maybe Text -> PutAppsListResponse)
-> Lens
     PutAppsListResponse PutAppsListResponse (Maybe Text) (Maybe Text)
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 details of the Firewall Manager applications list.
putAppsListResponse_appsList :: Lens.Lens' PutAppsListResponse (Prelude.Maybe AppsListData)
putAppsListResponse_appsList :: (Maybe AppsListData -> f (Maybe AppsListData))
-> PutAppsListResponse -> f PutAppsListResponse
putAppsListResponse_appsList = (PutAppsListResponse -> Maybe AppsListData)
-> (PutAppsListResponse
    -> Maybe AppsListData -> PutAppsListResponse)
-> Lens
     PutAppsListResponse
     PutAppsListResponse
     (Maybe AppsListData)
     (Maybe AppsListData)
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 response's http status code.
putAppsListResponse_httpStatus :: Lens.Lens' PutAppsListResponse Prelude.Int
putAppsListResponse_httpStatus :: (Int -> f Int) -> PutAppsListResponse -> f PutAppsListResponse
putAppsListResponse_httpStatus = (PutAppsListResponse -> Int)
-> (PutAppsListResponse -> Int -> PutAppsListResponse)
-> Lens PutAppsListResponse PutAppsListResponse Int Int
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