{-# 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.PutProtocolsList
-- 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 protocols list.
module Amazonka.FMS.PutProtocolsList
  ( -- * Creating a Request
    PutProtocolsList (..),
    newPutProtocolsList,

    -- * Request Lenses
    putProtocolsList_tagList,
    putProtocolsList_protocolsList,

    -- * Destructuring the Response
    PutProtocolsListResponse (..),
    newPutProtocolsListResponse,

    -- * Response Lenses
    putProtocolsListResponse_protocolsList,
    putProtocolsListResponse_protocolsListArn,
    putProtocolsListResponse_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:/ 'newPutProtocolsList' smart constructor.
data PutProtocolsList = PutProtocolsList'
  { -- | The tags associated with the resource.
    PutProtocolsList -> Maybe [Tag]
tagList :: Prelude.Maybe [Tag],
    -- | The details of the Firewall Manager protocols list to be created.
    PutProtocolsList -> ProtocolsListData
protocolsList :: ProtocolsListData
  }
  deriving (PutProtocolsList -> PutProtocolsList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutProtocolsList -> PutProtocolsList -> Bool
$c/= :: PutProtocolsList -> PutProtocolsList -> Bool
== :: PutProtocolsList -> PutProtocolsList -> Bool
$c== :: PutProtocolsList -> PutProtocolsList -> Bool
Prelude.Eq, ReadPrec [PutProtocolsList]
ReadPrec PutProtocolsList
Int -> ReadS PutProtocolsList
ReadS [PutProtocolsList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutProtocolsList]
$creadListPrec :: ReadPrec [PutProtocolsList]
readPrec :: ReadPrec PutProtocolsList
$creadPrec :: ReadPrec PutProtocolsList
readList :: ReadS [PutProtocolsList]
$creadList :: ReadS [PutProtocolsList]
readsPrec :: Int -> ReadS PutProtocolsList
$creadsPrec :: Int -> ReadS PutProtocolsList
Prelude.Read, Int -> PutProtocolsList -> ShowS
[PutProtocolsList] -> ShowS
PutProtocolsList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutProtocolsList] -> ShowS
$cshowList :: [PutProtocolsList] -> ShowS
show :: PutProtocolsList -> String
$cshow :: PutProtocolsList -> String
showsPrec :: Int -> PutProtocolsList -> ShowS
$cshowsPrec :: Int -> PutProtocolsList -> ShowS
Prelude.Show, forall x. Rep PutProtocolsList x -> PutProtocolsList
forall x. PutProtocolsList -> Rep PutProtocolsList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutProtocolsList x -> PutProtocolsList
$cfrom :: forall x. PutProtocolsList -> Rep PutProtocolsList x
Prelude.Generic)

-- |
-- Create a value of 'PutProtocolsList' 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', 'putProtocolsList_tagList' - The tags associated with the resource.
--
-- 'protocolsList', 'putProtocolsList_protocolsList' - The details of the Firewall Manager protocols list to be created.
newPutProtocolsList ::
  -- | 'protocolsList'
  ProtocolsListData ->
  PutProtocolsList
newPutProtocolsList :: ProtocolsListData -> PutProtocolsList
newPutProtocolsList ProtocolsListData
pProtocolsList_ =
  PutProtocolsList'
    { $sel:tagList:PutProtocolsList' :: Maybe [Tag]
tagList = forall a. Maybe a
Prelude.Nothing,
      $sel:protocolsList:PutProtocolsList' :: ProtocolsListData
protocolsList = ProtocolsListData
pProtocolsList_
    }

-- | The tags associated with the resource.
putProtocolsList_tagList :: Lens.Lens' PutProtocolsList (Prelude.Maybe [Tag])
putProtocolsList_tagList :: Lens' PutProtocolsList (Maybe [Tag])
putProtocolsList_tagList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutProtocolsList' {Maybe [Tag]
tagList :: Maybe [Tag]
$sel:tagList:PutProtocolsList' :: PutProtocolsList -> Maybe [Tag]
tagList} -> Maybe [Tag]
tagList) (\s :: PutProtocolsList
s@PutProtocolsList' {} Maybe [Tag]
a -> PutProtocolsList
s {$sel:tagList:PutProtocolsList' :: Maybe [Tag]
tagList = Maybe [Tag]
a} :: PutProtocolsList) 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 protocols list to be created.
putProtocolsList_protocolsList :: Lens.Lens' PutProtocolsList ProtocolsListData
putProtocolsList_protocolsList :: Lens' PutProtocolsList ProtocolsListData
putProtocolsList_protocolsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutProtocolsList' {ProtocolsListData
protocolsList :: ProtocolsListData
$sel:protocolsList:PutProtocolsList' :: PutProtocolsList -> ProtocolsListData
protocolsList} -> ProtocolsListData
protocolsList) (\s :: PutProtocolsList
s@PutProtocolsList' {} ProtocolsListData
a -> PutProtocolsList
s {$sel:protocolsList:PutProtocolsList' :: ProtocolsListData
protocolsList = ProtocolsListData
a} :: PutProtocolsList)

instance Core.AWSRequest PutProtocolsList where
  type
    AWSResponse PutProtocolsList =
      PutProtocolsListResponse
  request :: (Service -> Service)
-> PutProtocolsList -> Request PutProtocolsList
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 PutProtocolsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutProtocolsList)))
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 ProtocolsListData
-> Maybe Text -> Int -> PutProtocolsListResponse
PutProtocolsListResponse'
            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
"ProtocolsList")
            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
"ProtocolsListArn")
            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 PutProtocolsList where
  hashWithSalt :: Int -> PutProtocolsList -> Int
hashWithSalt Int
_salt PutProtocolsList' {Maybe [Tag]
ProtocolsListData
protocolsList :: ProtocolsListData
tagList :: Maybe [Tag]
$sel:protocolsList:PutProtocolsList' :: PutProtocolsList -> ProtocolsListData
$sel:tagList:PutProtocolsList' :: PutProtocolsList -> 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` ProtocolsListData
protocolsList

instance Prelude.NFData PutProtocolsList where
  rnf :: PutProtocolsList -> ()
rnf PutProtocolsList' {Maybe [Tag]
ProtocolsListData
protocolsList :: ProtocolsListData
tagList :: Maybe [Tag]
$sel:protocolsList:PutProtocolsList' :: PutProtocolsList -> ProtocolsListData
$sel:tagList:PutProtocolsList' :: PutProtocolsList -> 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 ProtocolsListData
protocolsList

instance Data.ToHeaders PutProtocolsList where
  toHeaders :: PutProtocolsList -> 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.PutProtocolsList" ::
                          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 PutProtocolsList where
  toJSON :: PutProtocolsList -> Value
toJSON PutProtocolsList' {Maybe [Tag]
ProtocolsListData
protocolsList :: ProtocolsListData
tagList :: Maybe [Tag]
$sel:protocolsList:PutProtocolsList' :: PutProtocolsList -> ProtocolsListData
$sel:tagList:PutProtocolsList' :: PutProtocolsList -> 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
"ProtocolsList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ProtocolsListData
protocolsList)
          ]
      )

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

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

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

-- |
-- Create a value of 'PutProtocolsListResponse' 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:
--
-- 'protocolsList', 'putProtocolsListResponse_protocolsList' - The details of the Firewall Manager protocols list.
--
-- 'protocolsListArn', 'putProtocolsListResponse_protocolsListArn' - The Amazon Resource Name (ARN) of the protocols list.
--
-- 'httpStatus', 'putProtocolsListResponse_httpStatus' - The response's http status code.
newPutProtocolsListResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutProtocolsListResponse
newPutProtocolsListResponse :: Int -> PutProtocolsListResponse
newPutProtocolsListResponse Int
pHttpStatus_ =
  PutProtocolsListResponse'
    { $sel:protocolsList:PutProtocolsListResponse' :: Maybe ProtocolsListData
protocolsList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:protocolsListArn:PutProtocolsListResponse' :: Maybe Text
protocolsListArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutProtocolsListResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the Firewall Manager protocols list.
putProtocolsListResponse_protocolsList :: Lens.Lens' PutProtocolsListResponse (Prelude.Maybe ProtocolsListData)
putProtocolsListResponse_protocolsList :: Lens' PutProtocolsListResponse (Maybe ProtocolsListData)
putProtocolsListResponse_protocolsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutProtocolsListResponse' {Maybe ProtocolsListData
protocolsList :: Maybe ProtocolsListData
$sel:protocolsList:PutProtocolsListResponse' :: PutProtocolsListResponse -> Maybe ProtocolsListData
protocolsList} -> Maybe ProtocolsListData
protocolsList) (\s :: PutProtocolsListResponse
s@PutProtocolsListResponse' {} Maybe ProtocolsListData
a -> PutProtocolsListResponse
s {$sel:protocolsList:PutProtocolsListResponse' :: Maybe ProtocolsListData
protocolsList = Maybe ProtocolsListData
a} :: PutProtocolsListResponse)

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

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

instance Prelude.NFData PutProtocolsListResponse where
  rnf :: PutProtocolsListResponse -> ()
rnf PutProtocolsListResponse' {Int
Maybe Text
Maybe ProtocolsListData
httpStatus :: Int
protocolsListArn :: Maybe Text
protocolsList :: Maybe ProtocolsListData
$sel:httpStatus:PutProtocolsListResponse' :: PutProtocolsListResponse -> Int
$sel:protocolsListArn:PutProtocolsListResponse' :: PutProtocolsListResponse -> Maybe Text
$sel:protocolsList:PutProtocolsListResponse' :: PutProtocolsListResponse -> Maybe ProtocolsListData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProtocolsListData
protocolsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocolsListArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus