{-# 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-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 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 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:/ '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
(PutProtocolsList -> PutProtocolsList -> Bool)
-> (PutProtocolsList -> PutProtocolsList -> Bool)
-> Eq PutProtocolsList
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]
(Int -> ReadS PutProtocolsList)
-> ReadS [PutProtocolsList]
-> ReadPrec PutProtocolsList
-> ReadPrec [PutProtocolsList]
-> Read 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
(Int -> PutProtocolsList -> ShowS)
-> (PutProtocolsList -> String)
-> ([PutProtocolsList] -> ShowS)
-> Show PutProtocolsList
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. PutProtocolsList -> Rep PutProtocolsList x)
-> (forall x. Rep PutProtocolsList x -> PutProtocolsList)
-> Generic PutProtocolsList
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' :: Maybe [Tag] -> ProtocolsListData -> PutProtocolsList
PutProtocolsList'
    { $sel:tagList:PutProtocolsList' :: Maybe [Tag]
tagList = Maybe [Tag]
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 :: (Maybe [Tag] -> f (Maybe [Tag]))
-> PutProtocolsList -> f PutProtocolsList
putProtocolsList_tagList = (PutProtocolsList -> Maybe [Tag])
-> (PutProtocolsList -> Maybe [Tag] -> PutProtocolsList)
-> Lens
     PutProtocolsList PutProtocolsList (Maybe [Tag]) (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> PutProtocolsList -> f PutProtocolsList)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutProtocolsList
-> f PutProtocolsList
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 protocols list to be created.
putProtocolsList_protocolsList :: Lens.Lens' PutProtocolsList ProtocolsListData
putProtocolsList_protocolsList :: (ProtocolsListData -> f ProtocolsListData)
-> PutProtocolsList -> f PutProtocolsList
putProtocolsList_protocolsList = (PutProtocolsList -> ProtocolsListData)
-> (PutProtocolsList -> ProtocolsListData -> PutProtocolsList)
-> Lens
     PutProtocolsList
     PutProtocolsList
     ProtocolsListData
     ProtocolsListData
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 :: PutProtocolsList -> Request PutProtocolsList
request = Service -> PutProtocolsList -> Request PutProtocolsList
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutProtocolsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutProtocolsList)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutProtocolsList))
-> Logger
-> Service
-> Proxy PutProtocolsList
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutProtocolsList)))
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 ProtocolsListData
-> Maybe Text -> Int -> PutProtocolsListResponse
PutProtocolsListResponse'
            (Maybe ProtocolsListData
 -> Maybe Text -> Int -> PutProtocolsListResponse)
-> Either String (Maybe ProtocolsListData)
-> Either String (Maybe Text -> Int -> PutProtocolsListResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ProtocolsListData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProtocolsList")
            Either String (Maybe Text -> Int -> PutProtocolsListResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutProtocolsListResponse)
forall (f :: * -> *) a b. Applicative f => 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
"ProtocolsListArn")
            Either String (Int -> PutProtocolsListResponse)
-> Either String Int -> Either String PutProtocolsListResponse
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 PutProtocolsList

instance Prelude.NFData PutProtocolsList

instance Core.ToHeaders PutProtocolsList where
  toHeaders :: PutProtocolsList -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutProtocolsList -> 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.PutProtocolsList" ::
                          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 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
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
"ProtocolsList" Text -> ProtocolsListData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ProtocolsListData
protocolsList)
          ]
      )

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

instance Core.ToQuery PutProtocolsList where
  toQuery :: PutProtocolsList -> QueryString
toQuery = QueryString -> PutProtocolsList -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutProtocolsListResponse -> PutProtocolsListResponse -> Bool)
-> (PutProtocolsListResponse -> PutProtocolsListResponse -> Bool)
-> Eq PutProtocolsListResponse
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]
(Int -> ReadS PutProtocolsListResponse)
-> ReadS [PutProtocolsListResponse]
-> ReadPrec PutProtocolsListResponse
-> ReadPrec [PutProtocolsListResponse]
-> Read 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
(Int -> PutProtocolsListResponse -> ShowS)
-> (PutProtocolsListResponse -> String)
-> ([PutProtocolsListResponse] -> ShowS)
-> Show PutProtocolsListResponse
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.
 PutProtocolsListResponse -> Rep PutProtocolsListResponse x)
-> (forall x.
    Rep PutProtocolsListResponse x -> PutProtocolsListResponse)
-> Generic PutProtocolsListResponse
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' :: Maybe ProtocolsListData
-> Maybe Text -> Int -> PutProtocolsListResponse
PutProtocolsListResponse'
    { $sel:protocolsList:PutProtocolsListResponse' :: Maybe ProtocolsListData
protocolsList =
        Maybe ProtocolsListData
forall a. Maybe a
Prelude.Nothing,
      $sel:protocolsListArn:PutProtocolsListResponse' :: Maybe Text
protocolsListArn = Maybe Text
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 :: (Maybe ProtocolsListData -> f (Maybe ProtocolsListData))
-> PutProtocolsListResponse -> f PutProtocolsListResponse
putProtocolsListResponse_protocolsList = (PutProtocolsListResponse -> Maybe ProtocolsListData)
-> (PutProtocolsListResponse
    -> Maybe ProtocolsListData -> PutProtocolsListResponse)
-> Lens
     PutProtocolsListResponse
     PutProtocolsListResponse
     (Maybe ProtocolsListData)
     (Maybe ProtocolsListData)
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 :: (Maybe Text -> f (Maybe Text))
-> PutProtocolsListResponse -> f PutProtocolsListResponse
putProtocolsListResponse_protocolsListArn = (PutProtocolsListResponse -> Maybe Text)
-> (PutProtocolsListResponse
    -> Maybe Text -> PutProtocolsListResponse)
-> Lens
     PutProtocolsListResponse
     PutProtocolsListResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> PutProtocolsListResponse -> f PutProtocolsListResponse
putProtocolsListResponse_httpStatus = (PutProtocolsListResponse -> Int)
-> (PutProtocolsListResponse -> Int -> PutProtocolsListResponse)
-> Lens PutProtocolsListResponse PutProtocolsListResponse Int Int
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