{-# 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.PutResourceSet
-- 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 the resource set.
--
-- An Firewall Manager resource set defines the resources to import into an
-- Firewall Manager policy from another Amazon Web Services service.
module Amazonka.FMS.PutResourceSet
  ( -- * Creating a Request
    PutResourceSet (..),
    newPutResourceSet,

    -- * Request Lenses
    putResourceSet_tagList,
    putResourceSet_resourceSet,

    -- * Destructuring the Response
    PutResourceSetResponse (..),
    newPutResourceSetResponse,

    -- * Response Lenses
    putResourceSetResponse_httpStatus,
    putResourceSetResponse_resourceSet,
    putResourceSetResponse_resourceSetArn,
  )
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:/ 'newPutResourceSet' smart constructor.
data PutResourceSet = PutResourceSet'
  { -- | Retrieves the tags associated with the specified resource set. Tags are
    -- key:value pairs that you can use to categorize and manage your
    -- resources, for purposes like billing. For example, you might set the tag
    -- key to \"customer\" and the value to the customer name or ID. You can
    -- specify one or more tags to add to each Amazon Web Services resource, up
    -- to 50 tags for a resource.
    PutResourceSet -> Maybe [Tag]
tagList :: Prelude.Maybe [Tag],
    -- | Details about the resource set to be created or updated.>
    PutResourceSet -> ResourceSet
resourceSet :: ResourceSet
  }
  deriving (PutResourceSet -> PutResourceSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutResourceSet -> PutResourceSet -> Bool
$c/= :: PutResourceSet -> PutResourceSet -> Bool
== :: PutResourceSet -> PutResourceSet -> Bool
$c== :: PutResourceSet -> PutResourceSet -> Bool
Prelude.Eq, ReadPrec [PutResourceSet]
ReadPrec PutResourceSet
Int -> ReadS PutResourceSet
ReadS [PutResourceSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutResourceSet]
$creadListPrec :: ReadPrec [PutResourceSet]
readPrec :: ReadPrec PutResourceSet
$creadPrec :: ReadPrec PutResourceSet
readList :: ReadS [PutResourceSet]
$creadList :: ReadS [PutResourceSet]
readsPrec :: Int -> ReadS PutResourceSet
$creadsPrec :: Int -> ReadS PutResourceSet
Prelude.Read, Int -> PutResourceSet -> ShowS
[PutResourceSet] -> ShowS
PutResourceSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutResourceSet] -> ShowS
$cshowList :: [PutResourceSet] -> ShowS
show :: PutResourceSet -> String
$cshow :: PutResourceSet -> String
showsPrec :: Int -> PutResourceSet -> ShowS
$cshowsPrec :: Int -> PutResourceSet -> ShowS
Prelude.Show, forall x. Rep PutResourceSet x -> PutResourceSet
forall x. PutResourceSet -> Rep PutResourceSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutResourceSet x -> PutResourceSet
$cfrom :: forall x. PutResourceSet -> Rep PutResourceSet x
Prelude.Generic)

-- |
-- Create a value of 'PutResourceSet' 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', 'putResourceSet_tagList' - Retrieves the tags associated with the specified resource set. Tags are
-- key:value pairs that you can use to categorize and manage your
-- resources, for purposes like billing. For example, you might set the tag
-- key to \"customer\" and the value to the customer name or ID. You can
-- specify one or more tags to add to each Amazon Web Services resource, up
-- to 50 tags for a resource.
--
-- 'resourceSet', 'putResourceSet_resourceSet' - Details about the resource set to be created or updated.>
newPutResourceSet ::
  -- | 'resourceSet'
  ResourceSet ->
  PutResourceSet
newPutResourceSet :: ResourceSet -> PutResourceSet
newPutResourceSet ResourceSet
pResourceSet_ =
  PutResourceSet'
    { $sel:tagList:PutResourceSet' :: Maybe [Tag]
tagList = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceSet:PutResourceSet' :: ResourceSet
resourceSet = ResourceSet
pResourceSet_
    }

-- | Retrieves the tags associated with the specified resource set. Tags are
-- key:value pairs that you can use to categorize and manage your
-- resources, for purposes like billing. For example, you might set the tag
-- key to \"customer\" and the value to the customer name or ID. You can
-- specify one or more tags to add to each Amazon Web Services resource, up
-- to 50 tags for a resource.
putResourceSet_tagList :: Lens.Lens' PutResourceSet (Prelude.Maybe [Tag])
putResourceSet_tagList :: Lens' PutResourceSet (Maybe [Tag])
putResourceSet_tagList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutResourceSet' {Maybe [Tag]
tagList :: Maybe [Tag]
$sel:tagList:PutResourceSet' :: PutResourceSet -> Maybe [Tag]
tagList} -> Maybe [Tag]
tagList) (\s :: PutResourceSet
s@PutResourceSet' {} Maybe [Tag]
a -> PutResourceSet
s {$sel:tagList:PutResourceSet' :: Maybe [Tag]
tagList = Maybe [Tag]
a} :: PutResourceSet) 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

-- | Details about the resource set to be created or updated.>
putResourceSet_resourceSet :: Lens.Lens' PutResourceSet ResourceSet
putResourceSet_resourceSet :: Lens' PutResourceSet ResourceSet
putResourceSet_resourceSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutResourceSet' {ResourceSet
resourceSet :: ResourceSet
$sel:resourceSet:PutResourceSet' :: PutResourceSet -> ResourceSet
resourceSet} -> ResourceSet
resourceSet) (\s :: PutResourceSet
s@PutResourceSet' {} ResourceSet
a -> PutResourceSet
s {$sel:resourceSet:PutResourceSet' :: ResourceSet
resourceSet = ResourceSet
a} :: PutResourceSet)

instance Core.AWSRequest PutResourceSet where
  type
    AWSResponse PutResourceSet =
      PutResourceSetResponse
  request :: (Service -> Service) -> PutResourceSet -> Request PutResourceSet
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 PutResourceSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutResourceSet)))
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 ->
          Int -> ResourceSet -> Text -> PutResourceSetResponse
PutResourceSetResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"ResourceSet")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"ResourceSetArn")
      )

instance Prelude.Hashable PutResourceSet where
  hashWithSalt :: Int -> PutResourceSet -> Int
hashWithSalt Int
_salt PutResourceSet' {Maybe [Tag]
ResourceSet
resourceSet :: ResourceSet
tagList :: Maybe [Tag]
$sel:resourceSet:PutResourceSet' :: PutResourceSet -> ResourceSet
$sel:tagList:PutResourceSet' :: PutResourceSet -> 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` ResourceSet
resourceSet

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

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

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

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

-- | /See:/ 'newPutResourceSetResponse' smart constructor.
data PutResourceSetResponse = PutResourceSetResponse'
  { -- | The response's http status code.
    PutResourceSetResponse -> Int
httpStatus :: Prelude.Int,
    -- | Details about the resource set.
    PutResourceSetResponse -> ResourceSet
resourceSet :: ResourceSet,
    -- | The Amazon Resource Name (ARN) of the resource set.
    PutResourceSetResponse -> Text
resourceSetArn :: Prelude.Text
  }
  deriving (PutResourceSetResponse -> PutResourceSetResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutResourceSetResponse -> PutResourceSetResponse -> Bool
$c/= :: PutResourceSetResponse -> PutResourceSetResponse -> Bool
== :: PutResourceSetResponse -> PutResourceSetResponse -> Bool
$c== :: PutResourceSetResponse -> PutResourceSetResponse -> Bool
Prelude.Eq, ReadPrec [PutResourceSetResponse]
ReadPrec PutResourceSetResponse
Int -> ReadS PutResourceSetResponse
ReadS [PutResourceSetResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutResourceSetResponse]
$creadListPrec :: ReadPrec [PutResourceSetResponse]
readPrec :: ReadPrec PutResourceSetResponse
$creadPrec :: ReadPrec PutResourceSetResponse
readList :: ReadS [PutResourceSetResponse]
$creadList :: ReadS [PutResourceSetResponse]
readsPrec :: Int -> ReadS PutResourceSetResponse
$creadsPrec :: Int -> ReadS PutResourceSetResponse
Prelude.Read, Int -> PutResourceSetResponse -> ShowS
[PutResourceSetResponse] -> ShowS
PutResourceSetResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutResourceSetResponse] -> ShowS
$cshowList :: [PutResourceSetResponse] -> ShowS
show :: PutResourceSetResponse -> String
$cshow :: PutResourceSetResponse -> String
showsPrec :: Int -> PutResourceSetResponse -> ShowS
$cshowsPrec :: Int -> PutResourceSetResponse -> ShowS
Prelude.Show, forall x. Rep PutResourceSetResponse x -> PutResourceSetResponse
forall x. PutResourceSetResponse -> Rep PutResourceSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutResourceSetResponse x -> PutResourceSetResponse
$cfrom :: forall x. PutResourceSetResponse -> Rep PutResourceSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutResourceSetResponse' 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:
--
-- 'httpStatus', 'putResourceSetResponse_httpStatus' - The response's http status code.
--
-- 'resourceSet', 'putResourceSetResponse_resourceSet' - Details about the resource set.
--
-- 'resourceSetArn', 'putResourceSetResponse_resourceSetArn' - The Amazon Resource Name (ARN) of the resource set.
newPutResourceSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'resourceSet'
  ResourceSet ->
  -- | 'resourceSetArn'
  Prelude.Text ->
  PutResourceSetResponse
newPutResourceSetResponse :: Int -> ResourceSet -> Text -> PutResourceSetResponse
newPutResourceSetResponse
  Int
pHttpStatus_
  ResourceSet
pResourceSet_
  Text
pResourceSetArn_ =
    PutResourceSetResponse'
      { $sel:httpStatus:PutResourceSetResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:resourceSet:PutResourceSetResponse' :: ResourceSet
resourceSet = ResourceSet
pResourceSet_,
        $sel:resourceSetArn:PutResourceSetResponse' :: Text
resourceSetArn = Text
pResourceSetArn_
      }

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

-- | Details about the resource set.
putResourceSetResponse_resourceSet :: Lens.Lens' PutResourceSetResponse ResourceSet
putResourceSetResponse_resourceSet :: Lens' PutResourceSetResponse ResourceSet
putResourceSetResponse_resourceSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutResourceSetResponse' {ResourceSet
resourceSet :: ResourceSet
$sel:resourceSet:PutResourceSetResponse' :: PutResourceSetResponse -> ResourceSet
resourceSet} -> ResourceSet
resourceSet) (\s :: PutResourceSetResponse
s@PutResourceSetResponse' {} ResourceSet
a -> PutResourceSetResponse
s {$sel:resourceSet:PutResourceSetResponse' :: ResourceSet
resourceSet = ResourceSet
a} :: PutResourceSetResponse)

-- | The Amazon Resource Name (ARN) of the resource set.
putResourceSetResponse_resourceSetArn :: Lens.Lens' PutResourceSetResponse Prelude.Text
putResourceSetResponse_resourceSetArn :: Lens' PutResourceSetResponse Text
putResourceSetResponse_resourceSetArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutResourceSetResponse' {Text
resourceSetArn :: Text
$sel:resourceSetArn:PutResourceSetResponse' :: PutResourceSetResponse -> Text
resourceSetArn} -> Text
resourceSetArn) (\s :: PutResourceSetResponse
s@PutResourceSetResponse' {} Text
a -> PutResourceSetResponse
s {$sel:resourceSetArn:PutResourceSetResponse' :: Text
resourceSetArn = Text
a} :: PutResourceSetResponse)

instance Prelude.NFData PutResourceSetResponse where
  rnf :: PutResourceSetResponse -> ()
rnf PutResourceSetResponse' {Int
Text
ResourceSet
resourceSetArn :: Text
resourceSet :: ResourceSet
httpStatus :: Int
$sel:resourceSetArn:PutResourceSetResponse' :: PutResourceSetResponse -> Text
$sel:resourceSet:PutResourceSetResponse' :: PutResourceSetResponse -> ResourceSet
$sel:httpStatus:PutResourceSetResponse' :: PutResourceSetResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceSet
resourceSet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceSetArn